documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980
  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. * @param useInstances defines if instances have to be turned on
  20010. * @param useThinInstances defines if thin instances have to be turned on
  20011. */
  20012. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20013. /**
  20014. * Prepares the defines for bones
  20015. * @param mesh The mesh containing the geometry data we will draw
  20016. * @param defines The defines to update
  20017. */
  20018. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20019. /**
  20020. * Prepares the defines for morph targets
  20021. * @param mesh The mesh containing the geometry data we will draw
  20022. * @param defines The defines to update
  20023. */
  20024. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20025. /**
  20026. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20027. * @param mesh The mesh containing the geometry data we will draw
  20028. * @param defines The defines to update
  20029. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20030. * @param useBones Precise whether bones should be used or not (override mesh info)
  20031. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20032. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20033. * @returns false if defines are considered not dirty and have not been checked
  20034. */
  20035. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20036. /**
  20037. * Prepares the defines related to multiview
  20038. * @param scene The scene we are intending to draw
  20039. * @param defines The defines to update
  20040. */
  20041. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20042. /**
  20043. * Prepares the defines related to the light information passed in parameter
  20044. * @param scene The scene we are intending to draw
  20045. * @param mesh The mesh the effect is compiling for
  20046. * @param light The light the effect is compiling for
  20047. * @param lightIndex The index of the light
  20048. * @param defines The defines to update
  20049. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20050. * @param state Defines the current state regarding what is needed (normals, etc...)
  20051. */
  20052. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20053. needNormals: boolean;
  20054. needRebuild: boolean;
  20055. shadowEnabled: boolean;
  20056. specularEnabled: boolean;
  20057. lightmapMode: boolean;
  20058. }): void;
  20059. /**
  20060. * Prepares the defines related to the light information passed in parameter
  20061. * @param scene The scene we are intending to draw
  20062. * @param mesh The mesh the effect is compiling for
  20063. * @param defines The defines to update
  20064. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20065. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20066. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20067. * @returns true if normals will be required for the rest of the effect
  20068. */
  20069. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20070. /**
  20071. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20072. * @param lightIndex defines the light index
  20073. * @param uniformsList The uniform list
  20074. * @param samplersList The sampler list
  20075. * @param projectedLightTexture defines if projected texture must be used
  20076. * @param uniformBuffersList defines an optional list of uniform buffers
  20077. */
  20078. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20079. /**
  20080. * Prepares the uniforms and samplers list to be used in the effect
  20081. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20082. * @param samplersList The sampler list
  20083. * @param defines The defines helping in the list generation
  20084. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20085. */
  20086. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20087. /**
  20088. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20089. * @param defines The defines to update while falling back
  20090. * @param fallbacks The authorized effect fallbacks
  20091. * @param maxSimultaneousLights The maximum number of lights allowed
  20092. * @param rank the current rank of the Effect
  20093. * @returns The newly affected rank
  20094. */
  20095. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20096. private static _TmpMorphInfluencers;
  20097. /**
  20098. * Prepares the list of attributes required for morph targets according to the effect defines.
  20099. * @param attribs The current list of supported attribs
  20100. * @param mesh The mesh to prepare the morph targets attributes for
  20101. * @param influencers The number of influencers
  20102. */
  20103. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20104. /**
  20105. * Prepares the list of attributes required for morph targets according to the effect defines.
  20106. * @param attribs The current list of supported attribs
  20107. * @param mesh The mesh to prepare the morph targets attributes for
  20108. * @param defines The current Defines of the effect
  20109. */
  20110. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20111. /**
  20112. * Prepares the list of attributes required for bones according to the effect defines.
  20113. * @param attribs The current list of supported attribs
  20114. * @param mesh The mesh to prepare the bones attributes for
  20115. * @param defines The current Defines of the effect
  20116. * @param fallbacks The current efffect fallback strategy
  20117. */
  20118. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20119. /**
  20120. * Check and prepare the list of attributes required for instances according to the effect defines.
  20121. * @param attribs The current list of supported attribs
  20122. * @param defines The current MaterialDefines of the effect
  20123. */
  20124. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20125. /**
  20126. * Add the list of attributes required for instances to the attribs array.
  20127. * @param attribs The current list of supported attribs
  20128. */
  20129. static PushAttributesForInstances(attribs: string[]): void;
  20130. /**
  20131. * Binds the light information to the effect.
  20132. * @param light The light containing the generator
  20133. * @param effect The effect we are binding the data to
  20134. * @param lightIndex The light index in the effect used to render
  20135. */
  20136. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20137. /**
  20138. * Binds the lights information from the scene to the effect for the given mesh.
  20139. * @param light Light to bind
  20140. * @param lightIndex Light index
  20141. * @param scene The scene where the light belongs to
  20142. * @param effect The effect we are binding the data to
  20143. * @param useSpecular Defines if specular is supported
  20144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20145. */
  20146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20147. /**
  20148. * Binds the lights information from the scene to the effect for the given mesh.
  20149. * @param scene The scene the lights belongs to
  20150. * @param mesh The mesh we are binding the information to render
  20151. * @param effect The effect we are binding the data to
  20152. * @param defines The generated defines for the effect
  20153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20155. */
  20156. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20157. private static _tempFogColor;
  20158. /**
  20159. * Binds the fog information from the scene to the effect for the given mesh.
  20160. * @param scene The scene the lights belongs to
  20161. * @param mesh The mesh we are binding the information to render
  20162. * @param effect The effect we are binding the data to
  20163. * @param linearSpace Defines if the fog effect is applied in linear space
  20164. */
  20165. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20166. /**
  20167. * Binds the bones information from the mesh to the effect.
  20168. * @param mesh The mesh we are binding the information to render
  20169. * @param effect The effect we are binding the data to
  20170. */
  20171. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20172. /**
  20173. * Binds the morph targets information from the mesh to the effect.
  20174. * @param abstractMesh The mesh we are binding the information to render
  20175. * @param effect The effect we are binding the data to
  20176. */
  20177. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20178. /**
  20179. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20180. * @param defines The generated defines used in the effect
  20181. * @param effect The effect we are binding the data to
  20182. * @param scene The scene we are willing to render with logarithmic scale for
  20183. */
  20184. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20185. /**
  20186. * Binds the clip plane information from the scene to the effect.
  20187. * @param scene The scene the clip plane information are extracted from
  20188. * @param effect The effect we are binding the data to
  20189. */
  20190. static BindClipPlane(effect: Effect, scene: Scene): void;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * Block used to expose an input value
  20196. */
  20197. export class InputBlock extends NodeMaterialBlock {
  20198. private _mode;
  20199. private _associatedVariableName;
  20200. private _storedValue;
  20201. private _valueCallback;
  20202. private _type;
  20203. private _animationType;
  20204. /** Gets or set a value used to limit the range of float values */
  20205. min: number;
  20206. /** Gets or set a value used to limit the range of float values */
  20207. max: number;
  20208. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20209. isBoolean: boolean;
  20210. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20211. matrixMode: number;
  20212. /** @hidden */
  20213. _systemValue: Nullable<NodeMaterialSystemValues>;
  20214. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20215. visibleInInspector: boolean;
  20216. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20217. isConstant: boolean;
  20218. /** Gets or sets the group to use to display this block in the Inspector */
  20219. groupInInspector: string;
  20220. /** Gets an observable raised when the value is changed */
  20221. onValueChangedObservable: Observable<InputBlock>;
  20222. /**
  20223. * Gets or sets the connection point type (default is float)
  20224. */
  20225. get type(): NodeMaterialBlockConnectionPointTypes;
  20226. /**
  20227. * Creates a new InputBlock
  20228. * @param name defines the block name
  20229. * @param target defines the target of that block (Vertex by default)
  20230. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20231. */
  20232. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20233. /**
  20234. * Gets the output component
  20235. */
  20236. get output(): NodeMaterialConnectionPoint;
  20237. /**
  20238. * Set the source of this connection point to a vertex attribute
  20239. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20240. * @returns the current connection point
  20241. */
  20242. setAsAttribute(attributeName?: string): InputBlock;
  20243. /**
  20244. * Set the source of this connection point to a system value
  20245. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20246. * @returns the current connection point
  20247. */
  20248. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20249. /**
  20250. * Gets or sets the value of that point.
  20251. * Please note that this value will be ignored if valueCallback is defined
  20252. */
  20253. get value(): any;
  20254. set value(value: any);
  20255. /**
  20256. * Gets or sets a callback used to get the value of that point.
  20257. * Please note that setting this value will force the connection point to ignore the value property
  20258. */
  20259. get valueCallback(): () => any;
  20260. set valueCallback(value: () => any);
  20261. /**
  20262. * Gets or sets the associated variable name in the shader
  20263. */
  20264. get associatedVariableName(): string;
  20265. set associatedVariableName(value: string);
  20266. /** Gets or sets the type of animation applied to the input */
  20267. get animationType(): AnimatedInputBlockTypes;
  20268. set animationType(value: AnimatedInputBlockTypes);
  20269. /**
  20270. * Gets a boolean indicating that this connection point not defined yet
  20271. */
  20272. get isUndefined(): boolean;
  20273. /**
  20274. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20275. * In this case the connection point name must be the name of the uniform to use.
  20276. * Can only be set on inputs
  20277. */
  20278. get isUniform(): boolean;
  20279. set isUniform(value: boolean);
  20280. /**
  20281. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20282. * In this case the connection point name must be the name of the attribute to use
  20283. * Can only be set on inputs
  20284. */
  20285. get isAttribute(): boolean;
  20286. set isAttribute(value: boolean);
  20287. /**
  20288. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20289. * Can only be set on exit points
  20290. */
  20291. get isVarying(): boolean;
  20292. set isVarying(value: boolean);
  20293. /**
  20294. * Gets a boolean indicating that the current connection point is a system value
  20295. */
  20296. get isSystemValue(): boolean;
  20297. /**
  20298. * Gets or sets the current well known value or null if not defined as a system value
  20299. */
  20300. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20301. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20302. /**
  20303. * Gets the current class name
  20304. * @returns the class name
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Animate the input if animationType !== None
  20309. * @param scene defines the rendering scene
  20310. */
  20311. animate(scene: Scene): void;
  20312. private _emitDefine;
  20313. initialize(state: NodeMaterialBuildState): void;
  20314. /**
  20315. * Set the input block to its default value (based on its type)
  20316. */
  20317. setDefaultValue(): void;
  20318. private _emitConstant;
  20319. /** @hidden */
  20320. get _noContextSwitch(): boolean;
  20321. private _emit;
  20322. /** @hidden */
  20323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20324. /** @hidden */
  20325. _transmit(effect: Effect, scene: Scene): void;
  20326. protected _buildBlock(state: NodeMaterialBuildState): void;
  20327. protected _dumpPropertiesCode(): string;
  20328. dispose(): void;
  20329. serialize(): any;
  20330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * Enum used to define the compatibility state between two connection points
  20336. */
  20337. export enum NodeMaterialConnectionPointCompatibilityStates {
  20338. /** Points are compatibles */
  20339. Compatible = 0,
  20340. /** Points are incompatible because of their types */
  20341. TypeIncompatible = 1,
  20342. /** Points are incompatible because of their targets (vertex vs fragment) */
  20343. TargetIncompatible = 2
  20344. }
  20345. /**
  20346. * Defines the direction of a connection point
  20347. */
  20348. export enum NodeMaterialConnectionPointDirection {
  20349. /** Input */
  20350. Input = 0,
  20351. /** Output */
  20352. Output = 1
  20353. }
  20354. /**
  20355. * Defines a connection point for a block
  20356. */
  20357. export class NodeMaterialConnectionPoint {
  20358. /** @hidden */
  20359. _ownerBlock: NodeMaterialBlock;
  20360. /** @hidden */
  20361. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20362. private _endpoints;
  20363. private _associatedVariableName;
  20364. private _direction;
  20365. /** @hidden */
  20366. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20367. /** @hidden */
  20368. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20369. private _type;
  20370. /** @hidden */
  20371. _enforceAssociatedVariableName: boolean;
  20372. /** Gets the direction of the point */
  20373. get direction(): NodeMaterialConnectionPointDirection;
  20374. /** Indicates that this connection point needs dual validation before being connected to another point */
  20375. needDualDirectionValidation: boolean;
  20376. /**
  20377. * Gets or sets the additional types supported by this connection point
  20378. */
  20379. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20380. /**
  20381. * Gets or sets the additional types excluded by this connection point
  20382. */
  20383. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20384. /**
  20385. * Observable triggered when this point is connected
  20386. */
  20387. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20388. /**
  20389. * Gets or sets the associated variable name in the shader
  20390. */
  20391. get associatedVariableName(): string;
  20392. set associatedVariableName(value: string);
  20393. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20394. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20395. /**
  20396. * Gets or sets the connection point type (default is float)
  20397. */
  20398. get type(): NodeMaterialBlockConnectionPointTypes;
  20399. set type(value: NodeMaterialBlockConnectionPointTypes);
  20400. /**
  20401. * Gets or sets the connection point name
  20402. */
  20403. name: string;
  20404. /**
  20405. * Gets or sets the connection point name
  20406. */
  20407. displayName: string;
  20408. /**
  20409. * Gets or sets a boolean indicating that this connection point can be omitted
  20410. */
  20411. isOptional: boolean;
  20412. /**
  20413. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20414. */
  20415. define: string;
  20416. /** @hidden */
  20417. _prioritizeVertex: boolean;
  20418. private _target;
  20419. /** Gets or sets the target of that connection point */
  20420. get target(): NodeMaterialBlockTargets;
  20421. set target(value: NodeMaterialBlockTargets);
  20422. /**
  20423. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20424. */
  20425. get isConnected(): boolean;
  20426. /**
  20427. * Gets a boolean indicating that the current point is connected to an input block
  20428. */
  20429. get isConnectedToInputBlock(): boolean;
  20430. /**
  20431. * Gets a the connected input block (if any)
  20432. */
  20433. get connectInputBlock(): Nullable<InputBlock>;
  20434. /** Get the other side of the connection (if any) */
  20435. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20436. /** Get the block that owns this connection point */
  20437. get ownerBlock(): NodeMaterialBlock;
  20438. /** Get the block connected on the other side of this connection (if any) */
  20439. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20440. /** Get the block connected on the endpoints of this connection (if any) */
  20441. get connectedBlocks(): Array<NodeMaterialBlock>;
  20442. /** Gets the list of connected endpoints */
  20443. get endpoints(): NodeMaterialConnectionPoint[];
  20444. /** Gets a boolean indicating if that output point is connected to at least one input */
  20445. get hasEndpoints(): boolean;
  20446. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20447. get isConnectedInVertexShader(): boolean;
  20448. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20449. get isConnectedInFragmentShader(): boolean;
  20450. /**
  20451. * Creates a block suitable to be used as an input for this input point.
  20452. * If null is returned, a block based on the point type will be created.
  20453. * @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
  20454. */
  20455. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20456. /**
  20457. * Creates a new connection point
  20458. * @param name defines the connection point name
  20459. * @param ownerBlock defines the block hosting this connection point
  20460. * @param direction defines the direction of the connection point
  20461. */
  20462. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20463. /**
  20464. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20465. * @returns the class name
  20466. */
  20467. getClassName(): string;
  20468. /**
  20469. * Gets a boolean indicating if the current point can be connected to another point
  20470. * @param connectionPoint defines the other connection point
  20471. * @returns a boolean
  20472. */
  20473. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20474. /**
  20475. * Gets a number indicating if the current point can be connected to another point
  20476. * @param connectionPoint defines the other connection point
  20477. * @returns a number defining the compatibility state
  20478. */
  20479. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20480. /**
  20481. * Connect this point to another connection point
  20482. * @param connectionPoint defines the other connection point
  20483. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20484. * @returns the current connection point
  20485. */
  20486. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20487. /**
  20488. * Disconnect this point from one of his endpoint
  20489. * @param endpoint defines the other connection point
  20490. * @returns the current connection point
  20491. */
  20492. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Serializes this point in a JSON representation
  20495. * @param isInput defines if the connection point is an input (default is true)
  20496. * @returns the serialized point object
  20497. */
  20498. serialize(isInput?: boolean): any;
  20499. /**
  20500. * Release resources
  20501. */
  20502. dispose(): void;
  20503. }
  20504. }
  20505. declare module BABYLON {
  20506. /**
  20507. * Enum used to define the material modes
  20508. */
  20509. export enum NodeMaterialModes {
  20510. /** Regular material */
  20511. Material = 0,
  20512. /** For post process */
  20513. PostProcess = 1,
  20514. /** For particle system */
  20515. Particle = 2
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. /**
  20520. * Block used to read a texture from a sampler
  20521. */
  20522. export class TextureBlock extends NodeMaterialBlock {
  20523. private _defineName;
  20524. private _linearDefineName;
  20525. private _gammaDefineName;
  20526. private _tempTextureRead;
  20527. private _samplerName;
  20528. private _transformedUVName;
  20529. private _textureTransformName;
  20530. private _textureInfoName;
  20531. private _mainUVName;
  20532. private _mainUVDefineName;
  20533. private _fragmentOnly;
  20534. /**
  20535. * Gets or sets the texture associated with the node
  20536. */
  20537. texture: Nullable<Texture>;
  20538. /**
  20539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20540. */
  20541. convertToGammaSpace: boolean;
  20542. /**
  20543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20544. */
  20545. convertToLinearSpace: boolean;
  20546. /**
  20547. * Create a new TextureBlock
  20548. * @param name defines the block name
  20549. */
  20550. constructor(name: string, fragmentOnly?: boolean);
  20551. /**
  20552. * Gets the current class name
  20553. * @returns the class name
  20554. */
  20555. getClassName(): string;
  20556. /**
  20557. * Gets the uv input component
  20558. */
  20559. get uv(): NodeMaterialConnectionPoint;
  20560. /**
  20561. * Gets the rgba output component
  20562. */
  20563. get rgba(): NodeMaterialConnectionPoint;
  20564. /**
  20565. * Gets the rgb output component
  20566. */
  20567. get rgb(): NodeMaterialConnectionPoint;
  20568. /**
  20569. * Gets the r output component
  20570. */
  20571. get r(): NodeMaterialConnectionPoint;
  20572. /**
  20573. * Gets the g output component
  20574. */
  20575. get g(): NodeMaterialConnectionPoint;
  20576. /**
  20577. * Gets the b output component
  20578. */
  20579. get b(): NodeMaterialConnectionPoint;
  20580. /**
  20581. * Gets the a output component
  20582. */
  20583. get a(): NodeMaterialConnectionPoint;
  20584. get target(): NodeMaterialBlockTargets;
  20585. autoConfigure(material: NodeMaterial): void;
  20586. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20588. isReady(): boolean;
  20589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20590. private get _isMixed();
  20591. private _injectVertexCode;
  20592. private _writeTextureRead;
  20593. private _writeOutput;
  20594. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20595. protected _dumpPropertiesCode(): string;
  20596. serialize(): any;
  20597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var reflectionFunction: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /**
  20609. * Base block used to read a reflection texture from a sampler
  20610. */
  20611. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20612. /** @hidden */
  20613. _define3DName: string;
  20614. /** @hidden */
  20615. _defineCubicName: string;
  20616. /** @hidden */
  20617. _defineExplicitName: string;
  20618. /** @hidden */
  20619. _defineProjectionName: string;
  20620. /** @hidden */
  20621. _defineLocalCubicName: string;
  20622. /** @hidden */
  20623. _defineSphericalName: string;
  20624. /** @hidden */
  20625. _definePlanarName: string;
  20626. /** @hidden */
  20627. _defineEquirectangularName: string;
  20628. /** @hidden */
  20629. _defineMirroredEquirectangularFixedName: string;
  20630. /** @hidden */
  20631. _defineEquirectangularFixedName: string;
  20632. /** @hidden */
  20633. _defineSkyboxName: string;
  20634. /** @hidden */
  20635. _defineOppositeZ: string;
  20636. /** @hidden */
  20637. _cubeSamplerName: string;
  20638. /** @hidden */
  20639. _2DSamplerName: string;
  20640. protected _positionUVWName: string;
  20641. protected _directionWName: string;
  20642. protected _reflectionVectorName: string;
  20643. /** @hidden */
  20644. _reflectionCoordsName: string;
  20645. /** @hidden */
  20646. _reflectionMatrixName: string;
  20647. protected _reflectionColorName: string;
  20648. /**
  20649. * Gets or sets the texture associated with the node
  20650. */
  20651. texture: Nullable<BaseTexture>;
  20652. /**
  20653. * Create a new ReflectionTextureBaseBlock
  20654. * @param name defines the block name
  20655. */
  20656. constructor(name: string);
  20657. /**
  20658. * Gets the current class name
  20659. * @returns the class name
  20660. */
  20661. getClassName(): string;
  20662. /**
  20663. * Gets the world position input component
  20664. */
  20665. abstract get position(): NodeMaterialConnectionPoint;
  20666. /**
  20667. * Gets the world position input component
  20668. */
  20669. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20670. /**
  20671. * Gets the world normal input component
  20672. */
  20673. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20674. /**
  20675. * Gets the world input component
  20676. */
  20677. abstract get world(): NodeMaterialConnectionPoint;
  20678. /**
  20679. * Gets the camera (or eye) position component
  20680. */
  20681. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20682. /**
  20683. * Gets the view input component
  20684. */
  20685. abstract get view(): NodeMaterialConnectionPoint;
  20686. protected _getTexture(): Nullable<BaseTexture>;
  20687. autoConfigure(material: NodeMaterial): void;
  20688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20689. isReady(): boolean;
  20690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20691. /**
  20692. * Gets the code to inject in the vertex shader
  20693. * @param state current state of the node material building
  20694. * @returns the shader code
  20695. */
  20696. handleVertexSide(state: NodeMaterialBuildState): string;
  20697. /**
  20698. * Handles the inits for the fragment code path
  20699. * @param state node material build state
  20700. */
  20701. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20702. /**
  20703. * Generates the reflection coords code for the fragment code path
  20704. * @param worldNormalVarName name of the world normal variable
  20705. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20706. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20707. * @returns the shader code
  20708. */
  20709. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20710. /**
  20711. * Generates the reflection color code for the fragment code path
  20712. * @param lodVarName name of the lod variable
  20713. * @param swizzleLookupTexture swizzle to use for the final color variable
  20714. * @returns the shader code
  20715. */
  20716. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20717. /**
  20718. * Generates the code corresponding to the connected output points
  20719. * @param state node material build state
  20720. * @param varName name of the variable to output
  20721. * @returns the shader code
  20722. */
  20723. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20724. protected _buildBlock(state: NodeMaterialBuildState): this;
  20725. protected _dumpPropertiesCode(): string;
  20726. serialize(): any;
  20727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Defines a connection point to be used for points with a custom object type
  20733. */
  20734. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20735. private _blockType;
  20736. private _blockName;
  20737. private _nameForCheking?;
  20738. /**
  20739. * Creates a new connection point
  20740. * @param name defines the connection point name
  20741. * @param ownerBlock defines the block hosting this connection point
  20742. * @param direction defines the direction of the connection point
  20743. */
  20744. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20745. /**
  20746. * Gets a number indicating if the current point can be connected to another point
  20747. * @param connectionPoint defines the other connection point
  20748. * @returns a number defining the compatibility state
  20749. */
  20750. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20751. /**
  20752. * Creates a block suitable to be used as an input for this input point.
  20753. * If null is returned, a block based on the point type will be created.
  20754. * @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
  20755. */
  20756. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * Enum defining the type of properties that can be edited in the property pages in the NME
  20762. */
  20763. export enum PropertyTypeForEdition {
  20764. /** property is a boolean */
  20765. Boolean = 0,
  20766. /** property is a float */
  20767. Float = 1,
  20768. /** property is a Vector2 */
  20769. Vector2 = 2,
  20770. /** property is a list of values */
  20771. List = 3
  20772. }
  20773. /**
  20774. * Interface that defines an option in a variable of type list
  20775. */
  20776. export interface IEditablePropertyListOption {
  20777. /** label of the option */
  20778. "label": string;
  20779. /** value of the option */
  20780. "value": number;
  20781. }
  20782. /**
  20783. * Interface that defines the options available for an editable property
  20784. */
  20785. export interface IEditablePropertyOption {
  20786. /** min value */
  20787. "min"?: number;
  20788. /** max value */
  20789. "max"?: number;
  20790. /** notifiers: indicates which actions to take when the property is changed */
  20791. "notifiers"?: {
  20792. /** the material should be rebuilt */
  20793. "rebuild"?: boolean;
  20794. /** the preview should be updated */
  20795. "update"?: boolean;
  20796. };
  20797. /** list of the options for a variable of type list */
  20798. "options"?: IEditablePropertyListOption[];
  20799. }
  20800. /**
  20801. * Interface that describes an editable property
  20802. */
  20803. export interface IPropertyDescriptionForEdition {
  20804. /** name of the property */
  20805. "propertyName": string;
  20806. /** display name of the property */
  20807. "displayName": string;
  20808. /** type of the property */
  20809. "type": PropertyTypeForEdition;
  20810. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20811. "groupName": string;
  20812. /** options for the property */
  20813. "options": IEditablePropertyOption;
  20814. }
  20815. /**
  20816. * Decorator that flags a property in a node material block as being editable
  20817. */
  20818. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * Block used to implement the refraction part of the sub surface module of the PBR material
  20823. */
  20824. export class RefractionBlock extends NodeMaterialBlock {
  20825. /** @hidden */
  20826. _define3DName: string;
  20827. /** @hidden */
  20828. _refractionMatrixName: string;
  20829. /** @hidden */
  20830. _defineLODRefractionAlpha: string;
  20831. /** @hidden */
  20832. _defineLinearSpecularRefraction: string;
  20833. /** @hidden */
  20834. _defineOppositeZ: string;
  20835. /** @hidden */
  20836. _cubeSamplerName: string;
  20837. /** @hidden */
  20838. _2DSamplerName: string;
  20839. /** @hidden */
  20840. _vRefractionMicrosurfaceInfosName: string;
  20841. /** @hidden */
  20842. _vRefractionInfosName: string;
  20843. private _scene;
  20844. /**
  20845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20846. * Materials half opaque for instance using refraction could benefit from this control.
  20847. */
  20848. linkRefractionWithTransparency: boolean;
  20849. /**
  20850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20851. */
  20852. invertRefractionY: boolean;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<BaseTexture>;
  20857. /**
  20858. * Create a new RefractionBlock
  20859. * @param name defines the block name
  20860. */
  20861. constructor(name: string);
  20862. /**
  20863. * Gets the current class name
  20864. * @returns the class name
  20865. */
  20866. getClassName(): string;
  20867. /**
  20868. * Gets the intensity input component
  20869. */
  20870. get intensity(): NodeMaterialConnectionPoint;
  20871. /**
  20872. * Gets the index of refraction input component
  20873. */
  20874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20875. /**
  20876. * Gets the tint at distance input component
  20877. */
  20878. get tintAtDistance(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the view input component
  20881. */
  20882. get view(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the refraction object output component
  20885. */
  20886. get refraction(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Returns true if the block has a texture
  20889. */
  20890. get hasTexture(): boolean;
  20891. protected _getTexture(): Nullable<BaseTexture>;
  20892. autoConfigure(material: NodeMaterial): void;
  20893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20894. isReady(): boolean;
  20895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20896. /**
  20897. * Gets the main code of the block (fragment side)
  20898. * @param state current state of the node material building
  20899. * @returns the shader code
  20900. */
  20901. getCode(state: NodeMaterialBuildState): string;
  20902. protected _buildBlock(state: NodeMaterialBuildState): this;
  20903. protected _dumpPropertiesCode(): string;
  20904. serialize(): any;
  20905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20906. }
  20907. }
  20908. declare module BABYLON {
  20909. /**
  20910. * Base block used as input for post process
  20911. */
  20912. export class CurrentScreenBlock extends NodeMaterialBlock {
  20913. private _samplerName;
  20914. private _linearDefineName;
  20915. private _gammaDefineName;
  20916. private _mainUVName;
  20917. private _tempTextureRead;
  20918. /**
  20919. * Gets or sets the texture associated with the node
  20920. */
  20921. texture: Nullable<BaseTexture>;
  20922. /**
  20923. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20924. */
  20925. convertToGammaSpace: boolean;
  20926. /**
  20927. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20928. */
  20929. convertToLinearSpace: boolean;
  20930. /**
  20931. * Create a new CurrentScreenBlock
  20932. * @param name defines the block name
  20933. */
  20934. constructor(name: string);
  20935. /**
  20936. * Gets the current class name
  20937. * @returns the class name
  20938. */
  20939. getClassName(): string;
  20940. /**
  20941. * Gets the uv input component
  20942. */
  20943. get uv(): NodeMaterialConnectionPoint;
  20944. /**
  20945. * Gets the rgba output component
  20946. */
  20947. get rgba(): NodeMaterialConnectionPoint;
  20948. /**
  20949. * Gets the rgb output component
  20950. */
  20951. get rgb(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the r output component
  20954. */
  20955. get r(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the g output component
  20958. */
  20959. get g(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the b output component
  20962. */
  20963. get b(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the a output component
  20966. */
  20967. get a(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Initialize the block and prepare the context for build
  20970. * @param state defines the state that will be used for the build
  20971. */
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. get target(): NodeMaterialBlockTargets;
  20974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20975. isReady(): boolean;
  20976. private _injectVertexCode;
  20977. private _writeTextureRead;
  20978. private _writeOutput;
  20979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20980. serialize(): any;
  20981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20982. }
  20983. }
  20984. declare module BABYLON {
  20985. /**
  20986. * Base block used for the particle texture
  20987. */
  20988. export class ParticleTextureBlock extends NodeMaterialBlock {
  20989. private _samplerName;
  20990. private _linearDefineName;
  20991. private _gammaDefineName;
  20992. private _tempTextureRead;
  20993. /**
  20994. * Gets or sets the texture associated with the node
  20995. */
  20996. texture: Nullable<BaseTexture>;
  20997. /**
  20998. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20999. */
  21000. convertToGammaSpace: boolean;
  21001. /**
  21002. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21003. */
  21004. convertToLinearSpace: boolean;
  21005. /**
  21006. * Create a new ParticleTextureBlock
  21007. * @param name defines the block name
  21008. */
  21009. constructor(name: string);
  21010. /**
  21011. * Gets the current class name
  21012. * @returns the class name
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Gets the uv input component
  21017. */
  21018. get uv(): NodeMaterialConnectionPoint;
  21019. /**
  21020. * Gets the rgba output component
  21021. */
  21022. get rgba(): NodeMaterialConnectionPoint;
  21023. /**
  21024. * Gets the rgb output component
  21025. */
  21026. get rgb(): NodeMaterialConnectionPoint;
  21027. /**
  21028. * Gets the r output component
  21029. */
  21030. get r(): NodeMaterialConnectionPoint;
  21031. /**
  21032. * Gets the g output component
  21033. */
  21034. get g(): NodeMaterialConnectionPoint;
  21035. /**
  21036. * Gets the b output component
  21037. */
  21038. get b(): NodeMaterialConnectionPoint;
  21039. /**
  21040. * Gets the a output component
  21041. */
  21042. get a(): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Initialize the block and prepare the context for build
  21045. * @param state defines the state that will be used for the build
  21046. */
  21047. initialize(state: NodeMaterialBuildState): void;
  21048. autoConfigure(material: NodeMaterial): void;
  21049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21050. isReady(): boolean;
  21051. private _writeOutput;
  21052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21053. serialize(): any;
  21054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. /**
  21059. * Class used to store shared data between 2 NodeMaterialBuildState
  21060. */
  21061. export class NodeMaterialBuildStateSharedData {
  21062. /**
  21063. * Gets the list of emitted varyings
  21064. */
  21065. temps: string[];
  21066. /**
  21067. * Gets the list of emitted varyings
  21068. */
  21069. varyings: string[];
  21070. /**
  21071. * Gets the varying declaration string
  21072. */
  21073. varyingDeclaration: string;
  21074. /**
  21075. * Input blocks
  21076. */
  21077. inputBlocks: InputBlock[];
  21078. /**
  21079. * Input blocks
  21080. */
  21081. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21082. /**
  21083. * Bindable blocks (Blocks that need to set data to the effect)
  21084. */
  21085. bindableBlocks: NodeMaterialBlock[];
  21086. /**
  21087. * List of blocks that can provide a compilation fallback
  21088. */
  21089. blocksWithFallbacks: NodeMaterialBlock[];
  21090. /**
  21091. * List of blocks that can provide a define update
  21092. */
  21093. blocksWithDefines: NodeMaterialBlock[];
  21094. /**
  21095. * List of blocks that can provide a repeatable content
  21096. */
  21097. repeatableContentBlocks: NodeMaterialBlock[];
  21098. /**
  21099. * List of blocks that can provide a dynamic list of uniforms
  21100. */
  21101. dynamicUniformBlocks: NodeMaterialBlock[];
  21102. /**
  21103. * List of blocks that can block the isReady function for the material
  21104. */
  21105. blockingBlocks: NodeMaterialBlock[];
  21106. /**
  21107. * Gets the list of animated inputs
  21108. */
  21109. animatedInputs: InputBlock[];
  21110. /**
  21111. * Build Id used to avoid multiple recompilations
  21112. */
  21113. buildId: number;
  21114. /** List of emitted variables */
  21115. variableNames: {
  21116. [key: string]: number;
  21117. };
  21118. /** List of emitted defines */
  21119. defineNames: {
  21120. [key: string]: number;
  21121. };
  21122. /** Should emit comments? */
  21123. emitComments: boolean;
  21124. /** Emit build activity */
  21125. verbose: boolean;
  21126. /** Gets or sets the hosting scene */
  21127. scene: Scene;
  21128. /**
  21129. * Gets the compilation hints emitted at compilation time
  21130. */
  21131. hints: {
  21132. needWorldViewMatrix: boolean;
  21133. needWorldViewProjectionMatrix: boolean;
  21134. needAlphaBlending: boolean;
  21135. needAlphaTesting: boolean;
  21136. };
  21137. /**
  21138. * List of compilation checks
  21139. */
  21140. checks: {
  21141. emitVertex: boolean;
  21142. emitFragment: boolean;
  21143. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21144. };
  21145. /**
  21146. * Is vertex program allowed to be empty?
  21147. */
  21148. allowEmptyVertexProgram: boolean;
  21149. /** Creates a new shared data */
  21150. constructor();
  21151. /**
  21152. * Emits console errors and exceptions if there is a failing check
  21153. */
  21154. emitErrors(): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class used to store node based material build state
  21160. */
  21161. export class NodeMaterialBuildState {
  21162. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21163. supportUniformBuffers: boolean;
  21164. /**
  21165. * Gets the list of emitted attributes
  21166. */
  21167. attributes: string[];
  21168. /**
  21169. * Gets the list of emitted uniforms
  21170. */
  21171. uniforms: string[];
  21172. /**
  21173. * Gets the list of emitted constants
  21174. */
  21175. constants: string[];
  21176. /**
  21177. * Gets the list of emitted samplers
  21178. */
  21179. samplers: string[];
  21180. /**
  21181. * Gets the list of emitted functions
  21182. */
  21183. functions: {
  21184. [key: string]: string;
  21185. };
  21186. /**
  21187. * Gets the list of emitted extensions
  21188. */
  21189. extensions: {
  21190. [key: string]: string;
  21191. };
  21192. /**
  21193. * Gets the target of the compilation state
  21194. */
  21195. target: NodeMaterialBlockTargets;
  21196. /**
  21197. * Gets the list of emitted counters
  21198. */
  21199. counters: {
  21200. [key: string]: number;
  21201. };
  21202. /**
  21203. * Shared data between multiple NodeMaterialBuildState instances
  21204. */
  21205. sharedData: NodeMaterialBuildStateSharedData;
  21206. /** @hidden */
  21207. _vertexState: NodeMaterialBuildState;
  21208. /** @hidden */
  21209. _attributeDeclaration: string;
  21210. /** @hidden */
  21211. _uniformDeclaration: string;
  21212. /** @hidden */
  21213. _constantDeclaration: string;
  21214. /** @hidden */
  21215. _samplerDeclaration: string;
  21216. /** @hidden */
  21217. _varyingTransfer: string;
  21218. /** @hidden */
  21219. _injectAtEnd: string;
  21220. private _repeatableContentAnchorIndex;
  21221. /** @hidden */
  21222. _builtCompilationString: string;
  21223. /**
  21224. * Gets the emitted compilation strings
  21225. */
  21226. compilationString: string;
  21227. /**
  21228. * Finalize the compilation strings
  21229. * @param state defines the current compilation state
  21230. */
  21231. finalize(state: NodeMaterialBuildState): void;
  21232. /** @hidden */
  21233. get _repeatableContentAnchor(): string;
  21234. /** @hidden */
  21235. _getFreeVariableName(prefix: string): string;
  21236. /** @hidden */
  21237. _getFreeDefineName(prefix: string): string;
  21238. /** @hidden */
  21239. _excludeVariableName(name: string): void;
  21240. /** @hidden */
  21241. _emit2DSampler(name: string): void;
  21242. /** @hidden */
  21243. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21244. /** @hidden */
  21245. _emitExtension(name: string, extension: string, define?: string): void;
  21246. /** @hidden */
  21247. _emitFunction(name: string, code: string, comments: string): void;
  21248. /** @hidden */
  21249. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21250. replaceStrings?: {
  21251. search: RegExp;
  21252. replace: string;
  21253. }[];
  21254. repeatKey?: string;
  21255. }): string;
  21256. /** @hidden */
  21257. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21258. repeatKey?: string;
  21259. removeAttributes?: boolean;
  21260. removeUniforms?: boolean;
  21261. removeVaryings?: boolean;
  21262. removeIfDef?: boolean;
  21263. replaceStrings?: {
  21264. search: RegExp;
  21265. replace: string;
  21266. }[];
  21267. }, storeKey?: string): void;
  21268. /** @hidden */
  21269. _registerTempVariable(name: string): boolean;
  21270. /** @hidden */
  21271. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21272. /** @hidden */
  21273. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21274. /** @hidden */
  21275. _emitFloat(value: number): string;
  21276. }
  21277. }
  21278. declare module BABYLON {
  21279. /**
  21280. * Helper class used to generate session unique ID
  21281. */
  21282. export class UniqueIdGenerator {
  21283. private static _UniqueIdCounter;
  21284. /**
  21285. * Gets an unique (relatively to the current scene) Id
  21286. */
  21287. static get UniqueId(): number;
  21288. }
  21289. }
  21290. declare module BABYLON {
  21291. /**
  21292. * Defines a block that can be used inside a node based material
  21293. */
  21294. export class NodeMaterialBlock {
  21295. private _buildId;
  21296. private _buildTarget;
  21297. private _target;
  21298. private _isFinalMerger;
  21299. private _isInput;
  21300. protected _isUnique: boolean;
  21301. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21302. inputsAreExclusive: boolean;
  21303. /** @hidden */
  21304. _codeVariableName: string;
  21305. /** @hidden */
  21306. _inputs: NodeMaterialConnectionPoint[];
  21307. /** @hidden */
  21308. _outputs: NodeMaterialConnectionPoint[];
  21309. /** @hidden */
  21310. _preparationId: number;
  21311. /**
  21312. * Gets or sets the name of the block
  21313. */
  21314. name: string;
  21315. /**
  21316. * Gets or sets the unique id of the node
  21317. */
  21318. uniqueId: number;
  21319. /**
  21320. * Gets or sets the comments associated with this block
  21321. */
  21322. comments: string;
  21323. /**
  21324. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21325. */
  21326. get isUnique(): boolean;
  21327. /**
  21328. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21329. */
  21330. get isFinalMerger(): boolean;
  21331. /**
  21332. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21333. */
  21334. get isInput(): boolean;
  21335. /**
  21336. * Gets or sets the build Id
  21337. */
  21338. get buildId(): number;
  21339. set buildId(value: number);
  21340. /**
  21341. * Gets or sets the target of the block
  21342. */
  21343. get target(): NodeMaterialBlockTargets;
  21344. set target(value: NodeMaterialBlockTargets);
  21345. /**
  21346. * Gets the list of input points
  21347. */
  21348. get inputs(): NodeMaterialConnectionPoint[];
  21349. /** Gets the list of output points */
  21350. get outputs(): NodeMaterialConnectionPoint[];
  21351. /**
  21352. * Find an input by its name
  21353. * @param name defines the name of the input to look for
  21354. * @returns the input or null if not found
  21355. */
  21356. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21357. /**
  21358. * Find an output by its name
  21359. * @param name defines the name of the outputto look for
  21360. * @returns the output or null if not found
  21361. */
  21362. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21363. /**
  21364. * Creates a new NodeMaterialBlock
  21365. * @param name defines the block name
  21366. * @param target defines the target of that block (Vertex by default)
  21367. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21368. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21369. */
  21370. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. /**
  21377. * Bind data to effect. Will only be called for blocks with isBindable === true
  21378. * @param effect defines the effect to bind data to
  21379. * @param nodeMaterial defines the hosting NodeMaterial
  21380. * @param mesh defines the mesh that will be rendered
  21381. * @param subMesh defines the submesh that will be rendered
  21382. */
  21383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21384. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21385. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21386. protected _writeFloat(value: number): string;
  21387. /**
  21388. * Gets the current class name e.g. "NodeMaterialBlock"
  21389. * @returns the class name
  21390. */
  21391. getClassName(): string;
  21392. /**
  21393. * Register a new input. Must be called inside a block constructor
  21394. * @param name defines the connection point name
  21395. * @param type defines the connection point type
  21396. * @param isOptional defines a boolean indicating that this input can be omitted
  21397. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21398. * @param point an already created connection point. If not provided, create a new one
  21399. * @returns the current block
  21400. */
  21401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21402. /**
  21403. * Register a new output. Must be called inside a block constructor
  21404. * @param name defines the connection point name
  21405. * @param type defines the connection point type
  21406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21407. * @param point an already created connection point. If not provided, create a new one
  21408. * @returns the current block
  21409. */
  21410. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21411. /**
  21412. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21413. * @param forOutput defines an optional connection point to check compatibility with
  21414. * @returns the first available input or null
  21415. */
  21416. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21417. /**
  21418. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21419. * @param forBlock defines an optional block to check compatibility with
  21420. * @returns the first available input or null
  21421. */
  21422. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21423. /**
  21424. * Gets the sibling of the given output
  21425. * @param current defines the current output
  21426. * @returns the next output in the list or null
  21427. */
  21428. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21429. /**
  21430. * Connect current block with another block
  21431. * @param other defines the block to connect with
  21432. * @param options define the various options to help pick the right connections
  21433. * @returns the current block
  21434. */
  21435. connectTo(other: NodeMaterialBlock, options?: {
  21436. input?: string;
  21437. output?: string;
  21438. outputSwizzle?: string;
  21439. }): this | undefined;
  21440. protected _buildBlock(state: NodeMaterialBuildState): void;
  21441. /**
  21442. * Add uniforms, samplers and uniform buffers at compilation time
  21443. * @param state defines the state to update
  21444. * @param nodeMaterial defines the node material requesting the update
  21445. * @param defines defines the material defines to update
  21446. * @param uniformBuffers defines the list of uniform buffer names
  21447. */
  21448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21449. /**
  21450. * Add potential fallbacks if shader compilation fails
  21451. * @param mesh defines the mesh to be rendered
  21452. * @param fallbacks defines the current prioritized list of fallbacks
  21453. */
  21454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21455. /**
  21456. * Initialize defines for shader compilation
  21457. * @param mesh defines the mesh to be rendered
  21458. * @param nodeMaterial defines the node material requesting the update
  21459. * @param defines defines the material defines to update
  21460. * @param useInstances specifies that instances should be used
  21461. */
  21462. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21463. /**
  21464. * Update defines for shader compilation
  21465. * @param mesh defines the mesh to be rendered
  21466. * @param nodeMaterial defines the node material requesting the update
  21467. * @param defines defines the material defines to update
  21468. * @param useInstances specifies that instances should be used
  21469. * @param subMesh defines which submesh to render
  21470. */
  21471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21472. /**
  21473. * Lets the block try to connect some inputs automatically
  21474. * @param material defines the hosting NodeMaterial
  21475. */
  21476. autoConfigure(material: NodeMaterial): void;
  21477. /**
  21478. * Function called when a block is declared as repeatable content generator
  21479. * @param vertexShaderState defines the current compilation state for the vertex shader
  21480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21481. * @param mesh defines the mesh to be rendered
  21482. * @param defines defines the material defines to update
  21483. */
  21484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21485. /**
  21486. * Checks if the block is ready
  21487. * @param mesh defines the mesh to be rendered
  21488. * @param nodeMaterial defines the node material requesting the update
  21489. * @param defines defines the material defines to update
  21490. * @param useInstances specifies that instances should be used
  21491. * @returns true if the block is ready
  21492. */
  21493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21495. private _processBuild;
  21496. /**
  21497. * Compile the current node and generate the shader code
  21498. * @param state defines the current compilation state (uniforms, samplers, current string)
  21499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21500. * @returns true if already built
  21501. */
  21502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21503. protected _inputRename(name: string): string;
  21504. protected _outputRename(name: string): string;
  21505. protected _dumpPropertiesCode(): string;
  21506. /** @hidden */
  21507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21508. /** @hidden */
  21509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21510. /**
  21511. * Clone the current block to a new identical block
  21512. * @param scene defines the hosting scene
  21513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21514. * @returns a copy of the current block
  21515. */
  21516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21517. /**
  21518. * Serializes this block in a JSON representation
  21519. * @returns the serialized block object
  21520. */
  21521. serialize(): any;
  21522. /** @hidden */
  21523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21524. private _deserializePortDisplayNames;
  21525. /**
  21526. * Release resources
  21527. */
  21528. dispose(): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * Base class of materials working in push mode in babylon JS
  21534. * @hidden
  21535. */
  21536. export class PushMaterial extends Material {
  21537. protected _activeEffect: Effect;
  21538. protected _normalMatrix: Matrix;
  21539. /**
  21540. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21541. * This means that the material can keep using a previous shader while a new one is being compiled.
  21542. * This is mostly used when shader parallel compilation is supported (true by default)
  21543. */
  21544. allowShaderHotSwapping: boolean;
  21545. constructor(name: string, scene: Scene);
  21546. getEffect(): Effect;
  21547. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21548. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21549. /**
  21550. * Binds the given world matrix to the active effect
  21551. *
  21552. * @param world the matrix to bind
  21553. */
  21554. bindOnlyWorldMatrix(world: Matrix): void;
  21555. /**
  21556. * Binds the given normal matrix to the active effect
  21557. *
  21558. * @param normalMatrix the matrix to bind
  21559. */
  21560. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21561. bind(world: Matrix, mesh?: Mesh): void;
  21562. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21563. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * Root class for all node material optimizers
  21569. */
  21570. export class NodeMaterialOptimizer {
  21571. /**
  21572. * Function used to optimize a NodeMaterial graph
  21573. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21574. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21575. */
  21576. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21577. }
  21578. }
  21579. declare module BABYLON {
  21580. /**
  21581. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21582. */
  21583. export class TransformBlock extends NodeMaterialBlock {
  21584. /**
  21585. * Defines the value to use to complement W value to transform it to a Vector4
  21586. */
  21587. complementW: number;
  21588. /**
  21589. * Defines the value to use to complement z value to transform it to a Vector4
  21590. */
  21591. complementZ: number;
  21592. /**
  21593. * Creates a new TransformBlock
  21594. * @param name defines the block name
  21595. */
  21596. constructor(name: string);
  21597. /**
  21598. * Gets the current class name
  21599. * @returns the class name
  21600. */
  21601. getClassName(): string;
  21602. /**
  21603. * Gets the vector input
  21604. */
  21605. get vector(): NodeMaterialConnectionPoint;
  21606. /**
  21607. * Gets the output component
  21608. */
  21609. get output(): NodeMaterialConnectionPoint;
  21610. /**
  21611. * Gets the xyz output component
  21612. */
  21613. get xyz(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the matrix transform input
  21616. */
  21617. get transform(): NodeMaterialConnectionPoint;
  21618. protected _buildBlock(state: NodeMaterialBuildState): this;
  21619. serialize(): any;
  21620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21621. protected _dumpPropertiesCode(): string;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Block used to output the vertex position
  21627. */
  21628. export class VertexOutputBlock extends NodeMaterialBlock {
  21629. /**
  21630. * Creates a new VertexOutputBlock
  21631. * @param name defines the block name
  21632. */
  21633. constructor(name: string);
  21634. /**
  21635. * Gets the current class name
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Gets the vector input component
  21641. */
  21642. get vector(): NodeMaterialConnectionPoint;
  21643. protected _buildBlock(state: NodeMaterialBuildState): this;
  21644. }
  21645. }
  21646. declare module BABYLON {
  21647. /**
  21648. * Block used to output the final color
  21649. */
  21650. export class FragmentOutputBlock extends NodeMaterialBlock {
  21651. /**
  21652. * Create a new FragmentOutputBlock
  21653. * @param name defines the block name
  21654. */
  21655. constructor(name: string);
  21656. /**
  21657. * Gets the current class name
  21658. * @returns the class name
  21659. */
  21660. getClassName(): string;
  21661. /**
  21662. * Gets the rgba input component
  21663. */
  21664. get rgba(): NodeMaterialConnectionPoint;
  21665. /**
  21666. * Gets the rgb input component
  21667. */
  21668. get rgb(): NodeMaterialConnectionPoint;
  21669. /**
  21670. * Gets the a input component
  21671. */
  21672. get a(): NodeMaterialConnectionPoint;
  21673. protected _buildBlock(state: NodeMaterialBuildState): this;
  21674. }
  21675. }
  21676. declare module BABYLON {
  21677. /**
  21678. * Block used for the particle ramp gradient section
  21679. */
  21680. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21681. /**
  21682. * Create a new ParticleRampGradientBlock
  21683. * @param name defines the block name
  21684. */
  21685. constructor(name: string);
  21686. /**
  21687. * Gets the current class name
  21688. * @returns the class name
  21689. */
  21690. getClassName(): string;
  21691. /**
  21692. * Gets the color input component
  21693. */
  21694. get color(): NodeMaterialConnectionPoint;
  21695. /**
  21696. * Gets the rampColor output component
  21697. */
  21698. get rampColor(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Initialize the block and prepare the context for build
  21701. * @param state defines the state that will be used for the build
  21702. */
  21703. initialize(state: NodeMaterialBuildState): void;
  21704. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21705. }
  21706. }
  21707. declare module BABYLON {
  21708. /**
  21709. * Block used for the particle blend multiply section
  21710. */
  21711. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21712. /**
  21713. * Create a new ParticleBlendMultiplyBlock
  21714. * @param name defines the block name
  21715. */
  21716. constructor(name: string);
  21717. /**
  21718. * Gets the current class name
  21719. * @returns the class name
  21720. */
  21721. getClassName(): string;
  21722. /**
  21723. * Gets the color input component
  21724. */
  21725. get color(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the alphaTexture input component
  21728. */
  21729. get alphaTexture(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the alphaColor input component
  21732. */
  21733. get alphaColor(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the blendColor output component
  21736. */
  21737. get blendColor(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Initialize the block and prepare the context for build
  21740. * @param state defines the state that will be used for the build
  21741. */
  21742. initialize(state: NodeMaterialBuildState): void;
  21743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21749. */
  21750. export class VectorMergerBlock extends NodeMaterialBlock {
  21751. /**
  21752. * Create a new VectorMergerBlock
  21753. * @param name defines the block name
  21754. */
  21755. constructor(name: string);
  21756. /**
  21757. * Gets the current class name
  21758. * @returns the class name
  21759. */
  21760. getClassName(): string;
  21761. /**
  21762. * Gets the xyz component (input)
  21763. */
  21764. get xyzIn(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the xy component (input)
  21767. */
  21768. get xyIn(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the x component (input)
  21771. */
  21772. get x(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the y component (input)
  21775. */
  21776. get y(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the z component (input)
  21779. */
  21780. get z(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the w component (input)
  21783. */
  21784. get w(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the xyzw component (output)
  21787. */
  21788. get xyzw(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the xyz component (output)
  21791. */
  21792. get xyzOut(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the xy component (output)
  21795. */
  21796. get xyOut(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the xy component (output)
  21799. * @deprecated Please use xyOut instead.
  21800. */
  21801. get xy(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the xyz component (output)
  21804. * @deprecated Please use xyzOut instead.
  21805. */
  21806. get xyz(): NodeMaterialConnectionPoint;
  21807. protected _buildBlock(state: NodeMaterialBuildState): this;
  21808. }
  21809. }
  21810. declare module BABYLON {
  21811. /**
  21812. * Block used to remap a float from a range to a new one
  21813. */
  21814. export class RemapBlock extends NodeMaterialBlock {
  21815. /**
  21816. * Gets or sets the source range
  21817. */
  21818. sourceRange: Vector2;
  21819. /**
  21820. * Gets or sets the target range
  21821. */
  21822. targetRange: Vector2;
  21823. /**
  21824. * Creates a new RemapBlock
  21825. * @param name defines the block name
  21826. */
  21827. constructor(name: string);
  21828. /**
  21829. * Gets the current class name
  21830. * @returns the class name
  21831. */
  21832. getClassName(): string;
  21833. /**
  21834. * Gets the input component
  21835. */
  21836. get input(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the source min input component
  21839. */
  21840. get sourceMin(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the source max input component
  21843. */
  21844. get sourceMax(): NodeMaterialConnectionPoint;
  21845. /**
  21846. * Gets the target min input component
  21847. */
  21848. get targetMin(): NodeMaterialConnectionPoint;
  21849. /**
  21850. * Gets the target max input component
  21851. */
  21852. get targetMax(): NodeMaterialConnectionPoint;
  21853. /**
  21854. * Gets the output component
  21855. */
  21856. get output(): NodeMaterialConnectionPoint;
  21857. protected _buildBlock(state: NodeMaterialBuildState): this;
  21858. protected _dumpPropertiesCode(): string;
  21859. serialize(): any;
  21860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * Block used to multiply 2 values
  21866. */
  21867. export class MultiplyBlock extends NodeMaterialBlock {
  21868. /**
  21869. * Creates a new MultiplyBlock
  21870. * @param name defines the block name
  21871. */
  21872. constructor(name: string);
  21873. /**
  21874. * Gets the current class name
  21875. * @returns the class name
  21876. */
  21877. getClassName(): string;
  21878. /**
  21879. * Gets the left operand input component
  21880. */
  21881. get left(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the right operand input component
  21884. */
  21885. get right(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the output component
  21888. */
  21889. get output(): NodeMaterialConnectionPoint;
  21890. protected _buildBlock(state: NodeMaterialBuildState): this;
  21891. }
  21892. }
  21893. declare module BABYLON {
  21894. /**
  21895. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21896. */
  21897. export class ColorSplitterBlock extends NodeMaterialBlock {
  21898. /**
  21899. * Create a new ColorSplitterBlock
  21900. * @param name defines the block name
  21901. */
  21902. constructor(name: string);
  21903. /**
  21904. * Gets the current class name
  21905. * @returns the class name
  21906. */
  21907. getClassName(): string;
  21908. /**
  21909. * Gets the rgba component (input)
  21910. */
  21911. get rgba(): NodeMaterialConnectionPoint;
  21912. /**
  21913. * Gets the rgb component (input)
  21914. */
  21915. get rgbIn(): NodeMaterialConnectionPoint;
  21916. /**
  21917. * Gets the rgb component (output)
  21918. */
  21919. get rgbOut(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the r component (output)
  21922. */
  21923. get r(): NodeMaterialConnectionPoint;
  21924. /**
  21925. * Gets the g component (output)
  21926. */
  21927. get g(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the b component (output)
  21930. */
  21931. get b(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the a component (output)
  21934. */
  21935. get a(): NodeMaterialConnectionPoint;
  21936. protected _inputRename(name: string): string;
  21937. protected _outputRename(name: string): string;
  21938. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. /**
  21943. * Interface used to configure the node material editor
  21944. */
  21945. export interface INodeMaterialEditorOptions {
  21946. /** Define the URl to load node editor script */
  21947. editorURL?: string;
  21948. }
  21949. /** @hidden */
  21950. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21951. NORMAL: boolean;
  21952. TANGENT: boolean;
  21953. UV1: boolean;
  21954. /** BONES */
  21955. NUM_BONE_INFLUENCERS: number;
  21956. BonesPerMesh: number;
  21957. BONETEXTURE: boolean;
  21958. /** MORPH TARGETS */
  21959. MORPHTARGETS: boolean;
  21960. MORPHTARGETS_NORMAL: boolean;
  21961. MORPHTARGETS_TANGENT: boolean;
  21962. MORPHTARGETS_UV: boolean;
  21963. NUM_MORPH_INFLUENCERS: number;
  21964. /** IMAGE PROCESSING */
  21965. IMAGEPROCESSING: boolean;
  21966. VIGNETTE: boolean;
  21967. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21968. VIGNETTEBLENDMODEOPAQUE: boolean;
  21969. TONEMAPPING: boolean;
  21970. TONEMAPPING_ACES: boolean;
  21971. CONTRAST: boolean;
  21972. EXPOSURE: boolean;
  21973. COLORCURVES: boolean;
  21974. COLORGRADING: boolean;
  21975. COLORGRADING3D: boolean;
  21976. SAMPLER3DGREENDEPTH: boolean;
  21977. SAMPLER3DBGRMAP: boolean;
  21978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21979. /** MISC. */
  21980. BUMPDIRECTUV: number;
  21981. constructor();
  21982. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21983. }
  21984. /**
  21985. * Class used to configure NodeMaterial
  21986. */
  21987. export interface INodeMaterialOptions {
  21988. /**
  21989. * Defines if blocks should emit comments
  21990. */
  21991. emitComments: boolean;
  21992. }
  21993. /**
  21994. * Class used to create a node based material built by assembling shader blocks
  21995. */
  21996. export class NodeMaterial extends PushMaterial {
  21997. private static _BuildIdGenerator;
  21998. private _options;
  21999. private _vertexCompilationState;
  22000. private _fragmentCompilationState;
  22001. private _sharedData;
  22002. private _buildId;
  22003. private _buildWasSuccessful;
  22004. private _cachedWorldViewMatrix;
  22005. private _cachedWorldViewProjectionMatrix;
  22006. private _optimizers;
  22007. private _animationFrame;
  22008. /** Define the Url to load node editor script */
  22009. static EditorURL: string;
  22010. /** Define the Url to load snippets */
  22011. static SnippetUrl: string;
  22012. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22013. static IgnoreTexturesAtLoadTime: boolean;
  22014. private BJSNODEMATERIALEDITOR;
  22015. /** Get the inspector from bundle or global */
  22016. private _getGlobalNodeMaterialEditor;
  22017. /**
  22018. * Snippet ID if the material was created from the snippet server
  22019. */
  22020. snippetId: string;
  22021. /**
  22022. * Gets or sets data used by visual editor
  22023. * @see https://nme.babylonjs.com
  22024. */
  22025. editorData: any;
  22026. /**
  22027. * 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)
  22028. */
  22029. ignoreAlpha: boolean;
  22030. /**
  22031. * Defines the maximum number of lights that can be used in the material
  22032. */
  22033. maxSimultaneousLights: number;
  22034. /**
  22035. * Observable raised when the material is built
  22036. */
  22037. onBuildObservable: Observable<NodeMaterial>;
  22038. /**
  22039. * Gets or sets the root nodes of the material vertex shader
  22040. */
  22041. _vertexOutputNodes: NodeMaterialBlock[];
  22042. /**
  22043. * Gets or sets the root nodes of the material fragment (pixel) shader
  22044. */
  22045. _fragmentOutputNodes: NodeMaterialBlock[];
  22046. /** Gets or sets options to control the node material overall behavior */
  22047. get options(): INodeMaterialOptions;
  22048. set options(options: INodeMaterialOptions);
  22049. /**
  22050. * Default configuration related to image processing available in the standard Material.
  22051. */
  22052. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22053. /**
  22054. * Gets the image processing configuration used either in this material.
  22055. */
  22056. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22057. /**
  22058. * Sets the Default image processing configuration used either in the this material.
  22059. *
  22060. * If sets to null, the scene one is in use.
  22061. */
  22062. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22063. /**
  22064. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22065. */
  22066. attachedBlocks: NodeMaterialBlock[];
  22067. /**
  22068. * Specifies the mode of the node material
  22069. * @hidden
  22070. */
  22071. _mode: NodeMaterialModes;
  22072. /**
  22073. * Gets the mode property
  22074. */
  22075. get mode(): NodeMaterialModes;
  22076. /**
  22077. * Create a new node based material
  22078. * @param name defines the material name
  22079. * @param scene defines the hosting scene
  22080. * @param options defines creation option
  22081. */
  22082. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22083. /**
  22084. * Gets the current class name of the material e.g. "NodeMaterial"
  22085. * @returns the class name
  22086. */
  22087. getClassName(): string;
  22088. /**
  22089. * Keep track of the image processing observer to allow dispose and replace.
  22090. */
  22091. private _imageProcessingObserver;
  22092. /**
  22093. * Attaches a new image processing configuration to the Standard Material.
  22094. * @param configuration
  22095. */
  22096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22097. /**
  22098. * Get a block by its name
  22099. * @param name defines the name of the block to retrieve
  22100. * @returns the required block or null if not found
  22101. */
  22102. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22103. /**
  22104. * Get a block by its name
  22105. * @param predicate defines the predicate used to find the good candidate
  22106. * @returns the required block or null if not found
  22107. */
  22108. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22109. /**
  22110. * Get an input block by its name
  22111. * @param predicate defines the predicate used to find the good candidate
  22112. * @returns the required input block or null if not found
  22113. */
  22114. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22115. /**
  22116. * Gets the list of input blocks attached to this material
  22117. * @returns an array of InputBlocks
  22118. */
  22119. getInputBlocks(): InputBlock[];
  22120. /**
  22121. * Adds a new optimizer to the list of optimizers
  22122. * @param optimizer defines the optimizers to add
  22123. * @returns the current material
  22124. */
  22125. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22126. /**
  22127. * Remove an optimizer from the list of optimizers
  22128. * @param optimizer defines the optimizers to remove
  22129. * @returns the current material
  22130. */
  22131. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22132. /**
  22133. * Add a new block to the list of output nodes
  22134. * @param node defines the node to add
  22135. * @returns the current material
  22136. */
  22137. addOutputNode(node: NodeMaterialBlock): this;
  22138. /**
  22139. * Remove a block from the list of root nodes
  22140. * @param node defines the node to remove
  22141. * @returns the current material
  22142. */
  22143. removeOutputNode(node: NodeMaterialBlock): this;
  22144. private _addVertexOutputNode;
  22145. private _removeVertexOutputNode;
  22146. private _addFragmentOutputNode;
  22147. private _removeFragmentOutputNode;
  22148. /**
  22149. * Specifies if the material will require alpha blending
  22150. * @returns a boolean specifying if alpha blending is needed
  22151. */
  22152. needAlphaBlending(): boolean;
  22153. /**
  22154. * Specifies if this material should be rendered in alpha test mode
  22155. * @returns a boolean specifying if an alpha test is needed.
  22156. */
  22157. needAlphaTesting(): boolean;
  22158. private _initializeBlock;
  22159. private _resetDualBlocks;
  22160. /**
  22161. * Remove a block from the current node material
  22162. * @param block defines the block to remove
  22163. */
  22164. removeBlock(block: NodeMaterialBlock): void;
  22165. /**
  22166. * Build the material and generates the inner effect
  22167. * @param verbose defines if the build should log activity
  22168. */
  22169. build(verbose?: boolean): void;
  22170. /**
  22171. * Runs an otpimization phase to try to improve the shader code
  22172. */
  22173. optimize(): void;
  22174. private _prepareDefinesForAttributes;
  22175. /**
  22176. * Create a post process from the material
  22177. * @param camera The camera to apply the render pass to.
  22178. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22180. * @param engine The engine which the post process will be applied. (default: current engine)
  22181. * @param reusable If the post process can be reused on the same frame. (default: false)
  22182. * @param textureType Type of textures used when performing the post process. (default: 0)
  22183. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22184. * @returns the post process created
  22185. */
  22186. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22187. /**
  22188. * Create the post process effect from the material
  22189. * @param postProcess The post process to create the effect for
  22190. */
  22191. createEffectForPostProcess(postProcess: PostProcess): void;
  22192. private _createEffectOrPostProcess;
  22193. private _createEffectForParticles;
  22194. /**
  22195. * Create the effect to be used as the custom effect for a particle system
  22196. * @param particleSystem Particle system to create the effect for
  22197. * @param onCompiled defines a function to call when the effect creation is successful
  22198. * @param onError defines a function to call when the effect creation has failed
  22199. */
  22200. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22201. private _processDefines;
  22202. /**
  22203. * Get if the submesh is ready to be used and all its information available.
  22204. * Child classes can use it to update shaders
  22205. * @param mesh defines the mesh to check
  22206. * @param subMesh defines which submesh to check
  22207. * @param useInstances specifies that instances should be used
  22208. * @returns a boolean indicating that the submesh is ready or not
  22209. */
  22210. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22211. /**
  22212. * Get a string representing the shaders built by the current node graph
  22213. */
  22214. get compiledShaders(): string;
  22215. /**
  22216. * Binds the world matrix to the material
  22217. * @param world defines the world transformation matrix
  22218. */
  22219. bindOnlyWorldMatrix(world: Matrix): void;
  22220. /**
  22221. * Binds the submesh to this material by preparing the effect and shader to draw
  22222. * @param world defines the world transformation matrix
  22223. * @param mesh defines the mesh containing the submesh
  22224. * @param subMesh defines the submesh to bind the material to
  22225. */
  22226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22227. /**
  22228. * Gets the active textures from the material
  22229. * @returns an array of textures
  22230. */
  22231. getActiveTextures(): BaseTexture[];
  22232. /**
  22233. * Gets the list of texture blocks
  22234. * @returns an array of texture blocks
  22235. */
  22236. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22237. /**
  22238. * Specifies if the material uses a texture
  22239. * @param texture defines the texture to check against the material
  22240. * @returns a boolean specifying if the material uses the texture
  22241. */
  22242. hasTexture(texture: BaseTexture): boolean;
  22243. /**
  22244. * Disposes the material
  22245. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22246. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22247. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22248. */
  22249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22250. /** Creates the node editor window. */
  22251. private _createNodeEditor;
  22252. /**
  22253. * Launch the node material editor
  22254. * @param config Define the configuration of the editor
  22255. * @return a promise fulfilled when the node editor is visible
  22256. */
  22257. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22258. /**
  22259. * Clear the current material
  22260. */
  22261. clear(): void;
  22262. /**
  22263. * Clear the current material and set it to a default state
  22264. */
  22265. setToDefault(): void;
  22266. /**
  22267. * Clear the current material and set it to a default state for post process
  22268. */
  22269. setToDefaultPostProcess(): void;
  22270. /**
  22271. * Clear the current material and set it to a default state for particle
  22272. */
  22273. setToDefaultParticle(): void;
  22274. /**
  22275. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22276. * @param url defines the url to load from
  22277. * @returns a promise that will fullfil when the material is fully loaded
  22278. */
  22279. loadAsync(url: string): Promise<void>;
  22280. private _gatherBlocks;
  22281. /**
  22282. * Generate a string containing the code declaration required to create an equivalent of this material
  22283. * @returns a string
  22284. */
  22285. generateCode(): string;
  22286. /**
  22287. * Serializes this material in a JSON representation
  22288. * @returns the serialized material object
  22289. */
  22290. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22291. private _restoreConnections;
  22292. /**
  22293. * Clear the current graph and load a new one from a serialization object
  22294. * @param source defines the JSON representation of the material
  22295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22296. */
  22297. loadFromSerialization(source: any, rootUrl?: string): void;
  22298. /**
  22299. * Makes a duplicate of the current material.
  22300. * @param name - name to use for the new material.
  22301. */
  22302. clone(name: string): NodeMaterial;
  22303. /**
  22304. * Creates a node material from parsed material data
  22305. * @param source defines the JSON representation of the material
  22306. * @param scene defines the hosting scene
  22307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22308. * @returns a new node material
  22309. */
  22310. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22311. /**
  22312. * Creates a node material from a snippet saved in a remote file
  22313. * @param name defines the name of the material to create
  22314. * @param url defines the url to load from
  22315. * @param scene defines the hosting scene
  22316. * @returns a promise that will resolve to the new node material
  22317. */
  22318. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22319. /**
  22320. * Creates a node material from a snippet saved by the node material editor
  22321. * @param snippetId defines the snippet to load
  22322. * @param scene defines the hosting scene
  22323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22324. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22325. * @returns a promise that will resolve to the new node material
  22326. */
  22327. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22328. /**
  22329. * Creates a new node material set to default basic configuration
  22330. * @param name defines the name of the material
  22331. * @param scene defines the hosting scene
  22332. * @returns a new NodeMaterial
  22333. */
  22334. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22335. }
  22336. }
  22337. declare module BABYLON {
  22338. /**
  22339. * Size options for a post process
  22340. */
  22341. export type PostProcessOptions = {
  22342. width: number;
  22343. height: number;
  22344. };
  22345. /**
  22346. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22347. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22348. */
  22349. export class PostProcess {
  22350. /** Name of the PostProcess. */
  22351. name: string;
  22352. /**
  22353. * Gets or sets the unique id of the post process
  22354. */
  22355. uniqueId: number;
  22356. /**
  22357. * Width of the texture to apply the post process on
  22358. */
  22359. width: number;
  22360. /**
  22361. * Height of the texture to apply the post process on
  22362. */
  22363. height: number;
  22364. /**
  22365. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22366. */
  22367. nodeMaterialSource: Nullable<NodeMaterial>;
  22368. /**
  22369. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22370. * @hidden
  22371. */
  22372. _outputTexture: Nullable<InternalTexture>;
  22373. /**
  22374. * Sampling mode used by the shader
  22375. * See https://doc.babylonjs.com/classes/3.1/texture
  22376. */
  22377. renderTargetSamplingMode: number;
  22378. /**
  22379. * Clear color to use when screen clearing
  22380. */
  22381. clearColor: Color4;
  22382. /**
  22383. * If the buffer needs to be cleared before applying the post process. (default: true)
  22384. * Should be set to false if shader will overwrite all previous pixels.
  22385. */
  22386. autoClear: boolean;
  22387. /**
  22388. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22389. */
  22390. alphaMode: number;
  22391. /**
  22392. * Sets the setAlphaBlendConstants of the babylon engine
  22393. */
  22394. alphaConstants: Color4;
  22395. /**
  22396. * Animations to be used for the post processing
  22397. */
  22398. animations: Animation[];
  22399. /**
  22400. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22401. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22402. */
  22403. enablePixelPerfectMode: boolean;
  22404. /**
  22405. * Force the postprocess to be applied without taking in account viewport
  22406. */
  22407. forceFullscreenViewport: boolean;
  22408. /**
  22409. * List of inspectable custom properties (used by the Inspector)
  22410. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22411. */
  22412. inspectableCustomProperties: IInspectable[];
  22413. /**
  22414. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22415. *
  22416. * | Value | Type | Description |
  22417. * | ----- | ----------------------------------- | ----------- |
  22418. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22419. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22420. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22421. *
  22422. */
  22423. scaleMode: number;
  22424. /**
  22425. * Force textures to be a power of two (default: false)
  22426. */
  22427. alwaysForcePOT: boolean;
  22428. private _samples;
  22429. /**
  22430. * Number of sample textures (default: 1)
  22431. */
  22432. get samples(): number;
  22433. set samples(n: number);
  22434. /**
  22435. * Modify the scale of the post process to be the same as the viewport (default: false)
  22436. */
  22437. adaptScaleToCurrentViewport: boolean;
  22438. private _camera;
  22439. private _scene;
  22440. private _engine;
  22441. private _options;
  22442. private _reusable;
  22443. private _textureType;
  22444. private _textureFormat;
  22445. /**
  22446. * Smart array of input and output textures for the post process.
  22447. * @hidden
  22448. */
  22449. _textures: SmartArray<InternalTexture>;
  22450. /**
  22451. * The index in _textures that corresponds to the output texture.
  22452. * @hidden
  22453. */
  22454. _currentRenderTextureInd: number;
  22455. private _effect;
  22456. private _samplers;
  22457. private _fragmentUrl;
  22458. private _vertexUrl;
  22459. private _parameters;
  22460. private _scaleRatio;
  22461. protected _indexParameters: any;
  22462. private _shareOutputWithPostProcess;
  22463. private _texelSize;
  22464. private _forcedOutputTexture;
  22465. /**
  22466. * Returns the fragment url or shader name used in the post process.
  22467. * @returns the fragment url or name in the shader store.
  22468. */
  22469. getEffectName(): string;
  22470. /**
  22471. * An event triggered when the postprocess is activated.
  22472. */
  22473. onActivateObservable: Observable<Camera>;
  22474. private _onActivateObserver;
  22475. /**
  22476. * A function that is added to the onActivateObservable
  22477. */
  22478. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22479. /**
  22480. * An event triggered when the postprocess changes its size.
  22481. */
  22482. onSizeChangedObservable: Observable<PostProcess>;
  22483. private _onSizeChangedObserver;
  22484. /**
  22485. * A function that is added to the onSizeChangedObservable
  22486. */
  22487. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22488. /**
  22489. * An event triggered when the postprocess applies its effect.
  22490. */
  22491. onApplyObservable: Observable<Effect>;
  22492. private _onApplyObserver;
  22493. /**
  22494. * A function that is added to the onApplyObservable
  22495. */
  22496. set onApply(callback: (effect: Effect) => void);
  22497. /**
  22498. * An event triggered before rendering the postprocess
  22499. */
  22500. onBeforeRenderObservable: Observable<Effect>;
  22501. private _onBeforeRenderObserver;
  22502. /**
  22503. * A function that is added to the onBeforeRenderObservable
  22504. */
  22505. set onBeforeRender(callback: (effect: Effect) => void);
  22506. /**
  22507. * An event triggered after rendering the postprocess
  22508. */
  22509. onAfterRenderObservable: Observable<Effect>;
  22510. private _onAfterRenderObserver;
  22511. /**
  22512. * A function that is added to the onAfterRenderObservable
  22513. */
  22514. set onAfterRender(callback: (efect: Effect) => void);
  22515. /**
  22516. * 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
  22517. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22518. */
  22519. get inputTexture(): InternalTexture;
  22520. set inputTexture(value: InternalTexture);
  22521. /**
  22522. * Gets the camera which post process is applied to.
  22523. * @returns The camera the post process is applied to.
  22524. */
  22525. getCamera(): Camera;
  22526. /**
  22527. * Gets the texel size of the postprocess.
  22528. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22529. */
  22530. get texelSize(): Vector2;
  22531. /**
  22532. * Creates a new instance PostProcess
  22533. * @param name The name of the PostProcess.
  22534. * @param fragmentUrl The url of the fragment shader to be used.
  22535. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22536. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22537. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22538. * @param camera The camera to apply the render pass to.
  22539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22540. * @param engine The engine which the post process will be applied. (default: current engine)
  22541. * @param reusable If the post process can be reused on the same frame. (default: false)
  22542. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22543. * @param textureType Type of textures used when performing the post process. (default: 0)
  22544. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22545. * @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
  22546. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22547. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22548. */
  22549. constructor(
  22550. /** Name of the PostProcess. */
  22551. 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);
  22552. /**
  22553. * Gets a string idenfifying the name of the class
  22554. * @returns "PostProcess" string
  22555. */
  22556. getClassName(): string;
  22557. /**
  22558. * Gets the engine which this post process belongs to.
  22559. * @returns The engine the post process was enabled with.
  22560. */
  22561. getEngine(): Engine;
  22562. /**
  22563. * The effect that is created when initializing the post process.
  22564. * @returns The created effect corresponding the the postprocess.
  22565. */
  22566. getEffect(): Effect;
  22567. /**
  22568. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22569. * @param postProcess The post process to share the output with.
  22570. * @returns This post process.
  22571. */
  22572. shareOutputWith(postProcess: PostProcess): PostProcess;
  22573. /**
  22574. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22575. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22576. */
  22577. useOwnOutput(): void;
  22578. /**
  22579. * Updates the effect with the current post process compile time values and recompiles the shader.
  22580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22583. * @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
  22584. * @param onCompiled Called when the shader has been compiled.
  22585. * @param onError Called if there is an error when compiling a shader.
  22586. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22587. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22588. */
  22589. 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;
  22590. /**
  22591. * The post process is reusable if it can be used multiple times within one frame.
  22592. * @returns If the post process is reusable
  22593. */
  22594. isReusable(): boolean;
  22595. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22596. markTextureDirty(): void;
  22597. /**
  22598. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22599. * 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.
  22600. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22601. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22602. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22603. * @returns The target texture that was bound to be written to.
  22604. */
  22605. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22606. /**
  22607. * If the post process is supported.
  22608. */
  22609. get isSupported(): boolean;
  22610. /**
  22611. * The aspect ratio of the output texture.
  22612. */
  22613. get aspectRatio(): number;
  22614. /**
  22615. * Get a value indicating if the post-process is ready to be used
  22616. * @returns true if the post-process is ready (shader is compiled)
  22617. */
  22618. isReady(): boolean;
  22619. /**
  22620. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22621. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22622. */
  22623. apply(): Nullable<Effect>;
  22624. private _disposeTextures;
  22625. /**
  22626. * Disposes the post process.
  22627. * @param camera The camera to dispose the post process on.
  22628. */
  22629. dispose(camera?: Camera): void;
  22630. }
  22631. }
  22632. declare module BABYLON {
  22633. /** @hidden */
  22634. export var kernelBlurVaryingDeclaration: {
  22635. name: string;
  22636. shader: string;
  22637. };
  22638. }
  22639. declare module BABYLON {
  22640. /** @hidden */
  22641. export var kernelBlurFragment: {
  22642. name: string;
  22643. shader: string;
  22644. };
  22645. }
  22646. declare module BABYLON {
  22647. /** @hidden */
  22648. export var kernelBlurFragment2: {
  22649. name: string;
  22650. shader: string;
  22651. };
  22652. }
  22653. declare module BABYLON {
  22654. /** @hidden */
  22655. export var kernelBlurPixelShader: {
  22656. name: string;
  22657. shader: string;
  22658. };
  22659. }
  22660. declare module BABYLON {
  22661. /** @hidden */
  22662. export var kernelBlurVertex: {
  22663. name: string;
  22664. shader: string;
  22665. };
  22666. }
  22667. declare module BABYLON {
  22668. /** @hidden */
  22669. export var kernelBlurVertexShader: {
  22670. name: string;
  22671. shader: string;
  22672. };
  22673. }
  22674. declare module BABYLON {
  22675. /**
  22676. * The Blur Post Process which blurs an image based on a kernel and direction.
  22677. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22678. */
  22679. export class BlurPostProcess extends PostProcess {
  22680. /** The direction in which to blur the image. */
  22681. direction: Vector2;
  22682. private blockCompilation;
  22683. protected _kernel: number;
  22684. protected _idealKernel: number;
  22685. protected _packedFloat: boolean;
  22686. private _staticDefines;
  22687. /**
  22688. * Sets the length in pixels of the blur sample region
  22689. */
  22690. set kernel(v: number);
  22691. /**
  22692. * Gets the length in pixels of the blur sample region
  22693. */
  22694. get kernel(): number;
  22695. /**
  22696. * Sets wether or not the blur needs to unpack/repack floats
  22697. */
  22698. set packedFloat(v: boolean);
  22699. /**
  22700. * Gets wether or not the blur is unpacking/repacking floats
  22701. */
  22702. get packedFloat(): boolean;
  22703. /**
  22704. * Creates a new instance BlurPostProcess
  22705. * @param name The name of the effect.
  22706. * @param direction The direction in which to blur the image.
  22707. * @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.
  22708. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22709. * @param camera The camera to apply the render pass to.
  22710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22711. * @param engine The engine which the post process will be applied. (default: current engine)
  22712. * @param reusable If the post process can be reused on the same frame. (default: false)
  22713. * @param textureType Type of textures used when performing the post process. (default: 0)
  22714. * @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)
  22715. */
  22716. constructor(name: string,
  22717. /** The direction in which to blur the image. */
  22718. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22719. /**
  22720. * Updates the effect with the current post process compile time values and recompiles the shader.
  22721. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22722. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22723. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22724. * @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
  22725. * @param onCompiled Called when the shader has been compiled.
  22726. * @param onError Called if there is an error when compiling a shader.
  22727. */
  22728. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22729. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22730. /**
  22731. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22732. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22733. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22734. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22735. * The gaps between physical kernels are compensated for in the weighting of the samples
  22736. * @param idealKernel Ideal blur kernel.
  22737. * @return Nearest best kernel.
  22738. */
  22739. protected _nearestBestKernel(idealKernel: number): number;
  22740. /**
  22741. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22742. * @param x The point on the Gaussian distribution to sample.
  22743. * @return the value of the Gaussian function at x.
  22744. */
  22745. protected _gaussianWeight(x: number): number;
  22746. /**
  22747. * Generates a string that can be used as a floating point number in GLSL.
  22748. * @param x Value to print.
  22749. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22750. * @return GLSL float string.
  22751. */
  22752. protected _glslFloat(x: number, decimalFigures?: number): string;
  22753. }
  22754. }
  22755. declare module BABYLON {
  22756. /**
  22757. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22758. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22759. * You can then easily use it as a reflectionTexture on a flat surface.
  22760. * In case the surface is not a plane, please consider relying on reflection probes.
  22761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22762. */
  22763. export class MirrorTexture extends RenderTargetTexture {
  22764. private scene;
  22765. /**
  22766. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22767. * 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.
  22768. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22769. */
  22770. mirrorPlane: Plane;
  22771. /**
  22772. * Define the blur ratio used to blur the reflection if needed.
  22773. */
  22774. set blurRatio(value: number);
  22775. get blurRatio(): number;
  22776. /**
  22777. * Define the adaptive blur kernel used to blur the reflection if needed.
  22778. * This will autocompute the closest best match for the `blurKernel`
  22779. */
  22780. set adaptiveBlurKernel(value: number);
  22781. /**
  22782. * Define the blur kernel used to blur the reflection if needed.
  22783. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22784. */
  22785. set blurKernel(value: number);
  22786. /**
  22787. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22789. */
  22790. set blurKernelX(value: number);
  22791. get blurKernelX(): number;
  22792. /**
  22793. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22794. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22795. */
  22796. set blurKernelY(value: number);
  22797. get blurKernelY(): number;
  22798. private _autoComputeBlurKernel;
  22799. protected _onRatioRescale(): void;
  22800. private _updateGammaSpace;
  22801. private _imageProcessingConfigChangeObserver;
  22802. private _transformMatrix;
  22803. private _mirrorMatrix;
  22804. private _savedViewMatrix;
  22805. private _blurX;
  22806. private _blurY;
  22807. private _adaptiveBlurKernel;
  22808. private _blurKernelX;
  22809. private _blurKernelY;
  22810. private _blurRatio;
  22811. /**
  22812. * Instantiates a Mirror Texture.
  22813. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22814. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22815. * You can then easily use it as a reflectionTexture on a flat surface.
  22816. * In case the surface is not a plane, please consider relying on reflection probes.
  22817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22818. * @param name
  22819. * @param size
  22820. * @param scene
  22821. * @param generateMipMaps
  22822. * @param type
  22823. * @param samplingMode
  22824. * @param generateDepthBuffer
  22825. */
  22826. constructor(name: string, size: number | {
  22827. width: number;
  22828. height: number;
  22829. } | {
  22830. ratio: number;
  22831. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22832. private _preparePostProcesses;
  22833. /**
  22834. * Clone the mirror texture.
  22835. * @returns the cloned texture
  22836. */
  22837. clone(): MirrorTexture;
  22838. /**
  22839. * Serialize the texture to a JSON representation you could use in Parse later on
  22840. * @returns the serialized JSON representation
  22841. */
  22842. serialize(): any;
  22843. /**
  22844. * Dispose the texture and release its associated resources.
  22845. */
  22846. dispose(): void;
  22847. }
  22848. }
  22849. declare module BABYLON {
  22850. /**
  22851. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22852. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22853. */
  22854. export class Texture extends BaseTexture {
  22855. /**
  22856. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22857. */
  22858. static SerializeBuffers: boolean;
  22859. /** @hidden */
  22860. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22861. /** @hidden */
  22862. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22863. /** @hidden */
  22864. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22865. /** nearest is mag = nearest and min = nearest and mip = linear */
  22866. static readonly NEAREST_SAMPLINGMODE: number;
  22867. /** nearest is mag = nearest and min = nearest and mip = linear */
  22868. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22870. static readonly BILINEAR_SAMPLINGMODE: number;
  22871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22872. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22873. /** Trilinear is mag = linear and min = linear and mip = linear */
  22874. static readonly TRILINEAR_SAMPLINGMODE: number;
  22875. /** Trilinear is mag = linear and min = linear and mip = linear */
  22876. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22877. /** mag = nearest and min = nearest and mip = nearest */
  22878. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22879. /** mag = nearest and min = linear and mip = nearest */
  22880. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22881. /** mag = nearest and min = linear and mip = linear */
  22882. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22883. /** mag = nearest and min = linear and mip = none */
  22884. static readonly NEAREST_LINEAR: number;
  22885. /** mag = nearest and min = nearest and mip = none */
  22886. static readonly NEAREST_NEAREST: number;
  22887. /** mag = linear and min = nearest and mip = nearest */
  22888. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22889. /** mag = linear and min = nearest and mip = linear */
  22890. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22891. /** mag = linear and min = linear and mip = none */
  22892. static readonly LINEAR_LINEAR: number;
  22893. /** mag = linear and min = nearest and mip = none */
  22894. static readonly LINEAR_NEAREST: number;
  22895. /** Explicit coordinates mode */
  22896. static readonly EXPLICIT_MODE: number;
  22897. /** Spherical coordinates mode */
  22898. static readonly SPHERICAL_MODE: number;
  22899. /** Planar coordinates mode */
  22900. static readonly PLANAR_MODE: number;
  22901. /** Cubic coordinates mode */
  22902. static readonly CUBIC_MODE: number;
  22903. /** Projection coordinates mode */
  22904. static readonly PROJECTION_MODE: number;
  22905. /** Inverse Cubic coordinates mode */
  22906. static readonly SKYBOX_MODE: number;
  22907. /** Inverse Cubic coordinates mode */
  22908. static readonly INVCUBIC_MODE: number;
  22909. /** Equirectangular coordinates mode */
  22910. static readonly EQUIRECTANGULAR_MODE: number;
  22911. /** Equirectangular Fixed coordinates mode */
  22912. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22913. /** Equirectangular Fixed Mirrored coordinates mode */
  22914. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22915. /** Texture is not repeating outside of 0..1 UVs */
  22916. static readonly CLAMP_ADDRESSMODE: number;
  22917. /** Texture is repeating outside of 0..1 UVs */
  22918. static readonly WRAP_ADDRESSMODE: number;
  22919. /** Texture is repeating and mirrored */
  22920. static readonly MIRROR_ADDRESSMODE: number;
  22921. /**
  22922. * 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
  22923. */
  22924. static UseSerializedUrlIfAny: boolean;
  22925. /**
  22926. * Define the url of the texture.
  22927. */
  22928. url: Nullable<string>;
  22929. /**
  22930. * Define an offset on the texture to offset the u coordinates of the UVs
  22931. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22932. */
  22933. uOffset: number;
  22934. /**
  22935. * Define an offset on the texture to offset the v coordinates of the UVs
  22936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22937. */
  22938. vOffset: number;
  22939. /**
  22940. * Define an offset on the texture to scale the u coordinates of the UVs
  22941. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22942. */
  22943. uScale: number;
  22944. /**
  22945. * Define an offset on the texture to scale the v coordinates of the UVs
  22946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22947. */
  22948. vScale: number;
  22949. /**
  22950. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22951. * @see http://doc.babylonjs.com/how_to/more_materials
  22952. */
  22953. uAng: number;
  22954. /**
  22955. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22956. * @see http://doc.babylonjs.com/how_to/more_materials
  22957. */
  22958. vAng: number;
  22959. /**
  22960. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22961. * @see http://doc.babylonjs.com/how_to/more_materials
  22962. */
  22963. wAng: number;
  22964. /**
  22965. * Defines the center of rotation (U)
  22966. */
  22967. uRotationCenter: number;
  22968. /**
  22969. * Defines the center of rotation (V)
  22970. */
  22971. vRotationCenter: number;
  22972. /**
  22973. * Defines the center of rotation (W)
  22974. */
  22975. wRotationCenter: number;
  22976. /**
  22977. * Are mip maps generated for this texture or not.
  22978. */
  22979. get noMipmap(): boolean;
  22980. /**
  22981. * List of inspectable custom properties (used by the Inspector)
  22982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22983. */
  22984. inspectableCustomProperties: Nullable<IInspectable[]>;
  22985. private _noMipmap;
  22986. /** @hidden */
  22987. _invertY: boolean;
  22988. private _rowGenerationMatrix;
  22989. private _cachedTextureMatrix;
  22990. private _projectionModeMatrix;
  22991. private _t0;
  22992. private _t1;
  22993. private _t2;
  22994. private _cachedUOffset;
  22995. private _cachedVOffset;
  22996. private _cachedUScale;
  22997. private _cachedVScale;
  22998. private _cachedUAng;
  22999. private _cachedVAng;
  23000. private _cachedWAng;
  23001. private _cachedProjectionMatrixId;
  23002. private _cachedCoordinatesMode;
  23003. /** @hidden */
  23004. protected _initialSamplingMode: number;
  23005. /** @hidden */
  23006. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23007. private _deleteBuffer;
  23008. protected _format: Nullable<number>;
  23009. private _delayedOnLoad;
  23010. private _delayedOnError;
  23011. private _mimeType?;
  23012. /**
  23013. * Observable triggered once the texture has been loaded.
  23014. */
  23015. onLoadObservable: Observable<Texture>;
  23016. protected _isBlocking: boolean;
  23017. /**
  23018. * Is the texture preventing material to render while loading.
  23019. * If false, a default texture will be used instead of the loading one during the preparation step.
  23020. */
  23021. set isBlocking(value: boolean);
  23022. get isBlocking(): boolean;
  23023. /**
  23024. * Get the current sampling mode associated with the texture.
  23025. */
  23026. get samplingMode(): number;
  23027. /**
  23028. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23029. */
  23030. get invertY(): boolean;
  23031. /**
  23032. * Instantiates a new texture.
  23033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23034. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23035. * @param url defines the url of the picture to load as a texture
  23036. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23037. * @param noMipmap defines if the texture will require mip maps or not
  23038. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23039. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23040. * @param onLoad defines a callback triggered when the texture has been loaded
  23041. * @param onError defines a callback triggered when an error occurred during the loading session
  23042. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23043. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23044. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23045. * @param mimeType defines an optional mime type information
  23046. */
  23047. 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);
  23048. /**
  23049. * Update the url (and optional buffer) of this texture if url was null during construction.
  23050. * @param url the url of the texture
  23051. * @param buffer the buffer of the texture (defaults to null)
  23052. * @param onLoad callback called when the texture is loaded (defaults to null)
  23053. */
  23054. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23055. /**
  23056. * Finish the loading sequence of a texture flagged as delayed load.
  23057. * @hidden
  23058. */
  23059. delayLoad(): void;
  23060. private _prepareRowForTextureGeneration;
  23061. /**
  23062. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23063. * @returns the transform matrix of the texture.
  23064. */
  23065. getTextureMatrix(uBase?: number): Matrix;
  23066. /**
  23067. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23068. * @returns The reflection texture transform
  23069. */
  23070. getReflectionTextureMatrix(): Matrix;
  23071. /**
  23072. * Clones the texture.
  23073. * @returns the cloned texture
  23074. */
  23075. clone(): Texture;
  23076. /**
  23077. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23078. * @returns The JSON representation of the texture
  23079. */
  23080. serialize(): any;
  23081. /**
  23082. * Get the current class name of the texture useful for serialization or dynamic coding.
  23083. * @returns "Texture"
  23084. */
  23085. getClassName(): string;
  23086. /**
  23087. * Dispose the texture and release its associated resources.
  23088. */
  23089. dispose(): void;
  23090. /**
  23091. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23092. * @param parsedTexture Define the JSON representation of the texture
  23093. * @param scene Define the scene the parsed texture should be instantiated in
  23094. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23095. * @returns The parsed texture if successful
  23096. */
  23097. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23098. /**
  23099. * Creates a texture from its base 64 representation.
  23100. * @param data Define the base64 payload without the data: prefix
  23101. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23102. * @param scene Define the scene the texture should belong to
  23103. * @param noMipmap Forces the texture to not create mip map information if true
  23104. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23105. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23106. * @param onLoad define a callback triggered when the texture has been loaded
  23107. * @param onError define a callback triggered when an error occurred during the loading session
  23108. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23109. * @returns the created texture
  23110. */
  23111. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23112. /**
  23113. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23114. * @param data Define the base64 payload without the data: prefix
  23115. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23116. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23117. * @param scene Define the scene the texture should belong to
  23118. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23119. * @param noMipmap Forces the texture to not create mip map information if true
  23120. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23121. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23122. * @param onLoad define a callback triggered when the texture has been loaded
  23123. * @param onError define a callback triggered when an error occurred during the loading session
  23124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23125. * @returns the created texture
  23126. */
  23127. 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;
  23128. }
  23129. }
  23130. declare module BABYLON {
  23131. /**
  23132. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23133. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23134. */
  23135. export class PostProcessManager {
  23136. private _scene;
  23137. private _indexBuffer;
  23138. private _vertexBuffers;
  23139. /**
  23140. * Creates a new instance PostProcess
  23141. * @param scene The scene that the post process is associated with.
  23142. */
  23143. constructor(scene: Scene);
  23144. private _prepareBuffers;
  23145. private _buildIndexBuffer;
  23146. /**
  23147. * Rebuilds the vertex buffers of the manager.
  23148. * @hidden
  23149. */
  23150. _rebuild(): void;
  23151. /**
  23152. * Prepares a frame to be run through a post process.
  23153. * @param sourceTexture The input texture to the post procesess. (default: null)
  23154. * @param postProcesses An array of post processes to be run. (default: null)
  23155. * @returns True if the post processes were able to be run.
  23156. * @hidden
  23157. */
  23158. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23159. /**
  23160. * Manually render a set of post processes to a texture.
  23161. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23162. * @param postProcesses An array of post processes to be run.
  23163. * @param targetTexture The target texture to render to.
  23164. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23165. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23166. * @param lodLevel defines which lod of the texture to render to
  23167. */
  23168. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23169. /**
  23170. * Finalize the result of the output of the postprocesses.
  23171. * @param doNotPresent If true the result will not be displayed to the screen.
  23172. * @param targetTexture The target texture to render to.
  23173. * @param faceIndex The index of the face to bind the target texture to.
  23174. * @param postProcesses The array of post processes to render.
  23175. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23176. * @hidden
  23177. */
  23178. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23179. /**
  23180. * Disposes of the post process manager.
  23181. */
  23182. dispose(): void;
  23183. }
  23184. }
  23185. declare module BABYLON {
  23186. /**
  23187. * This Helps creating a texture that will be created from a camera in your scene.
  23188. * It is basically a dynamic texture that could be used to create special effects for instance.
  23189. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23190. */
  23191. export class RenderTargetTexture extends Texture {
  23192. isCube: boolean;
  23193. /**
  23194. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23195. */
  23196. static readonly REFRESHRATE_RENDER_ONCE: number;
  23197. /**
  23198. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23199. */
  23200. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23201. /**
  23202. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23203. * the central point of your effect and can save a lot of performances.
  23204. */
  23205. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23206. /**
  23207. * Use this predicate to dynamically define the list of mesh you want to render.
  23208. * If set, the renderList property will be overwritten.
  23209. */
  23210. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23211. private _renderList;
  23212. /**
  23213. * Use this list to define the list of mesh you want to render.
  23214. */
  23215. get renderList(): Nullable<Array<AbstractMesh>>;
  23216. set renderList(value: Nullable<Array<AbstractMesh>>);
  23217. /**
  23218. * Use this function to overload the renderList array at rendering time.
  23219. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23220. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23221. * the cube (if the RTT is a cube, else layerOrFace=0).
  23222. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23223. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23224. * hold dummy elements!
  23225. */
  23226. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23227. private _hookArray;
  23228. /**
  23229. * Define if particles should be rendered in your texture.
  23230. */
  23231. renderParticles: boolean;
  23232. /**
  23233. * Define if sprites should be rendered in your texture.
  23234. */
  23235. renderSprites: boolean;
  23236. /**
  23237. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23238. */
  23239. coordinatesMode: number;
  23240. /**
  23241. * Define the camera used to render the texture.
  23242. */
  23243. activeCamera: Nullable<Camera>;
  23244. /**
  23245. * Override the mesh isReady function with your own one.
  23246. */
  23247. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23248. /**
  23249. * Override the render function of the texture with your own one.
  23250. */
  23251. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23252. /**
  23253. * Define if camera post processes should be use while rendering the texture.
  23254. */
  23255. useCameraPostProcesses: boolean;
  23256. /**
  23257. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23258. */
  23259. ignoreCameraViewport: boolean;
  23260. private _postProcessManager;
  23261. private _postProcesses;
  23262. private _resizeObserver;
  23263. /**
  23264. * An event triggered when the texture is unbind.
  23265. */
  23266. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23267. /**
  23268. * An event triggered when the texture is unbind.
  23269. */
  23270. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23271. private _onAfterUnbindObserver;
  23272. /**
  23273. * Set a after unbind callback in the texture.
  23274. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23275. */
  23276. set onAfterUnbind(callback: () => void);
  23277. /**
  23278. * An event triggered before rendering the texture
  23279. */
  23280. onBeforeRenderObservable: Observable<number>;
  23281. private _onBeforeRenderObserver;
  23282. /**
  23283. * Set a before render callback in the texture.
  23284. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23285. */
  23286. set onBeforeRender(callback: (faceIndex: number) => void);
  23287. /**
  23288. * An event triggered after rendering the texture
  23289. */
  23290. onAfterRenderObservable: Observable<number>;
  23291. private _onAfterRenderObserver;
  23292. /**
  23293. * Set a after render callback in the texture.
  23294. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23295. */
  23296. set onAfterRender(callback: (faceIndex: number) => void);
  23297. /**
  23298. * An event triggered after the texture clear
  23299. */
  23300. onClearObservable: Observable<Engine>;
  23301. private _onClearObserver;
  23302. /**
  23303. * Set a clear callback in the texture.
  23304. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23305. */
  23306. set onClear(callback: (Engine: Engine) => void);
  23307. /**
  23308. * An event triggered when the texture is resized.
  23309. */
  23310. onResizeObservable: Observable<RenderTargetTexture>;
  23311. /**
  23312. * Define the clear color of the Render Target if it should be different from the scene.
  23313. */
  23314. clearColor: Color4;
  23315. protected _size: number | {
  23316. width: number;
  23317. height: number;
  23318. layers?: number;
  23319. };
  23320. protected _initialSizeParameter: number | {
  23321. width: number;
  23322. height: number;
  23323. } | {
  23324. ratio: number;
  23325. };
  23326. protected _sizeRatio: Nullable<number>;
  23327. /** @hidden */
  23328. _generateMipMaps: boolean;
  23329. protected _renderingManager: RenderingManager;
  23330. /** @hidden */
  23331. _waitingRenderList: string[];
  23332. protected _doNotChangeAspectRatio: boolean;
  23333. protected _currentRefreshId: number;
  23334. protected _refreshRate: number;
  23335. protected _textureMatrix: Matrix;
  23336. protected _samples: number;
  23337. protected _renderTargetOptions: RenderTargetCreationOptions;
  23338. /**
  23339. * Gets render target creation options that were used.
  23340. */
  23341. get renderTargetOptions(): RenderTargetCreationOptions;
  23342. protected _onRatioRescale(): void;
  23343. /**
  23344. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23345. * It must define where the camera used to render the texture is set
  23346. */
  23347. boundingBoxPosition: Vector3;
  23348. private _boundingBoxSize;
  23349. /**
  23350. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23351. * When defined, the cubemap will switch to local mode
  23352. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23353. * @example https://www.babylonjs-playground.com/#RNASML
  23354. */
  23355. set boundingBoxSize(value: Vector3);
  23356. get boundingBoxSize(): Vector3;
  23357. /**
  23358. * In case the RTT has been created with a depth texture, get the associated
  23359. * depth texture.
  23360. * Otherwise, return null.
  23361. */
  23362. get depthStencilTexture(): Nullable<InternalTexture>;
  23363. /**
  23364. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23365. * or used a shadow, depth texture...
  23366. * @param name The friendly name of the texture
  23367. * @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)
  23368. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23369. * @param generateMipMaps True if mip maps need to be generated after render.
  23370. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23371. * @param type The type of the buffer in the RTT (int, half float, float...)
  23372. * @param isCube True if a cube texture needs to be created
  23373. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23374. * @param generateDepthBuffer True to generate a depth buffer
  23375. * @param generateStencilBuffer True to generate a stencil buffer
  23376. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23377. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23378. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23379. */
  23380. constructor(name: string, size: number | {
  23381. width: number;
  23382. height: number;
  23383. layers?: number;
  23384. } | {
  23385. ratio: number;
  23386. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23387. /**
  23388. * Creates a depth stencil texture.
  23389. * This is only available in WebGL 2 or with the depth texture extension available.
  23390. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23391. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23392. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23393. */
  23394. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23395. private _processSizeParameter;
  23396. /**
  23397. * Define the number of samples to use in case of MSAA.
  23398. * It defaults to one meaning no MSAA has been enabled.
  23399. */
  23400. get samples(): number;
  23401. set samples(value: number);
  23402. /**
  23403. * Resets the refresh counter of the texture and start bak from scratch.
  23404. * Could be useful to regenerate the texture if it is setup to render only once.
  23405. */
  23406. resetRefreshCounter(): void;
  23407. /**
  23408. * Define the refresh rate of the texture or the rendering frequency.
  23409. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23410. */
  23411. get refreshRate(): number;
  23412. set refreshRate(value: number);
  23413. /**
  23414. * Adds a post process to the render target rendering passes.
  23415. * @param postProcess define the post process to add
  23416. */
  23417. addPostProcess(postProcess: PostProcess): void;
  23418. /**
  23419. * Clear all the post processes attached to the render target
  23420. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23421. */
  23422. clearPostProcesses(dispose?: boolean): void;
  23423. /**
  23424. * Remove one of the post process from the list of attached post processes to the texture
  23425. * @param postProcess define the post process to remove from the list
  23426. */
  23427. removePostProcess(postProcess: PostProcess): void;
  23428. /** @hidden */
  23429. _shouldRender(): boolean;
  23430. /**
  23431. * Gets the actual render size of the texture.
  23432. * @returns the width of the render size
  23433. */
  23434. getRenderSize(): number;
  23435. /**
  23436. * Gets the actual render width of the texture.
  23437. * @returns the width of the render size
  23438. */
  23439. getRenderWidth(): number;
  23440. /**
  23441. * Gets the actual render height of the texture.
  23442. * @returns the height of the render size
  23443. */
  23444. getRenderHeight(): number;
  23445. /**
  23446. * Gets the actual number of layers of the texture.
  23447. * @returns the number of layers
  23448. */
  23449. getRenderLayers(): number;
  23450. /**
  23451. * Get if the texture can be rescaled or not.
  23452. */
  23453. get canRescale(): boolean;
  23454. /**
  23455. * Resize the texture using a ratio.
  23456. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23457. */
  23458. scale(ratio: number): void;
  23459. /**
  23460. * Get the texture reflection matrix used to rotate/transform the reflection.
  23461. * @returns the reflection matrix
  23462. */
  23463. getReflectionTextureMatrix(): Matrix;
  23464. /**
  23465. * Resize the texture to a new desired size.
  23466. * Be carrefull as it will recreate all the data in the new texture.
  23467. * @param size Define the new size. It can be:
  23468. * - a number for squared texture,
  23469. * - an object containing { width: number, height: number }
  23470. * - or an object containing a ratio { ratio: number }
  23471. */
  23472. resize(size: number | {
  23473. width: number;
  23474. height: number;
  23475. } | {
  23476. ratio: number;
  23477. }): void;
  23478. private _defaultRenderListPrepared;
  23479. /**
  23480. * Renders all the objects from the render list into the texture.
  23481. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23482. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23483. */
  23484. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23485. private _bestReflectionRenderTargetDimension;
  23486. private _prepareRenderingManager;
  23487. /**
  23488. * @hidden
  23489. * @param faceIndex face index to bind to if this is a cubetexture
  23490. * @param layer defines the index of the texture to bind in the array
  23491. */
  23492. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23493. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23494. private renderToTarget;
  23495. /**
  23496. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23497. * This allowed control for front to back rendering or reversly depending of the special needs.
  23498. *
  23499. * @param renderingGroupId The rendering group id corresponding to its index
  23500. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23501. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23502. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23503. */
  23504. 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;
  23505. /**
  23506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23507. *
  23508. * @param renderingGroupId The rendering group id corresponding to its index
  23509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23510. */
  23511. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23512. /**
  23513. * Clones the texture.
  23514. * @returns the cloned texture
  23515. */
  23516. clone(): RenderTargetTexture;
  23517. /**
  23518. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23519. * @returns The JSON representation of the texture
  23520. */
  23521. serialize(): any;
  23522. /**
  23523. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23524. */
  23525. disposeFramebufferObjects(): void;
  23526. /**
  23527. * Dispose the texture and release its associated resources.
  23528. */
  23529. dispose(): void;
  23530. /** @hidden */
  23531. _rebuild(): void;
  23532. /**
  23533. * Clear the info related to rendering groups preventing retention point in material dispose.
  23534. */
  23535. freeRenderingGroups(): void;
  23536. /**
  23537. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23538. * @returns the view count
  23539. */
  23540. getViewCount(): number;
  23541. }
  23542. }
  23543. declare module BABYLON {
  23544. /**
  23545. * Class used to manipulate GUIDs
  23546. */
  23547. export class GUID {
  23548. /**
  23549. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23550. * Be aware Math.random() could cause collisions, but:
  23551. * "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"
  23552. * @returns a pseudo random id
  23553. */
  23554. static RandomId(): string;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. /**
  23559. * Options to be used when creating a shadow depth material
  23560. */
  23561. export interface IIOptionShadowDepthMaterial {
  23562. /** Variables in the vertex shader code that need to have their names remapped.
  23563. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23564. * "var_name" should be either: worldPos or vNormalW
  23565. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23566. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23567. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23568. */
  23569. remappedVariables?: string[];
  23570. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23571. standalone?: boolean;
  23572. }
  23573. /**
  23574. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23575. */
  23576. export class ShadowDepthWrapper {
  23577. private _scene;
  23578. private _options?;
  23579. private _baseMaterial;
  23580. private _onEffectCreatedObserver;
  23581. private _subMeshToEffect;
  23582. private _subMeshToDepthEffect;
  23583. private _meshes;
  23584. /** @hidden */
  23585. _matriceNames: any;
  23586. /** Gets the standalone status of the wrapper */
  23587. get standalone(): boolean;
  23588. /** Gets the base material the wrapper is built upon */
  23589. get baseMaterial(): Material;
  23590. /**
  23591. * Instantiate a new shadow depth wrapper.
  23592. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23593. * generate the shadow depth map. For more information, please refer to the documentation:
  23594. * https://doc.babylonjs.com/babylon101/shadows
  23595. * @param baseMaterial Material to wrap
  23596. * @param scene Define the scene the material belongs to
  23597. * @param options Options used to create the wrapper
  23598. */
  23599. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23600. /**
  23601. * Gets the effect to use to generate the depth map
  23602. * @param subMesh subMesh to get the effect for
  23603. * @param shadowGenerator shadow generator to get the effect for
  23604. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23605. */
  23606. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23607. /**
  23608. * Specifies that the submesh is ready to be used for depth rendering
  23609. * @param subMesh submesh to check
  23610. * @param defines the list of defines to take into account when checking the effect
  23611. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23612. * @param useInstances specifies that instances should be used
  23613. * @returns a boolean indicating that the submesh is ready or not
  23614. */
  23615. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23616. /**
  23617. * Disposes the resources
  23618. */
  23619. dispose(): void;
  23620. private _makeEffect;
  23621. }
  23622. }
  23623. declare module BABYLON {
  23624. /**
  23625. * Options for compiling materials.
  23626. */
  23627. export interface IMaterialCompilationOptions {
  23628. /**
  23629. * Defines whether clip planes are enabled.
  23630. */
  23631. clipPlane: boolean;
  23632. /**
  23633. * Defines whether instances are enabled.
  23634. */
  23635. useInstances: boolean;
  23636. }
  23637. /**
  23638. * Options passed when calling customShaderNameResolve
  23639. */
  23640. export interface ICustomShaderNameResolveOptions {
  23641. /**
  23642. * 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
  23643. */
  23644. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23645. }
  23646. /**
  23647. * Base class for the main features of a material in Babylon.js
  23648. */
  23649. export class Material implements IAnimatable {
  23650. /**
  23651. * Returns the triangle fill mode
  23652. */
  23653. static readonly TriangleFillMode: number;
  23654. /**
  23655. * Returns the wireframe mode
  23656. */
  23657. static readonly WireFrameFillMode: number;
  23658. /**
  23659. * Returns the point fill mode
  23660. */
  23661. static readonly PointFillMode: number;
  23662. /**
  23663. * Returns the point list draw mode
  23664. */
  23665. static readonly PointListDrawMode: number;
  23666. /**
  23667. * Returns the line list draw mode
  23668. */
  23669. static readonly LineListDrawMode: number;
  23670. /**
  23671. * Returns the line loop draw mode
  23672. */
  23673. static readonly LineLoopDrawMode: number;
  23674. /**
  23675. * Returns the line strip draw mode
  23676. */
  23677. static readonly LineStripDrawMode: number;
  23678. /**
  23679. * Returns the triangle strip draw mode
  23680. */
  23681. static readonly TriangleStripDrawMode: number;
  23682. /**
  23683. * Returns the triangle fan draw mode
  23684. */
  23685. static readonly TriangleFanDrawMode: number;
  23686. /**
  23687. * Stores the clock-wise side orientation
  23688. */
  23689. static readonly ClockWiseSideOrientation: number;
  23690. /**
  23691. * Stores the counter clock-wise side orientation
  23692. */
  23693. static readonly CounterClockWiseSideOrientation: number;
  23694. /**
  23695. * The dirty texture flag value
  23696. */
  23697. static readonly TextureDirtyFlag: number;
  23698. /**
  23699. * The dirty light flag value
  23700. */
  23701. static readonly LightDirtyFlag: number;
  23702. /**
  23703. * The dirty fresnel flag value
  23704. */
  23705. static readonly FresnelDirtyFlag: number;
  23706. /**
  23707. * The dirty attribute flag value
  23708. */
  23709. static readonly AttributesDirtyFlag: number;
  23710. /**
  23711. * The dirty misc flag value
  23712. */
  23713. static readonly MiscDirtyFlag: number;
  23714. /**
  23715. * The all dirty flag value
  23716. */
  23717. static readonly AllDirtyFlag: number;
  23718. /**
  23719. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23720. */
  23721. static readonly MATERIAL_OPAQUE: number;
  23722. /**
  23723. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23724. */
  23725. static readonly MATERIAL_ALPHATEST: number;
  23726. /**
  23727. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23728. */
  23729. static readonly MATERIAL_ALPHABLEND: number;
  23730. /**
  23731. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23732. * They are also discarded below the alpha cutoff threshold to improve performances.
  23733. */
  23734. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23735. /**
  23736. * Custom callback helping to override the default shader used in the material.
  23737. */
  23738. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23739. /**
  23740. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23741. */
  23742. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23743. /**
  23744. * The ID of the material
  23745. */
  23746. id: string;
  23747. /**
  23748. * Gets or sets the unique id of the material
  23749. */
  23750. uniqueId: number;
  23751. /**
  23752. * The name of the material
  23753. */
  23754. name: string;
  23755. /**
  23756. * Gets or sets user defined metadata
  23757. */
  23758. metadata: any;
  23759. /**
  23760. * For internal use only. Please do not use.
  23761. */
  23762. reservedDataStore: any;
  23763. /**
  23764. * Specifies if the ready state should be checked on each call
  23765. */
  23766. checkReadyOnEveryCall: boolean;
  23767. /**
  23768. * Specifies if the ready state should be checked once
  23769. */
  23770. checkReadyOnlyOnce: boolean;
  23771. /**
  23772. * The state of the material
  23773. */
  23774. state: string;
  23775. /**
  23776. * The alpha value of the material
  23777. */
  23778. protected _alpha: number;
  23779. /**
  23780. * List of inspectable custom properties (used by the Inspector)
  23781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23782. */
  23783. inspectableCustomProperties: IInspectable[];
  23784. /**
  23785. * Sets the alpha value of the material
  23786. */
  23787. set alpha(value: number);
  23788. /**
  23789. * Gets the alpha value of the material
  23790. */
  23791. get alpha(): number;
  23792. /**
  23793. * Specifies if back face culling is enabled
  23794. */
  23795. protected _backFaceCulling: boolean;
  23796. /**
  23797. * Sets the back-face culling state
  23798. */
  23799. set backFaceCulling(value: boolean);
  23800. /**
  23801. * Gets the back-face culling state
  23802. */
  23803. get backFaceCulling(): boolean;
  23804. /**
  23805. * Stores the value for side orientation
  23806. */
  23807. sideOrientation: number;
  23808. /**
  23809. * Callback triggered when the material is compiled
  23810. */
  23811. onCompiled: Nullable<(effect: Effect) => void>;
  23812. /**
  23813. * Callback triggered when an error occurs
  23814. */
  23815. onError: Nullable<(effect: Effect, errors: string) => void>;
  23816. /**
  23817. * Callback triggered to get the render target textures
  23818. */
  23819. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23820. /**
  23821. * Gets a boolean indicating that current material needs to register RTT
  23822. */
  23823. get hasRenderTargetTextures(): boolean;
  23824. /**
  23825. * Specifies if the material should be serialized
  23826. */
  23827. doNotSerialize: boolean;
  23828. /**
  23829. * @hidden
  23830. */
  23831. _storeEffectOnSubMeshes: boolean;
  23832. /**
  23833. * Stores the animations for the material
  23834. */
  23835. animations: Nullable<Array<Animation>>;
  23836. /**
  23837. * An event triggered when the material is disposed
  23838. */
  23839. onDisposeObservable: Observable<Material>;
  23840. /**
  23841. * An observer which watches for dispose events
  23842. */
  23843. private _onDisposeObserver;
  23844. private _onUnBindObservable;
  23845. /**
  23846. * Called during a dispose event
  23847. */
  23848. set onDispose(callback: () => void);
  23849. private _onBindObservable;
  23850. /**
  23851. * An event triggered when the material is bound
  23852. */
  23853. get onBindObservable(): Observable<AbstractMesh>;
  23854. /**
  23855. * An observer which watches for bind events
  23856. */
  23857. private _onBindObserver;
  23858. /**
  23859. * Called during a bind event
  23860. */
  23861. set onBind(callback: (Mesh: AbstractMesh) => void);
  23862. /**
  23863. * An event triggered when the material is unbound
  23864. */
  23865. get onUnBindObservable(): Observable<Material>;
  23866. protected _onEffectCreatedObservable: Nullable<Observable<{
  23867. effect: Effect;
  23868. subMesh: Nullable<SubMesh>;
  23869. }>>;
  23870. /**
  23871. * An event triggered when the effect is (re)created
  23872. */
  23873. get onEffectCreatedObservable(): Observable<{
  23874. effect: Effect;
  23875. subMesh: Nullable<SubMesh>;
  23876. }>;
  23877. /**
  23878. * Stores the value of the alpha mode
  23879. */
  23880. private _alphaMode;
  23881. /**
  23882. * Sets the value of the alpha mode.
  23883. *
  23884. * | Value | Type | Description |
  23885. * | --- | --- | --- |
  23886. * | 0 | ALPHA_DISABLE | |
  23887. * | 1 | ALPHA_ADD | |
  23888. * | 2 | ALPHA_COMBINE | |
  23889. * | 3 | ALPHA_SUBTRACT | |
  23890. * | 4 | ALPHA_MULTIPLY | |
  23891. * | 5 | ALPHA_MAXIMIZED | |
  23892. * | 6 | ALPHA_ONEONE | |
  23893. * | 7 | ALPHA_PREMULTIPLIED | |
  23894. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23895. * | 9 | ALPHA_INTERPOLATE | |
  23896. * | 10 | ALPHA_SCREENMODE | |
  23897. *
  23898. */
  23899. set alphaMode(value: number);
  23900. /**
  23901. * Gets the value of the alpha mode
  23902. */
  23903. get alphaMode(): number;
  23904. /**
  23905. * Stores the state of the need depth pre-pass value
  23906. */
  23907. private _needDepthPrePass;
  23908. /**
  23909. * Sets the need depth pre-pass value
  23910. */
  23911. set needDepthPrePass(value: boolean);
  23912. /**
  23913. * Gets the depth pre-pass value
  23914. */
  23915. get needDepthPrePass(): boolean;
  23916. /**
  23917. * Specifies if depth writing should be disabled
  23918. */
  23919. disableDepthWrite: boolean;
  23920. /**
  23921. * Specifies if color writing should be disabled
  23922. */
  23923. disableColorWrite: boolean;
  23924. /**
  23925. * Specifies if depth writing should be forced
  23926. */
  23927. forceDepthWrite: boolean;
  23928. /**
  23929. * Specifies the depth function that should be used. 0 means the default engine function
  23930. */
  23931. depthFunction: number;
  23932. /**
  23933. * Specifies if there should be a separate pass for culling
  23934. */
  23935. separateCullingPass: boolean;
  23936. /**
  23937. * Stores the state specifing if fog should be enabled
  23938. */
  23939. private _fogEnabled;
  23940. /**
  23941. * Sets the state for enabling fog
  23942. */
  23943. set fogEnabled(value: boolean);
  23944. /**
  23945. * Gets the value of the fog enabled state
  23946. */
  23947. get fogEnabled(): boolean;
  23948. /**
  23949. * Stores the size of points
  23950. */
  23951. pointSize: number;
  23952. /**
  23953. * Stores the z offset value
  23954. */
  23955. zOffset: number;
  23956. get wireframe(): boolean;
  23957. /**
  23958. * Sets the state of wireframe mode
  23959. */
  23960. set wireframe(value: boolean);
  23961. /**
  23962. * Gets the value specifying if point clouds are enabled
  23963. */
  23964. get pointsCloud(): boolean;
  23965. /**
  23966. * Sets the state of point cloud mode
  23967. */
  23968. set pointsCloud(value: boolean);
  23969. /**
  23970. * Gets the material fill mode
  23971. */
  23972. get fillMode(): number;
  23973. /**
  23974. * Sets the material fill mode
  23975. */
  23976. set fillMode(value: number);
  23977. /**
  23978. * @hidden
  23979. * Stores the effects for the material
  23980. */
  23981. _effect: Nullable<Effect>;
  23982. /**
  23983. * Specifies if uniform buffers should be used
  23984. */
  23985. private _useUBO;
  23986. /**
  23987. * Stores a reference to the scene
  23988. */
  23989. private _scene;
  23990. /**
  23991. * Stores the fill mode state
  23992. */
  23993. private _fillMode;
  23994. /**
  23995. * Specifies if the depth write state should be cached
  23996. */
  23997. private _cachedDepthWriteState;
  23998. /**
  23999. * Specifies if the color write state should be cached
  24000. */
  24001. private _cachedColorWriteState;
  24002. /**
  24003. * Specifies if the depth function state should be cached
  24004. */
  24005. private _cachedDepthFunctionState;
  24006. /**
  24007. * Stores the uniform buffer
  24008. */
  24009. protected _uniformBuffer: UniformBuffer;
  24010. /** @hidden */
  24011. _indexInSceneMaterialArray: number;
  24012. /** @hidden */
  24013. meshMap: Nullable<{
  24014. [id: string]: AbstractMesh | undefined;
  24015. }>;
  24016. /**
  24017. * Creates a material instance
  24018. * @param name defines the name of the material
  24019. * @param scene defines the scene to reference
  24020. * @param doNotAdd specifies if the material should be added to the scene
  24021. */
  24022. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24023. /**
  24024. * Returns a string representation of the current material
  24025. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24026. * @returns a string with material information
  24027. */
  24028. toString(fullDetails?: boolean): string;
  24029. /**
  24030. * Gets the class name of the material
  24031. * @returns a string with the class name of the material
  24032. */
  24033. getClassName(): string;
  24034. /**
  24035. * Specifies if updates for the material been locked
  24036. */
  24037. get isFrozen(): boolean;
  24038. /**
  24039. * Locks updates for the material
  24040. */
  24041. freeze(): void;
  24042. /**
  24043. * Unlocks updates for the material
  24044. */
  24045. unfreeze(): void;
  24046. /**
  24047. * Specifies if the material is ready to be used
  24048. * @param mesh defines the mesh to check
  24049. * @param useInstances specifies if instances should be used
  24050. * @returns a boolean indicating if the material is ready to be used
  24051. */
  24052. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24053. /**
  24054. * Specifies that the submesh is ready to be used
  24055. * @param mesh defines the mesh to check
  24056. * @param subMesh defines which submesh to check
  24057. * @param useInstances specifies that instances should be used
  24058. * @returns a boolean indicating that the submesh is ready or not
  24059. */
  24060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24061. /**
  24062. * Returns the material effect
  24063. * @returns the effect associated with the material
  24064. */
  24065. getEffect(): Nullable<Effect>;
  24066. /**
  24067. * Returns the current scene
  24068. * @returns a Scene
  24069. */
  24070. getScene(): Scene;
  24071. /**
  24072. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24073. */
  24074. protected _forceAlphaTest: boolean;
  24075. /**
  24076. * The transparency mode of the material.
  24077. */
  24078. protected _transparencyMode: Nullable<number>;
  24079. /**
  24080. * Gets the current transparency mode.
  24081. */
  24082. get transparencyMode(): Nullable<number>;
  24083. /**
  24084. * Sets the transparency mode of the material.
  24085. *
  24086. * | Value | Type | Description |
  24087. * | ----- | ----------------------------------- | ----------- |
  24088. * | 0 | OPAQUE | |
  24089. * | 1 | ALPHATEST | |
  24090. * | 2 | ALPHABLEND | |
  24091. * | 3 | ALPHATESTANDBLEND | |
  24092. *
  24093. */
  24094. set transparencyMode(value: Nullable<number>);
  24095. /**
  24096. * Returns true if alpha blending should be disabled.
  24097. */
  24098. protected get _disableAlphaBlending(): boolean;
  24099. /**
  24100. * Specifies whether or not this material should be rendered in alpha blend mode.
  24101. * @returns a boolean specifying if alpha blending is needed
  24102. */
  24103. needAlphaBlending(): boolean;
  24104. /**
  24105. * Specifies if the mesh will require alpha blending
  24106. * @param mesh defines the mesh to check
  24107. * @returns a boolean specifying if alpha blending is needed for the mesh
  24108. */
  24109. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24110. /**
  24111. * Specifies whether or not this material should be rendered in alpha test mode.
  24112. * @returns a boolean specifying if an alpha test is needed.
  24113. */
  24114. needAlphaTesting(): boolean;
  24115. /**
  24116. * Specifies if material alpha testing should be turned on for the mesh
  24117. * @param mesh defines the mesh to check
  24118. */
  24119. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24120. /**
  24121. * Gets the texture used for the alpha test
  24122. * @returns the texture to use for alpha testing
  24123. */
  24124. getAlphaTestTexture(): Nullable<BaseTexture>;
  24125. /**
  24126. * Marks the material to indicate that it needs to be re-calculated
  24127. */
  24128. markDirty(): void;
  24129. /** @hidden */
  24130. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24131. /**
  24132. * Binds the material to the mesh
  24133. * @param world defines the world transformation matrix
  24134. * @param mesh defines the mesh to bind the material to
  24135. */
  24136. bind(world: Matrix, mesh?: Mesh): void;
  24137. /**
  24138. * Binds the submesh to the material
  24139. * @param world defines the world transformation matrix
  24140. * @param mesh defines the mesh containing the submesh
  24141. * @param subMesh defines the submesh to bind the material to
  24142. */
  24143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24144. /**
  24145. * Binds the world matrix to the material
  24146. * @param world defines the world transformation matrix
  24147. */
  24148. bindOnlyWorldMatrix(world: Matrix): void;
  24149. /**
  24150. * Binds the scene's uniform buffer to the effect.
  24151. * @param effect defines the effect to bind to the scene uniform buffer
  24152. * @param sceneUbo defines the uniform buffer storing scene data
  24153. */
  24154. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24155. /**
  24156. * Binds the view matrix to the effect
  24157. * @param effect defines the effect to bind the view matrix to
  24158. */
  24159. bindView(effect: Effect): void;
  24160. /**
  24161. * Binds the view projection matrix to the effect
  24162. * @param effect defines the effect to bind the view projection matrix to
  24163. */
  24164. bindViewProjection(effect: Effect): void;
  24165. /**
  24166. * Processes to execute after binding the material to a mesh
  24167. * @param mesh defines the rendered mesh
  24168. */
  24169. protected _afterBind(mesh?: Mesh): void;
  24170. /**
  24171. * Unbinds the material from the mesh
  24172. */
  24173. unbind(): void;
  24174. /**
  24175. * Gets the active textures from the material
  24176. * @returns an array of textures
  24177. */
  24178. getActiveTextures(): BaseTexture[];
  24179. /**
  24180. * Specifies if the material uses a texture
  24181. * @param texture defines the texture to check against the material
  24182. * @returns a boolean specifying if the material uses the texture
  24183. */
  24184. hasTexture(texture: BaseTexture): boolean;
  24185. /**
  24186. * Makes a duplicate of the material, and gives it a new name
  24187. * @param name defines the new name for the duplicated material
  24188. * @returns the cloned material
  24189. */
  24190. clone(name: string): Nullable<Material>;
  24191. /**
  24192. * Gets the meshes bound to the material
  24193. * @returns an array of meshes bound to the material
  24194. */
  24195. getBindedMeshes(): AbstractMesh[];
  24196. /**
  24197. * Force shader compilation
  24198. * @param mesh defines the mesh associated with this material
  24199. * @param onCompiled defines a function to execute once the material is compiled
  24200. * @param options defines the options to configure the compilation
  24201. * @param onError defines a function to execute if the material fails compiling
  24202. */
  24203. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24204. /**
  24205. * Force shader compilation
  24206. * @param mesh defines the mesh that will use this material
  24207. * @param options defines additional options for compiling the shaders
  24208. * @returns a promise that resolves when the compilation completes
  24209. */
  24210. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24211. private static readonly _AllDirtyCallBack;
  24212. private static readonly _ImageProcessingDirtyCallBack;
  24213. private static readonly _TextureDirtyCallBack;
  24214. private static readonly _FresnelDirtyCallBack;
  24215. private static readonly _MiscDirtyCallBack;
  24216. private static readonly _LightsDirtyCallBack;
  24217. private static readonly _AttributeDirtyCallBack;
  24218. private static _FresnelAndMiscDirtyCallBack;
  24219. private static _TextureAndMiscDirtyCallBack;
  24220. private static readonly _DirtyCallbackArray;
  24221. private static readonly _RunDirtyCallBacks;
  24222. /**
  24223. * Marks a define in the material to indicate that it needs to be re-computed
  24224. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24225. */
  24226. markAsDirty(flag: number): void;
  24227. /**
  24228. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24229. * @param func defines a function which checks material defines against the submeshes
  24230. */
  24231. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24232. /**
  24233. * Indicates that we need to re-calculated for all submeshes
  24234. */
  24235. protected _markAllSubMeshesAsAllDirty(): void;
  24236. /**
  24237. * Indicates that image processing needs to be re-calculated for all submeshes
  24238. */
  24239. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24240. /**
  24241. * Indicates that textures need to be re-calculated for all submeshes
  24242. */
  24243. protected _markAllSubMeshesAsTexturesDirty(): void;
  24244. /**
  24245. * Indicates that fresnel needs to be re-calculated for all submeshes
  24246. */
  24247. protected _markAllSubMeshesAsFresnelDirty(): void;
  24248. /**
  24249. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24250. */
  24251. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24252. /**
  24253. * Indicates that lights need to be re-calculated for all submeshes
  24254. */
  24255. protected _markAllSubMeshesAsLightsDirty(): void;
  24256. /**
  24257. * Indicates that attributes need to be re-calculated for all submeshes
  24258. */
  24259. protected _markAllSubMeshesAsAttributesDirty(): void;
  24260. /**
  24261. * Indicates that misc needs to be re-calculated for all submeshes
  24262. */
  24263. protected _markAllSubMeshesAsMiscDirty(): void;
  24264. /**
  24265. * Indicates that textures and misc need to be re-calculated for all submeshes
  24266. */
  24267. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24268. /**
  24269. * Disposes the material
  24270. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24271. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24272. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24273. */
  24274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24275. /** @hidden */
  24276. private releaseVertexArrayObject;
  24277. /**
  24278. * Serializes this material
  24279. * @returns the serialized material object
  24280. */
  24281. serialize(): any;
  24282. /**
  24283. * Creates a material from parsed material data
  24284. * @param parsedMaterial defines parsed material data
  24285. * @param scene defines the hosting scene
  24286. * @param rootUrl defines the root URL to use to load textures
  24287. * @returns a new material
  24288. */
  24289. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24290. }
  24291. }
  24292. declare module BABYLON {
  24293. /**
  24294. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24295. * separate meshes. This can be use to improve performances.
  24296. * @see http://doc.babylonjs.com/how_to/multi_materials
  24297. */
  24298. export class MultiMaterial extends Material {
  24299. private _subMaterials;
  24300. /**
  24301. * Gets or Sets the list of Materials used within the multi material.
  24302. * They need to be ordered according to the submeshes order in the associated mesh
  24303. */
  24304. get subMaterials(): Nullable<Material>[];
  24305. set subMaterials(value: Nullable<Material>[]);
  24306. /**
  24307. * Function used to align with Node.getChildren()
  24308. * @returns the list of Materials used within the multi material
  24309. */
  24310. getChildren(): Nullable<Material>[];
  24311. /**
  24312. * Instantiates a new Multi Material
  24313. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24314. * separate meshes. This can be use to improve performances.
  24315. * @see http://doc.babylonjs.com/how_to/multi_materials
  24316. * @param name Define the name in the scene
  24317. * @param scene Define the scene the material belongs to
  24318. */
  24319. constructor(name: string, scene: Scene);
  24320. private _hookArray;
  24321. /**
  24322. * Get one of the submaterial by its index in the submaterials array
  24323. * @param index The index to look the sub material at
  24324. * @returns The Material if the index has been defined
  24325. */
  24326. getSubMaterial(index: number): Nullable<Material>;
  24327. /**
  24328. * Get the list of active textures for the whole sub materials list.
  24329. * @returns All the textures that will be used during the rendering
  24330. */
  24331. getActiveTextures(): BaseTexture[];
  24332. /**
  24333. * Gets the current class name of the material e.g. "MultiMaterial"
  24334. * Mainly use in serialization.
  24335. * @returns the class name
  24336. */
  24337. getClassName(): string;
  24338. /**
  24339. * Checks if the material is ready to render the requested sub mesh
  24340. * @param mesh Define the mesh the submesh belongs to
  24341. * @param subMesh Define the sub mesh to look readyness for
  24342. * @param useInstances Define whether or not the material is used with instances
  24343. * @returns true if ready, otherwise false
  24344. */
  24345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24346. /**
  24347. * Clones the current material and its related sub materials
  24348. * @param name Define the name of the newly cloned material
  24349. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24350. * @returns the cloned material
  24351. */
  24352. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24353. /**
  24354. * Serializes the materials into a JSON representation.
  24355. * @returns the JSON representation
  24356. */
  24357. serialize(): any;
  24358. /**
  24359. * Dispose the material and release its associated resources
  24360. * @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)
  24361. * @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)
  24362. * @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)
  24363. */
  24364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24365. /**
  24366. * Creates a MultiMaterial from parsed MultiMaterial data.
  24367. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24368. * @param scene defines the hosting scene
  24369. * @returns a new MultiMaterial
  24370. */
  24371. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24372. }
  24373. }
  24374. declare module BABYLON {
  24375. /**
  24376. * Base class for submeshes
  24377. */
  24378. export class BaseSubMesh {
  24379. /** @hidden */
  24380. _materialDefines: Nullable<MaterialDefines>;
  24381. /** @hidden */
  24382. _materialEffect: Nullable<Effect>;
  24383. /** @hidden */
  24384. _effectOverride: Nullable<Effect>;
  24385. /**
  24386. * Gets material defines used by the effect associated to the sub mesh
  24387. */
  24388. get materialDefines(): Nullable<MaterialDefines>;
  24389. /**
  24390. * Sets material defines used by the effect associated to the sub mesh
  24391. */
  24392. set materialDefines(defines: Nullable<MaterialDefines>);
  24393. /**
  24394. * Gets associated effect
  24395. */
  24396. get effect(): Nullable<Effect>;
  24397. /**
  24398. * Sets associated effect (effect used to render this submesh)
  24399. * @param effect defines the effect to associate with
  24400. * @param defines defines the set of defines used to compile this effect
  24401. */
  24402. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24403. }
  24404. /**
  24405. * Defines a subdivision inside a mesh
  24406. */
  24407. export class SubMesh extends BaseSubMesh implements ICullable {
  24408. /** the material index to use */
  24409. materialIndex: number;
  24410. /** vertex index start */
  24411. verticesStart: number;
  24412. /** vertices count */
  24413. verticesCount: number;
  24414. /** index start */
  24415. indexStart: number;
  24416. /** indices count */
  24417. indexCount: number;
  24418. /** @hidden */
  24419. _linesIndexCount: number;
  24420. private _mesh;
  24421. private _renderingMesh;
  24422. private _boundingInfo;
  24423. private _linesIndexBuffer;
  24424. /** @hidden */
  24425. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24426. /** @hidden */
  24427. _trianglePlanes: Plane[];
  24428. /** @hidden */
  24429. _lastColliderTransformMatrix: Nullable<Matrix>;
  24430. /** @hidden */
  24431. _renderId: number;
  24432. /** @hidden */
  24433. _alphaIndex: number;
  24434. /** @hidden */
  24435. _distanceToCamera: number;
  24436. /** @hidden */
  24437. _id: number;
  24438. private _currentMaterial;
  24439. /**
  24440. * Add a new submesh to a mesh
  24441. * @param materialIndex defines the material index to use
  24442. * @param verticesStart defines vertex index start
  24443. * @param verticesCount defines vertices count
  24444. * @param indexStart defines index start
  24445. * @param indexCount defines indices count
  24446. * @param mesh defines the parent mesh
  24447. * @param renderingMesh defines an optional rendering mesh
  24448. * @param createBoundingBox defines if bounding box should be created for this submesh
  24449. * @returns the new submesh
  24450. */
  24451. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24452. /**
  24453. * Creates a new submesh
  24454. * @param materialIndex defines the material index to use
  24455. * @param verticesStart defines vertex index start
  24456. * @param verticesCount defines vertices count
  24457. * @param indexStart defines index start
  24458. * @param indexCount defines indices count
  24459. * @param mesh defines the parent mesh
  24460. * @param renderingMesh defines an optional rendering mesh
  24461. * @param createBoundingBox defines if bounding box should be created for this submesh
  24462. */
  24463. constructor(
  24464. /** the material index to use */
  24465. materialIndex: number,
  24466. /** vertex index start */
  24467. verticesStart: number,
  24468. /** vertices count */
  24469. verticesCount: number,
  24470. /** index start */
  24471. indexStart: number,
  24472. /** indices count */
  24473. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24474. /**
  24475. * Returns true if this submesh covers the entire parent mesh
  24476. * @ignorenaming
  24477. */
  24478. get IsGlobal(): boolean;
  24479. /**
  24480. * Returns the submesh BoudingInfo object
  24481. * @returns current bounding info (or mesh's one if the submesh is global)
  24482. */
  24483. getBoundingInfo(): BoundingInfo;
  24484. /**
  24485. * Sets the submesh BoundingInfo
  24486. * @param boundingInfo defines the new bounding info to use
  24487. * @returns the SubMesh
  24488. */
  24489. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24490. /**
  24491. * Returns the mesh of the current submesh
  24492. * @return the parent mesh
  24493. */
  24494. getMesh(): AbstractMesh;
  24495. /**
  24496. * Returns the rendering mesh of the submesh
  24497. * @returns the rendering mesh (could be different from parent mesh)
  24498. */
  24499. getRenderingMesh(): Mesh;
  24500. /**
  24501. * Returns the replacement mesh of the submesh
  24502. * @returns the replacement mesh (could be different from parent mesh)
  24503. */
  24504. getReplacementMesh(): Nullable<AbstractMesh>;
  24505. /**
  24506. * Returns the effective mesh of the submesh
  24507. * @returns the effective mesh (could be different from parent mesh)
  24508. */
  24509. getEffectiveMesh(): AbstractMesh;
  24510. /**
  24511. * Returns the submesh material
  24512. * @returns null or the current material
  24513. */
  24514. getMaterial(): Nullable<Material>;
  24515. /**
  24516. * Sets a new updated BoundingInfo object to the submesh
  24517. * @param data defines an optional position array to use to determine the bounding info
  24518. * @returns the SubMesh
  24519. */
  24520. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24521. /** @hidden */
  24522. _checkCollision(collider: Collider): boolean;
  24523. /**
  24524. * Updates the submesh BoundingInfo
  24525. * @param world defines the world matrix to use to update the bounding info
  24526. * @returns the submesh
  24527. */
  24528. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24529. /**
  24530. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24531. * @param frustumPlanes defines the frustum planes
  24532. * @returns true if the submesh is intersecting with the frustum
  24533. */
  24534. isInFrustum(frustumPlanes: Plane[]): boolean;
  24535. /**
  24536. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24537. * @param frustumPlanes defines the frustum planes
  24538. * @returns true if the submesh is inside the frustum
  24539. */
  24540. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24541. /**
  24542. * Renders the submesh
  24543. * @param enableAlphaMode defines if alpha needs to be used
  24544. * @returns the submesh
  24545. */
  24546. render(enableAlphaMode: boolean): SubMesh;
  24547. /**
  24548. * @hidden
  24549. */
  24550. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24551. /**
  24552. * Checks if the submesh intersects with a ray
  24553. * @param ray defines the ray to test
  24554. * @returns true is the passed ray intersects the submesh bounding box
  24555. */
  24556. canIntersects(ray: Ray): boolean;
  24557. /**
  24558. * Intersects current submesh with a ray
  24559. * @param ray defines the ray to test
  24560. * @param positions defines mesh's positions array
  24561. * @param indices defines mesh's indices array
  24562. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24563. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24564. * @returns intersection info or null if no intersection
  24565. */
  24566. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24567. /** @hidden */
  24568. private _intersectLines;
  24569. /** @hidden */
  24570. private _intersectUnIndexedLines;
  24571. /** @hidden */
  24572. private _intersectTriangles;
  24573. /** @hidden */
  24574. private _intersectUnIndexedTriangles;
  24575. /** @hidden */
  24576. _rebuild(): void;
  24577. /**
  24578. * Creates a new submesh from the passed mesh
  24579. * @param newMesh defines the new hosting mesh
  24580. * @param newRenderingMesh defines an optional rendering mesh
  24581. * @returns the new submesh
  24582. */
  24583. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24584. /**
  24585. * Release associated resources
  24586. */
  24587. dispose(): void;
  24588. /**
  24589. * Gets the class name
  24590. * @returns the string "SubMesh".
  24591. */
  24592. getClassName(): string;
  24593. /**
  24594. * Creates a new submesh from indices data
  24595. * @param materialIndex the index of the main mesh material
  24596. * @param startIndex the index where to start the copy in the mesh indices array
  24597. * @param indexCount the number of indices to copy then from the startIndex
  24598. * @param mesh the main mesh to create the submesh from
  24599. * @param renderingMesh the optional rendering mesh
  24600. * @returns a new submesh
  24601. */
  24602. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24603. }
  24604. }
  24605. declare module BABYLON {
  24606. /**
  24607. * Class used to represent data loading progression
  24608. */
  24609. export class SceneLoaderFlags {
  24610. private static _ForceFullSceneLoadingForIncremental;
  24611. private static _ShowLoadingScreen;
  24612. private static _CleanBoneMatrixWeights;
  24613. private static _loggingLevel;
  24614. /**
  24615. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24616. */
  24617. static get ForceFullSceneLoadingForIncremental(): boolean;
  24618. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24619. /**
  24620. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24621. */
  24622. static get ShowLoadingScreen(): boolean;
  24623. static set ShowLoadingScreen(value: boolean);
  24624. /**
  24625. * Defines the current logging level (while loading the scene)
  24626. * @ignorenaming
  24627. */
  24628. static get loggingLevel(): number;
  24629. static set loggingLevel(value: number);
  24630. /**
  24631. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24632. */
  24633. static get CleanBoneMatrixWeights(): boolean;
  24634. static set CleanBoneMatrixWeights(value: boolean);
  24635. }
  24636. }
  24637. declare module BABYLON {
  24638. /**
  24639. * Class used to store geometry data (vertex buffers + index buffer)
  24640. */
  24641. export class Geometry implements IGetSetVerticesData {
  24642. /**
  24643. * Gets or sets the ID of the geometry
  24644. */
  24645. id: string;
  24646. /**
  24647. * Gets or sets the unique ID of the geometry
  24648. */
  24649. uniqueId: number;
  24650. /**
  24651. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24652. */
  24653. delayLoadState: number;
  24654. /**
  24655. * Gets the file containing the data to load when running in delay load state
  24656. */
  24657. delayLoadingFile: Nullable<string>;
  24658. /**
  24659. * Callback called when the geometry is updated
  24660. */
  24661. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24662. private _scene;
  24663. private _engine;
  24664. private _meshes;
  24665. private _totalVertices;
  24666. /** @hidden */
  24667. _indices: IndicesArray;
  24668. /** @hidden */
  24669. _vertexBuffers: {
  24670. [key: string]: VertexBuffer;
  24671. };
  24672. private _isDisposed;
  24673. private _extend;
  24674. private _boundingBias;
  24675. /** @hidden */
  24676. _delayInfo: Array<string>;
  24677. private _indexBuffer;
  24678. private _indexBufferIsUpdatable;
  24679. /** @hidden */
  24680. _boundingInfo: Nullable<BoundingInfo>;
  24681. /** @hidden */
  24682. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24683. /** @hidden */
  24684. _softwareSkinningFrameId: number;
  24685. private _vertexArrayObjects;
  24686. private _updatable;
  24687. /** @hidden */
  24688. _positions: Nullable<Vector3[]>;
  24689. /**
  24690. * 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
  24691. */
  24692. get boundingBias(): Vector2;
  24693. /**
  24694. * 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
  24695. */
  24696. set boundingBias(value: Vector2);
  24697. /**
  24698. * Static function used to attach a new empty geometry to a mesh
  24699. * @param mesh defines the mesh to attach the geometry to
  24700. * @returns the new Geometry
  24701. */
  24702. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24703. /** Get the list of meshes using this geometry */
  24704. get meshes(): Mesh[];
  24705. /**
  24706. * Creates a new geometry
  24707. * @param id defines the unique ID
  24708. * @param scene defines the hosting scene
  24709. * @param vertexData defines the VertexData used to get geometry data
  24710. * @param updatable defines if geometry must be updatable (false by default)
  24711. * @param mesh defines the mesh that will be associated with the geometry
  24712. */
  24713. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24714. /**
  24715. * Gets the current extend of the geometry
  24716. */
  24717. get extend(): {
  24718. minimum: Vector3;
  24719. maximum: Vector3;
  24720. };
  24721. /**
  24722. * Gets the hosting scene
  24723. * @returns the hosting Scene
  24724. */
  24725. getScene(): Scene;
  24726. /**
  24727. * Gets the hosting engine
  24728. * @returns the hosting Engine
  24729. */
  24730. getEngine(): Engine;
  24731. /**
  24732. * Defines if the geometry is ready to use
  24733. * @returns true if the geometry is ready to be used
  24734. */
  24735. isReady(): boolean;
  24736. /**
  24737. * Gets a value indicating that the geometry should not be serialized
  24738. */
  24739. get doNotSerialize(): boolean;
  24740. /** @hidden */
  24741. _rebuild(): void;
  24742. /**
  24743. * Affects all geometry data in one call
  24744. * @param vertexData defines the geometry data
  24745. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24746. */
  24747. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24748. /**
  24749. * Set specific vertex data
  24750. * @param kind defines the data kind (Position, normal, etc...)
  24751. * @param data defines the vertex data to use
  24752. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24753. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24754. */
  24755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24756. /**
  24757. * Removes a specific vertex data
  24758. * @param kind defines the data kind (Position, normal, etc...)
  24759. */
  24760. removeVerticesData(kind: string): void;
  24761. /**
  24762. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24763. * @param buffer defines the vertex buffer to use
  24764. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24765. */
  24766. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24767. /**
  24768. * Update a specific vertex buffer
  24769. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24770. * It will do nothing if the buffer is not updatable
  24771. * @param kind defines the data kind (Position, normal, etc...)
  24772. * @param data defines the data to use
  24773. * @param offset defines the offset in the target buffer where to store the data
  24774. * @param useBytes set to true if the offset is in bytes
  24775. */
  24776. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24777. /**
  24778. * Update a specific vertex buffer
  24779. * This function will create a new buffer if the current one is not updatable
  24780. * @param kind defines the data kind (Position, normal, etc...)
  24781. * @param data defines the data to use
  24782. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24783. */
  24784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24785. private _updateBoundingInfo;
  24786. /** @hidden */
  24787. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24788. /**
  24789. * Gets total number of vertices
  24790. * @returns the total number of vertices
  24791. */
  24792. getTotalVertices(): number;
  24793. /**
  24794. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24795. * @param kind defines the data kind (Position, normal, etc...)
  24796. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24797. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24798. * @returns a float array containing vertex data
  24799. */
  24800. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24801. /**
  24802. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24803. * @param kind defines the data kind (Position, normal, etc...)
  24804. * @returns true if the vertex buffer with the specified kind is updatable
  24805. */
  24806. isVertexBufferUpdatable(kind: string): boolean;
  24807. /**
  24808. * Gets a specific vertex buffer
  24809. * @param kind defines the data kind (Position, normal, etc...)
  24810. * @returns a VertexBuffer
  24811. */
  24812. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24813. /**
  24814. * Returns all vertex buffers
  24815. * @return an object holding all vertex buffers indexed by kind
  24816. */
  24817. getVertexBuffers(): Nullable<{
  24818. [key: string]: VertexBuffer;
  24819. }>;
  24820. /**
  24821. * Gets a boolean indicating if specific vertex buffer is present
  24822. * @param kind defines the data kind (Position, normal, etc...)
  24823. * @returns true if data is present
  24824. */
  24825. isVerticesDataPresent(kind: string): boolean;
  24826. /**
  24827. * Gets a list of all attached data kinds (Position, normal, etc...)
  24828. * @returns a list of string containing all kinds
  24829. */
  24830. getVerticesDataKinds(): string[];
  24831. /**
  24832. * Update index buffer
  24833. * @param indices defines the indices to store in the index buffer
  24834. * @param offset defines the offset in the target buffer where to store the data
  24835. * @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)
  24836. */
  24837. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24838. /**
  24839. * Creates a new index buffer
  24840. * @param indices defines the indices to store in the index buffer
  24841. * @param totalVertices defines the total number of vertices (could be null)
  24842. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24843. */
  24844. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24845. /**
  24846. * Return the total number of indices
  24847. * @returns the total number of indices
  24848. */
  24849. getTotalIndices(): number;
  24850. /**
  24851. * Gets the index buffer array
  24852. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24854. * @returns the index buffer array
  24855. */
  24856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24857. /**
  24858. * Gets the index buffer
  24859. * @return the index buffer
  24860. */
  24861. getIndexBuffer(): Nullable<DataBuffer>;
  24862. /** @hidden */
  24863. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24864. /**
  24865. * Release the associated resources for a specific mesh
  24866. * @param mesh defines the source mesh
  24867. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24868. */
  24869. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24870. /**
  24871. * Apply current geometry to a given mesh
  24872. * @param mesh defines the mesh to apply geometry to
  24873. */
  24874. applyToMesh(mesh: Mesh): void;
  24875. private _updateExtend;
  24876. private _applyToMesh;
  24877. private notifyUpdate;
  24878. /**
  24879. * Load the geometry if it was flagged as delay loaded
  24880. * @param scene defines the hosting scene
  24881. * @param onLoaded defines a callback called when the geometry is loaded
  24882. */
  24883. load(scene: Scene, onLoaded?: () => void): void;
  24884. private _queueLoad;
  24885. /**
  24886. * Invert the geometry to move from a right handed system to a left handed one.
  24887. */
  24888. toLeftHanded(): void;
  24889. /** @hidden */
  24890. _resetPointsArrayCache(): void;
  24891. /** @hidden */
  24892. _generatePointsArray(): boolean;
  24893. /**
  24894. * Gets a value indicating if the geometry is disposed
  24895. * @returns true if the geometry was disposed
  24896. */
  24897. isDisposed(): boolean;
  24898. private _disposeVertexArrayObjects;
  24899. /**
  24900. * Free all associated resources
  24901. */
  24902. dispose(): void;
  24903. /**
  24904. * Clone the current geometry into a new geometry
  24905. * @param id defines the unique ID of the new geometry
  24906. * @returns a new geometry object
  24907. */
  24908. copy(id: string): Geometry;
  24909. /**
  24910. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24911. * @return a JSON representation of the current geometry data (without the vertices data)
  24912. */
  24913. serialize(): any;
  24914. private toNumberArray;
  24915. /**
  24916. * Serialize all vertices data into a JSON oject
  24917. * @returns a JSON representation of the current geometry data
  24918. */
  24919. serializeVerticeData(): any;
  24920. /**
  24921. * Extracts a clone of a mesh geometry
  24922. * @param mesh defines the source mesh
  24923. * @param id defines the unique ID of the new geometry object
  24924. * @returns the new geometry object
  24925. */
  24926. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24927. /**
  24928. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24929. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24930. * Be aware Math.random() could cause collisions, but:
  24931. * "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"
  24932. * @returns a string containing a new GUID
  24933. */
  24934. static RandomId(): string;
  24935. /** @hidden */
  24936. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24937. private static _CleanMatricesWeights;
  24938. /**
  24939. * Create a new geometry from persisted data (Using .babylon file format)
  24940. * @param parsedVertexData defines the persisted data
  24941. * @param scene defines the hosting scene
  24942. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24943. * @returns the new geometry object
  24944. */
  24945. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24946. }
  24947. }
  24948. declare module BABYLON {
  24949. /**
  24950. * Define an interface for all classes that will get and set the data on vertices
  24951. */
  24952. export interface IGetSetVerticesData {
  24953. /**
  24954. * Gets a boolean indicating if specific vertex data is present
  24955. * @param kind defines the vertex data kind to use
  24956. * @returns true is data kind is present
  24957. */
  24958. isVerticesDataPresent(kind: string): boolean;
  24959. /**
  24960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24961. * @param kind defines the data kind (Position, normal, etc...)
  24962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24964. * @returns a float array containing vertex data
  24965. */
  24966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24967. /**
  24968. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24969. * @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.
  24970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24971. * @returns the indices array or an empty array if the mesh has no geometry
  24972. */
  24973. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24974. /**
  24975. * Set specific vertex data
  24976. * @param kind defines the data kind (Position, normal, etc...)
  24977. * @param data defines the vertex data to use
  24978. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24979. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24980. */
  24981. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24982. /**
  24983. * Update a specific associated vertex buffer
  24984. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24985. * - VertexBuffer.PositionKind
  24986. * - VertexBuffer.UVKind
  24987. * - VertexBuffer.UV2Kind
  24988. * - VertexBuffer.UV3Kind
  24989. * - VertexBuffer.UV4Kind
  24990. * - VertexBuffer.UV5Kind
  24991. * - VertexBuffer.UV6Kind
  24992. * - VertexBuffer.ColorKind
  24993. * - VertexBuffer.MatricesIndicesKind
  24994. * - VertexBuffer.MatricesIndicesExtraKind
  24995. * - VertexBuffer.MatricesWeightsKind
  24996. * - VertexBuffer.MatricesWeightsExtraKind
  24997. * @param data defines the data source
  24998. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24999. * @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)
  25000. */
  25001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25002. /**
  25003. * Creates a new index buffer
  25004. * @param indices defines the indices to store in the index buffer
  25005. * @param totalVertices defines the total number of vertices (could be null)
  25006. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25007. */
  25008. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25009. }
  25010. /**
  25011. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25012. */
  25013. export class VertexData {
  25014. /**
  25015. * Mesh side orientation : usually the external or front surface
  25016. */
  25017. static readonly FRONTSIDE: number;
  25018. /**
  25019. * Mesh side orientation : usually the internal or back surface
  25020. */
  25021. static readonly BACKSIDE: number;
  25022. /**
  25023. * Mesh side orientation : both internal and external or front and back surfaces
  25024. */
  25025. static readonly DOUBLESIDE: number;
  25026. /**
  25027. * Mesh side orientation : by default, `FRONTSIDE`
  25028. */
  25029. static readonly DEFAULTSIDE: number;
  25030. /**
  25031. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25032. */
  25033. positions: Nullable<FloatArray>;
  25034. /**
  25035. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25036. */
  25037. normals: Nullable<FloatArray>;
  25038. /**
  25039. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25040. */
  25041. tangents: Nullable<FloatArray>;
  25042. /**
  25043. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25044. */
  25045. uvs: Nullable<FloatArray>;
  25046. /**
  25047. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25048. */
  25049. uvs2: Nullable<FloatArray>;
  25050. /**
  25051. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25052. */
  25053. uvs3: Nullable<FloatArray>;
  25054. /**
  25055. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25056. */
  25057. uvs4: Nullable<FloatArray>;
  25058. /**
  25059. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25060. */
  25061. uvs5: Nullable<FloatArray>;
  25062. /**
  25063. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25064. */
  25065. uvs6: Nullable<FloatArray>;
  25066. /**
  25067. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25068. */
  25069. colors: Nullable<FloatArray>;
  25070. /**
  25071. * 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).
  25072. */
  25073. matricesIndices: Nullable<FloatArray>;
  25074. /**
  25075. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25076. */
  25077. matricesWeights: Nullable<FloatArray>;
  25078. /**
  25079. * An array extending the number of possible indices
  25080. */
  25081. matricesIndicesExtra: Nullable<FloatArray>;
  25082. /**
  25083. * An array extending the number of possible weights when the number of indices is extended
  25084. */
  25085. matricesWeightsExtra: Nullable<FloatArray>;
  25086. /**
  25087. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25088. */
  25089. indices: Nullable<IndicesArray>;
  25090. /**
  25091. * Uses the passed data array to set the set the values for the specified kind of data
  25092. * @param data a linear array of floating numbers
  25093. * @param kind the type of data that is being set, eg positions, colors etc
  25094. */
  25095. set(data: FloatArray, kind: string): void;
  25096. /**
  25097. * Associates the vertexData to the passed Mesh.
  25098. * Sets it as updatable or not (default `false`)
  25099. * @param mesh the mesh the vertexData is applied to
  25100. * @param updatable when used and having the value true allows new data to update the vertexData
  25101. * @returns the VertexData
  25102. */
  25103. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25104. /**
  25105. * Associates the vertexData to the passed Geometry.
  25106. * Sets it as updatable or not (default `false`)
  25107. * @param geometry the geometry the vertexData is applied to
  25108. * @param updatable when used and having the value true allows new data to update the vertexData
  25109. * @returns VertexData
  25110. */
  25111. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25112. /**
  25113. * Updates the associated mesh
  25114. * @param mesh the mesh to be updated
  25115. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25116. * @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
  25117. * @returns VertexData
  25118. */
  25119. updateMesh(mesh: Mesh): VertexData;
  25120. /**
  25121. * Updates the associated geometry
  25122. * @param geometry the geometry to be updated
  25123. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25124. * @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
  25125. * @returns VertexData.
  25126. */
  25127. updateGeometry(geometry: Geometry): VertexData;
  25128. private _applyTo;
  25129. private _update;
  25130. /**
  25131. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25132. * @param matrix the transforming matrix
  25133. * @returns the VertexData
  25134. */
  25135. transform(matrix: Matrix): VertexData;
  25136. /**
  25137. * Merges the passed VertexData into the current one
  25138. * @param other the VertexData to be merged into the current one
  25139. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25140. * @returns the modified VertexData
  25141. */
  25142. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25143. private _mergeElement;
  25144. private _validate;
  25145. /**
  25146. * Serializes the VertexData
  25147. * @returns a serialized object
  25148. */
  25149. serialize(): any;
  25150. /**
  25151. * Extracts the vertexData from a mesh
  25152. * @param mesh the mesh from which to extract the VertexData
  25153. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25154. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25155. * @returns the object VertexData associated to the passed mesh
  25156. */
  25157. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25158. /**
  25159. * Extracts the vertexData from the geometry
  25160. * @param geometry the geometry from which to extract the VertexData
  25161. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25162. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25163. * @returns the object VertexData associated to the passed mesh
  25164. */
  25165. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25166. private static _ExtractFrom;
  25167. /**
  25168. * Creates the VertexData for a Ribbon
  25169. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25170. * * pathArray array of paths, each of which an array of successive Vector3
  25171. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25172. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25173. * * 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
  25174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25175. * * 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)
  25176. * * 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)
  25177. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25178. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25179. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25180. * @returns the VertexData of the ribbon
  25181. */
  25182. static CreateRibbon(options: {
  25183. pathArray: Vector3[][];
  25184. closeArray?: boolean;
  25185. closePath?: boolean;
  25186. offset?: number;
  25187. sideOrientation?: number;
  25188. frontUVs?: Vector4;
  25189. backUVs?: Vector4;
  25190. invertUV?: boolean;
  25191. uvs?: Vector2[];
  25192. colors?: Color4[];
  25193. }): VertexData;
  25194. /**
  25195. * Creates the VertexData for a box
  25196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25197. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25198. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25199. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25200. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25201. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25202. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25204. * * 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)
  25205. * * 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)
  25206. * @returns the VertexData of the box
  25207. */
  25208. static CreateBox(options: {
  25209. size?: number;
  25210. width?: number;
  25211. height?: number;
  25212. depth?: number;
  25213. faceUV?: Vector4[];
  25214. faceColors?: Color4[];
  25215. sideOrientation?: number;
  25216. frontUVs?: Vector4;
  25217. backUVs?: Vector4;
  25218. }): VertexData;
  25219. /**
  25220. * Creates the VertexData for a tiled box
  25221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25222. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25223. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25224. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25226. * @returns the VertexData of the box
  25227. */
  25228. static CreateTiledBox(options: {
  25229. pattern?: number;
  25230. width?: number;
  25231. height?: number;
  25232. depth?: number;
  25233. tileSize?: number;
  25234. tileWidth?: number;
  25235. tileHeight?: number;
  25236. alignHorizontal?: number;
  25237. alignVertical?: number;
  25238. faceUV?: Vector4[];
  25239. faceColors?: Color4[];
  25240. sideOrientation?: number;
  25241. }): VertexData;
  25242. /**
  25243. * Creates the VertexData for a tiled plane
  25244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25245. * * pattern a limited pattern arrangement depending on the number
  25246. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25247. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25248. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25250. * * 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)
  25251. * * 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)
  25252. * @returns the VertexData of the tiled plane
  25253. */
  25254. static CreateTiledPlane(options: {
  25255. pattern?: number;
  25256. tileSize?: number;
  25257. tileWidth?: number;
  25258. tileHeight?: number;
  25259. size?: number;
  25260. width?: number;
  25261. height?: number;
  25262. alignHorizontal?: number;
  25263. alignVertical?: number;
  25264. sideOrientation?: number;
  25265. frontUVs?: Vector4;
  25266. backUVs?: Vector4;
  25267. }): VertexData;
  25268. /**
  25269. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25270. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25271. * * segments sets the number of horizontal strips optional, default 32
  25272. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25273. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25274. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25275. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25276. * * 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
  25277. * * 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
  25278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25279. * * 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)
  25280. * * 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)
  25281. * @returns the VertexData of the ellipsoid
  25282. */
  25283. static CreateSphere(options: {
  25284. segments?: number;
  25285. diameter?: number;
  25286. diameterX?: number;
  25287. diameterY?: number;
  25288. diameterZ?: number;
  25289. arc?: number;
  25290. slice?: number;
  25291. sideOrientation?: number;
  25292. frontUVs?: Vector4;
  25293. backUVs?: Vector4;
  25294. }): VertexData;
  25295. /**
  25296. * Creates the VertexData for a cylinder, cone or prism
  25297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25298. * * height sets the height (y direction) of the cylinder, optional, default 2
  25299. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25300. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25301. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25303. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25304. * * 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
  25305. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25306. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25307. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25308. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25310. * * 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)
  25311. * * 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)
  25312. * @returns the VertexData of the cylinder, cone or prism
  25313. */
  25314. static CreateCylinder(options: {
  25315. height?: number;
  25316. diameterTop?: number;
  25317. diameterBottom?: number;
  25318. diameter?: number;
  25319. tessellation?: number;
  25320. subdivisions?: number;
  25321. arc?: number;
  25322. faceColors?: Color4[];
  25323. faceUV?: Vector4[];
  25324. hasRings?: boolean;
  25325. enclose?: boolean;
  25326. sideOrientation?: number;
  25327. frontUVs?: Vector4;
  25328. backUVs?: Vector4;
  25329. }): VertexData;
  25330. /**
  25331. * Creates the VertexData for a torus
  25332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25333. * * diameter the diameter of the torus, optional default 1
  25334. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25335. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25337. * * 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)
  25338. * * 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)
  25339. * @returns the VertexData of the torus
  25340. */
  25341. static CreateTorus(options: {
  25342. diameter?: number;
  25343. thickness?: number;
  25344. tessellation?: number;
  25345. sideOrientation?: number;
  25346. frontUVs?: Vector4;
  25347. backUVs?: Vector4;
  25348. }): VertexData;
  25349. /**
  25350. * Creates the VertexData of the LineSystem
  25351. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25352. * - lines an array of lines, each line being an array of successive Vector3
  25353. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25354. * @returns the VertexData of the LineSystem
  25355. */
  25356. static CreateLineSystem(options: {
  25357. lines: Vector3[][];
  25358. colors?: Nullable<Color4[][]>;
  25359. }): VertexData;
  25360. /**
  25361. * Create the VertexData for a DashedLines
  25362. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25363. * - points an array successive Vector3
  25364. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25365. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25366. * - dashNb the intended total number of dashes, optional, default 200
  25367. * @returns the VertexData for the DashedLines
  25368. */
  25369. static CreateDashedLines(options: {
  25370. points: Vector3[];
  25371. dashSize?: number;
  25372. gapSize?: number;
  25373. dashNb?: number;
  25374. }): VertexData;
  25375. /**
  25376. * Creates the VertexData for a Ground
  25377. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25378. * - width the width (x direction) of the ground, optional, default 1
  25379. * - height the height (z direction) of the ground, optional, default 1
  25380. * - subdivisions the number of subdivisions per side, optional, default 1
  25381. * @returns the VertexData of the Ground
  25382. */
  25383. static CreateGround(options: {
  25384. width?: number;
  25385. height?: number;
  25386. subdivisions?: number;
  25387. subdivisionsX?: number;
  25388. subdivisionsY?: number;
  25389. }): VertexData;
  25390. /**
  25391. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25393. * * xmin the ground minimum X coordinate, optional, default -1
  25394. * * zmin the ground minimum Z coordinate, optional, default -1
  25395. * * xmax the ground maximum X coordinate, optional, default 1
  25396. * * zmax the ground maximum Z coordinate, optional, default 1
  25397. * * 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}
  25398. * * 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}
  25399. * @returns the VertexData of the TiledGround
  25400. */
  25401. static CreateTiledGround(options: {
  25402. xmin: number;
  25403. zmin: number;
  25404. xmax: number;
  25405. zmax: number;
  25406. subdivisions?: {
  25407. w: number;
  25408. h: number;
  25409. };
  25410. precision?: {
  25411. w: number;
  25412. h: number;
  25413. };
  25414. }): VertexData;
  25415. /**
  25416. * Creates the VertexData of the Ground designed from a heightmap
  25417. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25418. * * width the width (x direction) of the ground
  25419. * * height the height (z direction) of the ground
  25420. * * subdivisions the number of subdivisions per side
  25421. * * minHeight the minimum altitude on the ground, optional, default 0
  25422. * * maxHeight the maximum altitude on the ground, optional default 1
  25423. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25424. * * buffer the array holding the image color data
  25425. * * bufferWidth the width of image
  25426. * * bufferHeight the height of image
  25427. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25428. * @returns the VertexData of the Ground designed from a heightmap
  25429. */
  25430. static CreateGroundFromHeightMap(options: {
  25431. width: number;
  25432. height: number;
  25433. subdivisions: number;
  25434. minHeight: number;
  25435. maxHeight: number;
  25436. colorFilter: Color3;
  25437. buffer: Uint8Array;
  25438. bufferWidth: number;
  25439. bufferHeight: number;
  25440. alphaFilter: number;
  25441. }): VertexData;
  25442. /**
  25443. * Creates the VertexData for a Plane
  25444. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25445. * * size sets the width and height of the plane to the value of size, optional default 1
  25446. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25447. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25449. * * 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)
  25450. * * 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)
  25451. * @returns the VertexData of the box
  25452. */
  25453. static CreatePlane(options: {
  25454. size?: number;
  25455. width?: number;
  25456. height?: number;
  25457. sideOrientation?: number;
  25458. frontUVs?: Vector4;
  25459. backUVs?: Vector4;
  25460. }): VertexData;
  25461. /**
  25462. * Creates the VertexData of the Disc or regular Polygon
  25463. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25464. * * radius the radius of the disc, optional default 0.5
  25465. * * tessellation the number of polygon sides, optional, default 64
  25466. * * 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
  25467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25468. * * 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)
  25469. * * 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)
  25470. * @returns the VertexData of the box
  25471. */
  25472. static CreateDisc(options: {
  25473. radius?: number;
  25474. tessellation?: number;
  25475. arc?: number;
  25476. sideOrientation?: number;
  25477. frontUVs?: Vector4;
  25478. backUVs?: Vector4;
  25479. }): VertexData;
  25480. /**
  25481. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25482. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25483. * @param polygon a mesh built from polygonTriangulation.build()
  25484. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25485. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25486. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25487. * @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)
  25488. * @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)
  25489. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25490. * @returns the VertexData of the Polygon
  25491. */
  25492. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25493. /**
  25494. * Creates the VertexData of the IcoSphere
  25495. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25496. * * radius the radius of the IcoSphere, optional default 1
  25497. * * radiusX allows stretching in the x direction, optional, default radius
  25498. * * radiusY allows stretching in the y direction, optional, default radius
  25499. * * radiusZ allows stretching in the z direction, optional, default radius
  25500. * * flat when true creates a flat shaded mesh, optional, default true
  25501. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25503. * * 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)
  25504. * * 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)
  25505. * @returns the VertexData of the IcoSphere
  25506. */
  25507. static CreateIcoSphere(options: {
  25508. radius?: number;
  25509. radiusX?: number;
  25510. radiusY?: number;
  25511. radiusZ?: number;
  25512. flat?: boolean;
  25513. subdivisions?: number;
  25514. sideOrientation?: number;
  25515. frontUVs?: Vector4;
  25516. backUVs?: Vector4;
  25517. }): VertexData;
  25518. /**
  25519. * Creates the VertexData for a Polyhedron
  25520. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25521. * * type provided types are:
  25522. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25523. * * 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)
  25524. * * size the size of the IcoSphere, optional default 1
  25525. * * sizeX allows stretching in the x direction, optional, default size
  25526. * * sizeY allows stretching in the y direction, optional, default size
  25527. * * sizeZ allows stretching in the z direction, optional, default size
  25528. * * 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
  25529. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25530. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25531. * * flat when true creates a flat shaded mesh, optional, default true
  25532. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25534. * * 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)
  25535. * * 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)
  25536. * @returns the VertexData of the Polyhedron
  25537. */
  25538. static CreatePolyhedron(options: {
  25539. type?: number;
  25540. size?: number;
  25541. sizeX?: number;
  25542. sizeY?: number;
  25543. sizeZ?: number;
  25544. custom?: any;
  25545. faceUV?: Vector4[];
  25546. faceColors?: Color4[];
  25547. flat?: boolean;
  25548. sideOrientation?: number;
  25549. frontUVs?: Vector4;
  25550. backUVs?: Vector4;
  25551. }): VertexData;
  25552. /**
  25553. * Creates the VertexData for a TorusKnot
  25554. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25555. * * radius the radius of the torus knot, optional, default 2
  25556. * * tube the thickness of the tube, optional, default 0.5
  25557. * * radialSegments the number of sides on each tube segments, optional, default 32
  25558. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25559. * * p the number of windings around the z axis, optional, default 2
  25560. * * q the number of windings around the x axis, optional, default 3
  25561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25562. * * 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)
  25563. * * 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)
  25564. * @returns the VertexData of the Torus Knot
  25565. */
  25566. static CreateTorusKnot(options: {
  25567. radius?: number;
  25568. tube?: number;
  25569. radialSegments?: number;
  25570. tubularSegments?: number;
  25571. p?: number;
  25572. q?: number;
  25573. sideOrientation?: number;
  25574. frontUVs?: Vector4;
  25575. backUVs?: Vector4;
  25576. }): VertexData;
  25577. /**
  25578. * Compute normals for given positions and indices
  25579. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25580. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25581. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25582. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25583. * * facetNormals : optional array of facet normals (vector3)
  25584. * * facetPositions : optional array of facet positions (vector3)
  25585. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25586. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25587. * * bInfo : optional bounding info, required for facetPartitioning computation
  25588. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25589. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25590. * * useRightHandedSystem: optional boolean to for right handed system computation
  25591. * * depthSort : optional boolean to enable the facet depth sort computation
  25592. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25593. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25594. */
  25595. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25596. facetNormals?: any;
  25597. facetPositions?: any;
  25598. facetPartitioning?: any;
  25599. ratio?: number;
  25600. bInfo?: any;
  25601. bbSize?: Vector3;
  25602. subDiv?: any;
  25603. useRightHandedSystem?: boolean;
  25604. depthSort?: boolean;
  25605. distanceTo?: Vector3;
  25606. depthSortedFacets?: any;
  25607. }): void;
  25608. /** @hidden */
  25609. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25610. /**
  25611. * Applies VertexData created from the imported parameters to the geometry
  25612. * @param parsedVertexData the parsed data from an imported file
  25613. * @param geometry the geometry to apply the VertexData to
  25614. */
  25615. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25616. }
  25617. }
  25618. declare module BABYLON {
  25619. /**
  25620. * Defines a target to use with MorphTargetManager
  25621. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25622. */
  25623. export class MorphTarget implements IAnimatable {
  25624. /** defines the name of the target */
  25625. name: string;
  25626. /**
  25627. * Gets or sets the list of animations
  25628. */
  25629. animations: Animation[];
  25630. private _scene;
  25631. private _positions;
  25632. private _normals;
  25633. private _tangents;
  25634. private _uvs;
  25635. private _influence;
  25636. private _uniqueId;
  25637. /**
  25638. * Observable raised when the influence changes
  25639. */
  25640. onInfluenceChanged: Observable<boolean>;
  25641. /** @hidden */
  25642. _onDataLayoutChanged: Observable<void>;
  25643. /**
  25644. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25645. */
  25646. get influence(): number;
  25647. set influence(influence: number);
  25648. /**
  25649. * Gets or sets the id of the morph Target
  25650. */
  25651. id: string;
  25652. private _animationPropertiesOverride;
  25653. /**
  25654. * Gets or sets the animation properties override
  25655. */
  25656. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25657. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25658. /**
  25659. * Creates a new MorphTarget
  25660. * @param name defines the name of the target
  25661. * @param influence defines the influence to use
  25662. * @param scene defines the scene the morphtarget belongs to
  25663. */
  25664. constructor(
  25665. /** defines the name of the target */
  25666. name: string, influence?: number, scene?: Nullable<Scene>);
  25667. /**
  25668. * Gets the unique ID of this manager
  25669. */
  25670. get uniqueId(): number;
  25671. /**
  25672. * Gets a boolean defining if the target contains position data
  25673. */
  25674. get hasPositions(): boolean;
  25675. /**
  25676. * Gets a boolean defining if the target contains normal data
  25677. */
  25678. get hasNormals(): boolean;
  25679. /**
  25680. * Gets a boolean defining if the target contains tangent data
  25681. */
  25682. get hasTangents(): boolean;
  25683. /**
  25684. * Gets a boolean defining if the target contains texture coordinates data
  25685. */
  25686. get hasUVs(): boolean;
  25687. /**
  25688. * Affects position data to this target
  25689. * @param data defines the position data to use
  25690. */
  25691. setPositions(data: Nullable<FloatArray>): void;
  25692. /**
  25693. * Gets the position data stored in this target
  25694. * @returns a FloatArray containing the position data (or null if not present)
  25695. */
  25696. getPositions(): Nullable<FloatArray>;
  25697. /**
  25698. * Affects normal data to this target
  25699. * @param data defines the normal data to use
  25700. */
  25701. setNormals(data: Nullable<FloatArray>): void;
  25702. /**
  25703. * Gets the normal data stored in this target
  25704. * @returns a FloatArray containing the normal data (or null if not present)
  25705. */
  25706. getNormals(): Nullable<FloatArray>;
  25707. /**
  25708. * Affects tangent data to this target
  25709. * @param data defines the tangent data to use
  25710. */
  25711. setTangents(data: Nullable<FloatArray>): void;
  25712. /**
  25713. * Gets the tangent data stored in this target
  25714. * @returns a FloatArray containing the tangent data (or null if not present)
  25715. */
  25716. getTangents(): Nullable<FloatArray>;
  25717. /**
  25718. * Affects texture coordinates data to this target
  25719. * @param data defines the texture coordinates data to use
  25720. */
  25721. setUVs(data: Nullable<FloatArray>): void;
  25722. /**
  25723. * Gets the texture coordinates data stored in this target
  25724. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25725. */
  25726. getUVs(): Nullable<FloatArray>;
  25727. /**
  25728. * Clone the current target
  25729. * @returns a new MorphTarget
  25730. */
  25731. clone(): MorphTarget;
  25732. /**
  25733. * Serializes the current target into a Serialization object
  25734. * @returns the serialized object
  25735. */
  25736. serialize(): any;
  25737. /**
  25738. * Returns the string "MorphTarget"
  25739. * @returns "MorphTarget"
  25740. */
  25741. getClassName(): string;
  25742. /**
  25743. * Creates a new target from serialized data
  25744. * @param serializationObject defines the serialized data to use
  25745. * @returns a new MorphTarget
  25746. */
  25747. static Parse(serializationObject: any): MorphTarget;
  25748. /**
  25749. * Creates a MorphTarget from mesh data
  25750. * @param mesh defines the source mesh
  25751. * @param name defines the name to use for the new target
  25752. * @param influence defines the influence to attach to the target
  25753. * @returns a new MorphTarget
  25754. */
  25755. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25756. }
  25757. }
  25758. declare module BABYLON {
  25759. /**
  25760. * This class is used to deform meshes using morphing between different targets
  25761. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25762. */
  25763. export class MorphTargetManager {
  25764. private _targets;
  25765. private _targetInfluenceChangedObservers;
  25766. private _targetDataLayoutChangedObservers;
  25767. private _activeTargets;
  25768. private _scene;
  25769. private _influences;
  25770. private _supportsNormals;
  25771. private _supportsTangents;
  25772. private _supportsUVs;
  25773. private _vertexCount;
  25774. private _uniqueId;
  25775. private _tempInfluences;
  25776. /**
  25777. * Gets or sets a boolean indicating if normals must be morphed
  25778. */
  25779. enableNormalMorphing: boolean;
  25780. /**
  25781. * Gets or sets a boolean indicating if tangents must be morphed
  25782. */
  25783. enableTangentMorphing: boolean;
  25784. /**
  25785. * Gets or sets a boolean indicating if UV must be morphed
  25786. */
  25787. enableUVMorphing: boolean;
  25788. /**
  25789. * Creates a new MorphTargetManager
  25790. * @param scene defines the current scene
  25791. */
  25792. constructor(scene?: Nullable<Scene>);
  25793. /**
  25794. * Gets the unique ID of this manager
  25795. */
  25796. get uniqueId(): number;
  25797. /**
  25798. * Gets the number of vertices handled by this manager
  25799. */
  25800. get vertexCount(): number;
  25801. /**
  25802. * Gets a boolean indicating if this manager supports morphing of normals
  25803. */
  25804. get supportsNormals(): boolean;
  25805. /**
  25806. * Gets a boolean indicating if this manager supports morphing of tangents
  25807. */
  25808. get supportsTangents(): boolean;
  25809. /**
  25810. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25811. */
  25812. get supportsUVs(): boolean;
  25813. /**
  25814. * Gets the number of targets stored in this manager
  25815. */
  25816. get numTargets(): number;
  25817. /**
  25818. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25819. */
  25820. get numInfluencers(): number;
  25821. /**
  25822. * Gets the list of influences (one per target)
  25823. */
  25824. get influences(): Float32Array;
  25825. /**
  25826. * Gets the active target at specified index. An active target is a target with an influence > 0
  25827. * @param index defines the index to check
  25828. * @returns the requested target
  25829. */
  25830. getActiveTarget(index: number): MorphTarget;
  25831. /**
  25832. * Gets the target at specified index
  25833. * @param index defines the index to check
  25834. * @returns the requested target
  25835. */
  25836. getTarget(index: number): MorphTarget;
  25837. /**
  25838. * Add a new target to this manager
  25839. * @param target defines the target to add
  25840. */
  25841. addTarget(target: MorphTarget): void;
  25842. /**
  25843. * Removes a target from the manager
  25844. * @param target defines the target to remove
  25845. */
  25846. removeTarget(target: MorphTarget): void;
  25847. /**
  25848. * Clone the current manager
  25849. * @returns a new MorphTargetManager
  25850. */
  25851. clone(): MorphTargetManager;
  25852. /**
  25853. * Serializes the current manager into a Serialization object
  25854. * @returns the serialized object
  25855. */
  25856. serialize(): any;
  25857. private _syncActiveTargets;
  25858. /**
  25859. * Syncrhonize the targets with all the meshes using this morph target manager
  25860. */
  25861. synchronize(): void;
  25862. /**
  25863. * Creates a new MorphTargetManager from serialized data
  25864. * @param serializationObject defines the serialized data
  25865. * @param scene defines the hosting scene
  25866. * @returns the new MorphTargetManager
  25867. */
  25868. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25869. }
  25870. }
  25871. declare module BABYLON {
  25872. /**
  25873. * Class used to represent a specific level of detail of a mesh
  25874. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25875. */
  25876. export class MeshLODLevel {
  25877. /** Defines the distance where this level should start being displayed */
  25878. distance: number;
  25879. /** Defines the mesh to use to render this level */
  25880. mesh: Nullable<Mesh>;
  25881. /**
  25882. * Creates a new LOD level
  25883. * @param distance defines the distance where this level should star being displayed
  25884. * @param mesh defines the mesh to use to render this level
  25885. */
  25886. constructor(
  25887. /** Defines the distance where this level should start being displayed */
  25888. distance: number,
  25889. /** Defines the mesh to use to render this level */
  25890. mesh: Nullable<Mesh>);
  25891. }
  25892. }
  25893. declare module BABYLON {
  25894. /**
  25895. * Mesh representing the gorund
  25896. */
  25897. export class GroundMesh extends Mesh {
  25898. /** If octree should be generated */
  25899. generateOctree: boolean;
  25900. private _heightQuads;
  25901. /** @hidden */
  25902. _subdivisionsX: number;
  25903. /** @hidden */
  25904. _subdivisionsY: number;
  25905. /** @hidden */
  25906. _width: number;
  25907. /** @hidden */
  25908. _height: number;
  25909. /** @hidden */
  25910. _minX: number;
  25911. /** @hidden */
  25912. _maxX: number;
  25913. /** @hidden */
  25914. _minZ: number;
  25915. /** @hidden */
  25916. _maxZ: number;
  25917. constructor(name: string, scene: Scene);
  25918. /**
  25919. * "GroundMesh"
  25920. * @returns "GroundMesh"
  25921. */
  25922. getClassName(): string;
  25923. /**
  25924. * The minimum of x and y subdivisions
  25925. */
  25926. get subdivisions(): number;
  25927. /**
  25928. * X subdivisions
  25929. */
  25930. get subdivisionsX(): number;
  25931. /**
  25932. * Y subdivisions
  25933. */
  25934. get subdivisionsY(): number;
  25935. /**
  25936. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25937. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25938. * @param chunksCount the number of subdivisions for x and y
  25939. * @param octreeBlocksSize (Default: 32)
  25940. */
  25941. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25942. /**
  25943. * Returns a height (y) value in the Worl system :
  25944. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25945. * @param x x coordinate
  25946. * @param z z coordinate
  25947. * @returns the ground y position if (x, z) are outside the ground surface.
  25948. */
  25949. getHeightAtCoordinates(x: number, z: number): number;
  25950. /**
  25951. * Returns a normalized vector (Vector3) orthogonal to the ground
  25952. * at the ground coordinates (x, z) expressed in the World system.
  25953. * @param x x coordinate
  25954. * @param z z coordinate
  25955. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25956. */
  25957. getNormalAtCoordinates(x: number, z: number): Vector3;
  25958. /**
  25959. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25960. * at the ground coordinates (x, z) expressed in the World system.
  25961. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25962. * @param x x coordinate
  25963. * @param z z coordinate
  25964. * @param ref vector to store the result
  25965. * @returns the GroundMesh.
  25966. */
  25967. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25968. /**
  25969. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25970. * if the ground has been updated.
  25971. * This can be used in the render loop.
  25972. * @returns the GroundMesh.
  25973. */
  25974. updateCoordinateHeights(): GroundMesh;
  25975. private _getFacetAt;
  25976. private _initHeightQuads;
  25977. private _computeHeightQuads;
  25978. /**
  25979. * Serializes this ground mesh
  25980. * @param serializationObject object to write serialization to
  25981. */
  25982. serialize(serializationObject: any): void;
  25983. /**
  25984. * Parses a serialized ground mesh
  25985. * @param parsedMesh the serialized mesh
  25986. * @param scene the scene to create the ground mesh in
  25987. * @returns the created ground mesh
  25988. */
  25989. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25990. }
  25991. }
  25992. declare module BABYLON {
  25993. /**
  25994. * Interface for Physics-Joint data
  25995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25996. */
  25997. export interface PhysicsJointData {
  25998. /**
  25999. * The main pivot of the joint
  26000. */
  26001. mainPivot?: Vector3;
  26002. /**
  26003. * The connected pivot of the joint
  26004. */
  26005. connectedPivot?: Vector3;
  26006. /**
  26007. * The main axis of the joint
  26008. */
  26009. mainAxis?: Vector3;
  26010. /**
  26011. * The connected axis of the joint
  26012. */
  26013. connectedAxis?: Vector3;
  26014. /**
  26015. * The collision of the joint
  26016. */
  26017. collision?: boolean;
  26018. /**
  26019. * Native Oimo/Cannon/Energy data
  26020. */
  26021. nativeParams?: any;
  26022. }
  26023. /**
  26024. * This is a holder class for the physics joint created by the physics plugin
  26025. * It holds a set of functions to control the underlying joint
  26026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26027. */
  26028. export class PhysicsJoint {
  26029. /**
  26030. * The type of the physics joint
  26031. */
  26032. type: number;
  26033. /**
  26034. * The data for the physics joint
  26035. */
  26036. jointData: PhysicsJointData;
  26037. private _physicsJoint;
  26038. protected _physicsPlugin: IPhysicsEnginePlugin;
  26039. /**
  26040. * Initializes the physics joint
  26041. * @param type The type of the physics joint
  26042. * @param jointData The data for the physics joint
  26043. */
  26044. constructor(
  26045. /**
  26046. * The type of the physics joint
  26047. */
  26048. type: number,
  26049. /**
  26050. * The data for the physics joint
  26051. */
  26052. jointData: PhysicsJointData);
  26053. /**
  26054. * Gets the physics joint
  26055. */
  26056. get physicsJoint(): any;
  26057. /**
  26058. * Sets the physics joint
  26059. */
  26060. set physicsJoint(newJoint: any);
  26061. /**
  26062. * Sets the physics plugin
  26063. */
  26064. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26065. /**
  26066. * Execute a function that is physics-plugin specific.
  26067. * @param {Function} func the function that will be executed.
  26068. * It accepts two parameters: the physics world and the physics joint
  26069. */
  26070. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26071. /**
  26072. * Distance-Joint type
  26073. */
  26074. static DistanceJoint: number;
  26075. /**
  26076. * Hinge-Joint type
  26077. */
  26078. static HingeJoint: number;
  26079. /**
  26080. * Ball-and-Socket joint type
  26081. */
  26082. static BallAndSocketJoint: number;
  26083. /**
  26084. * Wheel-Joint type
  26085. */
  26086. static WheelJoint: number;
  26087. /**
  26088. * Slider-Joint type
  26089. */
  26090. static SliderJoint: number;
  26091. /**
  26092. * Prismatic-Joint type
  26093. */
  26094. static PrismaticJoint: number;
  26095. /**
  26096. * Universal-Joint type
  26097. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26098. */
  26099. static UniversalJoint: number;
  26100. /**
  26101. * Hinge-Joint 2 type
  26102. */
  26103. static Hinge2Joint: number;
  26104. /**
  26105. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26106. */
  26107. static PointToPointJoint: number;
  26108. /**
  26109. * Spring-Joint type
  26110. */
  26111. static SpringJoint: number;
  26112. /**
  26113. * Lock-Joint type
  26114. */
  26115. static LockJoint: number;
  26116. }
  26117. /**
  26118. * A class representing a physics distance joint
  26119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26120. */
  26121. export class DistanceJoint extends PhysicsJoint {
  26122. /**
  26123. *
  26124. * @param jointData The data for the Distance-Joint
  26125. */
  26126. constructor(jointData: DistanceJointData);
  26127. /**
  26128. * Update the predefined distance.
  26129. * @param maxDistance The maximum preferred distance
  26130. * @param minDistance The minimum preferred distance
  26131. */
  26132. updateDistance(maxDistance: number, minDistance?: number): void;
  26133. }
  26134. /**
  26135. * Represents a Motor-Enabled Joint
  26136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26137. */
  26138. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26139. /**
  26140. * Initializes the Motor-Enabled Joint
  26141. * @param type The type of the joint
  26142. * @param jointData The physica joint data for the joint
  26143. */
  26144. constructor(type: number, jointData: PhysicsJointData);
  26145. /**
  26146. * Set the motor values.
  26147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26148. * @param force the force to apply
  26149. * @param maxForce max force for this motor.
  26150. */
  26151. setMotor(force?: number, maxForce?: number): void;
  26152. /**
  26153. * Set the motor's limits.
  26154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26155. * @param upperLimit The upper limit of the motor
  26156. * @param lowerLimit The lower limit of the motor
  26157. */
  26158. setLimit(upperLimit: number, lowerLimit?: number): void;
  26159. }
  26160. /**
  26161. * This class represents a single physics Hinge-Joint
  26162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26163. */
  26164. export class HingeJoint extends MotorEnabledJoint {
  26165. /**
  26166. * Initializes the Hinge-Joint
  26167. * @param jointData The joint data for the Hinge-Joint
  26168. */
  26169. constructor(jointData: PhysicsJointData);
  26170. /**
  26171. * Set the motor values.
  26172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26173. * @param {number} force the force to apply
  26174. * @param {number} maxForce max force for this motor.
  26175. */
  26176. setMotor(force?: number, maxForce?: number): void;
  26177. /**
  26178. * Set the motor's limits.
  26179. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26180. * @param upperLimit The upper limit of the motor
  26181. * @param lowerLimit The lower limit of the motor
  26182. */
  26183. setLimit(upperLimit: number, lowerLimit?: number): void;
  26184. }
  26185. /**
  26186. * This class represents a dual hinge physics joint (same as wheel joint)
  26187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26188. */
  26189. export class Hinge2Joint extends MotorEnabledJoint {
  26190. /**
  26191. * Initializes the Hinge2-Joint
  26192. * @param jointData The joint data for the Hinge2-Joint
  26193. */
  26194. constructor(jointData: PhysicsJointData);
  26195. /**
  26196. * Set the motor values.
  26197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26198. * @param {number} targetSpeed the speed the motor is to reach
  26199. * @param {number} maxForce max force for this motor.
  26200. * @param {motorIndex} the motor's index, 0 or 1.
  26201. */
  26202. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26203. /**
  26204. * Set the motor limits.
  26205. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26206. * @param {number} upperLimit the upper limit
  26207. * @param {number} lowerLimit lower limit
  26208. * @param {motorIndex} the motor's index, 0 or 1.
  26209. */
  26210. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26211. }
  26212. /**
  26213. * Interface for a motor enabled joint
  26214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26215. */
  26216. export interface IMotorEnabledJoint {
  26217. /**
  26218. * Physics joint
  26219. */
  26220. physicsJoint: any;
  26221. /**
  26222. * Sets the motor of the motor-enabled joint
  26223. * @param force The force of the motor
  26224. * @param maxForce The maximum force of the motor
  26225. * @param motorIndex The index of the motor
  26226. */
  26227. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26228. /**
  26229. * Sets the limit of the motor
  26230. * @param upperLimit The upper limit of the motor
  26231. * @param lowerLimit The lower limit of the motor
  26232. * @param motorIndex The index of the motor
  26233. */
  26234. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26235. }
  26236. /**
  26237. * Joint data for a Distance-Joint
  26238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26239. */
  26240. export interface DistanceJointData extends PhysicsJointData {
  26241. /**
  26242. * Max distance the 2 joint objects can be apart
  26243. */
  26244. maxDistance: number;
  26245. }
  26246. /**
  26247. * Joint data from a spring joint
  26248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26249. */
  26250. export interface SpringJointData extends PhysicsJointData {
  26251. /**
  26252. * Length of the spring
  26253. */
  26254. length: number;
  26255. /**
  26256. * Stiffness of the spring
  26257. */
  26258. stiffness: number;
  26259. /**
  26260. * Damping of the spring
  26261. */
  26262. damping: number;
  26263. /** this callback will be called when applying the force to the impostors. */
  26264. forceApplicationCallback: () => void;
  26265. }
  26266. }
  26267. declare module BABYLON {
  26268. /**
  26269. * Holds the data for the raycast result
  26270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26271. */
  26272. export class PhysicsRaycastResult {
  26273. private _hasHit;
  26274. private _hitDistance;
  26275. private _hitNormalWorld;
  26276. private _hitPointWorld;
  26277. private _rayFromWorld;
  26278. private _rayToWorld;
  26279. /**
  26280. * Gets if there was a hit
  26281. */
  26282. get hasHit(): boolean;
  26283. /**
  26284. * Gets the distance from the hit
  26285. */
  26286. get hitDistance(): number;
  26287. /**
  26288. * Gets the hit normal/direction in the world
  26289. */
  26290. get hitNormalWorld(): Vector3;
  26291. /**
  26292. * Gets the hit point in the world
  26293. */
  26294. get hitPointWorld(): Vector3;
  26295. /**
  26296. * Gets the ray "start point" of the ray in the world
  26297. */
  26298. get rayFromWorld(): Vector3;
  26299. /**
  26300. * Gets the ray "end point" of the ray in the world
  26301. */
  26302. get rayToWorld(): Vector3;
  26303. /**
  26304. * Sets the hit data (normal & point in world space)
  26305. * @param hitNormalWorld defines the normal in world space
  26306. * @param hitPointWorld defines the point in world space
  26307. */
  26308. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26309. /**
  26310. * Sets the distance from the start point to the hit point
  26311. * @param distance
  26312. */
  26313. setHitDistance(distance: number): void;
  26314. /**
  26315. * Calculates the distance manually
  26316. */
  26317. calculateHitDistance(): void;
  26318. /**
  26319. * Resets all the values to default
  26320. * @param from The from point on world space
  26321. * @param to The to point on world space
  26322. */
  26323. reset(from?: Vector3, to?: Vector3): void;
  26324. }
  26325. /**
  26326. * Interface for the size containing width and height
  26327. */
  26328. interface IXYZ {
  26329. /**
  26330. * X
  26331. */
  26332. x: number;
  26333. /**
  26334. * Y
  26335. */
  26336. y: number;
  26337. /**
  26338. * Z
  26339. */
  26340. z: number;
  26341. }
  26342. }
  26343. declare module BABYLON {
  26344. /**
  26345. * Interface used to describe a physics joint
  26346. */
  26347. export interface PhysicsImpostorJoint {
  26348. /** Defines the main impostor to which the joint is linked */
  26349. mainImpostor: PhysicsImpostor;
  26350. /** Defines the impostor that is connected to the main impostor using this joint */
  26351. connectedImpostor: PhysicsImpostor;
  26352. /** Defines the joint itself */
  26353. joint: PhysicsJoint;
  26354. }
  26355. /** @hidden */
  26356. export interface IPhysicsEnginePlugin {
  26357. world: any;
  26358. name: string;
  26359. setGravity(gravity: Vector3): void;
  26360. setTimeStep(timeStep: number): void;
  26361. getTimeStep(): number;
  26362. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26363. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26364. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26365. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26366. removePhysicsBody(impostor: PhysicsImpostor): void;
  26367. generateJoint(joint: PhysicsImpostorJoint): void;
  26368. removeJoint(joint: PhysicsImpostorJoint): void;
  26369. isSupported(): boolean;
  26370. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26371. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26372. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26373. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26374. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26375. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26376. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26377. getBodyMass(impostor: PhysicsImpostor): number;
  26378. getBodyFriction(impostor: PhysicsImpostor): number;
  26379. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26380. getBodyRestitution(impostor: PhysicsImpostor): number;
  26381. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26382. getBodyPressure?(impostor: PhysicsImpostor): number;
  26383. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26384. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26385. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26386. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26387. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26388. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26389. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26390. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26391. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26392. sleepBody(impostor: PhysicsImpostor): void;
  26393. wakeUpBody(impostor: PhysicsImpostor): void;
  26394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26395. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26396. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26397. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26398. getRadius(impostor: PhysicsImpostor): number;
  26399. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26400. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26401. dispose(): void;
  26402. }
  26403. /**
  26404. * Interface used to define a physics engine
  26405. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26406. */
  26407. export interface IPhysicsEngine {
  26408. /**
  26409. * Gets the gravity vector used by the simulation
  26410. */
  26411. gravity: Vector3;
  26412. /**
  26413. * Sets the gravity vector used by the simulation
  26414. * @param gravity defines the gravity vector to use
  26415. */
  26416. setGravity(gravity: Vector3): void;
  26417. /**
  26418. * Set the time step of the physics engine.
  26419. * Default is 1/60.
  26420. * To slow it down, enter 1/600 for example.
  26421. * To speed it up, 1/30
  26422. * @param newTimeStep the new timestep to apply to this world.
  26423. */
  26424. setTimeStep(newTimeStep: number): void;
  26425. /**
  26426. * Get the time step of the physics engine.
  26427. * @returns the current time step
  26428. */
  26429. getTimeStep(): number;
  26430. /**
  26431. * Set the sub time step of the physics engine.
  26432. * Default is 0 meaning there is no sub steps
  26433. * To increase physics resolution precision, set a small value (like 1 ms)
  26434. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26435. */
  26436. setSubTimeStep(subTimeStep: number): void;
  26437. /**
  26438. * Get the sub time step of the physics engine.
  26439. * @returns the current sub time step
  26440. */
  26441. getSubTimeStep(): number;
  26442. /**
  26443. * Release all resources
  26444. */
  26445. dispose(): void;
  26446. /**
  26447. * Gets the name of the current physics plugin
  26448. * @returns the name of the plugin
  26449. */
  26450. getPhysicsPluginName(): string;
  26451. /**
  26452. * Adding a new impostor for the impostor tracking.
  26453. * This will be done by the impostor itself.
  26454. * @param impostor the impostor to add
  26455. */
  26456. addImpostor(impostor: PhysicsImpostor): void;
  26457. /**
  26458. * Remove an impostor from the engine.
  26459. * This impostor and its mesh will not longer be updated by the physics engine.
  26460. * @param impostor the impostor to remove
  26461. */
  26462. removeImpostor(impostor: PhysicsImpostor): void;
  26463. /**
  26464. * Add a joint to the physics engine
  26465. * @param mainImpostor defines the main impostor to which the joint is added.
  26466. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26467. * @param joint defines the joint that will connect both impostors.
  26468. */
  26469. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26470. /**
  26471. * Removes a joint from the simulation
  26472. * @param mainImpostor defines the impostor used with the joint
  26473. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26474. * @param joint defines the joint to remove
  26475. */
  26476. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26477. /**
  26478. * Gets the current plugin used to run the simulation
  26479. * @returns current plugin
  26480. */
  26481. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26482. /**
  26483. * Gets the list of physic impostors
  26484. * @returns an array of PhysicsImpostor
  26485. */
  26486. getImpostors(): Array<PhysicsImpostor>;
  26487. /**
  26488. * Gets the impostor for a physics enabled object
  26489. * @param object defines the object impersonated by the impostor
  26490. * @returns the PhysicsImpostor or null if not found
  26491. */
  26492. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26493. /**
  26494. * Gets the impostor for a physics body object
  26495. * @param body defines physics body used by the impostor
  26496. * @returns the PhysicsImpostor or null if not found
  26497. */
  26498. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26499. /**
  26500. * Does a raycast in the physics world
  26501. * @param from when should the ray start?
  26502. * @param to when should the ray end?
  26503. * @returns PhysicsRaycastResult
  26504. */
  26505. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26506. /**
  26507. * Called by the scene. No need to call it.
  26508. * @param delta defines the timespam between frames
  26509. */
  26510. _step(delta: number): void;
  26511. }
  26512. }
  26513. declare module BABYLON {
  26514. /**
  26515. * The interface for the physics imposter parameters
  26516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26517. */
  26518. export interface PhysicsImpostorParameters {
  26519. /**
  26520. * The mass of the physics imposter
  26521. */
  26522. mass: number;
  26523. /**
  26524. * The friction of the physics imposter
  26525. */
  26526. friction?: number;
  26527. /**
  26528. * The coefficient of restitution of the physics imposter
  26529. */
  26530. restitution?: number;
  26531. /**
  26532. * The native options of the physics imposter
  26533. */
  26534. nativeOptions?: any;
  26535. /**
  26536. * Specifies if the parent should be ignored
  26537. */
  26538. ignoreParent?: boolean;
  26539. /**
  26540. * Specifies if bi-directional transformations should be disabled
  26541. */
  26542. disableBidirectionalTransformation?: boolean;
  26543. /**
  26544. * The pressure inside the physics imposter, soft object only
  26545. */
  26546. pressure?: number;
  26547. /**
  26548. * The stiffness the physics imposter, soft object only
  26549. */
  26550. stiffness?: number;
  26551. /**
  26552. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26553. */
  26554. velocityIterations?: number;
  26555. /**
  26556. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26557. */
  26558. positionIterations?: number;
  26559. /**
  26560. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26561. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26562. * Add to fix multiple points
  26563. */
  26564. fixedPoints?: number;
  26565. /**
  26566. * The collision margin around a soft object
  26567. */
  26568. margin?: number;
  26569. /**
  26570. * The collision margin around a soft object
  26571. */
  26572. damping?: number;
  26573. /**
  26574. * The path for a rope based on an extrusion
  26575. */
  26576. path?: any;
  26577. /**
  26578. * The shape of an extrusion used for a rope based on an extrusion
  26579. */
  26580. shape?: any;
  26581. }
  26582. /**
  26583. * Interface for a physics-enabled object
  26584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26585. */
  26586. export interface IPhysicsEnabledObject {
  26587. /**
  26588. * The position of the physics-enabled object
  26589. */
  26590. position: Vector3;
  26591. /**
  26592. * The rotation of the physics-enabled object
  26593. */
  26594. rotationQuaternion: Nullable<Quaternion>;
  26595. /**
  26596. * The scale of the physics-enabled object
  26597. */
  26598. scaling: Vector3;
  26599. /**
  26600. * The rotation of the physics-enabled object
  26601. */
  26602. rotation?: Vector3;
  26603. /**
  26604. * The parent of the physics-enabled object
  26605. */
  26606. parent?: any;
  26607. /**
  26608. * The bounding info of the physics-enabled object
  26609. * @returns The bounding info of the physics-enabled object
  26610. */
  26611. getBoundingInfo(): BoundingInfo;
  26612. /**
  26613. * Computes the world matrix
  26614. * @param force Specifies if the world matrix should be computed by force
  26615. * @returns A world matrix
  26616. */
  26617. computeWorldMatrix(force: boolean): Matrix;
  26618. /**
  26619. * Gets the world matrix
  26620. * @returns A world matrix
  26621. */
  26622. getWorldMatrix?(): Matrix;
  26623. /**
  26624. * Gets the child meshes
  26625. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26626. * @returns An array of abstract meshes
  26627. */
  26628. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26629. /**
  26630. * Gets the vertex data
  26631. * @param kind The type of vertex data
  26632. * @returns A nullable array of numbers, or a float32 array
  26633. */
  26634. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26635. /**
  26636. * Gets the indices from the mesh
  26637. * @returns A nullable array of index arrays
  26638. */
  26639. getIndices?(): Nullable<IndicesArray>;
  26640. /**
  26641. * Gets the scene from the mesh
  26642. * @returns the indices array or null
  26643. */
  26644. getScene?(): Scene;
  26645. /**
  26646. * Gets the absolute position from the mesh
  26647. * @returns the absolute position
  26648. */
  26649. getAbsolutePosition(): Vector3;
  26650. /**
  26651. * Gets the absolute pivot point from the mesh
  26652. * @returns the absolute pivot point
  26653. */
  26654. getAbsolutePivotPoint(): Vector3;
  26655. /**
  26656. * Rotates the mesh
  26657. * @param axis The axis of rotation
  26658. * @param amount The amount of rotation
  26659. * @param space The space of the rotation
  26660. * @returns The rotation transform node
  26661. */
  26662. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26663. /**
  26664. * Translates the mesh
  26665. * @param axis The axis of translation
  26666. * @param distance The distance of translation
  26667. * @param space The space of the translation
  26668. * @returns The transform node
  26669. */
  26670. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26671. /**
  26672. * Sets the absolute position of the mesh
  26673. * @param absolutePosition The absolute position of the mesh
  26674. * @returns The transform node
  26675. */
  26676. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26677. /**
  26678. * Gets the class name of the mesh
  26679. * @returns The class name
  26680. */
  26681. getClassName(): string;
  26682. }
  26683. /**
  26684. * Represents a physics imposter
  26685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26686. */
  26687. export class PhysicsImpostor {
  26688. /**
  26689. * The physics-enabled object used as the physics imposter
  26690. */
  26691. object: IPhysicsEnabledObject;
  26692. /**
  26693. * The type of the physics imposter
  26694. */
  26695. type: number;
  26696. private _options;
  26697. private _scene?;
  26698. /**
  26699. * The default object size of the imposter
  26700. */
  26701. static DEFAULT_OBJECT_SIZE: Vector3;
  26702. /**
  26703. * The identity quaternion of the imposter
  26704. */
  26705. static IDENTITY_QUATERNION: Quaternion;
  26706. /** @hidden */
  26707. _pluginData: any;
  26708. private _physicsEngine;
  26709. private _physicsBody;
  26710. private _bodyUpdateRequired;
  26711. private _onBeforePhysicsStepCallbacks;
  26712. private _onAfterPhysicsStepCallbacks;
  26713. /** @hidden */
  26714. _onPhysicsCollideCallbacks: Array<{
  26715. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26716. otherImpostors: Array<PhysicsImpostor>;
  26717. }>;
  26718. private _deltaPosition;
  26719. private _deltaRotation;
  26720. private _deltaRotationConjugated;
  26721. /** @hidden */
  26722. _isFromLine: boolean;
  26723. private _parent;
  26724. private _isDisposed;
  26725. private static _tmpVecs;
  26726. private static _tmpQuat;
  26727. /**
  26728. * Specifies if the physics imposter is disposed
  26729. */
  26730. get isDisposed(): boolean;
  26731. /**
  26732. * Gets the mass of the physics imposter
  26733. */
  26734. get mass(): number;
  26735. set mass(value: number);
  26736. /**
  26737. * Gets the coefficient of friction
  26738. */
  26739. get friction(): number;
  26740. /**
  26741. * Sets the coefficient of friction
  26742. */
  26743. set friction(value: number);
  26744. /**
  26745. * Gets the coefficient of restitution
  26746. */
  26747. get restitution(): number;
  26748. /**
  26749. * Sets the coefficient of restitution
  26750. */
  26751. set restitution(value: number);
  26752. /**
  26753. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26754. */
  26755. get pressure(): number;
  26756. /**
  26757. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26758. */
  26759. set pressure(value: number);
  26760. /**
  26761. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26762. */
  26763. get stiffness(): number;
  26764. /**
  26765. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26766. */
  26767. set stiffness(value: number);
  26768. /**
  26769. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26770. */
  26771. get velocityIterations(): number;
  26772. /**
  26773. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26774. */
  26775. set velocityIterations(value: number);
  26776. /**
  26777. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26778. */
  26779. get positionIterations(): number;
  26780. /**
  26781. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26782. */
  26783. set positionIterations(value: number);
  26784. /**
  26785. * The unique id of the physics imposter
  26786. * set by the physics engine when adding this impostor to the array
  26787. */
  26788. uniqueId: number;
  26789. /**
  26790. * @hidden
  26791. */
  26792. soft: boolean;
  26793. /**
  26794. * @hidden
  26795. */
  26796. segments: number;
  26797. private _joints;
  26798. /**
  26799. * Initializes the physics imposter
  26800. * @param object The physics-enabled object used as the physics imposter
  26801. * @param type The type of the physics imposter
  26802. * @param _options The options for the physics imposter
  26803. * @param _scene The Babylon scene
  26804. */
  26805. constructor(
  26806. /**
  26807. * The physics-enabled object used as the physics imposter
  26808. */
  26809. object: IPhysicsEnabledObject,
  26810. /**
  26811. * The type of the physics imposter
  26812. */
  26813. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26814. /**
  26815. * This function will completly initialize this impostor.
  26816. * It will create a new body - but only if this mesh has no parent.
  26817. * If it has, this impostor will not be used other than to define the impostor
  26818. * of the child mesh.
  26819. * @hidden
  26820. */
  26821. _init(): void;
  26822. private _getPhysicsParent;
  26823. /**
  26824. * Should a new body be generated.
  26825. * @returns boolean specifying if body initialization is required
  26826. */
  26827. isBodyInitRequired(): boolean;
  26828. /**
  26829. * Sets the updated scaling
  26830. * @param updated Specifies if the scaling is updated
  26831. */
  26832. setScalingUpdated(): void;
  26833. /**
  26834. * Force a regeneration of this or the parent's impostor's body.
  26835. * Use under cautious - This will remove all joints already implemented.
  26836. */
  26837. forceUpdate(): void;
  26838. /**
  26839. * Gets the body that holds this impostor. Either its own, or its parent.
  26840. */
  26841. get physicsBody(): any;
  26842. /**
  26843. * Get the parent of the physics imposter
  26844. * @returns Physics imposter or null
  26845. */
  26846. get parent(): Nullable<PhysicsImpostor>;
  26847. /**
  26848. * Sets the parent of the physics imposter
  26849. */
  26850. set parent(value: Nullable<PhysicsImpostor>);
  26851. /**
  26852. * Set the physics body. Used mainly by the physics engine/plugin
  26853. */
  26854. set physicsBody(physicsBody: any);
  26855. /**
  26856. * Resets the update flags
  26857. */
  26858. resetUpdateFlags(): void;
  26859. /**
  26860. * Gets the object extend size
  26861. * @returns the object extend size
  26862. */
  26863. getObjectExtendSize(): Vector3;
  26864. /**
  26865. * Gets the object center
  26866. * @returns The object center
  26867. */
  26868. getObjectCenter(): Vector3;
  26869. /**
  26870. * Get a specific parameter from the options parameters
  26871. * @param paramName The object parameter name
  26872. * @returns The object parameter
  26873. */
  26874. getParam(paramName: string): any;
  26875. /**
  26876. * Sets a specific parameter in the options given to the physics plugin
  26877. * @param paramName The parameter name
  26878. * @param value The value of the parameter
  26879. */
  26880. setParam(paramName: string, value: number): void;
  26881. /**
  26882. * Specifically change the body's mass option. Won't recreate the physics body object
  26883. * @param mass The mass of the physics imposter
  26884. */
  26885. setMass(mass: number): void;
  26886. /**
  26887. * Gets the linear velocity
  26888. * @returns linear velocity or null
  26889. */
  26890. getLinearVelocity(): Nullable<Vector3>;
  26891. /**
  26892. * Sets the linear velocity
  26893. * @param velocity linear velocity or null
  26894. */
  26895. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26896. /**
  26897. * Gets the angular velocity
  26898. * @returns angular velocity or null
  26899. */
  26900. getAngularVelocity(): Nullable<Vector3>;
  26901. /**
  26902. * Sets the angular velocity
  26903. * @param velocity The velocity or null
  26904. */
  26905. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26906. /**
  26907. * Execute a function with the physics plugin native code
  26908. * Provide a function the will have two variables - the world object and the physics body object
  26909. * @param func The function to execute with the physics plugin native code
  26910. */
  26911. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26912. /**
  26913. * Register a function that will be executed before the physics world is stepping forward
  26914. * @param func The function to execute before the physics world is stepped forward
  26915. */
  26916. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26917. /**
  26918. * Unregister a function that will be executed before the physics world is stepping forward
  26919. * @param func The function to execute before the physics world is stepped forward
  26920. */
  26921. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26922. /**
  26923. * Register a function that will be executed after the physics step
  26924. * @param func The function to execute after physics step
  26925. */
  26926. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26927. /**
  26928. * Unregisters a function that will be executed after the physics step
  26929. * @param func The function to execute after physics step
  26930. */
  26931. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26932. /**
  26933. * register a function that will be executed when this impostor collides against a different body
  26934. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26935. * @param func Callback that is executed on collision
  26936. */
  26937. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26938. /**
  26939. * Unregisters the physics imposter on contact
  26940. * @param collideAgainst The physics object to collide against
  26941. * @param func Callback to execute on collision
  26942. */
  26943. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26944. private _tmpQuat;
  26945. private _tmpQuat2;
  26946. /**
  26947. * Get the parent rotation
  26948. * @returns The parent rotation
  26949. */
  26950. getParentsRotation(): Quaternion;
  26951. /**
  26952. * this function is executed by the physics engine.
  26953. */
  26954. beforeStep: () => void;
  26955. /**
  26956. * this function is executed by the physics engine
  26957. */
  26958. afterStep: () => void;
  26959. /**
  26960. * Legacy collision detection event support
  26961. */
  26962. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26963. /**
  26964. * event and body object due to cannon's event-based architecture.
  26965. */
  26966. onCollide: (e: {
  26967. body: any;
  26968. }) => void;
  26969. /**
  26970. * Apply a force
  26971. * @param force The force to apply
  26972. * @param contactPoint The contact point for the force
  26973. * @returns The physics imposter
  26974. */
  26975. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26976. /**
  26977. * Apply an impulse
  26978. * @param force The impulse force
  26979. * @param contactPoint The contact point for the impulse force
  26980. * @returns The physics imposter
  26981. */
  26982. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26983. /**
  26984. * A help function to create a joint
  26985. * @param otherImpostor A physics imposter used to create a joint
  26986. * @param jointType The type of joint
  26987. * @param jointData The data for the joint
  26988. * @returns The physics imposter
  26989. */
  26990. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26991. /**
  26992. * Add a joint to this impostor with a different impostor
  26993. * @param otherImpostor A physics imposter used to add a joint
  26994. * @param joint The joint to add
  26995. * @returns The physics imposter
  26996. */
  26997. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26998. /**
  26999. * Add an anchor to a cloth impostor
  27000. * @param otherImpostor rigid impostor to anchor to
  27001. * @param width ratio across width from 0 to 1
  27002. * @param height ratio up height from 0 to 1
  27003. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27004. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27005. * @returns impostor the soft imposter
  27006. */
  27007. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27008. /**
  27009. * Add a hook to a rope impostor
  27010. * @param otherImpostor rigid impostor to anchor to
  27011. * @param length ratio across rope from 0 to 1
  27012. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27013. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27014. * @returns impostor the rope imposter
  27015. */
  27016. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27017. /**
  27018. * Will keep this body still, in a sleep mode.
  27019. * @returns the physics imposter
  27020. */
  27021. sleep(): PhysicsImpostor;
  27022. /**
  27023. * Wake the body up.
  27024. * @returns The physics imposter
  27025. */
  27026. wakeUp(): PhysicsImpostor;
  27027. /**
  27028. * Clones the physics imposter
  27029. * @param newObject The physics imposter clones to this physics-enabled object
  27030. * @returns A nullable physics imposter
  27031. */
  27032. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27033. /**
  27034. * Disposes the physics imposter
  27035. */
  27036. dispose(): void;
  27037. /**
  27038. * Sets the delta position
  27039. * @param position The delta position amount
  27040. */
  27041. setDeltaPosition(position: Vector3): void;
  27042. /**
  27043. * Sets the delta rotation
  27044. * @param rotation The delta rotation amount
  27045. */
  27046. setDeltaRotation(rotation: Quaternion): void;
  27047. /**
  27048. * Gets the box size of the physics imposter and stores the result in the input parameter
  27049. * @param result Stores the box size
  27050. * @returns The physics imposter
  27051. */
  27052. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27053. /**
  27054. * Gets the radius of the physics imposter
  27055. * @returns Radius of the physics imposter
  27056. */
  27057. getRadius(): number;
  27058. /**
  27059. * Sync a bone with this impostor
  27060. * @param bone The bone to sync to the impostor.
  27061. * @param boneMesh The mesh that the bone is influencing.
  27062. * @param jointPivot The pivot of the joint / bone in local space.
  27063. * @param distToJoint Optional distance from the impostor to the joint.
  27064. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27065. */
  27066. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27067. /**
  27068. * Sync impostor to a bone
  27069. * @param bone The bone that the impostor will be synced to.
  27070. * @param boneMesh The mesh that the bone is influencing.
  27071. * @param jointPivot The pivot of the joint / bone in local space.
  27072. * @param distToJoint Optional distance from the impostor to the joint.
  27073. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27074. * @param boneAxis Optional vector3 axis the bone is aligned with
  27075. */
  27076. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27077. /**
  27078. * No-Imposter type
  27079. */
  27080. static NoImpostor: number;
  27081. /**
  27082. * Sphere-Imposter type
  27083. */
  27084. static SphereImpostor: number;
  27085. /**
  27086. * Box-Imposter type
  27087. */
  27088. static BoxImpostor: number;
  27089. /**
  27090. * Plane-Imposter type
  27091. */
  27092. static PlaneImpostor: number;
  27093. /**
  27094. * Mesh-imposter type
  27095. */
  27096. static MeshImpostor: number;
  27097. /**
  27098. * Capsule-Impostor type (Ammo.js plugin only)
  27099. */
  27100. static CapsuleImpostor: number;
  27101. /**
  27102. * Cylinder-Imposter type
  27103. */
  27104. static CylinderImpostor: number;
  27105. /**
  27106. * Particle-Imposter type
  27107. */
  27108. static ParticleImpostor: number;
  27109. /**
  27110. * Heightmap-Imposter type
  27111. */
  27112. static HeightmapImpostor: number;
  27113. /**
  27114. * ConvexHull-Impostor type (Ammo.js plugin only)
  27115. */
  27116. static ConvexHullImpostor: number;
  27117. /**
  27118. * Custom-Imposter type (Ammo.js plugin only)
  27119. */
  27120. static CustomImpostor: number;
  27121. /**
  27122. * Rope-Imposter type
  27123. */
  27124. static RopeImpostor: number;
  27125. /**
  27126. * Cloth-Imposter type
  27127. */
  27128. static ClothImpostor: number;
  27129. /**
  27130. * Softbody-Imposter type
  27131. */
  27132. static SoftbodyImpostor: number;
  27133. }
  27134. }
  27135. declare module BABYLON {
  27136. /**
  27137. * @hidden
  27138. **/
  27139. export class _CreationDataStorage {
  27140. closePath?: boolean;
  27141. closeArray?: boolean;
  27142. idx: number[];
  27143. dashSize: number;
  27144. gapSize: number;
  27145. path3D: Path3D;
  27146. pathArray: Vector3[][];
  27147. arc: number;
  27148. radius: number;
  27149. cap: number;
  27150. tessellation: number;
  27151. }
  27152. /**
  27153. * @hidden
  27154. **/
  27155. class _InstanceDataStorage {
  27156. visibleInstances: any;
  27157. batchCache: _InstancesBatch;
  27158. instancesBufferSize: number;
  27159. instancesBuffer: Nullable<Buffer>;
  27160. instancesData: Float32Array;
  27161. overridenInstanceCount: number;
  27162. isFrozen: boolean;
  27163. previousBatch: Nullable<_InstancesBatch>;
  27164. hardwareInstancedRendering: boolean;
  27165. sideOrientation: number;
  27166. manualUpdate: boolean;
  27167. }
  27168. /**
  27169. * @hidden
  27170. **/
  27171. export class _InstancesBatch {
  27172. mustReturn: boolean;
  27173. visibleInstances: Nullable<InstancedMesh[]>[];
  27174. renderSelf: boolean[];
  27175. hardwareInstancedRendering: boolean[];
  27176. }
  27177. /**
  27178. * @hidden
  27179. **/
  27180. class _ThinInstanceDataStorage {
  27181. instancesCount: number;
  27182. matrixBuffer: Nullable<Buffer>;
  27183. matrixBufferSize: number;
  27184. matrixData: Nullable<Float32Array>;
  27185. boundingVectors: Array<Vector3>;
  27186. }
  27187. /**
  27188. * Class used to represent renderable models
  27189. */
  27190. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27191. /**
  27192. * Mesh side orientation : usually the external or front surface
  27193. */
  27194. static readonly FRONTSIDE: number;
  27195. /**
  27196. * Mesh side orientation : usually the internal or back surface
  27197. */
  27198. static readonly BACKSIDE: number;
  27199. /**
  27200. * Mesh side orientation : both internal and external or front and back surfaces
  27201. */
  27202. static readonly DOUBLESIDE: number;
  27203. /**
  27204. * Mesh side orientation : by default, `FRONTSIDE`
  27205. */
  27206. static readonly DEFAULTSIDE: number;
  27207. /**
  27208. * Mesh cap setting : no cap
  27209. */
  27210. static readonly NO_CAP: number;
  27211. /**
  27212. * Mesh cap setting : one cap at the beginning of the mesh
  27213. */
  27214. static readonly CAP_START: number;
  27215. /**
  27216. * Mesh cap setting : one cap at the end of the mesh
  27217. */
  27218. static readonly CAP_END: number;
  27219. /**
  27220. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27221. */
  27222. static readonly CAP_ALL: number;
  27223. /**
  27224. * Mesh pattern setting : no flip or rotate
  27225. */
  27226. static readonly NO_FLIP: number;
  27227. /**
  27228. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27229. */
  27230. static readonly FLIP_TILE: number;
  27231. /**
  27232. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27233. */
  27234. static readonly ROTATE_TILE: number;
  27235. /**
  27236. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27237. */
  27238. static readonly FLIP_ROW: number;
  27239. /**
  27240. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27241. */
  27242. static readonly ROTATE_ROW: number;
  27243. /**
  27244. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27245. */
  27246. static readonly FLIP_N_ROTATE_TILE: number;
  27247. /**
  27248. * Mesh pattern setting : rotate pattern and rotate
  27249. */
  27250. static readonly FLIP_N_ROTATE_ROW: number;
  27251. /**
  27252. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27253. */
  27254. static readonly CENTER: number;
  27255. /**
  27256. * Mesh tile positioning : part tiles on left
  27257. */
  27258. static readonly LEFT: number;
  27259. /**
  27260. * Mesh tile positioning : part tiles on right
  27261. */
  27262. static readonly RIGHT: number;
  27263. /**
  27264. * Mesh tile positioning : part tiles on top
  27265. */
  27266. static readonly TOP: number;
  27267. /**
  27268. * Mesh tile positioning : part tiles on bottom
  27269. */
  27270. static readonly BOTTOM: number;
  27271. /**
  27272. * Gets the default side orientation.
  27273. * @param orientation the orientation to value to attempt to get
  27274. * @returns the default orientation
  27275. * @hidden
  27276. */
  27277. static _GetDefaultSideOrientation(orientation?: number): number;
  27278. private _internalMeshDataInfo;
  27279. /**
  27280. * An event triggered before rendering the mesh
  27281. */
  27282. get onBeforeRenderObservable(): Observable<Mesh>;
  27283. /**
  27284. * An event triggered before binding the mesh
  27285. */
  27286. get onBeforeBindObservable(): Observable<Mesh>;
  27287. /**
  27288. * An event triggered after rendering the mesh
  27289. */
  27290. get onAfterRenderObservable(): Observable<Mesh>;
  27291. /**
  27292. * An event triggered before drawing the mesh
  27293. */
  27294. get onBeforeDrawObservable(): Observable<Mesh>;
  27295. private _onBeforeDrawObserver;
  27296. /**
  27297. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27298. */
  27299. set onBeforeDraw(callback: () => void);
  27300. get hasInstances(): boolean;
  27301. get hasThinInstances(): boolean;
  27302. /**
  27303. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27304. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27305. */
  27306. delayLoadState: number;
  27307. /**
  27308. * Gets the list of instances created from this mesh
  27309. * it is not supposed to be modified manually.
  27310. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27311. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27312. */
  27313. instances: InstancedMesh[];
  27314. /**
  27315. * Gets the file containing delay loading data for this mesh
  27316. */
  27317. delayLoadingFile: string;
  27318. /** @hidden */
  27319. _binaryInfo: any;
  27320. /**
  27321. * User defined function used to change how LOD level selection is done
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27323. */
  27324. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27325. /**
  27326. * Gets or sets the morph target manager
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27328. */
  27329. get morphTargetManager(): Nullable<MorphTargetManager>;
  27330. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27331. /** @hidden */
  27332. _creationDataStorage: Nullable<_CreationDataStorage>;
  27333. /** @hidden */
  27334. _geometry: Nullable<Geometry>;
  27335. /** @hidden */
  27336. _delayInfo: Array<string>;
  27337. /** @hidden */
  27338. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27339. /** @hidden */
  27340. _instanceDataStorage: _InstanceDataStorage;
  27341. /** @hidden */
  27342. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27343. private _effectiveMaterial;
  27344. /** @hidden */
  27345. _shouldGenerateFlatShading: boolean;
  27346. /** @hidden */
  27347. _originalBuilderSideOrientation: number;
  27348. /**
  27349. * Use this property to change the original side orientation defined at construction time
  27350. */
  27351. overrideMaterialSideOrientation: Nullable<number>;
  27352. /**
  27353. * Gets the source mesh (the one used to clone this one from)
  27354. */
  27355. get source(): Nullable<Mesh>;
  27356. /**
  27357. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27358. */
  27359. get isUnIndexed(): boolean;
  27360. set isUnIndexed(value: boolean);
  27361. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27362. get worldMatrixInstancedBuffer(): Float32Array;
  27363. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27364. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27365. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27366. /**
  27367. * @constructor
  27368. * @param name The value used by scene.getMeshByName() to do a lookup.
  27369. * @param scene The scene to add this mesh to.
  27370. * @param parent The parent of this mesh, if it has one
  27371. * @param source An optional Mesh from which geometry is shared, cloned.
  27372. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27373. * When false, achieved by calling a clone(), also passing False.
  27374. * This will make creation of children, recursive.
  27375. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27376. */
  27377. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27378. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27379. doNotInstantiate: boolean;
  27380. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27381. /**
  27382. * Gets the class name
  27383. * @returns the string "Mesh".
  27384. */
  27385. getClassName(): string;
  27386. /** @hidden */
  27387. get _isMesh(): boolean;
  27388. /**
  27389. * Returns a description of this mesh
  27390. * @param fullDetails define if full details about this mesh must be used
  27391. * @returns a descriptive string representing this mesh
  27392. */
  27393. toString(fullDetails?: boolean): string;
  27394. /** @hidden */
  27395. _unBindEffect(): void;
  27396. /**
  27397. * Gets a boolean indicating if this mesh has LOD
  27398. */
  27399. get hasLODLevels(): boolean;
  27400. /**
  27401. * Gets the list of MeshLODLevel associated with the current mesh
  27402. * @returns an array of MeshLODLevel
  27403. */
  27404. getLODLevels(): MeshLODLevel[];
  27405. private _sortLODLevels;
  27406. /**
  27407. * Add a mesh as LOD level triggered at the given distance.
  27408. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27409. * @param distance The distance from the center of the object to show this level
  27410. * @param mesh The mesh to be added as LOD level (can be null)
  27411. * @return This mesh (for chaining)
  27412. */
  27413. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27414. /**
  27415. * Returns the LOD level mesh at the passed distance or null if not found.
  27416. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27417. * @param distance The distance from the center of the object to show this level
  27418. * @returns a Mesh or `null`
  27419. */
  27420. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27421. /**
  27422. * Remove a mesh from the LOD array
  27423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27424. * @param mesh defines the mesh to be removed
  27425. * @return This mesh (for chaining)
  27426. */
  27427. removeLODLevel(mesh: Mesh): Mesh;
  27428. /**
  27429. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27431. * @param camera defines the camera to use to compute distance
  27432. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27433. * @return This mesh (for chaining)
  27434. */
  27435. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27436. /**
  27437. * Gets the mesh internal Geometry object
  27438. */
  27439. get geometry(): Nullable<Geometry>;
  27440. /**
  27441. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27442. * @returns the total number of vertices
  27443. */
  27444. getTotalVertices(): number;
  27445. /**
  27446. * Returns the content of an associated vertex buffer
  27447. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27448. * - VertexBuffer.PositionKind
  27449. * - VertexBuffer.UVKind
  27450. * - VertexBuffer.UV2Kind
  27451. * - VertexBuffer.UV3Kind
  27452. * - VertexBuffer.UV4Kind
  27453. * - VertexBuffer.UV5Kind
  27454. * - VertexBuffer.UV6Kind
  27455. * - VertexBuffer.ColorKind
  27456. * - VertexBuffer.MatricesIndicesKind
  27457. * - VertexBuffer.MatricesIndicesExtraKind
  27458. * - VertexBuffer.MatricesWeightsKind
  27459. * - VertexBuffer.MatricesWeightsExtraKind
  27460. * @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
  27461. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27462. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27463. */
  27464. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27465. /**
  27466. * Returns the mesh VertexBuffer object from the requested `kind`
  27467. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27468. * - VertexBuffer.PositionKind
  27469. * - VertexBuffer.NormalKind
  27470. * - VertexBuffer.UVKind
  27471. * - VertexBuffer.UV2Kind
  27472. * - VertexBuffer.UV3Kind
  27473. * - VertexBuffer.UV4Kind
  27474. * - VertexBuffer.UV5Kind
  27475. * - VertexBuffer.UV6Kind
  27476. * - VertexBuffer.ColorKind
  27477. * - VertexBuffer.MatricesIndicesKind
  27478. * - VertexBuffer.MatricesIndicesExtraKind
  27479. * - VertexBuffer.MatricesWeightsKind
  27480. * - VertexBuffer.MatricesWeightsExtraKind
  27481. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27482. */
  27483. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27484. /**
  27485. * Tests if a specific vertex buffer is associated with this mesh
  27486. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27487. * - VertexBuffer.PositionKind
  27488. * - VertexBuffer.NormalKind
  27489. * - VertexBuffer.UVKind
  27490. * - VertexBuffer.UV2Kind
  27491. * - VertexBuffer.UV3Kind
  27492. * - VertexBuffer.UV4Kind
  27493. * - VertexBuffer.UV5Kind
  27494. * - VertexBuffer.UV6Kind
  27495. * - VertexBuffer.ColorKind
  27496. * - VertexBuffer.MatricesIndicesKind
  27497. * - VertexBuffer.MatricesIndicesExtraKind
  27498. * - VertexBuffer.MatricesWeightsKind
  27499. * - VertexBuffer.MatricesWeightsExtraKind
  27500. * @returns a boolean
  27501. */
  27502. isVerticesDataPresent(kind: string): boolean;
  27503. /**
  27504. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27505. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27506. * - VertexBuffer.PositionKind
  27507. * - VertexBuffer.UVKind
  27508. * - VertexBuffer.UV2Kind
  27509. * - VertexBuffer.UV3Kind
  27510. * - VertexBuffer.UV4Kind
  27511. * - VertexBuffer.UV5Kind
  27512. * - VertexBuffer.UV6Kind
  27513. * - VertexBuffer.ColorKind
  27514. * - VertexBuffer.MatricesIndicesKind
  27515. * - VertexBuffer.MatricesIndicesExtraKind
  27516. * - VertexBuffer.MatricesWeightsKind
  27517. * - VertexBuffer.MatricesWeightsExtraKind
  27518. * @returns a boolean
  27519. */
  27520. isVertexBufferUpdatable(kind: string): boolean;
  27521. /**
  27522. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27523. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27524. * - VertexBuffer.PositionKind
  27525. * - VertexBuffer.NormalKind
  27526. * - VertexBuffer.UVKind
  27527. * - VertexBuffer.UV2Kind
  27528. * - VertexBuffer.UV3Kind
  27529. * - VertexBuffer.UV4Kind
  27530. * - VertexBuffer.UV5Kind
  27531. * - VertexBuffer.UV6Kind
  27532. * - VertexBuffer.ColorKind
  27533. * - VertexBuffer.MatricesIndicesKind
  27534. * - VertexBuffer.MatricesIndicesExtraKind
  27535. * - VertexBuffer.MatricesWeightsKind
  27536. * - VertexBuffer.MatricesWeightsExtraKind
  27537. * @returns an array of strings
  27538. */
  27539. getVerticesDataKinds(): string[];
  27540. /**
  27541. * Returns a positive integer : the total number of indices in this mesh geometry.
  27542. * @returns the numner of indices or zero if the mesh has no geometry.
  27543. */
  27544. getTotalIndices(): number;
  27545. /**
  27546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27547. * @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.
  27548. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27549. * @returns the indices array or an empty array if the mesh has no geometry
  27550. */
  27551. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27552. get isBlocked(): boolean;
  27553. /**
  27554. * Determine if the current mesh is ready to be rendered
  27555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27556. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27557. * @returns true if all associated assets are ready (material, textures, shaders)
  27558. */
  27559. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27560. /**
  27561. * 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.
  27562. */
  27563. get areNormalsFrozen(): boolean;
  27564. /**
  27565. * 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.
  27566. * @returns the current mesh
  27567. */
  27568. freezeNormals(): Mesh;
  27569. /**
  27570. * 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
  27571. * @returns the current mesh
  27572. */
  27573. unfreezeNormals(): Mesh;
  27574. /**
  27575. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27576. */
  27577. set overridenInstanceCount(count: number);
  27578. /** @hidden */
  27579. _preActivate(): Mesh;
  27580. /** @hidden */
  27581. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27582. /** @hidden */
  27583. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27584. protected _afterComputeWorldMatrix(): void;
  27585. /**
  27586. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27587. * This means the mesh underlying bounding box and sphere are recomputed.
  27588. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27589. * @returns the current mesh
  27590. */
  27591. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27592. /** @hidden */
  27593. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27594. /**
  27595. * This function will subdivide the mesh into multiple submeshes
  27596. * @param count defines the expected number of submeshes
  27597. */
  27598. subdivide(count: number): void;
  27599. /**
  27600. * Copy a FloatArray into a specific associated vertex buffer
  27601. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27602. * - VertexBuffer.PositionKind
  27603. * - VertexBuffer.UVKind
  27604. * - VertexBuffer.UV2Kind
  27605. * - VertexBuffer.UV3Kind
  27606. * - VertexBuffer.UV4Kind
  27607. * - VertexBuffer.UV5Kind
  27608. * - VertexBuffer.UV6Kind
  27609. * - VertexBuffer.ColorKind
  27610. * - VertexBuffer.MatricesIndicesKind
  27611. * - VertexBuffer.MatricesIndicesExtraKind
  27612. * - VertexBuffer.MatricesWeightsKind
  27613. * - VertexBuffer.MatricesWeightsExtraKind
  27614. * @param data defines the data source
  27615. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27616. * @param stride defines the data stride size (can be null)
  27617. * @returns the current mesh
  27618. */
  27619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27620. /**
  27621. * Delete a vertex buffer associated with this mesh
  27622. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27623. * - VertexBuffer.PositionKind
  27624. * - VertexBuffer.UVKind
  27625. * - VertexBuffer.UV2Kind
  27626. * - VertexBuffer.UV3Kind
  27627. * - VertexBuffer.UV4Kind
  27628. * - VertexBuffer.UV5Kind
  27629. * - VertexBuffer.UV6Kind
  27630. * - VertexBuffer.ColorKind
  27631. * - VertexBuffer.MatricesIndicesKind
  27632. * - VertexBuffer.MatricesIndicesExtraKind
  27633. * - VertexBuffer.MatricesWeightsKind
  27634. * - VertexBuffer.MatricesWeightsExtraKind
  27635. */
  27636. removeVerticesData(kind: string): void;
  27637. /**
  27638. * Flags an associated vertex buffer as updatable
  27639. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27640. * - VertexBuffer.PositionKind
  27641. * - VertexBuffer.UVKind
  27642. * - VertexBuffer.UV2Kind
  27643. * - VertexBuffer.UV3Kind
  27644. * - VertexBuffer.UV4Kind
  27645. * - VertexBuffer.UV5Kind
  27646. * - VertexBuffer.UV6Kind
  27647. * - VertexBuffer.ColorKind
  27648. * - VertexBuffer.MatricesIndicesKind
  27649. * - VertexBuffer.MatricesIndicesExtraKind
  27650. * - VertexBuffer.MatricesWeightsKind
  27651. * - VertexBuffer.MatricesWeightsExtraKind
  27652. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27653. */
  27654. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27655. /**
  27656. * Sets the mesh global Vertex Buffer
  27657. * @param buffer defines the buffer to use
  27658. * @returns the current mesh
  27659. */
  27660. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27661. /**
  27662. * Update a specific associated vertex buffer
  27663. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27664. * - VertexBuffer.PositionKind
  27665. * - VertexBuffer.UVKind
  27666. * - VertexBuffer.UV2Kind
  27667. * - VertexBuffer.UV3Kind
  27668. * - VertexBuffer.UV4Kind
  27669. * - VertexBuffer.UV5Kind
  27670. * - VertexBuffer.UV6Kind
  27671. * - VertexBuffer.ColorKind
  27672. * - VertexBuffer.MatricesIndicesKind
  27673. * - VertexBuffer.MatricesIndicesExtraKind
  27674. * - VertexBuffer.MatricesWeightsKind
  27675. * - VertexBuffer.MatricesWeightsExtraKind
  27676. * @param data defines the data source
  27677. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27678. * @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)
  27679. * @returns the current mesh
  27680. */
  27681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27682. /**
  27683. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27684. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27685. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27686. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27687. * @returns the current mesh
  27688. */
  27689. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27690. /**
  27691. * Creates a un-shared specific occurence of the geometry for the mesh.
  27692. * @returns the current mesh
  27693. */
  27694. makeGeometryUnique(): Mesh;
  27695. /**
  27696. * Set the index buffer of this mesh
  27697. * @param indices defines the source data
  27698. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27699. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27700. * @returns the current mesh
  27701. */
  27702. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27703. /**
  27704. * Update the current index buffer
  27705. * @param indices defines the source data
  27706. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27707. * @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)
  27708. * @returns the current mesh
  27709. */
  27710. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27711. /**
  27712. * Invert the geometry to move from a right handed system to a left handed one.
  27713. * @returns the current mesh
  27714. */
  27715. toLeftHanded(): Mesh;
  27716. /** @hidden */
  27717. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27718. /** @hidden */
  27719. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27720. /**
  27721. * Registers for this mesh a javascript function called just before the rendering process
  27722. * @param func defines the function to call before rendering this mesh
  27723. * @returns the current mesh
  27724. */
  27725. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27726. /**
  27727. * Disposes a previously registered javascript function called before the rendering
  27728. * @param func defines the function to remove
  27729. * @returns the current mesh
  27730. */
  27731. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27732. /**
  27733. * Registers for this mesh a javascript function called just after the rendering is complete
  27734. * @param func defines the function to call after rendering this mesh
  27735. * @returns the current mesh
  27736. */
  27737. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27738. /**
  27739. * Disposes a previously registered javascript function called after the rendering.
  27740. * @param func defines the function to remove
  27741. * @returns the current mesh
  27742. */
  27743. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27744. /** @hidden */
  27745. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27746. /** @hidden */
  27747. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27748. /** @hidden */
  27749. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27750. /** @hidden */
  27751. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27752. /** @hidden */
  27753. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27754. /** @hidden */
  27755. _rebuild(): void;
  27756. /** @hidden */
  27757. _freeze(): void;
  27758. /** @hidden */
  27759. _unFreeze(): void;
  27760. /**
  27761. * 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
  27762. * @param subMesh defines the subMesh to render
  27763. * @param enableAlphaMode defines if alpha mode can be changed
  27764. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27765. * @returns the current mesh
  27766. */
  27767. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27768. private _onBeforeDraw;
  27769. /**
  27770. * Renormalize the mesh and patch it up if there are no weights
  27771. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27772. * However in the case of zero weights then we set just a single influence to 1.
  27773. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27774. */
  27775. cleanMatrixWeights(): void;
  27776. private normalizeSkinFourWeights;
  27777. private normalizeSkinWeightsAndExtra;
  27778. /**
  27779. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27780. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27781. * the user know there was an issue with importing the mesh
  27782. * @returns a validation object with skinned, valid and report string
  27783. */
  27784. validateSkinning(): {
  27785. skinned: boolean;
  27786. valid: boolean;
  27787. report: string;
  27788. };
  27789. /** @hidden */
  27790. _checkDelayState(): Mesh;
  27791. private _queueLoad;
  27792. /**
  27793. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27794. * A mesh is in the frustum if its bounding box intersects the frustum
  27795. * @param frustumPlanes defines the frustum to test
  27796. * @returns true if the mesh is in the frustum planes
  27797. */
  27798. isInFrustum(frustumPlanes: Plane[]): boolean;
  27799. /**
  27800. * Sets the mesh material by the material or multiMaterial `id` property
  27801. * @param id is a string identifying the material or the multiMaterial
  27802. * @returns the current mesh
  27803. */
  27804. setMaterialByID(id: string): Mesh;
  27805. /**
  27806. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27807. * @returns an array of IAnimatable
  27808. */
  27809. getAnimatables(): IAnimatable[];
  27810. /**
  27811. * Modifies the mesh geometry according to the passed transformation matrix.
  27812. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27813. * The mesh normals are modified using the same transformation.
  27814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27815. * @param transform defines the transform matrix to use
  27816. * @see http://doc.babylonjs.com/resources/baking_transformations
  27817. * @returns the current mesh
  27818. */
  27819. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27820. /**
  27821. * Modifies the mesh geometry according to its own current World Matrix.
  27822. * The mesh World Matrix is then reset.
  27823. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27824. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27825. * @see http://doc.babylonjs.com/resources/baking_transformations
  27826. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27827. * @returns the current mesh
  27828. */
  27829. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27830. /** @hidden */
  27831. get _positions(): Nullable<Vector3[]>;
  27832. /** @hidden */
  27833. _resetPointsArrayCache(): Mesh;
  27834. /** @hidden */
  27835. _generatePointsArray(): boolean;
  27836. /**
  27837. * Returns a new Mesh object generated from the current mesh properties.
  27838. * This method must not get confused with createInstance()
  27839. * @param name is a string, the name given to the new mesh
  27840. * @param newParent can be any Node object (default `null`)
  27841. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27842. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27843. * @returns a new mesh
  27844. */
  27845. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27846. /**
  27847. * Releases resources associated with this mesh.
  27848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27850. */
  27851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27852. /** @hidden */
  27853. _disposeInstanceSpecificData(): void;
  27854. /** @hidden */
  27855. _disposeThinInstanceSpecificData(): void;
  27856. /**
  27857. * Modifies the mesh geometry according to a displacement map.
  27858. * 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.
  27859. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27860. * @param url is a string, the URL from the image file is to be downloaded.
  27861. * @param minHeight is the lower limit of the displacement.
  27862. * @param maxHeight is the upper limit of the displacement.
  27863. * @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.
  27864. * @param uvOffset is an optional vector2 used to offset UV.
  27865. * @param uvScale is an optional vector2 used to scale UV.
  27866. * @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.
  27867. * @returns the Mesh.
  27868. */
  27869. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27870. /**
  27871. * Modifies the mesh geometry according to a displacementMap buffer.
  27872. * 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.
  27873. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27874. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27875. * @param heightMapWidth is the width of the buffer image.
  27876. * @param heightMapHeight is the height of the buffer image.
  27877. * @param minHeight is the lower limit of the displacement.
  27878. * @param maxHeight is the upper limit of the displacement.
  27879. * @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.
  27880. * @param uvOffset is an optional vector2 used to offset UV.
  27881. * @param uvScale is an optional vector2 used to scale UV.
  27882. * @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.
  27883. * @returns the Mesh.
  27884. */
  27885. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27886. /**
  27887. * Modify the mesh to get a flat shading rendering.
  27888. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27889. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27890. * @returns current mesh
  27891. */
  27892. convertToFlatShadedMesh(): Mesh;
  27893. /**
  27894. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27895. * In other words, more vertices, no more indices and a single bigger VBO.
  27896. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27897. * @returns current mesh
  27898. */
  27899. convertToUnIndexedMesh(): Mesh;
  27900. /**
  27901. * Inverses facet orientations.
  27902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27903. * @param flipNormals will also inverts the normals
  27904. * @returns current mesh
  27905. */
  27906. flipFaces(flipNormals?: boolean): Mesh;
  27907. /**
  27908. * Increase the number of facets and hence vertices in a mesh
  27909. * Vertex normals are interpolated from existing vertex normals
  27910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27911. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27912. */
  27913. increaseVertices(numberPerEdge: number): void;
  27914. /**
  27915. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27916. * This will undo any application of covertToFlatShadedMesh
  27917. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27918. */
  27919. forceSharedVertices(): void;
  27920. /** @hidden */
  27921. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27922. /** @hidden */
  27923. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27924. /**
  27925. * Creates a new InstancedMesh object from the mesh model.
  27926. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27927. * @param name defines the name of the new instance
  27928. * @returns a new InstancedMesh
  27929. */
  27930. createInstance(name: string): InstancedMesh;
  27931. /**
  27932. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27933. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27934. * @returns the current mesh
  27935. */
  27936. synchronizeInstances(): Mesh;
  27937. /**
  27938. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27939. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27940. * This should be used together with the simplification to avoid disappearing triangles.
  27941. * @param successCallback an optional success callback to be called after the optimization finished.
  27942. * @returns the current mesh
  27943. */
  27944. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27945. /**
  27946. * Serialize current mesh
  27947. * @param serializationObject defines the object which will receive the serialization data
  27948. */
  27949. serialize(serializationObject: any): void;
  27950. /** @hidden */
  27951. _syncGeometryWithMorphTargetManager(): void;
  27952. /** @hidden */
  27953. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27954. /**
  27955. * Returns a new Mesh object parsed from the source provided.
  27956. * @param parsedMesh is the source
  27957. * @param scene defines the hosting scene
  27958. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27959. * @returns a new Mesh
  27960. */
  27961. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27962. /**
  27963. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27964. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27965. * @param name defines the name of the mesh to create
  27966. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27967. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27968. * @param closePath creates a seam between the first and the last points of each path of the path array
  27969. * @param offset is taken in account only if the `pathArray` is containing a single path
  27970. * @param scene defines the hosting scene
  27971. * @param updatable defines if the mesh must be flagged as updatable
  27972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27973. * @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)
  27974. * @returns a new Mesh
  27975. */
  27976. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27977. /**
  27978. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27979. * @param name defines the name of the mesh to create
  27980. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27981. * @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
  27982. * @param scene defines the hosting scene
  27983. * @param updatable defines if the mesh must be flagged as updatable
  27984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27985. * @returns a new Mesh
  27986. */
  27987. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27988. /**
  27989. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27990. * @param name defines the name of the mesh to create
  27991. * @param size sets the size (float) of each box side (default 1)
  27992. * @param scene defines the hosting scene
  27993. * @param updatable defines if the mesh must be flagged as updatable
  27994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27995. * @returns a new Mesh
  27996. */
  27997. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27998. /**
  27999. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28000. * @param name defines the name of the mesh to create
  28001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28003. * @param scene defines the hosting scene
  28004. * @param updatable defines if the mesh must be flagged as updatable
  28005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28006. * @returns a new Mesh
  28007. */
  28008. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28009. /**
  28010. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28011. * @param name defines the name of the mesh to create
  28012. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28013. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28014. * @param scene defines the hosting scene
  28015. * @returns a new Mesh
  28016. */
  28017. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28018. /**
  28019. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28020. * @param name defines the name of the mesh to create
  28021. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28022. * @param diameterTop set the top cap diameter (floats, default 1)
  28023. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28024. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28025. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28026. * @param scene defines the hosting scene
  28027. * @param updatable defines if the mesh must be flagged as updatable
  28028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28029. * @returns a new Mesh
  28030. */
  28031. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28032. /**
  28033. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28034. * @param name defines the name of the mesh to create
  28035. * @param diameter sets the diameter size (float) of the torus (default 1)
  28036. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28037. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28038. * @param scene defines the hosting scene
  28039. * @param updatable defines if the mesh must be flagged as updatable
  28040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28041. * @returns a new Mesh
  28042. */
  28043. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28044. /**
  28045. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28046. * @param name defines the name of the mesh to create
  28047. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28048. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28049. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28050. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28051. * @param p the number of windings on X axis (positive integers, default 2)
  28052. * @param q the number of windings on Y axis (positive integers, default 3)
  28053. * @param scene defines the hosting scene
  28054. * @param updatable defines if the mesh must be flagged as updatable
  28055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28056. * @returns a new Mesh
  28057. */
  28058. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28059. /**
  28060. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28061. * @param name defines the name of the mesh to create
  28062. * @param points is an array successive Vector3
  28063. * @param scene defines the hosting scene
  28064. * @param updatable defines if the mesh must be flagged as updatable
  28065. * @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).
  28066. * @returns a new Mesh
  28067. */
  28068. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28069. /**
  28070. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28071. * @param name defines the name of the mesh to create
  28072. * @param points is an array successive Vector3
  28073. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28074. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28075. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28076. * @param scene defines the hosting scene
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @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)
  28079. * @returns a new Mesh
  28080. */
  28081. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28082. /**
  28083. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28085. * 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.
  28086. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28088. * Remember you can only change the shape positions, not their number when updating a polygon.
  28089. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28090. * @param name defines the name of the mesh to create
  28091. * @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
  28092. * @param scene defines the hosting scene
  28093. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28094. * @param updatable defines if the mesh must be flagged as updatable
  28095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28096. * @param earcutInjection can be used to inject your own earcut reference
  28097. * @returns a new Mesh
  28098. */
  28099. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28100. /**
  28101. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28103. * @param name defines the name of the mesh to create
  28104. * @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
  28105. * @param depth defines the height of extrusion
  28106. * @param scene defines the hosting scene
  28107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28108. * @param updatable defines if the mesh must be flagged as updatable
  28109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28110. * @param earcutInjection can be used to inject your own earcut reference
  28111. * @returns a new Mesh
  28112. */
  28113. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28114. /**
  28115. * Creates an extruded shape mesh.
  28116. * 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
  28117. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28119. * @param name defines the name of the mesh to create
  28120. * @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
  28121. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28122. * @param scale is the value to scale the shape
  28123. * @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
  28124. * @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
  28125. * @param scene defines the hosting scene
  28126. * @param updatable defines if the mesh must be flagged as updatable
  28127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28128. * @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)
  28129. * @returns a new Mesh
  28130. */
  28131. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28132. /**
  28133. * Creates an custom extruded shape mesh.
  28134. * The custom extrusion is a parametric shape.
  28135. * It has no predefined shape. Its final shape will depend on the input parameters.
  28136. * Please consider using the same method from the MeshBuilder class instead
  28137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28138. * @param name defines the name of the mesh to create
  28139. * @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
  28140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28141. * @param scaleFunction is a custom Javascript function called on each path point
  28142. * @param rotationFunction is a custom Javascript function called on each path point
  28143. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28144. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28145. * @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
  28146. * @param scene defines the hosting scene
  28147. * @param updatable defines if the mesh must be flagged as updatable
  28148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28149. * @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)
  28150. * @returns a new Mesh
  28151. */
  28152. 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;
  28153. /**
  28154. * Creates lathe mesh.
  28155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28156. * Please consider using the same method from the MeshBuilder class instead
  28157. * @param name defines the name of the mesh to create
  28158. * @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
  28159. * @param radius is the radius value of the lathe
  28160. * @param tessellation is the side number of the lathe.
  28161. * @param scene defines the hosting scene
  28162. * @param updatable defines if the mesh must be flagged as updatable
  28163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28164. * @returns a new Mesh
  28165. */
  28166. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28167. /**
  28168. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28169. * @param name defines the name of the mesh to create
  28170. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28171. * @param scene defines the hosting scene
  28172. * @param updatable defines if the mesh must be flagged as updatable
  28173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28174. * @returns a new Mesh
  28175. */
  28176. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28177. /**
  28178. * Creates a ground mesh.
  28179. * Please consider using the same method from the MeshBuilder class instead
  28180. * @param name defines the name of the mesh to create
  28181. * @param width set the width of the ground
  28182. * @param height set the height of the ground
  28183. * @param subdivisions sets the number of subdivisions per side
  28184. * @param scene defines the hosting scene
  28185. * @param updatable defines if the mesh must be flagged as updatable
  28186. * @returns a new Mesh
  28187. */
  28188. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28189. /**
  28190. * Creates a tiled ground mesh.
  28191. * Please consider using the same method from the MeshBuilder class instead
  28192. * @param name defines the name of the mesh to create
  28193. * @param xmin set the ground minimum X coordinate
  28194. * @param zmin set the ground minimum Y coordinate
  28195. * @param xmax set the ground maximum X coordinate
  28196. * @param zmax set the ground maximum Z coordinate
  28197. * @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
  28198. * @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
  28199. * @param scene defines the hosting scene
  28200. * @param updatable defines if the mesh must be flagged as updatable
  28201. * @returns a new Mesh
  28202. */
  28203. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28204. w: number;
  28205. h: number;
  28206. }, precision: {
  28207. w: number;
  28208. h: number;
  28209. }, scene: Scene, updatable?: boolean): Mesh;
  28210. /**
  28211. * Creates a ground mesh from a height map.
  28212. * Please consider using the same method from the MeshBuilder class instead
  28213. * @see http://doc.babylonjs.com/babylon101/height_map
  28214. * @param name defines the name of the mesh to create
  28215. * @param url sets the URL of the height map image resource
  28216. * @param width set the ground width size
  28217. * @param height set the ground height size
  28218. * @param subdivisions sets the number of subdivision per side
  28219. * @param minHeight is the minimum altitude on the ground
  28220. * @param maxHeight is the maximum altitude on the ground
  28221. * @param scene defines the hosting scene
  28222. * @param updatable defines if the mesh must be flagged as updatable
  28223. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28224. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28225. * @returns a new Mesh
  28226. */
  28227. 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;
  28228. /**
  28229. * Creates a tube mesh.
  28230. * The tube is a parametric shape.
  28231. * It has no predefined shape. Its final shape will depend on the input parameters.
  28232. * Please consider using the same method from the MeshBuilder class instead
  28233. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28234. * @param name defines the name of the mesh to create
  28235. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28236. * @param radius sets the tube radius size
  28237. * @param tessellation is the number of sides on the tubular surface
  28238. * @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
  28239. * @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
  28240. * @param scene defines the hosting scene
  28241. * @param updatable defines if the mesh must be flagged as updatable
  28242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28243. * @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)
  28244. * @returns a new Mesh
  28245. */
  28246. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28247. (i: number, distance: number): number;
  28248. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28249. /**
  28250. * Creates a polyhedron mesh.
  28251. * Please consider using the same method from the MeshBuilder class instead.
  28252. * * 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
  28253. * * The parameter `size` (positive float, default 1) sets the polygon size
  28254. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28255. * * 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`
  28256. * * 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
  28257. * * 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)`)
  28258. * * 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
  28259. * * 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
  28260. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28261. * * 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
  28262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28263. * @param name defines the name of the mesh to create
  28264. * @param options defines the options used to create the mesh
  28265. * @param scene defines the hosting scene
  28266. * @returns a new Mesh
  28267. */
  28268. static CreatePolyhedron(name: string, options: {
  28269. type?: number;
  28270. size?: number;
  28271. sizeX?: number;
  28272. sizeY?: number;
  28273. sizeZ?: number;
  28274. custom?: any;
  28275. faceUV?: Vector4[];
  28276. faceColors?: Color4[];
  28277. updatable?: boolean;
  28278. sideOrientation?: number;
  28279. }, scene: Scene): Mesh;
  28280. /**
  28281. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28282. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28283. * * 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`)
  28284. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28285. * * 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
  28286. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28287. * * 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
  28288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28289. * @param name defines the name of the mesh
  28290. * @param options defines the options used to create the mesh
  28291. * @param scene defines the hosting scene
  28292. * @returns a new Mesh
  28293. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28294. */
  28295. static CreateIcoSphere(name: string, options: {
  28296. radius?: number;
  28297. flat?: boolean;
  28298. subdivisions?: number;
  28299. sideOrientation?: number;
  28300. updatable?: boolean;
  28301. }, scene: Scene): Mesh;
  28302. /**
  28303. * Creates a decal mesh.
  28304. * Please consider using the same method from the MeshBuilder class instead.
  28305. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28306. * @param name defines the name of the mesh
  28307. * @param sourceMesh defines the mesh receiving the decal
  28308. * @param position sets the position of the decal in world coordinates
  28309. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28310. * @param size sets the decal scaling
  28311. * @param angle sets the angle to rotate the decal
  28312. * @returns a new Mesh
  28313. */
  28314. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28315. /**
  28316. * Prepare internal position array for software CPU skinning
  28317. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28318. */
  28319. setPositionsForCPUSkinning(): Float32Array;
  28320. /**
  28321. * Prepare internal normal array for software CPU skinning
  28322. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28323. */
  28324. setNormalsForCPUSkinning(): Float32Array;
  28325. /**
  28326. * Updates the vertex buffer by applying transformation from the bones
  28327. * @param skeleton defines the skeleton to apply to current mesh
  28328. * @returns the current mesh
  28329. */
  28330. applySkeleton(skeleton: Skeleton): Mesh;
  28331. /**
  28332. * 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
  28333. * @param meshes defines the list of meshes to scan
  28334. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28335. */
  28336. static MinMax(meshes: AbstractMesh[]): {
  28337. min: Vector3;
  28338. max: Vector3;
  28339. };
  28340. /**
  28341. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28342. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28343. * @returns a vector3
  28344. */
  28345. static Center(meshesOrMinMaxVector: {
  28346. min: Vector3;
  28347. max: Vector3;
  28348. } | AbstractMesh[]): Vector3;
  28349. /**
  28350. * Merge the array of meshes into a single mesh for performance reasons.
  28351. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28352. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28353. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28354. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28355. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28356. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28357. * @returns a new mesh
  28358. */
  28359. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28360. /** @hidden */
  28361. addInstance(instance: InstancedMesh): void;
  28362. /** @hidden */
  28363. removeInstance(instance: InstancedMesh): void;
  28364. }
  28365. }
  28366. declare module BABYLON {
  28367. /**
  28368. * This is the base class of all the camera used in the application.
  28369. * @see http://doc.babylonjs.com/features/cameras
  28370. */
  28371. export class Camera extends Node {
  28372. /** @hidden */
  28373. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28374. /**
  28375. * This is the default projection mode used by the cameras.
  28376. * It helps recreating a feeling of perspective and better appreciate depth.
  28377. * This is the best way to simulate real life cameras.
  28378. */
  28379. static readonly PERSPECTIVE_CAMERA: number;
  28380. /**
  28381. * This helps creating camera with an orthographic mode.
  28382. * 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.
  28383. */
  28384. static readonly ORTHOGRAPHIC_CAMERA: number;
  28385. /**
  28386. * This is the default FOV mode for perspective cameras.
  28387. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28388. */
  28389. static readonly FOVMODE_VERTICAL_FIXED: number;
  28390. /**
  28391. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28392. */
  28393. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28394. /**
  28395. * This specifies ther is no need for a camera rig.
  28396. * Basically only one eye is rendered corresponding to the camera.
  28397. */
  28398. static readonly RIG_MODE_NONE: number;
  28399. /**
  28400. * Simulates a camera Rig with one blue eye and one red eye.
  28401. * This can be use with 3d blue and red glasses.
  28402. */
  28403. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28404. /**
  28405. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28406. */
  28407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28408. /**
  28409. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28410. */
  28411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28412. /**
  28413. * Defines that both eyes of the camera will be rendered over under each other.
  28414. */
  28415. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28416. /**
  28417. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28418. */
  28419. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28420. /**
  28421. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28422. */
  28423. static readonly RIG_MODE_VR: number;
  28424. /**
  28425. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28426. */
  28427. static readonly RIG_MODE_WEBVR: number;
  28428. /**
  28429. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28430. */
  28431. static readonly RIG_MODE_CUSTOM: number;
  28432. /**
  28433. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28434. */
  28435. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28436. /**
  28437. * Define the input manager associated with the camera.
  28438. */
  28439. inputs: CameraInputsManager<Camera>;
  28440. /** @hidden */
  28441. _position: Vector3;
  28442. /**
  28443. * Define the current local position of the camera in the scene
  28444. */
  28445. get position(): Vector3;
  28446. set position(newPosition: Vector3);
  28447. /**
  28448. * The vector the camera should consider as up.
  28449. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28450. */
  28451. upVector: Vector3;
  28452. /**
  28453. * Define the current limit on the left side for an orthographic camera
  28454. * In scene unit
  28455. */
  28456. orthoLeft: Nullable<number>;
  28457. /**
  28458. * Define the current limit on the right side for an orthographic camera
  28459. * In scene unit
  28460. */
  28461. orthoRight: Nullable<number>;
  28462. /**
  28463. * Define the current limit on the bottom side for an orthographic camera
  28464. * In scene unit
  28465. */
  28466. orthoBottom: Nullable<number>;
  28467. /**
  28468. * Define the current limit on the top side for an orthographic camera
  28469. * In scene unit
  28470. */
  28471. orthoTop: Nullable<number>;
  28472. /**
  28473. * Field Of View is set in Radians. (default is 0.8)
  28474. */
  28475. fov: number;
  28476. /**
  28477. * Define the minimum distance the camera can see from.
  28478. * This is important to note that the depth buffer are not infinite and the closer it starts
  28479. * the more your scene might encounter depth fighting issue.
  28480. */
  28481. minZ: number;
  28482. /**
  28483. * Define the maximum distance the camera can see to.
  28484. * This is important to note that the depth buffer are not infinite and the further it end
  28485. * the more your scene might encounter depth fighting issue.
  28486. */
  28487. maxZ: number;
  28488. /**
  28489. * Define the default inertia of the camera.
  28490. * This helps giving a smooth feeling to the camera movement.
  28491. */
  28492. inertia: number;
  28493. /**
  28494. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28495. */
  28496. mode: number;
  28497. /**
  28498. * Define whether the camera is intermediate.
  28499. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28500. */
  28501. isIntermediate: boolean;
  28502. /**
  28503. * Define the viewport of the camera.
  28504. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28505. */
  28506. viewport: Viewport;
  28507. /**
  28508. * Restricts the camera to viewing objects with the same layerMask.
  28509. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28510. */
  28511. layerMask: number;
  28512. /**
  28513. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28514. */
  28515. fovMode: number;
  28516. /**
  28517. * Rig mode of the camera.
  28518. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28519. * This is normally controlled byt the camera themselves as internal use.
  28520. */
  28521. cameraRigMode: number;
  28522. /**
  28523. * Defines the distance between both "eyes" in case of a RIG
  28524. */
  28525. interaxialDistance: number;
  28526. /**
  28527. * Defines if stereoscopic rendering is done side by side or over under.
  28528. */
  28529. isStereoscopicSideBySide: boolean;
  28530. /**
  28531. * 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
  28532. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28533. * else in the scene. (Eg. security camera)
  28534. *
  28535. * 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)
  28536. */
  28537. customRenderTargets: RenderTargetTexture[];
  28538. /**
  28539. * When set, the camera will render to this render target instead of the default canvas
  28540. *
  28541. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28542. */
  28543. outputRenderTarget: Nullable<RenderTargetTexture>;
  28544. /**
  28545. * Observable triggered when the camera view matrix has changed.
  28546. */
  28547. onViewMatrixChangedObservable: Observable<Camera>;
  28548. /**
  28549. * Observable triggered when the camera Projection matrix has changed.
  28550. */
  28551. onProjectionMatrixChangedObservable: Observable<Camera>;
  28552. /**
  28553. * Observable triggered when the inputs have been processed.
  28554. */
  28555. onAfterCheckInputsObservable: Observable<Camera>;
  28556. /**
  28557. * Observable triggered when reset has been called and applied to the camera.
  28558. */
  28559. onRestoreStateObservable: Observable<Camera>;
  28560. /**
  28561. * Is this camera a part of a rig system?
  28562. */
  28563. isRigCamera: boolean;
  28564. /**
  28565. * If isRigCamera set to true this will be set with the parent camera.
  28566. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28567. */
  28568. rigParent?: Camera;
  28569. /** @hidden */
  28570. _cameraRigParams: any;
  28571. /** @hidden */
  28572. _rigCameras: Camera[];
  28573. /** @hidden */
  28574. _rigPostProcess: Nullable<PostProcess>;
  28575. protected _webvrViewMatrix: Matrix;
  28576. /** @hidden */
  28577. _skipRendering: boolean;
  28578. /** @hidden */
  28579. _projectionMatrix: Matrix;
  28580. /** @hidden */
  28581. _postProcesses: Nullable<PostProcess>[];
  28582. /** @hidden */
  28583. _activeMeshes: SmartArray<AbstractMesh>;
  28584. protected _globalPosition: Vector3;
  28585. /** @hidden */
  28586. _computedViewMatrix: Matrix;
  28587. private _doNotComputeProjectionMatrix;
  28588. private _transformMatrix;
  28589. private _frustumPlanes;
  28590. private _refreshFrustumPlanes;
  28591. private _storedFov;
  28592. private _stateStored;
  28593. /**
  28594. * Instantiates a new camera object.
  28595. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28596. * @see http://doc.babylonjs.com/features/cameras
  28597. * @param name Defines the name of the camera in the scene
  28598. * @param position Defines the position of the camera
  28599. * @param scene Defines the scene the camera belongs too
  28600. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28601. */
  28602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28603. /**
  28604. * Store current camera state (fov, position, etc..)
  28605. * @returns the camera
  28606. */
  28607. storeState(): Camera;
  28608. /**
  28609. * Restores the camera state values if it has been stored. You must call storeState() first
  28610. */
  28611. protected _restoreStateValues(): boolean;
  28612. /**
  28613. * Restored camera state. You must call storeState() first.
  28614. * @returns true if restored and false otherwise
  28615. */
  28616. restoreState(): boolean;
  28617. /**
  28618. * Gets the class name of the camera.
  28619. * @returns the class name
  28620. */
  28621. getClassName(): string;
  28622. /** @hidden */
  28623. readonly _isCamera: boolean;
  28624. /**
  28625. * Gets a string representation of the camera useful for debug purpose.
  28626. * @param fullDetails Defines that a more verboe level of logging is required
  28627. * @returns the string representation
  28628. */
  28629. toString(fullDetails?: boolean): string;
  28630. /**
  28631. * Gets the current world space position of the camera.
  28632. */
  28633. get globalPosition(): Vector3;
  28634. /**
  28635. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28636. * @returns the active meshe list
  28637. */
  28638. getActiveMeshes(): SmartArray<AbstractMesh>;
  28639. /**
  28640. * Check whether a mesh is part of the current active mesh list of the camera
  28641. * @param mesh Defines the mesh to check
  28642. * @returns true if active, false otherwise
  28643. */
  28644. isActiveMesh(mesh: Mesh): boolean;
  28645. /**
  28646. * Is this camera ready to be used/rendered
  28647. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28648. * @return true if the camera is ready
  28649. */
  28650. isReady(completeCheck?: boolean): boolean;
  28651. /** @hidden */
  28652. _initCache(): void;
  28653. /** @hidden */
  28654. _updateCache(ignoreParentClass?: boolean): void;
  28655. /** @hidden */
  28656. _isSynchronized(): boolean;
  28657. /** @hidden */
  28658. _isSynchronizedViewMatrix(): boolean;
  28659. /** @hidden */
  28660. _isSynchronizedProjectionMatrix(): boolean;
  28661. /**
  28662. * Attach the input controls to a specific dom element to get the input from.
  28663. * @param element Defines the element the controls should be listened from
  28664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28665. */
  28666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28667. /**
  28668. * Detach the current controls from the specified dom element.
  28669. * @param element Defines the element to stop listening the inputs from
  28670. */
  28671. detachControl(element: HTMLElement): void;
  28672. /**
  28673. * Update the camera state according to the different inputs gathered during the frame.
  28674. */
  28675. update(): void;
  28676. /** @hidden */
  28677. _checkInputs(): void;
  28678. /** @hidden */
  28679. get rigCameras(): Camera[];
  28680. /**
  28681. * Gets the post process used by the rig cameras
  28682. */
  28683. get rigPostProcess(): Nullable<PostProcess>;
  28684. /**
  28685. * Internal, gets the first post proces.
  28686. * @returns the first post process to be run on this camera.
  28687. */
  28688. _getFirstPostProcess(): Nullable<PostProcess>;
  28689. private _cascadePostProcessesToRigCams;
  28690. /**
  28691. * Attach a post process to the camera.
  28692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28693. * @param postProcess The post process to attach to the camera
  28694. * @param insertAt The position of the post process in case several of them are in use in the scene
  28695. * @returns the position the post process has been inserted at
  28696. */
  28697. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28698. /**
  28699. * Detach a post process to the camera.
  28700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28701. * @param postProcess The post process to detach from the camera
  28702. */
  28703. detachPostProcess(postProcess: PostProcess): void;
  28704. /**
  28705. * Gets the current world matrix of the camera
  28706. */
  28707. getWorldMatrix(): Matrix;
  28708. /** @hidden */
  28709. _getViewMatrix(): Matrix;
  28710. /**
  28711. * Gets the current view matrix of the camera.
  28712. * @param force forces the camera to recompute the matrix without looking at the cached state
  28713. * @returns the view matrix
  28714. */
  28715. getViewMatrix(force?: boolean): Matrix;
  28716. /**
  28717. * Freeze the projection matrix.
  28718. * It will prevent the cache check of the camera projection compute and can speed up perf
  28719. * if no parameter of the camera are meant to change
  28720. * @param projection Defines manually a projection if necessary
  28721. */
  28722. freezeProjectionMatrix(projection?: Matrix): void;
  28723. /**
  28724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28725. */
  28726. unfreezeProjectionMatrix(): void;
  28727. /**
  28728. * Gets the current projection matrix of the camera.
  28729. * @param force forces the camera to recompute the matrix without looking at the cached state
  28730. * @returns the projection matrix
  28731. */
  28732. getProjectionMatrix(force?: boolean): Matrix;
  28733. /**
  28734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28735. * @returns a Matrix
  28736. */
  28737. getTransformationMatrix(): Matrix;
  28738. private _updateFrustumPlanes;
  28739. /**
  28740. * Checks if a cullable object (mesh...) is in the camera frustum
  28741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28742. * @param target The object to check
  28743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28744. * @returns true if the object is in frustum otherwise false
  28745. */
  28746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28747. /**
  28748. * Checks if a cullable object (mesh...) is in the camera frustum
  28749. * Unlike isInFrustum this cheks the full bounding box
  28750. * @param target The object to check
  28751. * @returns true if the object is in frustum otherwise false
  28752. */
  28753. isCompletelyInFrustum(target: ICullable): boolean;
  28754. /**
  28755. * Gets a ray in the forward direction from the camera.
  28756. * @param length Defines the length of the ray to create
  28757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28758. * @param origin Defines the start point of the ray which defaults to the camera position
  28759. * @returns the forward ray
  28760. */
  28761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28762. /**
  28763. * Releases resources associated with this node.
  28764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28766. */
  28767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28768. /** @hidden */
  28769. _isLeftCamera: boolean;
  28770. /**
  28771. * Gets the left camera of a rig setup in case of Rigged Camera
  28772. */
  28773. get isLeftCamera(): boolean;
  28774. /** @hidden */
  28775. _isRightCamera: boolean;
  28776. /**
  28777. * Gets the right camera of a rig setup in case of Rigged Camera
  28778. */
  28779. get isRightCamera(): boolean;
  28780. /**
  28781. * Gets the left camera of a rig setup in case of Rigged Camera
  28782. */
  28783. get leftCamera(): Nullable<FreeCamera>;
  28784. /**
  28785. * Gets the right camera of a rig setup in case of Rigged Camera
  28786. */
  28787. get rightCamera(): Nullable<FreeCamera>;
  28788. /**
  28789. * Gets the left camera target of a rig setup in case of Rigged Camera
  28790. * @returns the target position
  28791. */
  28792. getLeftTarget(): Nullable<Vector3>;
  28793. /**
  28794. * Gets the right camera target of a rig setup in case of Rigged Camera
  28795. * @returns the target position
  28796. */
  28797. getRightTarget(): Nullable<Vector3>;
  28798. /**
  28799. * @hidden
  28800. */
  28801. setCameraRigMode(mode: number, rigParams: any): void;
  28802. /** @hidden */
  28803. static _setStereoscopicRigMode(camera: Camera): void;
  28804. /** @hidden */
  28805. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28806. /** @hidden */
  28807. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28808. /** @hidden */
  28809. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28810. /** @hidden */
  28811. _getVRProjectionMatrix(): Matrix;
  28812. protected _updateCameraRotationMatrix(): void;
  28813. protected _updateWebVRCameraRotationMatrix(): void;
  28814. /**
  28815. * This function MUST be overwritten by the different WebVR cameras available.
  28816. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28817. * @hidden
  28818. */
  28819. _getWebVRProjectionMatrix(): Matrix;
  28820. /**
  28821. * This function MUST be overwritten by the different WebVR cameras available.
  28822. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28823. * @hidden
  28824. */
  28825. _getWebVRViewMatrix(): Matrix;
  28826. /** @hidden */
  28827. setCameraRigParameter(name: string, value: any): void;
  28828. /**
  28829. * needs to be overridden by children so sub has required properties to be copied
  28830. * @hidden
  28831. */
  28832. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28833. /**
  28834. * May need to be overridden by children
  28835. * @hidden
  28836. */
  28837. _updateRigCameras(): void;
  28838. /** @hidden */
  28839. _setupInputs(): void;
  28840. /**
  28841. * Serialiaze the camera setup to a json represention
  28842. * @returns the JSON representation
  28843. */
  28844. serialize(): any;
  28845. /**
  28846. * Clones the current camera.
  28847. * @param name The cloned camera name
  28848. * @returns the cloned camera
  28849. */
  28850. clone(name: string): Camera;
  28851. /**
  28852. * Gets the direction of the camera relative to a given local axis.
  28853. * @param localAxis Defines the reference axis to provide a relative direction.
  28854. * @return the direction
  28855. */
  28856. getDirection(localAxis: Vector3): Vector3;
  28857. /**
  28858. * Returns the current camera absolute rotation
  28859. */
  28860. get absoluteRotation(): Quaternion;
  28861. /**
  28862. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28863. * @param localAxis Defines the reference axis to provide a relative direction.
  28864. * @param result Defines the vector to store the result in
  28865. */
  28866. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28867. /**
  28868. * Gets a camera constructor for a given camera type
  28869. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28870. * @param name The name of the camera the result will be able to instantiate
  28871. * @param scene The scene the result will construct the camera in
  28872. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28873. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28874. * @returns a factory method to construc the camera
  28875. */
  28876. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28877. /**
  28878. * Compute the world matrix of the camera.
  28879. * @returns the camera world matrix
  28880. */
  28881. computeWorldMatrix(): Matrix;
  28882. /**
  28883. * Parse a JSON and creates the camera from the parsed information
  28884. * @param parsedCamera The JSON to parse
  28885. * @param scene The scene to instantiate the camera in
  28886. * @returns the newly constructed camera
  28887. */
  28888. static Parse(parsedCamera: any, scene: Scene): Camera;
  28889. }
  28890. }
  28891. declare module BABYLON {
  28892. /**
  28893. * Class containing static functions to help procedurally build meshes
  28894. */
  28895. export class DiscBuilder {
  28896. /**
  28897. * Creates a plane polygonal mesh. By default, this is a disc
  28898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28899. * * 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
  28900. * * 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
  28901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28902. * * 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
  28903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28904. * @param name defines the name of the mesh
  28905. * @param options defines the options used to create the mesh
  28906. * @param scene defines the hosting scene
  28907. * @returns the plane polygonal mesh
  28908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28909. */
  28910. static CreateDisc(name: string, options: {
  28911. radius?: number;
  28912. tessellation?: number;
  28913. arc?: number;
  28914. updatable?: boolean;
  28915. sideOrientation?: number;
  28916. frontUVs?: Vector4;
  28917. backUVs?: Vector4;
  28918. }, scene?: Nullable<Scene>): Mesh;
  28919. }
  28920. }
  28921. declare module BABYLON {
  28922. /**
  28923. * Options to be used when creating a FresnelParameters.
  28924. */
  28925. export type IFresnelParametersCreationOptions = {
  28926. /**
  28927. * Define the color used on edges (grazing angle)
  28928. */
  28929. leftColor?: Color3;
  28930. /**
  28931. * Define the color used on center
  28932. */
  28933. rightColor?: Color3;
  28934. /**
  28935. * Define bias applied to computed fresnel term
  28936. */
  28937. bias?: number;
  28938. /**
  28939. * Defined the power exponent applied to fresnel term
  28940. */
  28941. power?: number;
  28942. /**
  28943. * Define if the fresnel effect is enable or not.
  28944. */
  28945. isEnabled?: boolean;
  28946. };
  28947. /**
  28948. * Serialized format for FresnelParameters.
  28949. */
  28950. export type IFresnelParametersSerialized = {
  28951. /**
  28952. * Define the color used on edges (grazing angle) [as an array]
  28953. */
  28954. leftColor: number[];
  28955. /**
  28956. * Define the color used on center [as an array]
  28957. */
  28958. rightColor: number[];
  28959. /**
  28960. * Define bias applied to computed fresnel term
  28961. */
  28962. bias: number;
  28963. /**
  28964. * Defined the power exponent applied to fresnel term
  28965. */
  28966. power?: number;
  28967. /**
  28968. * Define if the fresnel effect is enable or not.
  28969. */
  28970. isEnabled: boolean;
  28971. };
  28972. /**
  28973. * This represents all the required information to add a fresnel effect on a material:
  28974. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28975. */
  28976. export class FresnelParameters {
  28977. private _isEnabled;
  28978. /**
  28979. * Define if the fresnel effect is enable or not.
  28980. */
  28981. get isEnabled(): boolean;
  28982. set isEnabled(value: boolean);
  28983. /**
  28984. * Define the color used on edges (grazing angle)
  28985. */
  28986. leftColor: Color3;
  28987. /**
  28988. * Define the color used on center
  28989. */
  28990. rightColor: Color3;
  28991. /**
  28992. * Define bias applied to computed fresnel term
  28993. */
  28994. bias: number;
  28995. /**
  28996. * Defined the power exponent applied to fresnel term
  28997. */
  28998. power: number;
  28999. /**
  29000. * Creates a new FresnelParameters object.
  29001. *
  29002. * @param options provide your own settings to optionally to override defaults
  29003. */
  29004. constructor(options?: IFresnelParametersCreationOptions);
  29005. /**
  29006. * Clones the current fresnel and its valuues
  29007. * @returns a clone fresnel configuration
  29008. */
  29009. clone(): FresnelParameters;
  29010. /**
  29011. * Determines equality between FresnelParameters objects
  29012. * @param otherFresnelParameters defines the second operand
  29013. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29014. */
  29015. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29016. /**
  29017. * Serializes the current fresnel parameters to a JSON representation.
  29018. * @return the JSON serialization
  29019. */
  29020. serialize(): IFresnelParametersSerialized;
  29021. /**
  29022. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29023. * @param parsedFresnelParameters Define the JSON representation
  29024. * @returns the parsed parameters
  29025. */
  29026. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29027. }
  29028. }
  29029. declare module BABYLON {
  29030. /**
  29031. * This groups all the flags used to control the materials channel.
  29032. */
  29033. export class MaterialFlags {
  29034. private static _DiffuseTextureEnabled;
  29035. /**
  29036. * Are diffuse textures enabled in the application.
  29037. */
  29038. static get DiffuseTextureEnabled(): boolean;
  29039. static set DiffuseTextureEnabled(value: boolean);
  29040. private static _AmbientTextureEnabled;
  29041. /**
  29042. * Are ambient textures enabled in the application.
  29043. */
  29044. static get AmbientTextureEnabled(): boolean;
  29045. static set AmbientTextureEnabled(value: boolean);
  29046. private static _OpacityTextureEnabled;
  29047. /**
  29048. * Are opacity textures enabled in the application.
  29049. */
  29050. static get OpacityTextureEnabled(): boolean;
  29051. static set OpacityTextureEnabled(value: boolean);
  29052. private static _ReflectionTextureEnabled;
  29053. /**
  29054. * Are reflection textures enabled in the application.
  29055. */
  29056. static get ReflectionTextureEnabled(): boolean;
  29057. static set ReflectionTextureEnabled(value: boolean);
  29058. private static _EmissiveTextureEnabled;
  29059. /**
  29060. * Are emissive textures enabled in the application.
  29061. */
  29062. static get EmissiveTextureEnabled(): boolean;
  29063. static set EmissiveTextureEnabled(value: boolean);
  29064. private static _SpecularTextureEnabled;
  29065. /**
  29066. * Are specular textures enabled in the application.
  29067. */
  29068. static get SpecularTextureEnabled(): boolean;
  29069. static set SpecularTextureEnabled(value: boolean);
  29070. private static _BumpTextureEnabled;
  29071. /**
  29072. * Are bump textures enabled in the application.
  29073. */
  29074. static get BumpTextureEnabled(): boolean;
  29075. static set BumpTextureEnabled(value: boolean);
  29076. private static _LightmapTextureEnabled;
  29077. /**
  29078. * Are lightmap textures enabled in the application.
  29079. */
  29080. static get LightmapTextureEnabled(): boolean;
  29081. static set LightmapTextureEnabled(value: boolean);
  29082. private static _RefractionTextureEnabled;
  29083. /**
  29084. * Are refraction textures enabled in the application.
  29085. */
  29086. static get RefractionTextureEnabled(): boolean;
  29087. static set RefractionTextureEnabled(value: boolean);
  29088. private static _ColorGradingTextureEnabled;
  29089. /**
  29090. * Are color grading textures enabled in the application.
  29091. */
  29092. static get ColorGradingTextureEnabled(): boolean;
  29093. static set ColorGradingTextureEnabled(value: boolean);
  29094. private static _FresnelEnabled;
  29095. /**
  29096. * Are fresnels enabled in the application.
  29097. */
  29098. static get FresnelEnabled(): boolean;
  29099. static set FresnelEnabled(value: boolean);
  29100. private static _ClearCoatTextureEnabled;
  29101. /**
  29102. * Are clear coat textures enabled in the application.
  29103. */
  29104. static get ClearCoatTextureEnabled(): boolean;
  29105. static set ClearCoatTextureEnabled(value: boolean);
  29106. private static _ClearCoatBumpTextureEnabled;
  29107. /**
  29108. * Are clear coat bump textures enabled in the application.
  29109. */
  29110. static get ClearCoatBumpTextureEnabled(): boolean;
  29111. static set ClearCoatBumpTextureEnabled(value: boolean);
  29112. private static _ClearCoatTintTextureEnabled;
  29113. /**
  29114. * Are clear coat tint textures enabled in the application.
  29115. */
  29116. static get ClearCoatTintTextureEnabled(): boolean;
  29117. static set ClearCoatTintTextureEnabled(value: boolean);
  29118. private static _SheenTextureEnabled;
  29119. /**
  29120. * Are sheen textures enabled in the application.
  29121. */
  29122. static get SheenTextureEnabled(): boolean;
  29123. static set SheenTextureEnabled(value: boolean);
  29124. private static _AnisotropicTextureEnabled;
  29125. /**
  29126. * Are anisotropic textures enabled in the application.
  29127. */
  29128. static get AnisotropicTextureEnabled(): boolean;
  29129. static set AnisotropicTextureEnabled(value: boolean);
  29130. private static _ThicknessTextureEnabled;
  29131. /**
  29132. * Are thickness textures enabled in the application.
  29133. */
  29134. static get ThicknessTextureEnabled(): boolean;
  29135. static set ThicknessTextureEnabled(value: boolean);
  29136. }
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var defaultFragmentDeclaration: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var defaultUboDeclaration: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var lightFragmentDeclaration: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var lightUboDeclaration: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var lightsFragmentFunctions: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var shadowsFragmentFunctions: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var fresnelFunction: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var bumpFragmentMainFunctions: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var bumpFragmentFunctions: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var logDepthDeclaration: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var bumpFragment: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var depthPrePass: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var lightFragment: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var logDepthFragment: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var defaultPixelShader: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var defaultVertexDeclaration: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export var bumpVertexDeclaration: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export var bumpVertex: {
  29260. name: string;
  29261. shader: string;
  29262. };
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export var fogVertex: {
  29267. name: string;
  29268. shader: string;
  29269. };
  29270. }
  29271. declare module BABYLON {
  29272. /** @hidden */
  29273. export var shadowsVertex: {
  29274. name: string;
  29275. shader: string;
  29276. };
  29277. }
  29278. declare module BABYLON {
  29279. /** @hidden */
  29280. export var pointCloudVertex: {
  29281. name: string;
  29282. shader: string;
  29283. };
  29284. }
  29285. declare module BABYLON {
  29286. /** @hidden */
  29287. export var logDepthVertex: {
  29288. name: string;
  29289. shader: string;
  29290. };
  29291. }
  29292. declare module BABYLON {
  29293. /** @hidden */
  29294. export var defaultVertexShader: {
  29295. name: string;
  29296. shader: string;
  29297. };
  29298. }
  29299. declare module BABYLON {
  29300. /** @hidden */
  29301. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29302. MAINUV1: boolean;
  29303. MAINUV2: boolean;
  29304. DIFFUSE: boolean;
  29305. DIFFUSEDIRECTUV: number;
  29306. AMBIENT: boolean;
  29307. AMBIENTDIRECTUV: number;
  29308. OPACITY: boolean;
  29309. OPACITYDIRECTUV: number;
  29310. OPACITYRGB: boolean;
  29311. REFLECTION: boolean;
  29312. EMISSIVE: boolean;
  29313. EMISSIVEDIRECTUV: number;
  29314. SPECULAR: boolean;
  29315. SPECULARDIRECTUV: number;
  29316. BUMP: boolean;
  29317. BUMPDIRECTUV: number;
  29318. PARALLAX: boolean;
  29319. PARALLAXOCCLUSION: boolean;
  29320. SPECULAROVERALPHA: boolean;
  29321. CLIPPLANE: boolean;
  29322. CLIPPLANE2: boolean;
  29323. CLIPPLANE3: boolean;
  29324. CLIPPLANE4: boolean;
  29325. CLIPPLANE5: boolean;
  29326. CLIPPLANE6: boolean;
  29327. ALPHATEST: boolean;
  29328. DEPTHPREPASS: boolean;
  29329. ALPHAFROMDIFFUSE: boolean;
  29330. POINTSIZE: boolean;
  29331. FOG: boolean;
  29332. SPECULARTERM: boolean;
  29333. DIFFUSEFRESNEL: boolean;
  29334. OPACITYFRESNEL: boolean;
  29335. REFLECTIONFRESNEL: boolean;
  29336. REFRACTIONFRESNEL: boolean;
  29337. EMISSIVEFRESNEL: boolean;
  29338. FRESNEL: boolean;
  29339. NORMAL: boolean;
  29340. UV1: boolean;
  29341. UV2: boolean;
  29342. VERTEXCOLOR: boolean;
  29343. VERTEXALPHA: boolean;
  29344. NUM_BONE_INFLUENCERS: number;
  29345. BonesPerMesh: number;
  29346. BONETEXTURE: boolean;
  29347. INSTANCES: boolean;
  29348. THIN_INSTANCES: boolean;
  29349. GLOSSINESS: boolean;
  29350. ROUGHNESS: boolean;
  29351. EMISSIVEASILLUMINATION: boolean;
  29352. LINKEMISSIVEWITHDIFFUSE: boolean;
  29353. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29354. LIGHTMAP: boolean;
  29355. LIGHTMAPDIRECTUV: number;
  29356. OBJECTSPACE_NORMALMAP: boolean;
  29357. USELIGHTMAPASSHADOWMAP: boolean;
  29358. REFLECTIONMAP_3D: boolean;
  29359. REFLECTIONMAP_SPHERICAL: boolean;
  29360. REFLECTIONMAP_PLANAR: boolean;
  29361. REFLECTIONMAP_CUBIC: boolean;
  29362. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29363. REFLECTIONMAP_PROJECTION: boolean;
  29364. REFLECTIONMAP_SKYBOX: boolean;
  29365. REFLECTIONMAP_EXPLICIT: boolean;
  29366. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29367. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29368. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29369. INVERTCUBICMAP: boolean;
  29370. LOGARITHMICDEPTH: boolean;
  29371. REFRACTION: boolean;
  29372. REFRACTIONMAP_3D: boolean;
  29373. REFLECTIONOVERALPHA: boolean;
  29374. TWOSIDEDLIGHTING: boolean;
  29375. SHADOWFLOAT: boolean;
  29376. MORPHTARGETS: boolean;
  29377. MORPHTARGETS_NORMAL: boolean;
  29378. MORPHTARGETS_TANGENT: boolean;
  29379. MORPHTARGETS_UV: boolean;
  29380. NUM_MORPH_INFLUENCERS: number;
  29381. NONUNIFORMSCALING: boolean;
  29382. PREMULTIPLYALPHA: boolean;
  29383. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29384. ALPHABLEND: boolean;
  29385. RGBDLIGHTMAP: boolean;
  29386. RGBDREFLECTION: boolean;
  29387. RGBDREFRACTION: boolean;
  29388. IMAGEPROCESSING: boolean;
  29389. VIGNETTE: boolean;
  29390. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29391. VIGNETTEBLENDMODEOPAQUE: boolean;
  29392. TONEMAPPING: boolean;
  29393. TONEMAPPING_ACES: boolean;
  29394. CONTRAST: boolean;
  29395. COLORCURVES: boolean;
  29396. COLORGRADING: boolean;
  29397. COLORGRADING3D: boolean;
  29398. SAMPLER3DGREENDEPTH: boolean;
  29399. SAMPLER3DBGRMAP: boolean;
  29400. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29401. MULTIVIEW: boolean;
  29402. /**
  29403. * If the reflection texture on this material is in linear color space
  29404. * @hidden
  29405. */
  29406. IS_REFLECTION_LINEAR: boolean;
  29407. /**
  29408. * If the refraction texture on this material is in linear color space
  29409. * @hidden
  29410. */
  29411. IS_REFRACTION_LINEAR: boolean;
  29412. EXPOSURE: boolean;
  29413. constructor();
  29414. setReflectionMode(modeToEnable: string): void;
  29415. }
  29416. /**
  29417. * This is the default material used in Babylon. It is the best trade off between quality
  29418. * and performances.
  29419. * @see http://doc.babylonjs.com/babylon101/materials
  29420. */
  29421. export class StandardMaterial extends PushMaterial {
  29422. private _diffuseTexture;
  29423. /**
  29424. * The basic texture of the material as viewed under a light.
  29425. */
  29426. diffuseTexture: Nullable<BaseTexture>;
  29427. private _ambientTexture;
  29428. /**
  29429. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29430. */
  29431. ambientTexture: Nullable<BaseTexture>;
  29432. private _opacityTexture;
  29433. /**
  29434. * Define the transparency of the material from a texture.
  29435. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29436. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29437. */
  29438. opacityTexture: Nullable<BaseTexture>;
  29439. private _reflectionTexture;
  29440. /**
  29441. * Define the texture used to display the reflection.
  29442. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29443. */
  29444. reflectionTexture: Nullable<BaseTexture>;
  29445. private _emissiveTexture;
  29446. /**
  29447. * Define texture of the material as if self lit.
  29448. * This will be mixed in the final result even in the absence of light.
  29449. */
  29450. emissiveTexture: Nullable<BaseTexture>;
  29451. private _specularTexture;
  29452. /**
  29453. * Define how the color and intensity of the highlight given by the light in the material.
  29454. */
  29455. specularTexture: Nullable<BaseTexture>;
  29456. private _bumpTexture;
  29457. /**
  29458. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29459. * 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.
  29460. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29461. */
  29462. bumpTexture: Nullable<BaseTexture>;
  29463. private _lightmapTexture;
  29464. /**
  29465. * Complex lighting can be computationally expensive to compute at runtime.
  29466. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29467. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29468. */
  29469. lightmapTexture: Nullable<BaseTexture>;
  29470. private _refractionTexture;
  29471. /**
  29472. * Define the texture used to display the refraction.
  29473. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29474. */
  29475. refractionTexture: Nullable<BaseTexture>;
  29476. /**
  29477. * The color of the material lit by the environmental background lighting.
  29478. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29479. */
  29480. ambientColor: Color3;
  29481. /**
  29482. * The basic color of the material as viewed under a light.
  29483. */
  29484. diffuseColor: Color3;
  29485. /**
  29486. * Define how the color and intensity of the highlight given by the light in the material.
  29487. */
  29488. specularColor: Color3;
  29489. /**
  29490. * Define the color of the material as if self lit.
  29491. * This will be mixed in the final result even in the absence of light.
  29492. */
  29493. emissiveColor: Color3;
  29494. /**
  29495. * Defines how sharp are the highlights in the material.
  29496. * The bigger the value the sharper giving a more glossy feeling to the result.
  29497. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29498. */
  29499. specularPower: number;
  29500. private _useAlphaFromDiffuseTexture;
  29501. /**
  29502. * Does the transparency come from the diffuse texture alpha channel.
  29503. */
  29504. useAlphaFromDiffuseTexture: boolean;
  29505. private _useEmissiveAsIllumination;
  29506. /**
  29507. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29508. */
  29509. useEmissiveAsIllumination: boolean;
  29510. private _linkEmissiveWithDiffuse;
  29511. /**
  29512. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29513. * the emissive level when the final color is close to one.
  29514. */
  29515. linkEmissiveWithDiffuse: boolean;
  29516. private _useSpecularOverAlpha;
  29517. /**
  29518. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29519. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29520. */
  29521. useSpecularOverAlpha: boolean;
  29522. private _useReflectionOverAlpha;
  29523. /**
  29524. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29525. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29526. */
  29527. useReflectionOverAlpha: boolean;
  29528. private _disableLighting;
  29529. /**
  29530. * Does lights from the scene impacts this material.
  29531. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29532. */
  29533. disableLighting: boolean;
  29534. private _useObjectSpaceNormalMap;
  29535. /**
  29536. * Allows using an object space normal map (instead of tangent space).
  29537. */
  29538. useObjectSpaceNormalMap: boolean;
  29539. private _useParallax;
  29540. /**
  29541. * Is parallax enabled or not.
  29542. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29543. */
  29544. useParallax: boolean;
  29545. private _useParallaxOcclusion;
  29546. /**
  29547. * Is parallax occlusion enabled or not.
  29548. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29549. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29550. */
  29551. useParallaxOcclusion: boolean;
  29552. /**
  29553. * 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.
  29554. */
  29555. parallaxScaleBias: number;
  29556. private _roughness;
  29557. /**
  29558. * Helps to define how blurry the reflections should appears in the material.
  29559. */
  29560. roughness: number;
  29561. /**
  29562. * In case of refraction, define the value of the index of refraction.
  29563. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29564. */
  29565. indexOfRefraction: number;
  29566. /**
  29567. * Invert the refraction texture alongside the y axis.
  29568. * It can be useful with procedural textures or probe for instance.
  29569. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29570. */
  29571. invertRefractionY: boolean;
  29572. /**
  29573. * Defines the alpha limits in alpha test mode.
  29574. */
  29575. alphaCutOff: number;
  29576. private _useLightmapAsShadowmap;
  29577. /**
  29578. * In case of light mapping, define whether the map contains light or shadow informations.
  29579. */
  29580. useLightmapAsShadowmap: boolean;
  29581. private _diffuseFresnelParameters;
  29582. /**
  29583. * Define the diffuse fresnel parameters of the material.
  29584. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29585. */
  29586. diffuseFresnelParameters: FresnelParameters;
  29587. private _opacityFresnelParameters;
  29588. /**
  29589. * Define the opacity fresnel parameters of the material.
  29590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29591. */
  29592. opacityFresnelParameters: FresnelParameters;
  29593. private _reflectionFresnelParameters;
  29594. /**
  29595. * Define the reflection fresnel parameters of the material.
  29596. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29597. */
  29598. reflectionFresnelParameters: FresnelParameters;
  29599. private _refractionFresnelParameters;
  29600. /**
  29601. * Define the refraction fresnel parameters of the material.
  29602. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29603. */
  29604. refractionFresnelParameters: FresnelParameters;
  29605. private _emissiveFresnelParameters;
  29606. /**
  29607. * Define the emissive fresnel parameters of the material.
  29608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29609. */
  29610. emissiveFresnelParameters: FresnelParameters;
  29611. private _useReflectionFresnelFromSpecular;
  29612. /**
  29613. * If true automatically deducts the fresnels values from the material specularity.
  29614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29615. */
  29616. useReflectionFresnelFromSpecular: boolean;
  29617. private _useGlossinessFromSpecularMapAlpha;
  29618. /**
  29619. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29620. */
  29621. useGlossinessFromSpecularMapAlpha: boolean;
  29622. private _maxSimultaneousLights;
  29623. /**
  29624. * Defines the maximum number of lights that can be used in the material
  29625. */
  29626. maxSimultaneousLights: number;
  29627. private _invertNormalMapX;
  29628. /**
  29629. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29630. */
  29631. invertNormalMapX: boolean;
  29632. private _invertNormalMapY;
  29633. /**
  29634. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29635. */
  29636. invertNormalMapY: boolean;
  29637. private _twoSidedLighting;
  29638. /**
  29639. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29640. */
  29641. twoSidedLighting: boolean;
  29642. /**
  29643. * Default configuration related to image processing available in the standard Material.
  29644. */
  29645. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29646. /**
  29647. * Gets the image processing configuration used either in this material.
  29648. */
  29649. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29650. /**
  29651. * Sets the Default image processing configuration used either in the this material.
  29652. *
  29653. * If sets to null, the scene one is in use.
  29654. */
  29655. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29656. /**
  29657. * Keep track of the image processing observer to allow dispose and replace.
  29658. */
  29659. private _imageProcessingObserver;
  29660. /**
  29661. * Attaches a new image processing configuration to the Standard Material.
  29662. * @param configuration
  29663. */
  29664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29665. /**
  29666. * Gets wether the color curves effect is enabled.
  29667. */
  29668. get cameraColorCurvesEnabled(): boolean;
  29669. /**
  29670. * Sets wether the color curves effect is enabled.
  29671. */
  29672. set cameraColorCurvesEnabled(value: boolean);
  29673. /**
  29674. * Gets wether the color grading effect is enabled.
  29675. */
  29676. get cameraColorGradingEnabled(): boolean;
  29677. /**
  29678. * Gets wether the color grading effect is enabled.
  29679. */
  29680. set cameraColorGradingEnabled(value: boolean);
  29681. /**
  29682. * Gets wether tonemapping is enabled or not.
  29683. */
  29684. get cameraToneMappingEnabled(): boolean;
  29685. /**
  29686. * Sets wether tonemapping is enabled or not
  29687. */
  29688. set cameraToneMappingEnabled(value: boolean);
  29689. /**
  29690. * The camera exposure used on this material.
  29691. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29692. * This corresponds to a photographic exposure.
  29693. */
  29694. get cameraExposure(): number;
  29695. /**
  29696. * The camera exposure used on this material.
  29697. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29698. * This corresponds to a photographic exposure.
  29699. */
  29700. set cameraExposure(value: number);
  29701. /**
  29702. * Gets The camera contrast used on this material.
  29703. */
  29704. get cameraContrast(): number;
  29705. /**
  29706. * Sets The camera contrast used on this material.
  29707. */
  29708. set cameraContrast(value: number);
  29709. /**
  29710. * Gets the Color Grading 2D Lookup Texture.
  29711. */
  29712. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29713. /**
  29714. * Sets the Color Grading 2D Lookup Texture.
  29715. */
  29716. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29717. /**
  29718. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29719. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29720. * 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;
  29721. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29722. */
  29723. get cameraColorCurves(): Nullable<ColorCurves>;
  29724. /**
  29725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29727. * 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;
  29728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29729. */
  29730. set cameraColorCurves(value: Nullable<ColorCurves>);
  29731. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29732. protected _worldViewProjectionMatrix: Matrix;
  29733. protected _globalAmbientColor: Color3;
  29734. protected _useLogarithmicDepth: boolean;
  29735. protected _rebuildInParallel: boolean;
  29736. /**
  29737. * Instantiates a new standard material.
  29738. * This is the default material used in Babylon. It is the best trade off between quality
  29739. * and performances.
  29740. * @see http://doc.babylonjs.com/babylon101/materials
  29741. * @param name Define the name of the material in the scene
  29742. * @param scene Define the scene the material belong to
  29743. */
  29744. constructor(name: string, scene: Scene);
  29745. /**
  29746. * Gets a boolean indicating that current material needs to register RTT
  29747. */
  29748. get hasRenderTargetTextures(): boolean;
  29749. /**
  29750. * Gets the current class name of the material e.g. "StandardMaterial"
  29751. * Mainly use in serialization.
  29752. * @returns the class name
  29753. */
  29754. getClassName(): string;
  29755. /**
  29756. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29757. * You can try switching to logarithmic depth.
  29758. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29759. */
  29760. get useLogarithmicDepth(): boolean;
  29761. set useLogarithmicDepth(value: boolean);
  29762. /**
  29763. * Specifies if the material will require alpha blending
  29764. * @returns a boolean specifying if alpha blending is needed
  29765. */
  29766. needAlphaBlending(): boolean;
  29767. /**
  29768. * Specifies if this material should be rendered in alpha test mode
  29769. * @returns a boolean specifying if an alpha test is needed.
  29770. */
  29771. needAlphaTesting(): boolean;
  29772. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29773. /**
  29774. * Get the texture used for alpha test purpose.
  29775. * @returns the diffuse texture in case of the standard material.
  29776. */
  29777. getAlphaTestTexture(): Nullable<BaseTexture>;
  29778. /**
  29779. * Get if the submesh is ready to be used and all its information available.
  29780. * Child classes can use it to update shaders
  29781. * @param mesh defines the mesh to check
  29782. * @param subMesh defines which submesh to check
  29783. * @param useInstances specifies that instances should be used
  29784. * @returns a boolean indicating that the submesh is ready or not
  29785. */
  29786. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29787. /**
  29788. * Builds the material UBO layouts.
  29789. * Used internally during the effect preparation.
  29790. */
  29791. buildUniformLayout(): void;
  29792. /**
  29793. * Unbinds the material from the mesh
  29794. */
  29795. unbind(): void;
  29796. /**
  29797. * Binds the submesh to this material by preparing the effect and shader to draw
  29798. * @param world defines the world transformation matrix
  29799. * @param mesh defines the mesh containing the submesh
  29800. * @param subMesh defines the submesh to bind the material to
  29801. */
  29802. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29803. /**
  29804. * Get the list of animatables in the material.
  29805. * @returns the list of animatables object used in the material
  29806. */
  29807. getAnimatables(): IAnimatable[];
  29808. /**
  29809. * Gets the active textures from the material
  29810. * @returns an array of textures
  29811. */
  29812. getActiveTextures(): BaseTexture[];
  29813. /**
  29814. * Specifies if the material uses a texture
  29815. * @param texture defines the texture to check against the material
  29816. * @returns a boolean specifying if the material uses the texture
  29817. */
  29818. hasTexture(texture: BaseTexture): boolean;
  29819. /**
  29820. * Disposes the material
  29821. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29822. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29823. */
  29824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29825. /**
  29826. * Makes a duplicate of the material, and gives it a new name
  29827. * @param name defines the new name for the duplicated material
  29828. * @returns the cloned material
  29829. */
  29830. clone(name: string): StandardMaterial;
  29831. /**
  29832. * Serializes this material in a JSON representation
  29833. * @returns the serialized material object
  29834. */
  29835. serialize(): any;
  29836. /**
  29837. * Creates a standard material from parsed material data
  29838. * @param source defines the JSON representation of the material
  29839. * @param scene defines the hosting scene
  29840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29841. * @returns a new standard material
  29842. */
  29843. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29844. /**
  29845. * Are diffuse textures enabled in the application.
  29846. */
  29847. static get DiffuseTextureEnabled(): boolean;
  29848. static set DiffuseTextureEnabled(value: boolean);
  29849. /**
  29850. * Are ambient textures enabled in the application.
  29851. */
  29852. static get AmbientTextureEnabled(): boolean;
  29853. static set AmbientTextureEnabled(value: boolean);
  29854. /**
  29855. * Are opacity textures enabled in the application.
  29856. */
  29857. static get OpacityTextureEnabled(): boolean;
  29858. static set OpacityTextureEnabled(value: boolean);
  29859. /**
  29860. * Are reflection textures enabled in the application.
  29861. */
  29862. static get ReflectionTextureEnabled(): boolean;
  29863. static set ReflectionTextureEnabled(value: boolean);
  29864. /**
  29865. * Are emissive textures enabled in the application.
  29866. */
  29867. static get EmissiveTextureEnabled(): boolean;
  29868. static set EmissiveTextureEnabled(value: boolean);
  29869. /**
  29870. * Are specular textures enabled in the application.
  29871. */
  29872. static get SpecularTextureEnabled(): boolean;
  29873. static set SpecularTextureEnabled(value: boolean);
  29874. /**
  29875. * Are bump textures enabled in the application.
  29876. */
  29877. static get BumpTextureEnabled(): boolean;
  29878. static set BumpTextureEnabled(value: boolean);
  29879. /**
  29880. * Are lightmap textures enabled in the application.
  29881. */
  29882. static get LightmapTextureEnabled(): boolean;
  29883. static set LightmapTextureEnabled(value: boolean);
  29884. /**
  29885. * Are refraction textures enabled in the application.
  29886. */
  29887. static get RefractionTextureEnabled(): boolean;
  29888. static set RefractionTextureEnabled(value: boolean);
  29889. /**
  29890. * Are color grading textures enabled in the application.
  29891. */
  29892. static get ColorGradingTextureEnabled(): boolean;
  29893. static set ColorGradingTextureEnabled(value: boolean);
  29894. /**
  29895. * Are fresnels enabled in the application.
  29896. */
  29897. static get FresnelEnabled(): boolean;
  29898. static set FresnelEnabled(value: boolean);
  29899. }
  29900. }
  29901. declare module BABYLON {
  29902. /**
  29903. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29904. *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.
  29905. * The SPS is also a particle system. It provides some methods to manage the particles.
  29906. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29907. *
  29908. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29909. */
  29910. export class SolidParticleSystem implements IDisposable {
  29911. /**
  29912. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29913. * Example : var p = SPS.particles[i];
  29914. */
  29915. particles: SolidParticle[];
  29916. /**
  29917. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29918. */
  29919. nbParticles: number;
  29920. /**
  29921. * If the particles must ever face the camera (default false). Useful for planar particles.
  29922. */
  29923. billboard: boolean;
  29924. /**
  29925. * Recompute normals when adding a shape
  29926. */
  29927. recomputeNormals: boolean;
  29928. /**
  29929. * This a counter ofr your own usage. It's not set by any SPS functions.
  29930. */
  29931. counter: number;
  29932. /**
  29933. * The SPS name. This name is also given to the underlying mesh.
  29934. */
  29935. name: string;
  29936. /**
  29937. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29938. */
  29939. mesh: Mesh;
  29940. /**
  29941. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29942. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29943. */
  29944. vars: any;
  29945. /**
  29946. * This array is populated when the SPS is set as 'pickable'.
  29947. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29948. * Each element of this array is an object `{idx: int, faceId: int}`.
  29949. * `idx` is the picked particle index in the `SPS.particles` array
  29950. * `faceId` is the picked face index counted within this particle.
  29951. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29952. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29953. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29954. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29955. */
  29956. pickedParticles: {
  29957. idx: number;
  29958. faceId: number;
  29959. }[];
  29960. /**
  29961. * This array is populated when the SPS is set as 'pickable'
  29962. * Each key of this array is a submesh index.
  29963. * Each element of this array is a second array defined like this :
  29964. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29965. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29966. * `idx` is the picked particle index in the `SPS.particles` array
  29967. * `faceId` is the picked face index counted within this particle.
  29968. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29969. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29970. */
  29971. pickedBySubMesh: {
  29972. idx: number;
  29973. faceId: number;
  29974. }[][];
  29975. /**
  29976. * This array is populated when `enableDepthSort` is set to true.
  29977. * Each element of this array is an instance of the class DepthSortedParticle.
  29978. */
  29979. depthSortedParticles: DepthSortedParticle[];
  29980. /**
  29981. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29982. * @hidden
  29983. */
  29984. _bSphereOnly: boolean;
  29985. /**
  29986. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29987. * @hidden
  29988. */
  29989. _bSphereRadiusFactor: number;
  29990. private _scene;
  29991. private _positions;
  29992. private _indices;
  29993. private _normals;
  29994. private _colors;
  29995. private _uvs;
  29996. private _indices32;
  29997. private _positions32;
  29998. private _normals32;
  29999. private _fixedNormal32;
  30000. private _colors32;
  30001. private _uvs32;
  30002. private _index;
  30003. private _updatable;
  30004. private _pickable;
  30005. private _isVisibilityBoxLocked;
  30006. private _alwaysVisible;
  30007. private _depthSort;
  30008. private _expandable;
  30009. private _shapeCounter;
  30010. private _copy;
  30011. private _color;
  30012. private _computeParticleColor;
  30013. private _computeParticleTexture;
  30014. private _computeParticleRotation;
  30015. private _computeParticleVertex;
  30016. private _computeBoundingBox;
  30017. private _depthSortParticles;
  30018. private _camera;
  30019. private _mustUnrotateFixedNormals;
  30020. private _particlesIntersect;
  30021. private _needs32Bits;
  30022. private _isNotBuilt;
  30023. private _lastParticleId;
  30024. private _idxOfId;
  30025. private _multimaterialEnabled;
  30026. private _useModelMaterial;
  30027. private _indicesByMaterial;
  30028. private _materialIndexes;
  30029. private _depthSortFunction;
  30030. private _materialSortFunction;
  30031. private _materials;
  30032. private _multimaterial;
  30033. private _materialIndexesById;
  30034. private _defaultMaterial;
  30035. private _autoUpdateSubMeshes;
  30036. private _tmpVertex;
  30037. /**
  30038. * Creates a SPS (Solid Particle System) object.
  30039. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30040. * @param scene (Scene) is the scene in which the SPS is added.
  30041. * @param options defines the options of the sps e.g.
  30042. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30043. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30044. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30045. * * 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.
  30046. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30047. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30048. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30049. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30050. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30051. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30052. */
  30053. constructor(name: string, scene: Scene, options?: {
  30054. updatable?: boolean;
  30055. isPickable?: boolean;
  30056. enableDepthSort?: boolean;
  30057. particleIntersection?: boolean;
  30058. boundingSphereOnly?: boolean;
  30059. bSphereRadiusFactor?: number;
  30060. expandable?: boolean;
  30061. useModelMaterial?: boolean;
  30062. enableMultiMaterial?: boolean;
  30063. });
  30064. /**
  30065. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30066. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30067. * @returns the created mesh
  30068. */
  30069. buildMesh(): Mesh;
  30070. /**
  30071. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30072. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30073. * Thus the particles generated from `digest()` have their property `position` set yet.
  30074. * @param mesh ( Mesh ) is the mesh to be digested
  30075. * @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
  30076. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30077. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30078. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30079. * @returns the current SPS
  30080. */
  30081. digest(mesh: Mesh, options?: {
  30082. facetNb?: number;
  30083. number?: number;
  30084. delta?: number;
  30085. storage?: [];
  30086. }): SolidParticleSystem;
  30087. /**
  30088. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30089. * @hidden
  30090. */
  30091. private _unrotateFixedNormals;
  30092. /**
  30093. * Resets the temporary working copy particle
  30094. * @hidden
  30095. */
  30096. private _resetCopy;
  30097. /**
  30098. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30099. * @param p the current index in the positions array to be updated
  30100. * @param ind the current index in the indices array
  30101. * @param shape a Vector3 array, the shape geometry
  30102. * @param positions the positions array to be updated
  30103. * @param meshInd the shape indices array
  30104. * @param indices the indices array to be updated
  30105. * @param meshUV the shape uv array
  30106. * @param uvs the uv array to be updated
  30107. * @param meshCol the shape color array
  30108. * @param colors the color array to be updated
  30109. * @param meshNor the shape normals array
  30110. * @param normals the normals array to be updated
  30111. * @param idx the particle index
  30112. * @param idxInShape the particle index in its shape
  30113. * @param options the addShape() method passed options
  30114. * @model the particle model
  30115. * @hidden
  30116. */
  30117. private _meshBuilder;
  30118. /**
  30119. * Returns a shape Vector3 array from positions float array
  30120. * @param positions float array
  30121. * @returns a vector3 array
  30122. * @hidden
  30123. */
  30124. private _posToShape;
  30125. /**
  30126. * Returns a shapeUV array from a float uvs (array deep copy)
  30127. * @param uvs as a float array
  30128. * @returns a shapeUV array
  30129. * @hidden
  30130. */
  30131. private _uvsToShapeUV;
  30132. /**
  30133. * Adds a new particle object in the particles array
  30134. * @param idx particle index in particles array
  30135. * @param id particle id
  30136. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30137. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30138. * @param model particle ModelShape object
  30139. * @param shapeId model shape identifier
  30140. * @param idxInShape index of the particle in the current model
  30141. * @param bInfo model bounding info object
  30142. * @param storage target storage array, if any
  30143. * @hidden
  30144. */
  30145. private _addParticle;
  30146. /**
  30147. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30148. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30149. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30150. * @param nb (positive integer) the number of particles to be created from this model
  30151. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30152. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30153. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30154. * @returns the number of shapes in the system
  30155. */
  30156. addShape(mesh: Mesh, nb: number, options?: {
  30157. positionFunction?: any;
  30158. vertexFunction?: any;
  30159. storage?: [];
  30160. }): number;
  30161. /**
  30162. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30163. * @hidden
  30164. */
  30165. private _rebuildParticle;
  30166. /**
  30167. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30168. * @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.
  30169. * @returns the SPS.
  30170. */
  30171. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30172. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30173. * Returns an array with the removed particles.
  30174. * 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.
  30175. * The SPS can't be empty so at least one particle needs to remain in place.
  30176. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30177. * @param start index of the first particle to remove
  30178. * @param end index of the last particle to remove (included)
  30179. * @returns an array populated with the removed particles
  30180. */
  30181. removeParticles(start: number, end: number): SolidParticle[];
  30182. /**
  30183. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30184. * @param solidParticleArray an array populated with Solid Particles objects
  30185. * @returns the SPS
  30186. */
  30187. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30188. /**
  30189. * Creates a new particle and modifies the SPS mesh geometry :
  30190. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30191. * - calls _addParticle() to populate the particle array
  30192. * factorized code from addShape() and insertParticlesFromArray()
  30193. * @param idx particle index in the particles array
  30194. * @param i particle index in its shape
  30195. * @param modelShape particle ModelShape object
  30196. * @param shape shape vertex array
  30197. * @param meshInd shape indices array
  30198. * @param meshUV shape uv array
  30199. * @param meshCol shape color array
  30200. * @param meshNor shape normals array
  30201. * @param bbInfo shape bounding info
  30202. * @param storage target particle storage
  30203. * @options addShape() passed options
  30204. * @hidden
  30205. */
  30206. private _insertNewParticle;
  30207. /**
  30208. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30209. * This method calls `updateParticle()` for each particle of the SPS.
  30210. * For an animated SPS, it is usually called within the render loop.
  30211. * 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.
  30212. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30213. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30214. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30215. * @returns the SPS.
  30216. */
  30217. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30218. /**
  30219. * Disposes the SPS.
  30220. */
  30221. dispose(): void;
  30222. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30223. * idx is the particle index in the SPS
  30224. * faceId is the picked face index counted within this particle.
  30225. * Returns null if the pickInfo can't identify a picked particle.
  30226. * @param pickingInfo (PickingInfo object)
  30227. * @returns {idx: number, faceId: number} or null
  30228. */
  30229. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30230. idx: number;
  30231. faceId: number;
  30232. }>;
  30233. /**
  30234. * Returns a SolidParticle object from its identifier : particle.id
  30235. * @param id (integer) the particle Id
  30236. * @returns the searched particle or null if not found in the SPS.
  30237. */
  30238. getParticleById(id: number): Nullable<SolidParticle>;
  30239. /**
  30240. * Returns a new array populated with the particles having the passed shapeId.
  30241. * @param shapeId (integer) the shape identifier
  30242. * @returns a new solid particle array
  30243. */
  30244. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30245. /**
  30246. * Populates the passed array "ref" with the particles having the passed shapeId.
  30247. * @param shapeId the shape identifier
  30248. * @returns the SPS
  30249. * @param ref
  30250. */
  30251. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30252. /**
  30253. * Computes the required SubMeshes according the materials assigned to the particles.
  30254. * @returns the solid particle system.
  30255. * Does nothing if called before the SPS mesh is built.
  30256. */
  30257. computeSubMeshes(): SolidParticleSystem;
  30258. /**
  30259. * Sorts the solid particles by material when MultiMaterial is enabled.
  30260. * Updates the indices32 array.
  30261. * Updates the indicesByMaterial array.
  30262. * Updates the mesh indices array.
  30263. * @returns the SPS
  30264. * @hidden
  30265. */
  30266. private _sortParticlesByMaterial;
  30267. /**
  30268. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30269. * @hidden
  30270. */
  30271. private _setMaterialIndexesById;
  30272. /**
  30273. * Returns an array with unique values of Materials from the passed array
  30274. * @param array the material array to be checked and filtered
  30275. * @hidden
  30276. */
  30277. private _filterUniqueMaterialId;
  30278. /**
  30279. * Sets a new Standard Material as _defaultMaterial if not already set.
  30280. * @hidden
  30281. */
  30282. private _setDefaultMaterial;
  30283. /**
  30284. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30286. * @returns the SPS.
  30287. */
  30288. refreshVisibleSize(): SolidParticleSystem;
  30289. /**
  30290. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30291. * @param size the size (float) of the visibility box
  30292. * note : this doesn't lock the SPS mesh bounding box.
  30293. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30294. */
  30295. setVisibilityBox(size: number): void;
  30296. /**
  30297. * Gets whether the SPS as always visible or not
  30298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30299. */
  30300. get isAlwaysVisible(): boolean;
  30301. /**
  30302. * Sets the SPS as always visible or not
  30303. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30304. */
  30305. set isAlwaysVisible(val: boolean);
  30306. /**
  30307. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30308. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30309. */
  30310. set isVisibilityBoxLocked(val: boolean);
  30311. /**
  30312. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30313. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30314. */
  30315. get isVisibilityBoxLocked(): boolean;
  30316. /**
  30317. * Tells to `setParticles()` to compute the particle rotations or not.
  30318. * Default value : true. The SPS is faster when it's set to false.
  30319. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30320. */
  30321. set computeParticleRotation(val: boolean);
  30322. /**
  30323. * Tells to `setParticles()` to compute the particle colors or not.
  30324. * Default value : true. The SPS is faster when it's set to false.
  30325. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30326. */
  30327. set computeParticleColor(val: boolean);
  30328. set computeParticleTexture(val: boolean);
  30329. /**
  30330. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30331. * Default value : false. The SPS is faster when it's set to false.
  30332. * Note : the particle custom vertex positions aren't stored values.
  30333. */
  30334. set computeParticleVertex(val: boolean);
  30335. /**
  30336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30337. */
  30338. set computeBoundingBox(val: boolean);
  30339. /**
  30340. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30342. * Default : `true`
  30343. */
  30344. set depthSortParticles(val: boolean);
  30345. /**
  30346. * Gets if `setParticles()` computes the particle rotations or not.
  30347. * Default value : true. The SPS is faster when it's set to false.
  30348. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30349. */
  30350. get computeParticleRotation(): boolean;
  30351. /**
  30352. * Gets if `setParticles()` computes the particle colors or not.
  30353. * Default value : true. The SPS is faster when it's set to false.
  30354. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30355. */
  30356. get computeParticleColor(): boolean;
  30357. /**
  30358. * Gets if `setParticles()` computes the particle textures or not.
  30359. * Default value : true. The SPS is faster when it's set to false.
  30360. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30361. */
  30362. get computeParticleTexture(): boolean;
  30363. /**
  30364. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30365. * Default value : false. The SPS is faster when it's set to false.
  30366. * Note : the particle custom vertex positions aren't stored values.
  30367. */
  30368. get computeParticleVertex(): boolean;
  30369. /**
  30370. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30371. */
  30372. get computeBoundingBox(): boolean;
  30373. /**
  30374. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30375. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30376. * Default : `true`
  30377. */
  30378. get depthSortParticles(): boolean;
  30379. /**
  30380. * Gets if the SPS is created as expandable at construction time.
  30381. * Default : `false`
  30382. */
  30383. get expandable(): boolean;
  30384. /**
  30385. * Gets if the SPS supports the Multi Materials
  30386. */
  30387. get multimaterialEnabled(): boolean;
  30388. /**
  30389. * Gets if the SPS uses the model materials for its own multimaterial.
  30390. */
  30391. get useModelMaterial(): boolean;
  30392. /**
  30393. * The SPS used material array.
  30394. */
  30395. get materials(): Material[];
  30396. /**
  30397. * Sets the SPS MultiMaterial from the passed materials.
  30398. * Note : the passed array is internally copied and not used then by reference.
  30399. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30400. */
  30401. setMultiMaterial(materials: Material[]): void;
  30402. /**
  30403. * The SPS computed multimaterial object
  30404. */
  30405. get multimaterial(): MultiMaterial;
  30406. set multimaterial(mm: MultiMaterial);
  30407. /**
  30408. * If the subMeshes must be updated on the next call to setParticles()
  30409. */
  30410. get autoUpdateSubMeshes(): boolean;
  30411. set autoUpdateSubMeshes(val: boolean);
  30412. /**
  30413. * This function does nothing. It may be overwritten to set all the particle first values.
  30414. * The SPS doesn't call this function, you may have to call it by your own.
  30415. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30416. */
  30417. initParticles(): void;
  30418. /**
  30419. * This function does nothing. It may be overwritten to recycle a particle.
  30420. * The SPS doesn't call this function, you may have to call it by your own.
  30421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30422. * @param particle The particle to recycle
  30423. * @returns the recycled particle
  30424. */
  30425. recycleParticle(particle: SolidParticle): SolidParticle;
  30426. /**
  30427. * Updates a particle : this function should be overwritten by the user.
  30428. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30429. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30430. * @example : just set a particle position or velocity and recycle conditions
  30431. * @param particle The particle to update
  30432. * @returns the updated particle
  30433. */
  30434. updateParticle(particle: SolidParticle): SolidParticle;
  30435. /**
  30436. * Updates a vertex of a particle : it can be overwritten by the user.
  30437. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30438. * @param particle the current particle
  30439. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30440. * @param pt the index of the current vertex in the particle shape
  30441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30442. * @example : just set a vertex particle position or color
  30443. * @returns the sps
  30444. */
  30445. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30446. /**
  30447. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30448. * This does nothing and may be overwritten by the user.
  30449. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30450. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30451. * @param update the boolean update value actually passed to setParticles()
  30452. */
  30453. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30454. /**
  30455. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30456. * This will be passed three parameters.
  30457. * This does nothing and may be overwritten by the user.
  30458. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30459. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30460. * @param update the boolean update value actually passed to setParticles()
  30461. */
  30462. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30463. }
  30464. }
  30465. declare module BABYLON {
  30466. /**
  30467. * Represents one particle of a solid particle system.
  30468. */
  30469. export class SolidParticle {
  30470. /**
  30471. * particle global index
  30472. */
  30473. idx: number;
  30474. /**
  30475. * particle identifier
  30476. */
  30477. id: number;
  30478. /**
  30479. * The color of the particle
  30480. */
  30481. color: Nullable<Color4>;
  30482. /**
  30483. * The world space position of the particle.
  30484. */
  30485. position: Vector3;
  30486. /**
  30487. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30488. */
  30489. rotation: Vector3;
  30490. /**
  30491. * The world space rotation quaternion of the particle.
  30492. */
  30493. rotationQuaternion: Nullable<Quaternion>;
  30494. /**
  30495. * The scaling of the particle.
  30496. */
  30497. scaling: Vector3;
  30498. /**
  30499. * The uvs of the particle.
  30500. */
  30501. uvs: Vector4;
  30502. /**
  30503. * The current speed of the particle.
  30504. */
  30505. velocity: Vector3;
  30506. /**
  30507. * The pivot point in the particle local space.
  30508. */
  30509. pivot: Vector3;
  30510. /**
  30511. * Must the particle be translated from its pivot point in its local space ?
  30512. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30513. * Default : false
  30514. */
  30515. translateFromPivot: boolean;
  30516. /**
  30517. * Is the particle active or not ?
  30518. */
  30519. alive: boolean;
  30520. /**
  30521. * Is the particle visible or not ?
  30522. */
  30523. isVisible: boolean;
  30524. /**
  30525. * Index of this particle in the global "positions" array (Internal use)
  30526. * @hidden
  30527. */
  30528. _pos: number;
  30529. /**
  30530. * @hidden Index of this particle in the global "indices" array (Internal use)
  30531. */
  30532. _ind: number;
  30533. /**
  30534. * @hidden ModelShape of this particle (Internal use)
  30535. */
  30536. _model: ModelShape;
  30537. /**
  30538. * ModelShape id of this particle
  30539. */
  30540. shapeId: number;
  30541. /**
  30542. * Index of the particle in its shape id
  30543. */
  30544. idxInShape: number;
  30545. /**
  30546. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30547. */
  30548. _modelBoundingInfo: BoundingInfo;
  30549. /**
  30550. * @hidden Particle BoundingInfo object (Internal use)
  30551. */
  30552. _boundingInfo: BoundingInfo;
  30553. /**
  30554. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30555. */
  30556. _sps: SolidParticleSystem;
  30557. /**
  30558. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30559. */
  30560. _stillInvisible: boolean;
  30561. /**
  30562. * @hidden Last computed particle rotation matrix
  30563. */
  30564. _rotationMatrix: number[];
  30565. /**
  30566. * Parent particle Id, if any.
  30567. * Default null.
  30568. */
  30569. parentId: Nullable<number>;
  30570. /**
  30571. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30572. */
  30573. materialIndex: Nullable<number>;
  30574. /**
  30575. * Custom object or properties.
  30576. */
  30577. props: Nullable<any>;
  30578. /**
  30579. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30580. * The possible values are :
  30581. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30582. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30583. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30584. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30585. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30586. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30587. * */
  30588. cullingStrategy: number;
  30589. /**
  30590. * @hidden Internal global position in the SPS.
  30591. */
  30592. _globalPosition: Vector3;
  30593. /**
  30594. * Creates a Solid Particle object.
  30595. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30596. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30597. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30598. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30599. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30600. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30601. * @param shapeId (integer) is the model shape identifier in the SPS.
  30602. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30603. * @param sps defines the sps it is associated to
  30604. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30605. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30606. */
  30607. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30608. /**
  30609. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30610. * @param target the particle target
  30611. * @returns the current particle
  30612. */
  30613. copyToRef(target: SolidParticle): SolidParticle;
  30614. /**
  30615. * Legacy support, changed scale to scaling
  30616. */
  30617. get scale(): Vector3;
  30618. /**
  30619. * Legacy support, changed scale to scaling
  30620. */
  30621. set scale(scale: Vector3);
  30622. /**
  30623. * Legacy support, changed quaternion to rotationQuaternion
  30624. */
  30625. get quaternion(): Nullable<Quaternion>;
  30626. /**
  30627. * Legacy support, changed quaternion to rotationQuaternion
  30628. */
  30629. set quaternion(q: Nullable<Quaternion>);
  30630. /**
  30631. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30632. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30633. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30634. * @returns true if it intersects
  30635. */
  30636. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30637. /**
  30638. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30639. * A particle is in the frustum if its bounding box intersects the frustum
  30640. * @param frustumPlanes defines the frustum to test
  30641. * @returns true if the particle is in the frustum planes
  30642. */
  30643. isInFrustum(frustumPlanes: Plane[]): boolean;
  30644. /**
  30645. * get the rotation matrix of the particle
  30646. * @hidden
  30647. */
  30648. getRotationMatrix(m: Matrix): void;
  30649. }
  30650. /**
  30651. * Represents the shape of the model used by one particle of a solid particle system.
  30652. * SPS internal tool, don't use it manually.
  30653. */
  30654. export class ModelShape {
  30655. /**
  30656. * The shape id
  30657. * @hidden
  30658. */
  30659. shapeID: number;
  30660. /**
  30661. * flat array of model positions (internal use)
  30662. * @hidden
  30663. */
  30664. _shape: Vector3[];
  30665. /**
  30666. * flat array of model UVs (internal use)
  30667. * @hidden
  30668. */
  30669. _shapeUV: number[];
  30670. /**
  30671. * color array of the model
  30672. * @hidden
  30673. */
  30674. _shapeColors: number[];
  30675. /**
  30676. * indices array of the model
  30677. * @hidden
  30678. */
  30679. _indices: number[];
  30680. /**
  30681. * normals array of the model
  30682. * @hidden
  30683. */
  30684. _normals: number[];
  30685. /**
  30686. * length of the shape in the model indices array (internal use)
  30687. * @hidden
  30688. */
  30689. _indicesLength: number;
  30690. /**
  30691. * Custom position function (internal use)
  30692. * @hidden
  30693. */
  30694. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30695. /**
  30696. * Custom vertex function (internal use)
  30697. * @hidden
  30698. */
  30699. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30700. /**
  30701. * Model material (internal use)
  30702. * @hidden
  30703. */
  30704. _material: Nullable<Material>;
  30705. /**
  30706. * 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.
  30707. * SPS internal tool, don't use it manually.
  30708. * @hidden
  30709. */
  30710. 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>);
  30711. }
  30712. /**
  30713. * Represents a Depth Sorted Particle in the solid particle system.
  30714. * @hidden
  30715. */
  30716. export class DepthSortedParticle {
  30717. /**
  30718. * Particle index
  30719. */
  30720. idx: number;
  30721. /**
  30722. * Index of the particle in the "indices" array
  30723. */
  30724. ind: number;
  30725. /**
  30726. * Length of the particle shape in the "indices" array
  30727. */
  30728. indicesLength: number;
  30729. /**
  30730. * Squared distance from the particle to the camera
  30731. */
  30732. sqDistance: number;
  30733. /**
  30734. * Material index when used with MultiMaterials
  30735. */
  30736. materialIndex: number;
  30737. /**
  30738. * Creates a new sorted particle
  30739. * @param materialIndex
  30740. */
  30741. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30742. }
  30743. /**
  30744. * Represents a solid particle vertex
  30745. */
  30746. export class SolidParticleVertex {
  30747. /**
  30748. * Vertex position
  30749. */
  30750. position: Vector3;
  30751. /**
  30752. * Vertex color
  30753. */
  30754. color: Color4;
  30755. /**
  30756. * Vertex UV
  30757. */
  30758. uv: Vector2;
  30759. /**
  30760. * Creates a new solid particle vertex
  30761. */
  30762. constructor();
  30763. /** Vertex x coordinate */
  30764. get x(): number;
  30765. set x(val: number);
  30766. /** Vertex y coordinate */
  30767. get y(): number;
  30768. set y(val: number);
  30769. /** Vertex z coordinate */
  30770. get z(): number;
  30771. set z(val: number);
  30772. }
  30773. }
  30774. declare module BABYLON {
  30775. /**
  30776. * @hidden
  30777. */
  30778. export class _MeshCollisionData {
  30779. _checkCollisions: boolean;
  30780. _collisionMask: number;
  30781. _collisionGroup: number;
  30782. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30783. _collider: Nullable<Collider>;
  30784. _oldPositionForCollisions: Vector3;
  30785. _diffPositionForCollisions: Vector3;
  30786. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30787. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30788. }
  30789. }
  30790. declare module BABYLON {
  30791. /** @hidden */
  30792. class _FacetDataStorage {
  30793. facetPositions: Vector3[];
  30794. facetNormals: Vector3[];
  30795. facetPartitioning: number[][];
  30796. facetNb: number;
  30797. partitioningSubdivisions: number;
  30798. partitioningBBoxRatio: number;
  30799. facetDataEnabled: boolean;
  30800. facetParameters: any;
  30801. bbSize: Vector3;
  30802. subDiv: {
  30803. max: number;
  30804. X: number;
  30805. Y: number;
  30806. Z: number;
  30807. };
  30808. facetDepthSort: boolean;
  30809. facetDepthSortEnabled: boolean;
  30810. depthSortedIndices: IndicesArray;
  30811. depthSortedFacets: {
  30812. ind: number;
  30813. sqDistance: number;
  30814. }[];
  30815. facetDepthSortFunction: (f1: {
  30816. ind: number;
  30817. sqDistance: number;
  30818. }, f2: {
  30819. ind: number;
  30820. sqDistance: number;
  30821. }) => number;
  30822. facetDepthSortFrom: Vector3;
  30823. facetDepthSortOrigin: Vector3;
  30824. invertedMatrix: Matrix;
  30825. }
  30826. /**
  30827. * @hidden
  30828. **/
  30829. class _InternalAbstractMeshDataInfo {
  30830. _hasVertexAlpha: boolean;
  30831. _useVertexColors: boolean;
  30832. _numBoneInfluencers: number;
  30833. _applyFog: boolean;
  30834. _receiveShadows: boolean;
  30835. _facetData: _FacetDataStorage;
  30836. _visibility: number;
  30837. _skeleton: Nullable<Skeleton>;
  30838. _layerMask: number;
  30839. _computeBonesUsingShaders: boolean;
  30840. _isActive: boolean;
  30841. _onlyForInstances: boolean;
  30842. _isActiveIntermediate: boolean;
  30843. _onlyForInstancesIntermediate: boolean;
  30844. _actAsRegularMesh: boolean;
  30845. }
  30846. /**
  30847. * Class used to store all common mesh properties
  30848. */
  30849. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30850. /** No occlusion */
  30851. static OCCLUSION_TYPE_NONE: number;
  30852. /** Occlusion set to optimisitic */
  30853. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30854. /** Occlusion set to strict */
  30855. static OCCLUSION_TYPE_STRICT: number;
  30856. /** Use an accurante occlusion algorithm */
  30857. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30858. /** Use a conservative occlusion algorithm */
  30859. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30860. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30861. * Test order :
  30862. * Is the bounding sphere outside the frustum ?
  30863. * If not, are the bounding box vertices outside the frustum ?
  30864. * It not, then the cullable object is in the frustum.
  30865. */
  30866. static readonly CULLINGSTRATEGY_STANDARD: number;
  30867. /** Culling strategy : Bounding Sphere Only.
  30868. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30869. * It's also less accurate than the standard because some not visible objects can still be selected.
  30870. * Test : is the bounding sphere outside the frustum ?
  30871. * If not, then the cullable object is in the frustum.
  30872. */
  30873. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30874. /** Culling strategy : Optimistic Inclusion.
  30875. * This in an inclusion test first, then the standard exclusion test.
  30876. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30877. * 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.
  30878. * Anyway, it's as accurate as the standard strategy.
  30879. * Test :
  30880. * Is the cullable object bounding sphere center in the frustum ?
  30881. * If not, apply the default culling strategy.
  30882. */
  30883. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30884. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30885. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30886. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30887. * 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.
  30888. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30889. * Test :
  30890. * Is the cullable object bounding sphere center in the frustum ?
  30891. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30892. */
  30893. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30894. /**
  30895. * No billboard
  30896. */
  30897. static get BILLBOARDMODE_NONE(): number;
  30898. /** Billboard on X axis */
  30899. static get BILLBOARDMODE_X(): number;
  30900. /** Billboard on Y axis */
  30901. static get BILLBOARDMODE_Y(): number;
  30902. /** Billboard on Z axis */
  30903. static get BILLBOARDMODE_Z(): number;
  30904. /** Billboard on all axes */
  30905. static get BILLBOARDMODE_ALL(): number;
  30906. /** Billboard on using position instead of orientation */
  30907. static get BILLBOARDMODE_USE_POSITION(): number;
  30908. /** @hidden */
  30909. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30910. /**
  30911. * The culling strategy to use to check whether the mesh must be rendered or not.
  30912. * This value can be changed at any time and will be used on the next render mesh selection.
  30913. * The possible values are :
  30914. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30915. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30918. * Please read each static variable documentation to get details about the culling process.
  30919. * */
  30920. cullingStrategy: number;
  30921. /**
  30922. * Gets the number of facets in the mesh
  30923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30924. */
  30925. get facetNb(): number;
  30926. /**
  30927. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30929. */
  30930. get partitioningSubdivisions(): number;
  30931. set partitioningSubdivisions(nb: number);
  30932. /**
  30933. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30934. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30936. */
  30937. get partitioningBBoxRatio(): number;
  30938. set partitioningBBoxRatio(ratio: number);
  30939. /**
  30940. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30941. * Works only for updatable meshes.
  30942. * Doesn't work with multi-materials
  30943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30944. */
  30945. get mustDepthSortFacets(): boolean;
  30946. set mustDepthSortFacets(sort: boolean);
  30947. /**
  30948. * The location (Vector3) where the facet depth sort must be computed from.
  30949. * By default, the active camera position.
  30950. * Used only when facet depth sort is enabled
  30951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30952. */
  30953. get facetDepthSortFrom(): Vector3;
  30954. set facetDepthSortFrom(location: Vector3);
  30955. /**
  30956. * gets a boolean indicating if facetData is enabled
  30957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30958. */
  30959. get isFacetDataEnabled(): boolean;
  30960. /** @hidden */
  30961. _updateNonUniformScalingState(value: boolean): boolean;
  30962. /**
  30963. * An event triggered when this mesh collides with another one
  30964. */
  30965. onCollideObservable: Observable<AbstractMesh>;
  30966. /** Set a function to call when this mesh collides with another one */
  30967. set onCollide(callback: () => void);
  30968. /**
  30969. * An event triggered when the collision's position changes
  30970. */
  30971. onCollisionPositionChangeObservable: Observable<Vector3>;
  30972. /** Set a function to call when the collision's position changes */
  30973. set onCollisionPositionChange(callback: () => void);
  30974. /**
  30975. * An event triggered when material is changed
  30976. */
  30977. onMaterialChangedObservable: Observable<AbstractMesh>;
  30978. /**
  30979. * Gets or sets the orientation for POV movement & rotation
  30980. */
  30981. definedFacingForward: boolean;
  30982. /** @hidden */
  30983. _occlusionQuery: Nullable<WebGLQuery>;
  30984. /** @hidden */
  30985. _renderingGroup: Nullable<RenderingGroup>;
  30986. /**
  30987. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30988. */
  30989. get visibility(): number;
  30990. /**
  30991. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30992. */
  30993. set visibility(value: number);
  30994. /** Gets or sets the alpha index used to sort transparent meshes
  30995. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30996. */
  30997. alphaIndex: number;
  30998. /**
  30999. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31000. */
  31001. isVisible: boolean;
  31002. /**
  31003. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31004. */
  31005. isPickable: boolean;
  31006. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31007. showSubMeshesBoundingBox: boolean;
  31008. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31009. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31010. */
  31011. isBlocker: boolean;
  31012. /**
  31013. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31014. */
  31015. enablePointerMoveEvents: boolean;
  31016. /**
  31017. * Specifies the rendering group id for this mesh (0 by default)
  31018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31019. */
  31020. renderingGroupId: number;
  31021. private _material;
  31022. /** Gets or sets current material */
  31023. get material(): Nullable<Material>;
  31024. set material(value: Nullable<Material>);
  31025. /**
  31026. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31027. * @see http://doc.babylonjs.com/babylon101/shadows
  31028. */
  31029. get receiveShadows(): boolean;
  31030. set receiveShadows(value: boolean);
  31031. /** Defines color to use when rendering outline */
  31032. outlineColor: Color3;
  31033. /** Define width to use when rendering outline */
  31034. outlineWidth: number;
  31035. /** Defines color to use when rendering overlay */
  31036. overlayColor: Color3;
  31037. /** Defines alpha to use when rendering overlay */
  31038. overlayAlpha: number;
  31039. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31040. get hasVertexAlpha(): boolean;
  31041. set hasVertexAlpha(value: boolean);
  31042. /** 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) */
  31043. get useVertexColors(): boolean;
  31044. set useVertexColors(value: boolean);
  31045. /**
  31046. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31047. */
  31048. get computeBonesUsingShaders(): boolean;
  31049. set computeBonesUsingShaders(value: boolean);
  31050. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31051. get numBoneInfluencers(): number;
  31052. set numBoneInfluencers(value: number);
  31053. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31054. get applyFog(): boolean;
  31055. set applyFog(value: boolean);
  31056. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31057. useOctreeForRenderingSelection: boolean;
  31058. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31059. useOctreeForPicking: boolean;
  31060. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31061. useOctreeForCollisions: boolean;
  31062. /**
  31063. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31064. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31065. */
  31066. get layerMask(): number;
  31067. set layerMask(value: number);
  31068. /**
  31069. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31070. */
  31071. alwaysSelectAsActiveMesh: boolean;
  31072. /**
  31073. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31074. */
  31075. doNotSyncBoundingInfo: boolean;
  31076. /**
  31077. * Gets or sets the current action manager
  31078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31079. */
  31080. actionManager: Nullable<AbstractActionManager>;
  31081. private _meshCollisionData;
  31082. /**
  31083. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31084. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31085. */
  31086. ellipsoid: Vector3;
  31087. /**
  31088. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31090. */
  31091. ellipsoidOffset: Vector3;
  31092. /**
  31093. * Gets or sets a collision mask used to mask collisions (default is -1).
  31094. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31095. */
  31096. get collisionMask(): number;
  31097. set collisionMask(mask: number);
  31098. /**
  31099. * Gets or sets the current collision group mask (-1 by default).
  31100. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31101. */
  31102. get collisionGroup(): number;
  31103. set collisionGroup(mask: number);
  31104. /**
  31105. * Gets or sets current surrounding meshes (null by default).
  31106. *
  31107. * By default collision detection is tested against every mesh in the scene.
  31108. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31109. * meshes will be tested for the collision.
  31110. *
  31111. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31112. */
  31113. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31114. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31115. /**
  31116. * Defines edge width used when edgesRenderer is enabled
  31117. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31118. */
  31119. edgesWidth: number;
  31120. /**
  31121. * Defines edge color used when edgesRenderer is enabled
  31122. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31123. */
  31124. edgesColor: Color4;
  31125. /** @hidden */
  31126. _edgesRenderer: Nullable<IEdgesRenderer>;
  31127. /** @hidden */
  31128. _masterMesh: Nullable<AbstractMesh>;
  31129. /** @hidden */
  31130. _boundingInfo: Nullable<BoundingInfo>;
  31131. /** @hidden */
  31132. _renderId: number;
  31133. /**
  31134. * Gets or sets the list of subMeshes
  31135. * @see http://doc.babylonjs.com/how_to/multi_materials
  31136. */
  31137. subMeshes: SubMesh[];
  31138. /** @hidden */
  31139. _intersectionsInProgress: AbstractMesh[];
  31140. /** @hidden */
  31141. _unIndexed: boolean;
  31142. /** @hidden */
  31143. _lightSources: Light[];
  31144. /** Gets the list of lights affecting that mesh */
  31145. get lightSources(): Light[];
  31146. /** @hidden */
  31147. get _positions(): Nullable<Vector3[]>;
  31148. /** @hidden */
  31149. _waitingData: {
  31150. lods: Nullable<any>;
  31151. actions: Nullable<any>;
  31152. freezeWorldMatrix: Nullable<boolean>;
  31153. };
  31154. /** @hidden */
  31155. _bonesTransformMatrices: Nullable<Float32Array>;
  31156. /** @hidden */
  31157. _transformMatrixTexture: Nullable<RawTexture>;
  31158. /**
  31159. * Gets or sets a skeleton to apply skining transformations
  31160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31161. */
  31162. set skeleton(value: Nullable<Skeleton>);
  31163. get skeleton(): Nullable<Skeleton>;
  31164. /**
  31165. * An event triggered when the mesh is rebuilt.
  31166. */
  31167. onRebuildObservable: Observable<AbstractMesh>;
  31168. /**
  31169. * Creates a new AbstractMesh
  31170. * @param name defines the name of the mesh
  31171. * @param scene defines the hosting scene
  31172. */
  31173. constructor(name: string, scene?: Nullable<Scene>);
  31174. /**
  31175. * Returns the string "AbstractMesh"
  31176. * @returns "AbstractMesh"
  31177. */
  31178. getClassName(): string;
  31179. /**
  31180. * Gets a string representation of the current mesh
  31181. * @param fullDetails defines a boolean indicating if full details must be included
  31182. * @returns a string representation of the current mesh
  31183. */
  31184. toString(fullDetails?: boolean): string;
  31185. /**
  31186. * @hidden
  31187. */
  31188. protected _getEffectiveParent(): Nullable<Node>;
  31189. /** @hidden */
  31190. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31191. /** @hidden */
  31192. _rebuild(): void;
  31193. /** @hidden */
  31194. _resyncLightSources(): void;
  31195. /** @hidden */
  31196. _resyncLightSource(light: Light): void;
  31197. /** @hidden */
  31198. _unBindEffect(): void;
  31199. /** @hidden */
  31200. _removeLightSource(light: Light, dispose: boolean): void;
  31201. private _markSubMeshesAsDirty;
  31202. /** @hidden */
  31203. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31204. /** @hidden */
  31205. _markSubMeshesAsAttributesDirty(): void;
  31206. /** @hidden */
  31207. _markSubMeshesAsMiscDirty(): void;
  31208. /**
  31209. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31210. */
  31211. get scaling(): Vector3;
  31212. set scaling(newScaling: Vector3);
  31213. /**
  31214. * Returns true if the mesh is blocked. Implemented by child classes
  31215. */
  31216. get isBlocked(): boolean;
  31217. /**
  31218. * Returns the mesh itself by default. Implemented by child classes
  31219. * @param camera defines the camera to use to pick the right LOD level
  31220. * @returns the currentAbstractMesh
  31221. */
  31222. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31223. /**
  31224. * Returns 0 by default. Implemented by child classes
  31225. * @returns an integer
  31226. */
  31227. getTotalVertices(): number;
  31228. /**
  31229. * Returns a positive integer : the total number of indices in this mesh geometry.
  31230. * @returns the numner of indices or zero if the mesh has no geometry.
  31231. */
  31232. getTotalIndices(): number;
  31233. /**
  31234. * Returns null by default. Implemented by child classes
  31235. * @returns null
  31236. */
  31237. getIndices(): Nullable<IndicesArray>;
  31238. /**
  31239. * Returns the array of the requested vertex data kind. Implemented by child classes
  31240. * @param kind defines the vertex data kind to use
  31241. * @returns null
  31242. */
  31243. getVerticesData(kind: string): Nullable<FloatArray>;
  31244. /**
  31245. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31246. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31247. * Note that a new underlying VertexBuffer object is created each call.
  31248. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31249. * @param kind defines vertex data kind:
  31250. * * VertexBuffer.PositionKind
  31251. * * VertexBuffer.UVKind
  31252. * * VertexBuffer.UV2Kind
  31253. * * VertexBuffer.UV3Kind
  31254. * * VertexBuffer.UV4Kind
  31255. * * VertexBuffer.UV5Kind
  31256. * * VertexBuffer.UV6Kind
  31257. * * VertexBuffer.ColorKind
  31258. * * VertexBuffer.MatricesIndicesKind
  31259. * * VertexBuffer.MatricesIndicesExtraKind
  31260. * * VertexBuffer.MatricesWeightsKind
  31261. * * VertexBuffer.MatricesWeightsExtraKind
  31262. * @param data defines the data source
  31263. * @param updatable defines if the data must be flagged as updatable (or static)
  31264. * @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
  31265. * @returns the current mesh
  31266. */
  31267. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31268. /**
  31269. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31270. * If the mesh has no geometry, it is simply returned as it is.
  31271. * @param kind defines vertex data kind:
  31272. * * VertexBuffer.PositionKind
  31273. * * VertexBuffer.UVKind
  31274. * * VertexBuffer.UV2Kind
  31275. * * VertexBuffer.UV3Kind
  31276. * * VertexBuffer.UV4Kind
  31277. * * VertexBuffer.UV5Kind
  31278. * * VertexBuffer.UV6Kind
  31279. * * VertexBuffer.ColorKind
  31280. * * VertexBuffer.MatricesIndicesKind
  31281. * * VertexBuffer.MatricesIndicesExtraKind
  31282. * * VertexBuffer.MatricesWeightsKind
  31283. * * VertexBuffer.MatricesWeightsExtraKind
  31284. * @param data defines the data source
  31285. * @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
  31286. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31287. * @returns the current mesh
  31288. */
  31289. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31290. /**
  31291. * Sets the mesh indices,
  31292. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31293. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31294. * @param totalVertices Defines the total number of vertices
  31295. * @returns the current mesh
  31296. */
  31297. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31298. /**
  31299. * Gets a boolean indicating if specific vertex data is present
  31300. * @param kind defines the vertex data kind to use
  31301. * @returns true is data kind is present
  31302. */
  31303. isVerticesDataPresent(kind: string): boolean;
  31304. /**
  31305. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31306. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31307. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31308. * @returns a BoundingInfo
  31309. */
  31310. getBoundingInfo(): BoundingInfo;
  31311. /**
  31312. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31313. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31314. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31315. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31316. * @returns the current mesh
  31317. */
  31318. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31319. /**
  31320. * Overwrite the current bounding info
  31321. * @param boundingInfo defines the new bounding info
  31322. * @returns the current mesh
  31323. */
  31324. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31325. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31326. get useBones(): boolean;
  31327. /** @hidden */
  31328. _preActivate(): void;
  31329. /** @hidden */
  31330. _preActivateForIntermediateRendering(renderId: number): void;
  31331. /** @hidden */
  31332. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31333. /** @hidden */
  31334. _postActivate(): void;
  31335. /** @hidden */
  31336. _freeze(): void;
  31337. /** @hidden */
  31338. _unFreeze(): void;
  31339. /**
  31340. * Gets the current world matrix
  31341. * @returns a Matrix
  31342. */
  31343. getWorldMatrix(): Matrix;
  31344. /** @hidden */
  31345. _getWorldMatrixDeterminant(): number;
  31346. /**
  31347. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31348. */
  31349. get isAnInstance(): boolean;
  31350. /**
  31351. * Gets a boolean indicating if this mesh has instances
  31352. */
  31353. get hasInstances(): boolean;
  31354. /**
  31355. * Gets a boolean indicating if this mesh has thin instances
  31356. */
  31357. get hasThinInstances(): boolean;
  31358. /**
  31359. * Perform relative position change from the point of view of behind the front of the mesh.
  31360. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31361. * Supports definition of mesh facing forward or backward
  31362. * @param amountRight defines the distance on the right axis
  31363. * @param amountUp defines the distance on the up axis
  31364. * @param amountForward defines the distance on the forward axis
  31365. * @returns the current mesh
  31366. */
  31367. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31368. /**
  31369. * Calculate relative position change from the point of view of behind the front of the mesh.
  31370. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31371. * Supports definition of mesh facing forward or backward
  31372. * @param amountRight defines the distance on the right axis
  31373. * @param amountUp defines the distance on the up axis
  31374. * @param amountForward defines the distance on the forward axis
  31375. * @returns the new displacement vector
  31376. */
  31377. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31378. /**
  31379. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31380. * Supports definition of mesh facing forward or backward
  31381. * @param flipBack defines the flip
  31382. * @param twirlClockwise defines the twirl
  31383. * @param tiltRight defines the tilt
  31384. * @returns the current mesh
  31385. */
  31386. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31387. /**
  31388. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31389. * Supports definition of mesh facing forward or backward.
  31390. * @param flipBack defines the flip
  31391. * @param twirlClockwise defines the twirl
  31392. * @param tiltRight defines the tilt
  31393. * @returns the new rotation vector
  31394. */
  31395. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31396. /**
  31397. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31398. * This means the mesh underlying bounding box and sphere are recomputed.
  31399. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31400. * @returns the current mesh
  31401. */
  31402. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31403. /** @hidden */
  31404. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31405. /** @hidden */
  31406. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31407. /** @hidden */
  31408. _updateBoundingInfo(): AbstractMesh;
  31409. /** @hidden */
  31410. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31411. /** @hidden */
  31412. protected _afterComputeWorldMatrix(): void;
  31413. /** @hidden */
  31414. get _effectiveMesh(): AbstractMesh;
  31415. /**
  31416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31417. * A mesh is in the frustum if its bounding box intersects the frustum
  31418. * @param frustumPlanes defines the frustum to test
  31419. * @returns true if the mesh is in the frustum planes
  31420. */
  31421. isInFrustum(frustumPlanes: Plane[]): boolean;
  31422. /**
  31423. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31424. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31425. * @param frustumPlanes defines the frustum to test
  31426. * @returns true if the mesh is completely in the frustum planes
  31427. */
  31428. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31429. /**
  31430. * True if the mesh intersects another mesh or a SolidParticle object
  31431. * @param mesh defines a target mesh or SolidParticle to test
  31432. * @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)
  31433. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31434. * @returns true if there is an intersection
  31435. */
  31436. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31437. /**
  31438. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31439. * @param point defines the point to test
  31440. * @returns true if there is an intersection
  31441. */
  31442. intersectsPoint(point: Vector3): boolean;
  31443. /**
  31444. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31446. */
  31447. get checkCollisions(): boolean;
  31448. set checkCollisions(collisionEnabled: boolean);
  31449. /**
  31450. * Gets Collider object used to compute collisions (not physics)
  31451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31452. */
  31453. get collider(): Nullable<Collider>;
  31454. /**
  31455. * Move the mesh using collision engine
  31456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31457. * @param displacement defines the requested displacement vector
  31458. * @returns the current mesh
  31459. */
  31460. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31461. private _onCollisionPositionChange;
  31462. /** @hidden */
  31463. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31464. /** @hidden */
  31465. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31466. /** @hidden */
  31467. _checkCollision(collider: Collider): AbstractMesh;
  31468. /** @hidden */
  31469. _generatePointsArray(): boolean;
  31470. /**
  31471. * Checks if the passed Ray intersects with the mesh
  31472. * @param ray defines the ray to use
  31473. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31475. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31476. * @returns the picking info
  31477. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31478. */
  31479. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31480. /**
  31481. * Clones the current mesh
  31482. * @param name defines the mesh name
  31483. * @param newParent defines the new mesh parent
  31484. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31485. * @returns the new mesh
  31486. */
  31487. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31488. /**
  31489. * Disposes all the submeshes of the current meshnp
  31490. * @returns the current mesh
  31491. */
  31492. releaseSubMeshes(): AbstractMesh;
  31493. /**
  31494. * Releases resources associated with this abstract mesh.
  31495. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31496. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31497. */
  31498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31499. /**
  31500. * Adds the passed mesh as a child to the current mesh
  31501. * @param mesh defines the child mesh
  31502. * @returns the current mesh
  31503. */
  31504. addChild(mesh: AbstractMesh): AbstractMesh;
  31505. /**
  31506. * Removes the passed mesh from the current mesh children list
  31507. * @param mesh defines the child mesh
  31508. * @returns the current mesh
  31509. */
  31510. removeChild(mesh: AbstractMesh): AbstractMesh;
  31511. /** @hidden */
  31512. private _initFacetData;
  31513. /**
  31514. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31515. * This method can be called within the render loop.
  31516. * 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
  31517. * @returns the current mesh
  31518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31519. */
  31520. updateFacetData(): AbstractMesh;
  31521. /**
  31522. * Returns the facetLocalNormals array.
  31523. * The normals are expressed in the mesh local spac
  31524. * @returns an array of Vector3
  31525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31526. */
  31527. getFacetLocalNormals(): Vector3[];
  31528. /**
  31529. * Returns the facetLocalPositions array.
  31530. * The facet positions are expressed in the mesh local space
  31531. * @returns an array of Vector3
  31532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31533. */
  31534. getFacetLocalPositions(): Vector3[];
  31535. /**
  31536. * Returns the facetLocalPartioning array
  31537. * @returns an array of array of numbers
  31538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31539. */
  31540. getFacetLocalPartitioning(): number[][];
  31541. /**
  31542. * Returns the i-th facet position in the world system.
  31543. * This method allocates a new Vector3 per call
  31544. * @param i defines the facet index
  31545. * @returns a new Vector3
  31546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31547. */
  31548. getFacetPosition(i: number): Vector3;
  31549. /**
  31550. * Sets the reference Vector3 with the i-th facet position in the world system
  31551. * @param i defines the facet index
  31552. * @param ref defines the target vector
  31553. * @returns the current mesh
  31554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31555. */
  31556. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31557. /**
  31558. * Returns the i-th facet normal in the world system.
  31559. * This method allocates a new Vector3 per call
  31560. * @param i defines the facet index
  31561. * @returns a new Vector3
  31562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31563. */
  31564. getFacetNormal(i: number): Vector3;
  31565. /**
  31566. * Sets the reference Vector3 with the i-th facet normal in the world system
  31567. * @param i defines the facet index
  31568. * @param ref defines the target vector
  31569. * @returns the current mesh
  31570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31571. */
  31572. getFacetNormalToRef(i: number, ref: Vector3): this;
  31573. /**
  31574. * 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)
  31575. * @param x defines x coordinate
  31576. * @param y defines y coordinate
  31577. * @param z defines z coordinate
  31578. * @returns the array of facet indexes
  31579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31580. */
  31581. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31582. /**
  31583. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31584. * @param projected sets as the (x,y,z) world projection on the facet
  31585. * @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
  31586. * @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
  31587. * @param x defines x coordinate
  31588. * @param y defines y coordinate
  31589. * @param z defines z coordinate
  31590. * @returns the face index if found (or null instead)
  31591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31592. */
  31593. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31594. /**
  31595. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31596. * @param projected sets as the (x,y,z) local projection on the facet
  31597. * @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
  31598. * @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
  31599. * @param x defines x coordinate
  31600. * @param y defines y coordinate
  31601. * @param z defines z coordinate
  31602. * @returns the face index if found (or null instead)
  31603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31604. */
  31605. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31606. /**
  31607. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31608. * @returns the parameters
  31609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31610. */
  31611. getFacetDataParameters(): any;
  31612. /**
  31613. * Disables the feature FacetData and frees the related memory
  31614. * @returns the current mesh
  31615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31616. */
  31617. disableFacetData(): AbstractMesh;
  31618. /**
  31619. * Updates the AbstractMesh indices array
  31620. * @param indices defines the data source
  31621. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31622. * @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)
  31623. * @returns the current mesh
  31624. */
  31625. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31626. /**
  31627. * Creates new normals data for the mesh
  31628. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31629. * @returns the current mesh
  31630. */
  31631. createNormals(updatable: boolean): AbstractMesh;
  31632. /**
  31633. * Align the mesh with a normal
  31634. * @param normal defines the normal to use
  31635. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31636. * @returns the current mesh
  31637. */
  31638. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31639. /** @hidden */
  31640. _checkOcclusionQuery(): boolean;
  31641. /**
  31642. * Disables the mesh edge rendering mode
  31643. * @returns the currentAbstractMesh
  31644. */
  31645. disableEdgesRendering(): AbstractMesh;
  31646. /**
  31647. * Enables the edge rendering mode on the mesh.
  31648. * This mode makes the mesh edges visible
  31649. * @param epsilon defines the maximal distance between two angles to detect a face
  31650. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31651. * @returns the currentAbstractMesh
  31652. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31653. */
  31654. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31655. }
  31656. }
  31657. declare module BABYLON {
  31658. /**
  31659. * Interface used to define ActionEvent
  31660. */
  31661. export interface IActionEvent {
  31662. /** The mesh or sprite that triggered the action */
  31663. source: any;
  31664. /** The X mouse cursor position at the time of the event */
  31665. pointerX: number;
  31666. /** The Y mouse cursor position at the time of the event */
  31667. pointerY: number;
  31668. /** The mesh that is currently pointed at (can be null) */
  31669. meshUnderPointer: Nullable<AbstractMesh>;
  31670. /** the original (browser) event that triggered the ActionEvent */
  31671. sourceEvent?: any;
  31672. /** additional data for the event */
  31673. additionalData?: any;
  31674. }
  31675. /**
  31676. * ActionEvent is the event being sent when an action is triggered.
  31677. */
  31678. export class ActionEvent implements IActionEvent {
  31679. /** The mesh or sprite that triggered the action */
  31680. source: any;
  31681. /** The X mouse cursor position at the time of the event */
  31682. pointerX: number;
  31683. /** The Y mouse cursor position at the time of the event */
  31684. pointerY: number;
  31685. /** The mesh that is currently pointed at (can be null) */
  31686. meshUnderPointer: Nullable<AbstractMesh>;
  31687. /** the original (browser) event that triggered the ActionEvent */
  31688. sourceEvent?: any;
  31689. /** additional data for the event */
  31690. additionalData?: any;
  31691. /**
  31692. * Creates a new ActionEvent
  31693. * @param source The mesh or sprite that triggered the action
  31694. * @param pointerX The X mouse cursor position at the time of the event
  31695. * @param pointerY The Y mouse cursor position at the time of the event
  31696. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31697. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31698. * @param additionalData additional data for the event
  31699. */
  31700. constructor(
  31701. /** The mesh or sprite that triggered the action */
  31702. source: any,
  31703. /** The X mouse cursor position at the time of the event */
  31704. pointerX: number,
  31705. /** The Y mouse cursor position at the time of the event */
  31706. pointerY: number,
  31707. /** The mesh that is currently pointed at (can be null) */
  31708. meshUnderPointer: Nullable<AbstractMesh>,
  31709. /** the original (browser) event that triggered the ActionEvent */
  31710. sourceEvent?: any,
  31711. /** additional data for the event */
  31712. additionalData?: any);
  31713. /**
  31714. * Helper function to auto-create an ActionEvent from a source mesh.
  31715. * @param source The source mesh that triggered the event
  31716. * @param evt The original (browser) event
  31717. * @param additionalData additional data for the event
  31718. * @returns the new ActionEvent
  31719. */
  31720. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31721. /**
  31722. * Helper function to auto-create an ActionEvent from a source sprite
  31723. * @param source The source sprite that triggered the event
  31724. * @param scene Scene associated with the sprite
  31725. * @param evt The original (browser) event
  31726. * @param additionalData additional data for the event
  31727. * @returns the new ActionEvent
  31728. */
  31729. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31730. /**
  31731. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31732. * @param scene the scene where the event occurred
  31733. * @param evt The original (browser) event
  31734. * @returns the new ActionEvent
  31735. */
  31736. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31737. /**
  31738. * Helper function to auto-create an ActionEvent from a primitive
  31739. * @param prim defines the target primitive
  31740. * @param pointerPos defines the pointer position
  31741. * @param evt The original (browser) event
  31742. * @param additionalData additional data for the event
  31743. * @returns the new ActionEvent
  31744. */
  31745. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31746. }
  31747. }
  31748. declare module BABYLON {
  31749. /**
  31750. * Abstract class used to decouple action Manager from scene and meshes.
  31751. * Do not instantiate.
  31752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31753. */
  31754. export abstract class AbstractActionManager implements IDisposable {
  31755. /** Gets the list of active triggers */
  31756. static Triggers: {
  31757. [key: string]: number;
  31758. };
  31759. /** Gets the cursor to use when hovering items */
  31760. hoverCursor: string;
  31761. /** Gets the list of actions */
  31762. actions: IAction[];
  31763. /**
  31764. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31765. */
  31766. isRecursive: boolean;
  31767. /**
  31768. * Releases all associated resources
  31769. */
  31770. abstract dispose(): void;
  31771. /**
  31772. * Does this action manager has pointer triggers
  31773. */
  31774. abstract get hasPointerTriggers(): boolean;
  31775. /**
  31776. * Does this action manager has pick triggers
  31777. */
  31778. abstract get hasPickTriggers(): boolean;
  31779. /**
  31780. * Process a specific trigger
  31781. * @param trigger defines the trigger to process
  31782. * @param evt defines the event details to be processed
  31783. */
  31784. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31785. /**
  31786. * Does this action manager handles actions of any of the given triggers
  31787. * @param triggers defines the triggers to be tested
  31788. * @return a boolean indicating whether one (or more) of the triggers is handled
  31789. */
  31790. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31791. /**
  31792. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31793. * speed.
  31794. * @param triggerA defines the trigger to be tested
  31795. * @param triggerB defines the trigger to be tested
  31796. * @return a boolean indicating whether one (or more) of the triggers is handled
  31797. */
  31798. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31799. /**
  31800. * Does this action manager handles actions of a given trigger
  31801. * @param trigger defines the trigger to be tested
  31802. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31803. * @return whether the trigger is handled
  31804. */
  31805. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31806. /**
  31807. * Serialize this manager to a JSON object
  31808. * @param name defines the property name to store this manager
  31809. * @returns a JSON representation of this manager
  31810. */
  31811. abstract serialize(name: string): any;
  31812. /**
  31813. * Registers an action to this action manager
  31814. * @param action defines the action to be registered
  31815. * @return the action amended (prepared) after registration
  31816. */
  31817. abstract registerAction(action: IAction): Nullable<IAction>;
  31818. /**
  31819. * Unregisters an action to this action manager
  31820. * @param action defines the action to be unregistered
  31821. * @return a boolean indicating whether the action has been unregistered
  31822. */
  31823. abstract unregisterAction(action: IAction): Boolean;
  31824. /**
  31825. * Does exist one action manager with at least one trigger
  31826. **/
  31827. static get HasTriggers(): boolean;
  31828. /**
  31829. * Does exist one action manager with at least one pick trigger
  31830. **/
  31831. static get HasPickTriggers(): boolean;
  31832. /**
  31833. * Does exist one action manager that handles actions of a given trigger
  31834. * @param trigger defines the trigger to be tested
  31835. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31836. **/
  31837. static HasSpecificTrigger(trigger: number): boolean;
  31838. }
  31839. }
  31840. declare module BABYLON {
  31841. /**
  31842. * Defines how a node can be built from a string name.
  31843. */
  31844. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31845. /**
  31846. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31847. */
  31848. export class Node implements IBehaviorAware<Node> {
  31849. /** @hidden */
  31850. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31851. private static _NodeConstructors;
  31852. /**
  31853. * Add a new node constructor
  31854. * @param type defines the type name of the node to construct
  31855. * @param constructorFunc defines the constructor function
  31856. */
  31857. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31858. /**
  31859. * Returns a node constructor based on type name
  31860. * @param type defines the type name
  31861. * @param name defines the new node name
  31862. * @param scene defines the hosting scene
  31863. * @param options defines optional options to transmit to constructors
  31864. * @returns the new constructor or null
  31865. */
  31866. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31867. /**
  31868. * Gets or sets the name of the node
  31869. */
  31870. name: string;
  31871. /**
  31872. * Gets or sets the id of the node
  31873. */
  31874. id: string;
  31875. /**
  31876. * Gets or sets the unique id of the node
  31877. */
  31878. uniqueId: number;
  31879. /**
  31880. * Gets or sets a string used to store user defined state for the node
  31881. */
  31882. state: string;
  31883. /**
  31884. * Gets or sets an object used to store user defined information for the node
  31885. */
  31886. metadata: any;
  31887. /**
  31888. * For internal use only. Please do not use.
  31889. */
  31890. reservedDataStore: any;
  31891. /**
  31892. * List of inspectable custom properties (used by the Inspector)
  31893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31894. */
  31895. inspectableCustomProperties: IInspectable[];
  31896. private _doNotSerialize;
  31897. /**
  31898. * Gets or sets a boolean used to define if the node must be serialized
  31899. */
  31900. get doNotSerialize(): boolean;
  31901. set doNotSerialize(value: boolean);
  31902. /** @hidden */
  31903. _isDisposed: boolean;
  31904. /**
  31905. * Gets a list of Animations associated with the node
  31906. */
  31907. animations: Animation[];
  31908. protected _ranges: {
  31909. [name: string]: Nullable<AnimationRange>;
  31910. };
  31911. /**
  31912. * Callback raised when the node is ready to be used
  31913. */
  31914. onReady: Nullable<(node: Node) => void>;
  31915. private _isEnabled;
  31916. private _isParentEnabled;
  31917. private _isReady;
  31918. /** @hidden */
  31919. _currentRenderId: number;
  31920. private _parentUpdateId;
  31921. /** @hidden */
  31922. _childUpdateId: number;
  31923. /** @hidden */
  31924. _waitingParentId: Nullable<string>;
  31925. /** @hidden */
  31926. _scene: Scene;
  31927. /** @hidden */
  31928. _cache: any;
  31929. private _parentNode;
  31930. private _children;
  31931. /** @hidden */
  31932. _worldMatrix: Matrix;
  31933. /** @hidden */
  31934. _worldMatrixDeterminant: number;
  31935. /** @hidden */
  31936. _worldMatrixDeterminantIsDirty: boolean;
  31937. /** @hidden */
  31938. private _sceneRootNodesIndex;
  31939. /**
  31940. * Gets a boolean indicating if the node has been disposed
  31941. * @returns true if the node was disposed
  31942. */
  31943. isDisposed(): boolean;
  31944. /**
  31945. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31946. * @see https://doc.babylonjs.com/how_to/parenting
  31947. */
  31948. set parent(parent: Nullable<Node>);
  31949. get parent(): Nullable<Node>;
  31950. /** @hidden */
  31951. _addToSceneRootNodes(): void;
  31952. /** @hidden */
  31953. _removeFromSceneRootNodes(): void;
  31954. private _animationPropertiesOverride;
  31955. /**
  31956. * Gets or sets the animation properties override
  31957. */
  31958. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31959. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31960. /**
  31961. * Gets a string idenfifying the name of the class
  31962. * @returns "Node" string
  31963. */
  31964. getClassName(): string;
  31965. /** @hidden */
  31966. readonly _isNode: boolean;
  31967. /**
  31968. * An event triggered when the mesh is disposed
  31969. */
  31970. onDisposeObservable: Observable<Node>;
  31971. private _onDisposeObserver;
  31972. /**
  31973. * Sets a callback that will be raised when the node will be disposed
  31974. */
  31975. set onDispose(callback: () => void);
  31976. /**
  31977. * Creates a new Node
  31978. * @param name the name and id to be given to this node
  31979. * @param scene the scene this node will be added to
  31980. */
  31981. constructor(name: string, scene?: Nullable<Scene>);
  31982. /**
  31983. * Gets the scene of the node
  31984. * @returns a scene
  31985. */
  31986. getScene(): Scene;
  31987. /**
  31988. * Gets the engine of the node
  31989. * @returns a Engine
  31990. */
  31991. getEngine(): Engine;
  31992. private _behaviors;
  31993. /**
  31994. * Attach a behavior to the node
  31995. * @see http://doc.babylonjs.com/features/behaviour
  31996. * @param behavior defines the behavior to attach
  31997. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31998. * @returns the current Node
  31999. */
  32000. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32001. /**
  32002. * Remove an attached behavior
  32003. * @see http://doc.babylonjs.com/features/behaviour
  32004. * @param behavior defines the behavior to attach
  32005. * @returns the current Node
  32006. */
  32007. removeBehavior(behavior: Behavior<Node>): Node;
  32008. /**
  32009. * Gets the list of attached behaviors
  32010. * @see http://doc.babylonjs.com/features/behaviour
  32011. */
  32012. get behaviors(): Behavior<Node>[];
  32013. /**
  32014. * Gets an attached behavior by name
  32015. * @param name defines the name of the behavior to look for
  32016. * @see http://doc.babylonjs.com/features/behaviour
  32017. * @returns null if behavior was not found else the requested behavior
  32018. */
  32019. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32020. /**
  32021. * Returns the latest update of the World matrix
  32022. * @returns a Matrix
  32023. */
  32024. getWorldMatrix(): Matrix;
  32025. /** @hidden */
  32026. _getWorldMatrixDeterminant(): number;
  32027. /**
  32028. * Returns directly the latest state of the mesh World matrix.
  32029. * A Matrix is returned.
  32030. */
  32031. get worldMatrixFromCache(): Matrix;
  32032. /** @hidden */
  32033. _initCache(): void;
  32034. /** @hidden */
  32035. updateCache(force?: boolean): void;
  32036. /** @hidden */
  32037. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32038. /** @hidden */
  32039. _updateCache(ignoreParentClass?: boolean): void;
  32040. /** @hidden */
  32041. _isSynchronized(): boolean;
  32042. /** @hidden */
  32043. _markSyncedWithParent(): void;
  32044. /** @hidden */
  32045. isSynchronizedWithParent(): boolean;
  32046. /** @hidden */
  32047. isSynchronized(): boolean;
  32048. /**
  32049. * Is this node ready to be used/rendered
  32050. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32051. * @return true if the node is ready
  32052. */
  32053. isReady(completeCheck?: boolean): boolean;
  32054. /**
  32055. * Is this node enabled?
  32056. * 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
  32057. * @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
  32058. * @return whether this node (and its parent) is enabled
  32059. */
  32060. isEnabled(checkAncestors?: boolean): boolean;
  32061. /** @hidden */
  32062. protected _syncParentEnabledState(): void;
  32063. /**
  32064. * Set the enabled state of this node
  32065. * @param value defines the new enabled state
  32066. */
  32067. setEnabled(value: boolean): void;
  32068. /**
  32069. * Is this node a descendant of the given node?
  32070. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32071. * @param ancestor defines the parent node to inspect
  32072. * @returns a boolean indicating if this node is a descendant of the given node
  32073. */
  32074. isDescendantOf(ancestor: Node): boolean;
  32075. /** @hidden */
  32076. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32077. /**
  32078. * Will return all nodes that have this node as ascendant
  32079. * @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
  32080. * @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
  32081. * @return all children nodes of all types
  32082. */
  32083. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32084. /**
  32085. * Get all child-meshes of this node
  32086. * @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)
  32087. * @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
  32088. * @returns an array of AbstractMesh
  32089. */
  32090. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32091. /**
  32092. * Get all direct children of this node
  32093. * @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
  32094. * @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)
  32095. * @returns an array of Node
  32096. */
  32097. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32098. /** @hidden */
  32099. _setReady(state: boolean): void;
  32100. /**
  32101. * Get an animation by name
  32102. * @param name defines the name of the animation to look for
  32103. * @returns null if not found else the requested animation
  32104. */
  32105. getAnimationByName(name: string): Nullable<Animation>;
  32106. /**
  32107. * Creates an animation range for this node
  32108. * @param name defines the name of the range
  32109. * @param from defines the starting key
  32110. * @param to defines the end key
  32111. */
  32112. createAnimationRange(name: string, from: number, to: number): void;
  32113. /**
  32114. * Delete a specific animation range
  32115. * @param name defines the name of the range to delete
  32116. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32117. */
  32118. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32119. /**
  32120. * Get an animation range by name
  32121. * @param name defines the name of the animation range to look for
  32122. * @returns null if not found else the requested animation range
  32123. */
  32124. getAnimationRange(name: string): Nullable<AnimationRange>;
  32125. /**
  32126. * Gets the list of all animation ranges defined on this node
  32127. * @returns an array
  32128. */
  32129. getAnimationRanges(): Nullable<AnimationRange>[];
  32130. /**
  32131. * Will start the animation sequence
  32132. * @param name defines the range frames for animation sequence
  32133. * @param loop defines if the animation should loop (false by default)
  32134. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32135. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32136. * @returns the object created for this animation. If range does not exist, it will return null
  32137. */
  32138. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32139. /**
  32140. * Serialize animation ranges into a JSON compatible object
  32141. * @returns serialization object
  32142. */
  32143. serializeAnimationRanges(): any;
  32144. /**
  32145. * Computes the world matrix of the node
  32146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32147. * @returns the world matrix
  32148. */
  32149. computeWorldMatrix(force?: boolean): Matrix;
  32150. /**
  32151. * Releases resources associated with this node.
  32152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32154. */
  32155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32156. /**
  32157. * Parse animation range data from a serialization object and store them into a given node
  32158. * @param node defines where to store the animation ranges
  32159. * @param parsedNode defines the serialization object to read data from
  32160. * @param scene defines the hosting scene
  32161. */
  32162. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32163. /**
  32164. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32165. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32166. * @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
  32167. * @returns the new bounding vectors
  32168. */
  32169. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32170. min: Vector3;
  32171. max: Vector3;
  32172. };
  32173. }
  32174. }
  32175. declare module BABYLON {
  32176. /**
  32177. * @hidden
  32178. */
  32179. export class _IAnimationState {
  32180. key: number;
  32181. repeatCount: number;
  32182. workValue?: any;
  32183. loopMode?: number;
  32184. offsetValue?: any;
  32185. highLimitValue?: any;
  32186. }
  32187. /**
  32188. * Class used to store any kind of animation
  32189. */
  32190. export class Animation {
  32191. /**Name of the animation */
  32192. name: string;
  32193. /**Property to animate */
  32194. targetProperty: string;
  32195. /**The frames per second of the animation */
  32196. framePerSecond: number;
  32197. /**The data type of the animation */
  32198. dataType: number;
  32199. /**The loop mode of the animation */
  32200. loopMode?: number | undefined;
  32201. /**Specifies if blending should be enabled */
  32202. enableBlending?: boolean | undefined;
  32203. /**
  32204. * Use matrix interpolation instead of using direct key value when animating matrices
  32205. */
  32206. static AllowMatricesInterpolation: boolean;
  32207. /**
  32208. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32209. */
  32210. static AllowMatrixDecomposeForInterpolation: boolean;
  32211. /**
  32212. * Stores the key frames of the animation
  32213. */
  32214. private _keys;
  32215. /**
  32216. * Stores the easing function of the animation
  32217. */
  32218. private _easingFunction;
  32219. /**
  32220. * @hidden Internal use only
  32221. */
  32222. _runtimeAnimations: RuntimeAnimation[];
  32223. /**
  32224. * The set of event that will be linked to this animation
  32225. */
  32226. private _events;
  32227. /**
  32228. * Stores an array of target property paths
  32229. */
  32230. targetPropertyPath: string[];
  32231. /**
  32232. * Stores the blending speed of the animation
  32233. */
  32234. blendingSpeed: number;
  32235. /**
  32236. * Stores the animation ranges for the animation
  32237. */
  32238. private _ranges;
  32239. /**
  32240. * @hidden Internal use
  32241. */
  32242. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32243. /**
  32244. * Sets up an animation
  32245. * @param property The property to animate
  32246. * @param animationType The animation type to apply
  32247. * @param framePerSecond The frames per second of the animation
  32248. * @param easingFunction The easing function used in the animation
  32249. * @returns The created animation
  32250. */
  32251. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32252. /**
  32253. * Create and start an animation on a node
  32254. * @param name defines the name of the global animation that will be run on all nodes
  32255. * @param node defines the root node where the animation will take place
  32256. * @param targetProperty defines property to animate
  32257. * @param framePerSecond defines the number of frame per second yo use
  32258. * @param totalFrame defines the number of frames in total
  32259. * @param from defines the initial value
  32260. * @param to defines the final value
  32261. * @param loopMode defines which loop mode you want to use (off by default)
  32262. * @param easingFunction defines the easing function to use (linear by default)
  32263. * @param onAnimationEnd defines the callback to call when animation end
  32264. * @returns the animatable created for this animation
  32265. */
  32266. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32267. /**
  32268. * Create and start an animation on a node and its descendants
  32269. * @param name defines the name of the global animation that will be run on all nodes
  32270. * @param node defines the root node where the animation will take place
  32271. * @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
  32272. * @param targetProperty defines property to animate
  32273. * @param framePerSecond defines the number of frame per second to use
  32274. * @param totalFrame defines the number of frames in total
  32275. * @param from defines the initial value
  32276. * @param to defines the final value
  32277. * @param loopMode defines which loop mode you want to use (off by default)
  32278. * @param easingFunction defines the easing function to use (linear by default)
  32279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32280. * @returns the list of animatables created for all nodes
  32281. * @example https://www.babylonjs-playground.com/#MH0VLI
  32282. */
  32283. 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[]>;
  32284. /**
  32285. * Creates a new animation, merges it with the existing animations and starts it
  32286. * @param name Name of the animation
  32287. * @param node Node which contains the scene that begins the animations
  32288. * @param targetProperty Specifies which property to animate
  32289. * @param framePerSecond The frames per second of the animation
  32290. * @param totalFrame The total number of frames
  32291. * @param from The frame at the beginning of the animation
  32292. * @param to The frame at the end of the animation
  32293. * @param loopMode Specifies the loop mode of the animation
  32294. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32295. * @param onAnimationEnd Callback to run once the animation is complete
  32296. * @returns Nullable animation
  32297. */
  32298. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32299. /**
  32300. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32301. * @param sourceAnimation defines the Animation containing keyframes to convert
  32302. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32303. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32304. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32305. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32306. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32307. */
  32308. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32309. /**
  32310. * Transition property of an host to the target Value
  32311. * @param property The property to transition
  32312. * @param targetValue The target Value of the property
  32313. * @param host The object where the property to animate belongs
  32314. * @param scene Scene used to run the animation
  32315. * @param frameRate Framerate (in frame/s) to use
  32316. * @param transition The transition type we want to use
  32317. * @param duration The duration of the animation, in milliseconds
  32318. * @param onAnimationEnd Callback trigger at the end of the animation
  32319. * @returns Nullable animation
  32320. */
  32321. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32322. /**
  32323. * Return the array of runtime animations currently using this animation
  32324. */
  32325. get runtimeAnimations(): RuntimeAnimation[];
  32326. /**
  32327. * Specifies if any of the runtime animations are currently running
  32328. */
  32329. get hasRunningRuntimeAnimations(): boolean;
  32330. /**
  32331. * Initializes the animation
  32332. * @param name Name of the animation
  32333. * @param targetProperty Property to animate
  32334. * @param framePerSecond The frames per second of the animation
  32335. * @param dataType The data type of the animation
  32336. * @param loopMode The loop mode of the animation
  32337. * @param enableBlending Specifies if blending should be enabled
  32338. */
  32339. constructor(
  32340. /**Name of the animation */
  32341. name: string,
  32342. /**Property to animate */
  32343. targetProperty: string,
  32344. /**The frames per second of the animation */
  32345. framePerSecond: number,
  32346. /**The data type of the animation */
  32347. dataType: number,
  32348. /**The loop mode of the animation */
  32349. loopMode?: number | undefined,
  32350. /**Specifies if blending should be enabled */
  32351. enableBlending?: boolean | undefined);
  32352. /**
  32353. * Converts the animation to a string
  32354. * @param fullDetails support for multiple levels of logging within scene loading
  32355. * @returns String form of the animation
  32356. */
  32357. toString(fullDetails?: boolean): string;
  32358. /**
  32359. * Add an event to this animation
  32360. * @param event Event to add
  32361. */
  32362. addEvent(event: AnimationEvent): void;
  32363. /**
  32364. * Remove all events found at the given frame
  32365. * @param frame The frame to remove events from
  32366. */
  32367. removeEvents(frame: number): void;
  32368. /**
  32369. * Retrieves all the events from the animation
  32370. * @returns Events from the animation
  32371. */
  32372. getEvents(): AnimationEvent[];
  32373. /**
  32374. * Creates an animation range
  32375. * @param name Name of the animation range
  32376. * @param from Starting frame of the animation range
  32377. * @param to Ending frame of the animation
  32378. */
  32379. createRange(name: string, from: number, to: number): void;
  32380. /**
  32381. * Deletes an animation range by name
  32382. * @param name Name of the animation range to delete
  32383. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32384. */
  32385. deleteRange(name: string, deleteFrames?: boolean): void;
  32386. /**
  32387. * Gets the animation range by name, or null if not defined
  32388. * @param name Name of the animation range
  32389. * @returns Nullable animation range
  32390. */
  32391. getRange(name: string): Nullable<AnimationRange>;
  32392. /**
  32393. * Gets the key frames from the animation
  32394. * @returns The key frames of the animation
  32395. */
  32396. getKeys(): Array<IAnimationKey>;
  32397. /**
  32398. * Gets the highest frame rate of the animation
  32399. * @returns Highest frame rate of the animation
  32400. */
  32401. getHighestFrame(): number;
  32402. /**
  32403. * Gets the easing function of the animation
  32404. * @returns Easing function of the animation
  32405. */
  32406. getEasingFunction(): IEasingFunction;
  32407. /**
  32408. * Sets the easing function of the animation
  32409. * @param easingFunction A custom mathematical formula for animation
  32410. */
  32411. setEasingFunction(easingFunction: EasingFunction): void;
  32412. /**
  32413. * Interpolates a scalar linearly
  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. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32420. /**
  32421. * Interpolates a scalar 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 Interpolated scalar value
  32428. */
  32429. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32430. /**
  32431. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  32436. */
  32437. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32438. /**
  32439. * Interpolates a quaternion cubically
  32440. * @param startValue Start value of the animation curve
  32441. * @param outTangent End tangent of the animation curve
  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 quaternion value
  32446. */
  32447. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32448. /**
  32449. * Interpolates a Vector3 linearl
  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 scalar value
  32454. */
  32455. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32456. /**
  32457. * Interpolates a Vector3 cubically
  32458. * @param startValue Start value of the animation curve
  32459. * @param outTangent End tangent of the animation
  32460. * @param endValue End value of the animation curve
  32461. * @param inTangent Start tangent of the animation curve
  32462. * @param gradient Scalar amount to interpolate
  32463. * @returns InterpolatedVector3 value
  32464. */
  32465. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32466. /**
  32467. * Interpolates a Vector2 linearly
  32468. * @param startValue Start value of the animation curve
  32469. * @param endValue End value of the animation curve
  32470. * @param gradient Scalar amount to interpolate
  32471. * @returns Interpolated Vector2 value
  32472. */
  32473. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32474. /**
  32475. * Interpolates a Vector2 cubically
  32476. * @param startValue Start value of the animation curve
  32477. * @param outTangent End tangent of the animation
  32478. * @param endValue End value of the animation curve
  32479. * @param inTangent Start tangent of the animation curve
  32480. * @param gradient Scalar amount to interpolate
  32481. * @returns Interpolated Vector2 value
  32482. */
  32483. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32484. /**
  32485. * Interpolates a size linearly
  32486. * @param startValue Start value of the animation curve
  32487. * @param endValue End value of the animation curve
  32488. * @param gradient Scalar amount to interpolate
  32489. * @returns Interpolated Size value
  32490. */
  32491. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32492. /**
  32493. * Interpolates a Color3 linearly
  32494. * @param startValue Start value of the animation curve
  32495. * @param endValue End value of the animation curve
  32496. * @param gradient Scalar amount to interpolate
  32497. * @returns Interpolated Color3 value
  32498. */
  32499. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32500. /**
  32501. * Interpolates a Color4 linearly
  32502. * @param startValue Start value of the animation curve
  32503. * @param endValue End value of the animation curve
  32504. * @param gradient Scalar amount to interpolate
  32505. * @returns Interpolated Color3 value
  32506. */
  32507. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32508. /**
  32509. * @hidden Internal use only
  32510. */
  32511. _getKeyValue(value: any): any;
  32512. /**
  32513. * @hidden Internal use only
  32514. */
  32515. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32516. /**
  32517. * Defines the function to use to interpolate matrices
  32518. * @param startValue defines the start matrix
  32519. * @param endValue defines the end matrix
  32520. * @param gradient defines the gradient between both matrices
  32521. * @param result defines an optional target matrix where to store the interpolation
  32522. * @returns the interpolated matrix
  32523. */
  32524. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32525. /**
  32526. * Makes a copy of the animation
  32527. * @returns Cloned animation
  32528. */
  32529. clone(): Animation;
  32530. /**
  32531. * Sets the key frames of the animation
  32532. * @param values The animation key frames to set
  32533. */
  32534. setKeys(values: Array<IAnimationKey>): void;
  32535. /**
  32536. * Serializes the animation to an object
  32537. * @returns Serialized object
  32538. */
  32539. serialize(): any;
  32540. /**
  32541. * Float animation type
  32542. */
  32543. static readonly ANIMATIONTYPE_FLOAT: number;
  32544. /**
  32545. * Vector3 animation type
  32546. */
  32547. static readonly ANIMATIONTYPE_VECTOR3: number;
  32548. /**
  32549. * Quaternion animation type
  32550. */
  32551. static readonly ANIMATIONTYPE_QUATERNION: number;
  32552. /**
  32553. * Matrix animation type
  32554. */
  32555. static readonly ANIMATIONTYPE_MATRIX: number;
  32556. /**
  32557. * Color3 animation type
  32558. */
  32559. static readonly ANIMATIONTYPE_COLOR3: number;
  32560. /**
  32561. * Color3 animation type
  32562. */
  32563. static readonly ANIMATIONTYPE_COLOR4: number;
  32564. /**
  32565. * Vector2 animation type
  32566. */
  32567. static readonly ANIMATIONTYPE_VECTOR2: number;
  32568. /**
  32569. * Size animation type
  32570. */
  32571. static readonly ANIMATIONTYPE_SIZE: number;
  32572. /**
  32573. * Relative Loop Mode
  32574. */
  32575. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32576. /**
  32577. * Cycle Loop Mode
  32578. */
  32579. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32580. /**
  32581. * Constant Loop Mode
  32582. */
  32583. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32584. /** @hidden */
  32585. static _UniversalLerp(left: any, right: any, amount: number): any;
  32586. /**
  32587. * Parses an animation object and creates an animation
  32588. * @param parsedAnimation Parsed animation object
  32589. * @returns Animation object
  32590. */
  32591. static Parse(parsedAnimation: any): Animation;
  32592. /**
  32593. * Appends the serialized animations from the source animations
  32594. * @param source Source containing the animations
  32595. * @param destination Target to store the animations
  32596. */
  32597. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32598. }
  32599. }
  32600. declare module BABYLON {
  32601. /**
  32602. * Interface containing an array of animations
  32603. */
  32604. export interface IAnimatable {
  32605. /**
  32606. * Array of animations
  32607. */
  32608. animations: Nullable<Array<Animation>>;
  32609. }
  32610. }
  32611. declare module BABYLON {
  32612. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32613. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32614. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32615. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32616. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32617. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32618. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32619. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32620. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32621. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32622. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32623. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32624. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32625. /**
  32626. * Decorator used to define property that can be serialized as reference to a camera
  32627. * @param sourceName defines the name of the property to decorate
  32628. */
  32629. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32630. /**
  32631. * Class used to help serialization objects
  32632. */
  32633. export class SerializationHelper {
  32634. /** @hidden */
  32635. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32636. /** @hidden */
  32637. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32638. /** @hidden */
  32639. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32640. /** @hidden */
  32641. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32642. /**
  32643. * Appends the serialized animations from the source animations
  32644. * @param source Source containing the animations
  32645. * @param destination Target to store the animations
  32646. */
  32647. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32648. /**
  32649. * Static function used to serialized a specific entity
  32650. * @param entity defines the entity to serialize
  32651. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32652. * @returns a JSON compatible object representing the serialization of the entity
  32653. */
  32654. static Serialize<T>(entity: T, serializationObject?: any): any;
  32655. /**
  32656. * Creates a new entity from a serialization data object
  32657. * @param creationFunction defines a function used to instanciated the new entity
  32658. * @param source defines the source serialization data
  32659. * @param scene defines the hosting scene
  32660. * @param rootUrl defines the root url for resources
  32661. * @returns a new entity
  32662. */
  32663. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32664. /**
  32665. * Clones an object
  32666. * @param creationFunction defines the function used to instanciate the new object
  32667. * @param source defines the source object
  32668. * @returns the cloned object
  32669. */
  32670. static Clone<T>(creationFunction: () => T, source: T): T;
  32671. /**
  32672. * Instanciates a new object based on a source one (some data will be shared between both object)
  32673. * @param creationFunction defines the function used to instanciate the new object
  32674. * @param source defines the source object
  32675. * @returns the new object
  32676. */
  32677. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32678. }
  32679. }
  32680. declare module BABYLON {
  32681. /**
  32682. * Base class of all the textures in babylon.
  32683. * It groups all the common properties the materials, post process, lights... might need
  32684. * in order to make a correct use of the texture.
  32685. */
  32686. export class BaseTexture implements IAnimatable {
  32687. /**
  32688. * Default anisotropic filtering level for the application.
  32689. * It is set to 4 as a good tradeoff between perf and quality.
  32690. */
  32691. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32692. /**
  32693. * Gets or sets the unique id of the texture
  32694. */
  32695. uniqueId: number;
  32696. /**
  32697. * Define the name of the texture.
  32698. */
  32699. name: string;
  32700. /**
  32701. * Gets or sets an object used to store user defined information.
  32702. */
  32703. metadata: any;
  32704. /**
  32705. * For internal use only. Please do not use.
  32706. */
  32707. reservedDataStore: any;
  32708. private _hasAlpha;
  32709. /**
  32710. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32711. */
  32712. set hasAlpha(value: boolean);
  32713. get hasAlpha(): boolean;
  32714. /**
  32715. * Defines if the alpha value should be determined via the rgb values.
  32716. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32717. */
  32718. getAlphaFromRGB: boolean;
  32719. /**
  32720. * Intensity or strength of the texture.
  32721. * It is commonly used by materials to fine tune the intensity of the texture
  32722. */
  32723. level: number;
  32724. /**
  32725. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32726. * This is part of the texture as textures usually maps to one uv set.
  32727. */
  32728. coordinatesIndex: number;
  32729. private _coordinatesMode;
  32730. /**
  32731. * How a texture is mapped.
  32732. *
  32733. * | Value | Type | Description |
  32734. * | ----- | ----------------------------------- | ----------- |
  32735. * | 0 | EXPLICIT_MODE | |
  32736. * | 1 | SPHERICAL_MODE | |
  32737. * | 2 | PLANAR_MODE | |
  32738. * | 3 | CUBIC_MODE | |
  32739. * | 4 | PROJECTION_MODE | |
  32740. * | 5 | SKYBOX_MODE | |
  32741. * | 6 | INVCUBIC_MODE | |
  32742. * | 7 | EQUIRECTANGULAR_MODE | |
  32743. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32744. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32745. */
  32746. set coordinatesMode(value: number);
  32747. get coordinatesMode(): number;
  32748. /**
  32749. * | Value | Type | Description |
  32750. * | ----- | ------------------ | ----------- |
  32751. * | 0 | CLAMP_ADDRESSMODE | |
  32752. * | 1 | WRAP_ADDRESSMODE | |
  32753. * | 2 | MIRROR_ADDRESSMODE | |
  32754. */
  32755. wrapU: number;
  32756. /**
  32757. * | Value | Type | Description |
  32758. * | ----- | ------------------ | ----------- |
  32759. * | 0 | CLAMP_ADDRESSMODE | |
  32760. * | 1 | WRAP_ADDRESSMODE | |
  32761. * | 2 | MIRROR_ADDRESSMODE | |
  32762. */
  32763. wrapV: number;
  32764. /**
  32765. * | Value | Type | Description |
  32766. * | ----- | ------------------ | ----------- |
  32767. * | 0 | CLAMP_ADDRESSMODE | |
  32768. * | 1 | WRAP_ADDRESSMODE | |
  32769. * | 2 | MIRROR_ADDRESSMODE | |
  32770. */
  32771. wrapR: number;
  32772. /**
  32773. * With compliant hardware and browser (supporting anisotropic filtering)
  32774. * this defines the level of anisotropic filtering in the texture.
  32775. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32776. */
  32777. anisotropicFilteringLevel: number;
  32778. /**
  32779. * Define if the texture is a cube texture or if false a 2d texture.
  32780. */
  32781. get isCube(): boolean;
  32782. set isCube(value: boolean);
  32783. /**
  32784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32785. */
  32786. get is3D(): boolean;
  32787. set is3D(value: boolean);
  32788. /**
  32789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32790. */
  32791. get is2DArray(): boolean;
  32792. set is2DArray(value: boolean);
  32793. /**
  32794. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32795. * HDR texture are usually stored in linear space.
  32796. * This only impacts the PBR and Background materials
  32797. */
  32798. gammaSpace: boolean;
  32799. /**
  32800. * Gets or sets whether or not the texture contains RGBD data.
  32801. */
  32802. get isRGBD(): boolean;
  32803. set isRGBD(value: boolean);
  32804. /**
  32805. * Is Z inverted in the texture (useful in a cube texture).
  32806. */
  32807. invertZ: boolean;
  32808. /**
  32809. * Are mip maps generated for this texture or not.
  32810. */
  32811. get noMipmap(): boolean;
  32812. /**
  32813. * @hidden
  32814. */
  32815. lodLevelInAlpha: boolean;
  32816. /**
  32817. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32818. */
  32819. get lodGenerationOffset(): number;
  32820. set lodGenerationOffset(value: number);
  32821. /**
  32822. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32823. */
  32824. get lodGenerationScale(): number;
  32825. set lodGenerationScale(value: number);
  32826. /**
  32827. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32828. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32829. * average roughness values.
  32830. */
  32831. get linearSpecularLOD(): boolean;
  32832. set linearSpecularLOD(value: boolean);
  32833. /**
  32834. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32835. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32836. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32837. */
  32838. get irradianceTexture(): Nullable<BaseTexture>;
  32839. set irradianceTexture(value: Nullable<BaseTexture>);
  32840. /**
  32841. * Define if the texture is a render target.
  32842. */
  32843. isRenderTarget: boolean;
  32844. /**
  32845. * Define the unique id of the texture in the scene.
  32846. */
  32847. get uid(): string;
  32848. /** @hidden */
  32849. _prefiltered: boolean;
  32850. /**
  32851. * Return a string representation of the texture.
  32852. * @returns the texture as a string
  32853. */
  32854. toString(): string;
  32855. /**
  32856. * Get the class name of the texture.
  32857. * @returns "BaseTexture"
  32858. */
  32859. getClassName(): string;
  32860. /**
  32861. * Define the list of animation attached to the texture.
  32862. */
  32863. animations: Animation[];
  32864. /**
  32865. * An event triggered when the texture is disposed.
  32866. */
  32867. onDisposeObservable: Observable<BaseTexture>;
  32868. private _onDisposeObserver;
  32869. /**
  32870. * Callback triggered when the texture has been disposed.
  32871. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32872. */
  32873. set onDispose(callback: () => void);
  32874. /**
  32875. * Define the current state of the loading sequence when in delayed load mode.
  32876. */
  32877. delayLoadState: number;
  32878. private _scene;
  32879. private _engine;
  32880. /** @hidden */
  32881. _texture: Nullable<InternalTexture>;
  32882. private _uid;
  32883. /**
  32884. * Define if the texture is preventinga material to render or not.
  32885. * If not and the texture is not ready, the engine will use a default black texture instead.
  32886. */
  32887. get isBlocking(): boolean;
  32888. /**
  32889. * Instantiates a new BaseTexture.
  32890. * Base class of all the textures in babylon.
  32891. * It groups all the common properties the materials, post process, lights... might need
  32892. * in order to make a correct use of the texture.
  32893. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32894. */
  32895. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32896. /**
  32897. * Get the scene the texture belongs to.
  32898. * @returns the scene or null if undefined
  32899. */
  32900. getScene(): Nullable<Scene>;
  32901. /** @hidden */
  32902. protected _getEngine(): Nullable<ThinEngine>;
  32903. /**
  32904. * Get the texture transform matrix used to offset tile the texture for istance.
  32905. * @returns the transformation matrix
  32906. */
  32907. getTextureMatrix(): Matrix;
  32908. /**
  32909. * Get the texture reflection matrix used to rotate/transform the reflection.
  32910. * @returns the reflection matrix
  32911. */
  32912. getReflectionTextureMatrix(): Matrix;
  32913. /**
  32914. * Get the underlying lower level texture from Babylon.
  32915. * @returns the insternal texture
  32916. */
  32917. getInternalTexture(): Nullable<InternalTexture>;
  32918. /**
  32919. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32920. * @returns true if ready or not blocking
  32921. */
  32922. isReadyOrNotBlocking(): boolean;
  32923. /**
  32924. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32925. * @returns true if fully ready
  32926. */
  32927. isReady(): boolean;
  32928. private _cachedSize;
  32929. /**
  32930. * Get the size of the texture.
  32931. * @returns the texture size.
  32932. */
  32933. getSize(): ISize;
  32934. /**
  32935. * Get the base size of the texture.
  32936. * It can be different from the size if the texture has been resized for POT for instance
  32937. * @returns the base size
  32938. */
  32939. getBaseSize(): ISize;
  32940. /**
  32941. * Update the sampling mode of the texture.
  32942. * Default is Trilinear mode.
  32943. *
  32944. * | Value | Type | Description |
  32945. * | ----- | ------------------ | ----------- |
  32946. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32947. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32948. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32949. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32950. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32951. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32952. * | 7 | NEAREST_LINEAR | |
  32953. * | 8 | NEAREST_NEAREST | |
  32954. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32955. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32956. * | 11 | LINEAR_LINEAR | |
  32957. * | 12 | LINEAR_NEAREST | |
  32958. *
  32959. * > _mag_: magnification filter (close to the viewer)
  32960. * > _min_: minification filter (far from the viewer)
  32961. * > _mip_: filter used between mip map levels
  32962. *@param samplingMode Define the new sampling mode of the texture
  32963. */
  32964. updateSamplingMode(samplingMode: number): void;
  32965. /**
  32966. * Scales the texture if is `canRescale()`
  32967. * @param ratio the resize factor we want to use to rescale
  32968. */
  32969. scale(ratio: number): void;
  32970. /**
  32971. * Get if the texture can rescale.
  32972. */
  32973. get canRescale(): boolean;
  32974. /** @hidden */
  32975. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32976. /** @hidden */
  32977. _rebuild(): void;
  32978. /**
  32979. * Triggers the load sequence in delayed load mode.
  32980. */
  32981. delayLoad(): void;
  32982. /**
  32983. * Clones the texture.
  32984. * @returns the cloned texture
  32985. */
  32986. clone(): Nullable<BaseTexture>;
  32987. /**
  32988. * Get the texture underlying type (INT, FLOAT...)
  32989. */
  32990. get textureType(): number;
  32991. /**
  32992. * Get the texture underlying format (RGB, RGBA...)
  32993. */
  32994. get textureFormat(): number;
  32995. /**
  32996. * Indicates that textures need to be re-calculated for all materials
  32997. */
  32998. protected _markAllSubMeshesAsTexturesDirty(): void;
  32999. /**
  33000. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33001. * This will returns an RGBA array buffer containing either in values (0-255) or
  33002. * float values (0-1) depending of the underlying buffer type.
  33003. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33004. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33005. * @param buffer defines a user defined buffer to fill with data (can be null)
  33006. * @returns The Array buffer containing the pixels data.
  33007. */
  33008. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33009. /**
  33010. * Release and destroy the underlying lower level texture aka internalTexture.
  33011. */
  33012. releaseInternalTexture(): void;
  33013. /** @hidden */
  33014. get _lodTextureHigh(): Nullable<BaseTexture>;
  33015. /** @hidden */
  33016. get _lodTextureMid(): Nullable<BaseTexture>;
  33017. /** @hidden */
  33018. get _lodTextureLow(): Nullable<BaseTexture>;
  33019. /**
  33020. * Dispose the texture and release its associated resources.
  33021. */
  33022. dispose(): void;
  33023. /**
  33024. * Serialize the texture into a JSON representation that can be parsed later on.
  33025. * @returns the JSON representation of the texture
  33026. */
  33027. serialize(): any;
  33028. /**
  33029. * Helper function to be called back once a list of texture contains only ready textures.
  33030. * @param textures Define the list of textures to wait for
  33031. * @param callback Define the callback triggered once the entire list will be ready
  33032. */
  33033. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33034. private static _isScene;
  33035. }
  33036. }
  33037. declare module BABYLON {
  33038. /**
  33039. * Options to be used when creating an effect.
  33040. */
  33041. export interface IEffectCreationOptions {
  33042. /**
  33043. * Atrributes that will be used in the shader.
  33044. */
  33045. attributes: string[];
  33046. /**
  33047. * Uniform varible names that will be set in the shader.
  33048. */
  33049. uniformsNames: string[];
  33050. /**
  33051. * Uniform buffer variable names that will be set in the shader.
  33052. */
  33053. uniformBuffersNames: string[];
  33054. /**
  33055. * Sampler texture variable names that will be set in the shader.
  33056. */
  33057. samplers: string[];
  33058. /**
  33059. * Define statements that will be set in the shader.
  33060. */
  33061. defines: any;
  33062. /**
  33063. * Possible fallbacks for this effect to improve performance when needed.
  33064. */
  33065. fallbacks: Nullable<IEffectFallbacks>;
  33066. /**
  33067. * Callback that will be called when the shader is compiled.
  33068. */
  33069. onCompiled: Nullable<(effect: Effect) => void>;
  33070. /**
  33071. * Callback that will be called if an error occurs during shader compilation.
  33072. */
  33073. onError: Nullable<(effect: Effect, errors: string) => void>;
  33074. /**
  33075. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33076. */
  33077. indexParameters?: any;
  33078. /**
  33079. * Max number of lights that can be used in the shader.
  33080. */
  33081. maxSimultaneousLights?: number;
  33082. /**
  33083. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33084. */
  33085. transformFeedbackVaryings?: Nullable<string[]>;
  33086. /**
  33087. * 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
  33088. */
  33089. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33090. }
  33091. /**
  33092. * Effect containing vertex and fragment shader that can be executed on an object.
  33093. */
  33094. export class Effect implements IDisposable {
  33095. /**
  33096. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33097. */
  33098. static ShadersRepository: string;
  33099. /**
  33100. * Enable logging of the shader code when a compilation error occurs
  33101. */
  33102. static LogShaderCodeOnCompilationError: boolean;
  33103. /**
  33104. * Name of the effect.
  33105. */
  33106. name: any;
  33107. /**
  33108. * String container all the define statements that should be set on the shader.
  33109. */
  33110. defines: string;
  33111. /**
  33112. * Callback that will be called when the shader is compiled.
  33113. */
  33114. onCompiled: Nullable<(effect: Effect) => void>;
  33115. /**
  33116. * Callback that will be called if an error occurs during shader compilation.
  33117. */
  33118. onError: Nullable<(effect: Effect, errors: string) => void>;
  33119. /**
  33120. * Callback that will be called when effect is bound.
  33121. */
  33122. onBind: Nullable<(effect: Effect) => void>;
  33123. /**
  33124. * Unique ID of the effect.
  33125. */
  33126. uniqueId: number;
  33127. /**
  33128. * Observable that will be called when the shader is compiled.
  33129. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33130. */
  33131. onCompileObservable: Observable<Effect>;
  33132. /**
  33133. * Observable that will be called if an error occurs during shader compilation.
  33134. */
  33135. onErrorObservable: Observable<Effect>;
  33136. /** @hidden */
  33137. _onBindObservable: Nullable<Observable<Effect>>;
  33138. /**
  33139. * @hidden
  33140. * Specifies if the effect was previously ready
  33141. */
  33142. _wasPreviouslyReady: boolean;
  33143. /**
  33144. * Observable that will be called when effect is bound.
  33145. */
  33146. get onBindObservable(): Observable<Effect>;
  33147. /** @hidden */
  33148. _bonesComputationForcedToCPU: boolean;
  33149. private static _uniqueIdSeed;
  33150. private _engine;
  33151. private _uniformBuffersNames;
  33152. private _uniformBuffersNamesList;
  33153. private _uniformsNames;
  33154. private _samplerList;
  33155. private _samplers;
  33156. private _isReady;
  33157. private _compilationError;
  33158. private _allFallbacksProcessed;
  33159. private _attributesNames;
  33160. private _attributes;
  33161. private _attributeLocationByName;
  33162. private _uniforms;
  33163. /**
  33164. * Key for the effect.
  33165. * @hidden
  33166. */
  33167. _key: string;
  33168. private _indexParameters;
  33169. private _fallbacks;
  33170. private _vertexSourceCode;
  33171. private _fragmentSourceCode;
  33172. private _vertexSourceCodeOverride;
  33173. private _fragmentSourceCodeOverride;
  33174. private _transformFeedbackVaryings;
  33175. /**
  33176. * Compiled shader to webGL program.
  33177. * @hidden
  33178. */
  33179. _pipelineContext: Nullable<IPipelineContext>;
  33180. private _valueCache;
  33181. private static _baseCache;
  33182. /**
  33183. * Instantiates an effect.
  33184. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33185. * @param baseName Name of the effect.
  33186. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33187. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33188. * @param samplers List of sampler variables that will be passed to the shader.
  33189. * @param engine Engine to be used to render the effect
  33190. * @param defines Define statements to be added to the shader.
  33191. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33192. * @param onCompiled Callback that will be called when the shader is compiled.
  33193. * @param onError Callback that will be called if an error occurs during shader compilation.
  33194. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33195. */
  33196. 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);
  33197. private _useFinalCode;
  33198. /**
  33199. * Unique key for this effect
  33200. */
  33201. get key(): string;
  33202. /**
  33203. * If the effect has been compiled and prepared.
  33204. * @returns if the effect is compiled and prepared.
  33205. */
  33206. isReady(): boolean;
  33207. private _isReadyInternal;
  33208. /**
  33209. * The engine the effect was initialized with.
  33210. * @returns the engine.
  33211. */
  33212. getEngine(): Engine;
  33213. /**
  33214. * The pipeline context for this effect
  33215. * @returns the associated pipeline context
  33216. */
  33217. getPipelineContext(): Nullable<IPipelineContext>;
  33218. /**
  33219. * The set of names of attribute variables for the shader.
  33220. * @returns An array of attribute names.
  33221. */
  33222. getAttributesNames(): string[];
  33223. /**
  33224. * Returns the attribute at the given index.
  33225. * @param index The index of the attribute.
  33226. * @returns The location of the attribute.
  33227. */
  33228. getAttributeLocation(index: number): number;
  33229. /**
  33230. * Returns the attribute based on the name of the variable.
  33231. * @param name of the attribute to look up.
  33232. * @returns the attribute location.
  33233. */
  33234. getAttributeLocationByName(name: string): number;
  33235. /**
  33236. * The number of attributes.
  33237. * @returns the numnber of attributes.
  33238. */
  33239. getAttributesCount(): number;
  33240. /**
  33241. * Gets the index of a uniform variable.
  33242. * @param uniformName of the uniform to look up.
  33243. * @returns the index.
  33244. */
  33245. getUniformIndex(uniformName: string): number;
  33246. /**
  33247. * Returns the attribute based on the name of the variable.
  33248. * @param uniformName of the uniform to look up.
  33249. * @returns the location of the uniform.
  33250. */
  33251. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33252. /**
  33253. * Returns an array of sampler variable names
  33254. * @returns The array of sampler variable names.
  33255. */
  33256. getSamplers(): string[];
  33257. /**
  33258. * Returns an array of uniform variable names
  33259. * @returns The array of uniform variable names.
  33260. */
  33261. getUniformNames(): string[];
  33262. /**
  33263. * Returns an array of uniform buffer variable names
  33264. * @returns The array of uniform buffer variable names.
  33265. */
  33266. getUniformBuffersNames(): string[];
  33267. /**
  33268. * Returns the index parameters used to create the effect
  33269. * @returns The index parameters object
  33270. */
  33271. getIndexParameters(): any;
  33272. /**
  33273. * The error from the last compilation.
  33274. * @returns the error string.
  33275. */
  33276. getCompilationError(): string;
  33277. /**
  33278. * Gets a boolean indicating that all fallbacks were used during compilation
  33279. * @returns true if all fallbacks were used
  33280. */
  33281. allFallbacksProcessed(): boolean;
  33282. /**
  33283. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33284. * @param func The callback to be used.
  33285. */
  33286. executeWhenCompiled(func: (effect: Effect) => void): void;
  33287. private _checkIsReady;
  33288. private _loadShader;
  33289. /**
  33290. * Gets the vertex shader source code of this effect
  33291. */
  33292. get vertexSourceCode(): string;
  33293. /**
  33294. * Gets the fragment shader source code of this effect
  33295. */
  33296. get fragmentSourceCode(): string;
  33297. /**
  33298. * Recompiles the webGL program
  33299. * @param vertexSourceCode The source code for the vertex shader.
  33300. * @param fragmentSourceCode The source code for the fragment shader.
  33301. * @param onCompiled Callback called when completed.
  33302. * @param onError Callback called on error.
  33303. * @hidden
  33304. */
  33305. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33306. /**
  33307. * Prepares the effect
  33308. * @hidden
  33309. */
  33310. _prepareEffect(): void;
  33311. private _getShaderCodeAndErrorLine;
  33312. private _processCompilationErrors;
  33313. /**
  33314. * Checks if the effect is supported. (Must be called after compilation)
  33315. */
  33316. get isSupported(): boolean;
  33317. /**
  33318. * Binds a texture to the engine to be used as output of the shader.
  33319. * @param channel Name of the output variable.
  33320. * @param texture Texture to bind.
  33321. * @hidden
  33322. */
  33323. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33324. /**
  33325. * Sets a texture on the engine to be used in the shader.
  33326. * @param channel Name of the sampler variable.
  33327. * @param texture Texture to set.
  33328. */
  33329. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33330. /**
  33331. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33332. * @param channel Name of the sampler variable.
  33333. * @param texture Texture to set.
  33334. */
  33335. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33336. /**
  33337. * Sets an array of textures on the engine to be used in the shader.
  33338. * @param channel Name of the variable.
  33339. * @param textures Textures to set.
  33340. */
  33341. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33342. /**
  33343. * 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)
  33344. * @param channel Name of the sampler variable.
  33345. * @param postProcess Post process to get the input texture from.
  33346. */
  33347. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33348. /**
  33349. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33350. * 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)
  33351. * @param channel Name of the sampler variable.
  33352. * @param postProcess Post process to get the output texture from.
  33353. */
  33354. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33355. /** @hidden */
  33356. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33357. /** @hidden */
  33358. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33359. /** @hidden */
  33360. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33361. /** @hidden */
  33362. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33363. /**
  33364. * Binds a buffer to a uniform.
  33365. * @param buffer Buffer to bind.
  33366. * @param name Name of the uniform variable to bind to.
  33367. */
  33368. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33369. /**
  33370. * Binds block to a uniform.
  33371. * @param blockName Name of the block to bind.
  33372. * @param index Index to bind.
  33373. */
  33374. bindUniformBlock(blockName: string, index: number): void;
  33375. /**
  33376. * Sets an interger value on a uniform variable.
  33377. * @param uniformName Name of the variable.
  33378. * @param value Value to be set.
  33379. * @returns this effect.
  33380. */
  33381. setInt(uniformName: string, value: number): Effect;
  33382. /**
  33383. * Sets an int array on a uniform variable.
  33384. * @param uniformName Name of the variable.
  33385. * @param array array to be set.
  33386. * @returns this effect.
  33387. */
  33388. setIntArray(uniformName: string, array: Int32Array): Effect;
  33389. /**
  33390. * 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)
  33391. * @param uniformName Name of the variable.
  33392. * @param array array to be set.
  33393. * @returns this effect.
  33394. */
  33395. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33396. /**
  33397. * 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)
  33398. * @param uniformName Name of the variable.
  33399. * @param array array to be set.
  33400. * @returns this effect.
  33401. */
  33402. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33403. /**
  33404. * 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)
  33405. * @param uniformName Name of the variable.
  33406. * @param array array to be set.
  33407. * @returns this effect.
  33408. */
  33409. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33410. /**
  33411. * Sets an float array on a uniform variable.
  33412. * @param uniformName Name of the variable.
  33413. * @param array array to be set.
  33414. * @returns this effect.
  33415. */
  33416. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33417. /**
  33418. * 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)
  33419. * @param uniformName Name of the variable.
  33420. * @param array array to be set.
  33421. * @returns this effect.
  33422. */
  33423. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33424. /**
  33425. * 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)
  33426. * @param uniformName Name of the variable.
  33427. * @param array array to be set.
  33428. * @returns this effect.
  33429. */
  33430. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33431. /**
  33432. * 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)
  33433. * @param uniformName Name of the variable.
  33434. * @param array array to be set.
  33435. * @returns this effect.
  33436. */
  33437. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33438. /**
  33439. * Sets an array on a uniform variable.
  33440. * @param uniformName Name of the variable.
  33441. * @param array array to be set.
  33442. * @returns this effect.
  33443. */
  33444. setArray(uniformName: string, array: number[]): Effect;
  33445. /**
  33446. * 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)
  33447. * @param uniformName Name of the variable.
  33448. * @param array array to be set.
  33449. * @returns this effect.
  33450. */
  33451. setArray2(uniformName: string, array: number[]): Effect;
  33452. /**
  33453. * 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)
  33454. * @param uniformName Name of the variable.
  33455. * @param array array to be set.
  33456. * @returns this effect.
  33457. */
  33458. setArray3(uniformName: string, array: number[]): Effect;
  33459. /**
  33460. * 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)
  33461. * @param uniformName Name of the variable.
  33462. * @param array array to be set.
  33463. * @returns this effect.
  33464. */
  33465. setArray4(uniformName: string, array: number[]): Effect;
  33466. /**
  33467. * Sets matrices on a uniform variable.
  33468. * @param uniformName Name of the variable.
  33469. * @param matrices matrices to be set.
  33470. * @returns this effect.
  33471. */
  33472. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33473. /**
  33474. * Sets matrix on a uniform variable.
  33475. * @param uniformName Name of the variable.
  33476. * @param matrix matrix to be set.
  33477. * @returns this effect.
  33478. */
  33479. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33480. /**
  33481. * 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)
  33482. * @param uniformName Name of the variable.
  33483. * @param matrix matrix to be set.
  33484. * @returns this effect.
  33485. */
  33486. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33487. /**
  33488. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33489. * @param uniformName Name of the variable.
  33490. * @param matrix matrix to be set.
  33491. * @returns this effect.
  33492. */
  33493. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33494. /**
  33495. * Sets a float on a uniform variable.
  33496. * @param uniformName Name of the variable.
  33497. * @param value value to be set.
  33498. * @returns this effect.
  33499. */
  33500. setFloat(uniformName: string, value: number): Effect;
  33501. /**
  33502. * Sets a boolean on a uniform variable.
  33503. * @param uniformName Name of the variable.
  33504. * @param bool value to be set.
  33505. * @returns this effect.
  33506. */
  33507. setBool(uniformName: string, bool: boolean): Effect;
  33508. /**
  33509. * Sets a Vector2 on a uniform variable.
  33510. * @param uniformName Name of the variable.
  33511. * @param vector2 vector2 to be set.
  33512. * @returns this effect.
  33513. */
  33514. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33515. /**
  33516. * Sets a float2 on a uniform variable.
  33517. * @param uniformName Name of the variable.
  33518. * @param x First float in float2.
  33519. * @param y Second float in float2.
  33520. * @returns this effect.
  33521. */
  33522. setFloat2(uniformName: string, x: number, y: number): Effect;
  33523. /**
  33524. * Sets a Vector3 on a uniform variable.
  33525. * @param uniformName Name of the variable.
  33526. * @param vector3 Value to be set.
  33527. * @returns this effect.
  33528. */
  33529. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33530. /**
  33531. * Sets a float3 on a uniform variable.
  33532. * @param uniformName Name of the variable.
  33533. * @param x First float in float3.
  33534. * @param y Second float in float3.
  33535. * @param z Third float in float3.
  33536. * @returns this effect.
  33537. */
  33538. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33539. /**
  33540. * Sets a Vector4 on a uniform variable.
  33541. * @param uniformName Name of the variable.
  33542. * @param vector4 Value to be set.
  33543. * @returns this effect.
  33544. */
  33545. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33546. /**
  33547. * Sets a float4 on a uniform variable.
  33548. * @param uniformName Name of the variable.
  33549. * @param x First float in float4.
  33550. * @param y Second float in float4.
  33551. * @param z Third float in float4.
  33552. * @param w Fourth float in float4.
  33553. * @returns this effect.
  33554. */
  33555. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33556. /**
  33557. * Sets a Color3 on a uniform variable.
  33558. * @param uniformName Name of the variable.
  33559. * @param color3 Value to be set.
  33560. * @returns this effect.
  33561. */
  33562. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33563. /**
  33564. * Sets a Color4 on a uniform variable.
  33565. * @param uniformName Name of the variable.
  33566. * @param color3 Value to be set.
  33567. * @param alpha Alpha value to be set.
  33568. * @returns this effect.
  33569. */
  33570. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33571. /**
  33572. * Sets a Color4 on a uniform variable
  33573. * @param uniformName defines the name of the variable
  33574. * @param color4 defines the value to be set
  33575. * @returns this effect.
  33576. */
  33577. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33578. /** Release all associated resources */
  33579. dispose(): void;
  33580. /**
  33581. * This function will add a new shader to the shader store
  33582. * @param name the name of the shader
  33583. * @param pixelShader optional pixel shader content
  33584. * @param vertexShader optional vertex shader content
  33585. */
  33586. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33587. /**
  33588. * Store of each shader (The can be looked up using effect.key)
  33589. */
  33590. static ShadersStore: {
  33591. [key: string]: string;
  33592. };
  33593. /**
  33594. * Store of each included file for a shader (The can be looked up using effect.key)
  33595. */
  33596. static IncludesShadersStore: {
  33597. [key: string]: string;
  33598. };
  33599. /**
  33600. * Resets the cache of effects.
  33601. */
  33602. static ResetCache(): void;
  33603. }
  33604. }
  33605. declare module BABYLON {
  33606. /**
  33607. * Interface used to describe the capabilities of the engine relatively to the current browser
  33608. */
  33609. export interface EngineCapabilities {
  33610. /** Maximum textures units per fragment shader */
  33611. maxTexturesImageUnits: number;
  33612. /** Maximum texture units per vertex shader */
  33613. maxVertexTextureImageUnits: number;
  33614. /** Maximum textures units in the entire pipeline */
  33615. maxCombinedTexturesImageUnits: number;
  33616. /** Maximum texture size */
  33617. maxTextureSize: number;
  33618. /** Maximum texture samples */
  33619. maxSamples?: number;
  33620. /** Maximum cube texture size */
  33621. maxCubemapTextureSize: number;
  33622. /** Maximum render texture size */
  33623. maxRenderTextureSize: number;
  33624. /** Maximum number of vertex attributes */
  33625. maxVertexAttribs: number;
  33626. /** Maximum number of varyings */
  33627. maxVaryingVectors: number;
  33628. /** Maximum number of uniforms per vertex shader */
  33629. maxVertexUniformVectors: number;
  33630. /** Maximum number of uniforms per fragment shader */
  33631. maxFragmentUniformVectors: number;
  33632. /** Defines if standard derivates (dx/dy) are supported */
  33633. standardDerivatives: boolean;
  33634. /** Defines if s3tc texture compression is supported */
  33635. s3tc?: WEBGL_compressed_texture_s3tc;
  33636. /** Defines if pvrtc texture compression is supported */
  33637. pvrtc: any;
  33638. /** Defines if etc1 texture compression is supported */
  33639. etc1: any;
  33640. /** Defines if etc2 texture compression is supported */
  33641. etc2: any;
  33642. /** Defines if astc texture compression is supported */
  33643. astc: any;
  33644. /** Defines if float textures are supported */
  33645. textureFloat: boolean;
  33646. /** Defines if vertex array objects are supported */
  33647. vertexArrayObject: boolean;
  33648. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33649. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33650. /** Gets the maximum level of anisotropy supported */
  33651. maxAnisotropy: number;
  33652. /** Defines if instancing is supported */
  33653. instancedArrays: boolean;
  33654. /** Defines if 32 bits indices are supported */
  33655. uintIndices: boolean;
  33656. /** Defines if high precision shaders are supported */
  33657. highPrecisionShaderSupported: boolean;
  33658. /** Defines if depth reading in the fragment shader is supported */
  33659. fragmentDepthSupported: boolean;
  33660. /** Defines if float texture linear filtering is supported*/
  33661. textureFloatLinearFiltering: boolean;
  33662. /** Defines if rendering to float textures is supported */
  33663. textureFloatRender: boolean;
  33664. /** Defines if half float textures are supported*/
  33665. textureHalfFloat: boolean;
  33666. /** Defines if half float texture linear filtering is supported*/
  33667. textureHalfFloatLinearFiltering: boolean;
  33668. /** Defines if rendering to half float textures is supported */
  33669. textureHalfFloatRender: boolean;
  33670. /** Defines if textureLOD shader command is supported */
  33671. textureLOD: boolean;
  33672. /** Defines if draw buffers extension is supported */
  33673. drawBuffersExtension: boolean;
  33674. /** Defines if depth textures are supported */
  33675. depthTextureExtension: boolean;
  33676. /** Defines if float color buffer are supported */
  33677. colorBufferFloat: boolean;
  33678. /** Gets disjoint timer query extension (null if not supported) */
  33679. timerQuery?: EXT_disjoint_timer_query;
  33680. /** Defines if timestamp can be used with timer query */
  33681. canUseTimestampForTimerQuery: boolean;
  33682. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33683. multiview?: any;
  33684. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33685. oculusMultiview?: any;
  33686. /** Function used to let the system compiles shaders in background */
  33687. parallelShaderCompile?: {
  33688. COMPLETION_STATUS_KHR: number;
  33689. };
  33690. /** Max number of texture samples for MSAA */
  33691. maxMSAASamples: number;
  33692. /** Defines if the blend min max extension is supported */
  33693. blendMinMax: boolean;
  33694. }
  33695. }
  33696. declare module BABYLON {
  33697. /**
  33698. * @hidden
  33699. **/
  33700. export class DepthCullingState {
  33701. private _isDepthTestDirty;
  33702. private _isDepthMaskDirty;
  33703. private _isDepthFuncDirty;
  33704. private _isCullFaceDirty;
  33705. private _isCullDirty;
  33706. private _isZOffsetDirty;
  33707. private _isFrontFaceDirty;
  33708. private _depthTest;
  33709. private _depthMask;
  33710. private _depthFunc;
  33711. private _cull;
  33712. private _cullFace;
  33713. private _zOffset;
  33714. private _frontFace;
  33715. /**
  33716. * Initializes the state.
  33717. */
  33718. constructor();
  33719. get isDirty(): boolean;
  33720. get zOffset(): number;
  33721. set zOffset(value: number);
  33722. get cullFace(): Nullable<number>;
  33723. set cullFace(value: Nullable<number>);
  33724. get cull(): Nullable<boolean>;
  33725. set cull(value: Nullable<boolean>);
  33726. get depthFunc(): Nullable<number>;
  33727. set depthFunc(value: Nullable<number>);
  33728. get depthMask(): boolean;
  33729. set depthMask(value: boolean);
  33730. get depthTest(): boolean;
  33731. set depthTest(value: boolean);
  33732. get frontFace(): Nullable<number>;
  33733. set frontFace(value: Nullable<number>);
  33734. reset(): void;
  33735. apply(gl: WebGLRenderingContext): void;
  33736. }
  33737. }
  33738. declare module BABYLON {
  33739. /**
  33740. * @hidden
  33741. **/
  33742. export class StencilState {
  33743. /** 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 */
  33744. static readonly ALWAYS: number;
  33745. /** Passed to stencilOperation to specify that stencil value must be kept */
  33746. static readonly KEEP: number;
  33747. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33748. static readonly REPLACE: number;
  33749. private _isStencilTestDirty;
  33750. private _isStencilMaskDirty;
  33751. private _isStencilFuncDirty;
  33752. private _isStencilOpDirty;
  33753. private _stencilTest;
  33754. private _stencilMask;
  33755. private _stencilFunc;
  33756. private _stencilFuncRef;
  33757. private _stencilFuncMask;
  33758. private _stencilOpStencilFail;
  33759. private _stencilOpDepthFail;
  33760. private _stencilOpStencilDepthPass;
  33761. get isDirty(): boolean;
  33762. get stencilFunc(): number;
  33763. set stencilFunc(value: number);
  33764. get stencilFuncRef(): number;
  33765. set stencilFuncRef(value: number);
  33766. get stencilFuncMask(): number;
  33767. set stencilFuncMask(value: number);
  33768. get stencilOpStencilFail(): number;
  33769. set stencilOpStencilFail(value: number);
  33770. get stencilOpDepthFail(): number;
  33771. set stencilOpDepthFail(value: number);
  33772. get stencilOpStencilDepthPass(): number;
  33773. set stencilOpStencilDepthPass(value: number);
  33774. get stencilMask(): number;
  33775. set stencilMask(value: number);
  33776. get stencilTest(): boolean;
  33777. set stencilTest(value: boolean);
  33778. constructor();
  33779. reset(): void;
  33780. apply(gl: WebGLRenderingContext): void;
  33781. }
  33782. }
  33783. declare module BABYLON {
  33784. /**
  33785. * @hidden
  33786. **/
  33787. export class AlphaState {
  33788. private _isAlphaBlendDirty;
  33789. private _isBlendFunctionParametersDirty;
  33790. private _isBlendEquationParametersDirty;
  33791. private _isBlendConstantsDirty;
  33792. private _alphaBlend;
  33793. private _blendFunctionParameters;
  33794. private _blendEquationParameters;
  33795. private _blendConstants;
  33796. /**
  33797. * Initializes the state.
  33798. */
  33799. constructor();
  33800. get isDirty(): boolean;
  33801. get alphaBlend(): boolean;
  33802. set alphaBlend(value: boolean);
  33803. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33804. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33805. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33806. reset(): void;
  33807. apply(gl: WebGLRenderingContext): void;
  33808. }
  33809. }
  33810. declare module BABYLON {
  33811. /** @hidden */
  33812. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33813. attributeProcessor(attribute: string): string;
  33814. varyingProcessor(varying: string, isFragment: boolean): string;
  33815. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33816. }
  33817. }
  33818. declare module BABYLON {
  33819. /**
  33820. * Interface for attribute information associated with buffer instanciation
  33821. */
  33822. export interface InstancingAttributeInfo {
  33823. /**
  33824. * Name of the GLSL attribute
  33825. * if attribute index is not specified, this is used to retrieve the index from the effect
  33826. */
  33827. attributeName: string;
  33828. /**
  33829. * Index/offset of the attribute in the vertex shader
  33830. * if not specified, this will be computes from the name.
  33831. */
  33832. index?: number;
  33833. /**
  33834. * size of the attribute, 1, 2, 3 or 4
  33835. */
  33836. attributeSize: number;
  33837. /**
  33838. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33839. */
  33840. offset: number;
  33841. /**
  33842. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33843. * default to 1
  33844. */
  33845. divisor?: number;
  33846. /**
  33847. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33848. * default is FLOAT
  33849. */
  33850. attributeType?: number;
  33851. /**
  33852. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33853. */
  33854. normalized?: boolean;
  33855. }
  33856. }
  33857. declare module BABYLON {
  33858. interface ThinEngine {
  33859. /**
  33860. * Update a video texture
  33861. * @param texture defines the texture to update
  33862. * @param video defines the video element to use
  33863. * @param invertY defines if data must be stored with Y axis inverted
  33864. */
  33865. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33866. }
  33867. }
  33868. declare module BABYLON {
  33869. /**
  33870. * Settings for finer control over video usage
  33871. */
  33872. export interface VideoTextureSettings {
  33873. /**
  33874. * Applies `autoplay` to video, if specified
  33875. */
  33876. autoPlay?: boolean;
  33877. /**
  33878. * Applies `loop` to video, if specified
  33879. */
  33880. loop?: boolean;
  33881. /**
  33882. * Automatically updates internal texture from video at every frame in the render loop
  33883. */
  33884. autoUpdateTexture: boolean;
  33885. /**
  33886. * Image src displayed during the video loading or until the user interacts with the video.
  33887. */
  33888. poster?: string;
  33889. }
  33890. /**
  33891. * If you want to display a video in your scene, this is the special texture for that.
  33892. * This special texture works similar to other textures, with the exception of a few parameters.
  33893. * @see https://doc.babylonjs.com/how_to/video_texture
  33894. */
  33895. export class VideoTexture extends Texture {
  33896. /**
  33897. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33898. */
  33899. readonly autoUpdateTexture: boolean;
  33900. /**
  33901. * The video instance used by the texture internally
  33902. */
  33903. readonly video: HTMLVideoElement;
  33904. private _onUserActionRequestedObservable;
  33905. /**
  33906. * Event triggerd when a dom action is required by the user to play the video.
  33907. * This happens due to recent changes in browser policies preventing video to auto start.
  33908. */
  33909. get onUserActionRequestedObservable(): Observable<Texture>;
  33910. private _generateMipMaps;
  33911. private _stillImageCaptured;
  33912. private _displayingPosterTexture;
  33913. private _settings;
  33914. private _createInternalTextureOnEvent;
  33915. private _frameId;
  33916. private _currentSrc;
  33917. /**
  33918. * Creates a video texture.
  33919. * If you want to display a video in your scene, this is the special texture for that.
  33920. * This special texture works similar to other textures, with the exception of a few parameters.
  33921. * @see https://doc.babylonjs.com/how_to/video_texture
  33922. * @param name optional name, will detect from video source, if not defined
  33923. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33924. * @param scene is obviously the current scene.
  33925. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33926. * @param invertY is false by default but can be used to invert video on Y axis
  33927. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33928. * @param settings allows finer control over video usage
  33929. */
  33930. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33931. private _getName;
  33932. private _getVideo;
  33933. private _createInternalTexture;
  33934. private reset;
  33935. /**
  33936. * @hidden Internal method to initiate `update`.
  33937. */
  33938. _rebuild(): void;
  33939. /**
  33940. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33941. */
  33942. update(): void;
  33943. /**
  33944. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33945. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33946. */
  33947. updateTexture(isVisible: boolean): void;
  33948. protected _updateInternalTexture: () => void;
  33949. /**
  33950. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33951. * @param url New url.
  33952. */
  33953. updateURL(url: string): void;
  33954. /**
  33955. * Clones the texture.
  33956. * @returns the cloned texture
  33957. */
  33958. clone(): VideoTexture;
  33959. /**
  33960. * Dispose the texture and release its associated resources.
  33961. */
  33962. dispose(): void;
  33963. /**
  33964. * Creates a video texture straight from a stream.
  33965. * @param scene Define the scene the texture should be created in
  33966. * @param stream Define the stream the texture should be created from
  33967. * @returns The created video texture as a promise
  33968. */
  33969. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33970. /**
  33971. * Creates a video texture straight from your WebCam video feed.
  33972. * @param scene Define the scene the texture should be created in
  33973. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33974. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33975. * @returns The created video texture as a promise
  33976. */
  33977. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33978. minWidth: number;
  33979. maxWidth: number;
  33980. minHeight: number;
  33981. maxHeight: number;
  33982. deviceId: string;
  33983. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33984. /**
  33985. * Creates a video texture straight from your WebCam video feed.
  33986. * @param scene Define the scene the texture should be created in
  33987. * @param onReady Define a callback to triggered once the texture will be ready
  33988. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33989. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33990. */
  33991. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33992. minWidth: number;
  33993. maxWidth: number;
  33994. minHeight: number;
  33995. maxHeight: number;
  33996. deviceId: string;
  33997. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33998. }
  33999. }
  34000. declare module BABYLON {
  34001. /**
  34002. * Defines the interface used by objects working like Scene
  34003. * @hidden
  34004. */
  34005. export interface ISceneLike {
  34006. _addPendingData(data: any): void;
  34007. _removePendingData(data: any): void;
  34008. offlineProvider: IOfflineProvider;
  34009. }
  34010. /** Interface defining initialization parameters for Engine class */
  34011. export interface EngineOptions extends WebGLContextAttributes {
  34012. /**
  34013. * Defines if the engine should no exceed a specified device ratio
  34014. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34015. */
  34016. limitDeviceRatio?: number;
  34017. /**
  34018. * Defines if webvr should be enabled automatically
  34019. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34020. */
  34021. autoEnableWebVR?: boolean;
  34022. /**
  34023. * Defines if webgl2 should be turned off even if supported
  34024. * @see http://doc.babylonjs.com/features/webgl2
  34025. */
  34026. disableWebGL2Support?: boolean;
  34027. /**
  34028. * Defines if webaudio should be initialized as well
  34029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34030. */
  34031. audioEngine?: boolean;
  34032. /**
  34033. * Defines if animations should run using a deterministic lock step
  34034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34035. */
  34036. deterministicLockstep?: boolean;
  34037. /** Defines the maximum steps to use with deterministic lock step mode */
  34038. lockstepMaxSteps?: number;
  34039. /** Defines the seconds between each deterministic lock step */
  34040. timeStep?: number;
  34041. /**
  34042. * Defines that engine should ignore context lost events
  34043. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34044. */
  34045. doNotHandleContextLost?: boolean;
  34046. /**
  34047. * Defines that engine should ignore modifying touch action attribute and style
  34048. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34049. */
  34050. doNotHandleTouchAction?: boolean;
  34051. /**
  34052. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34053. */
  34054. useHighPrecisionFloats?: boolean;
  34055. }
  34056. /**
  34057. * The base engine class (root of all engines)
  34058. */
  34059. export class ThinEngine {
  34060. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34061. static ExceptionList: ({
  34062. key: string;
  34063. capture: string;
  34064. captureConstraint: number;
  34065. targets: string[];
  34066. } | {
  34067. key: string;
  34068. capture: null;
  34069. captureConstraint: null;
  34070. targets: string[];
  34071. })[];
  34072. /** @hidden */
  34073. static _TextureLoaders: IInternalTextureLoader[];
  34074. /**
  34075. * Returns the current npm package of the sdk
  34076. */
  34077. static get NpmPackage(): string;
  34078. /**
  34079. * Returns the current version of the framework
  34080. */
  34081. static get Version(): string;
  34082. /**
  34083. * Returns a string describing the current engine
  34084. */
  34085. get description(): string;
  34086. /**
  34087. * Gets or sets the epsilon value used by collision engine
  34088. */
  34089. static CollisionsEpsilon: number;
  34090. /**
  34091. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34092. */
  34093. static get ShadersRepository(): string;
  34094. static set ShadersRepository(value: string);
  34095. /** @hidden */
  34096. _shaderProcessor: IShaderProcessor;
  34097. /**
  34098. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34099. */
  34100. forcePOTTextures: boolean;
  34101. /**
  34102. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34103. */
  34104. isFullscreen: boolean;
  34105. /**
  34106. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34107. */
  34108. cullBackFaces: boolean;
  34109. /**
  34110. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34111. */
  34112. renderEvenInBackground: boolean;
  34113. /**
  34114. * Gets or sets a boolean indicating that cache can be kept between frames
  34115. */
  34116. preventCacheWipeBetweenFrames: boolean;
  34117. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34118. validateShaderPrograms: boolean;
  34119. /**
  34120. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34121. * This can provide greater z depth for distant objects.
  34122. */
  34123. useReverseDepthBuffer: boolean;
  34124. /**
  34125. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34126. */
  34127. disableUniformBuffers: boolean;
  34128. /** @hidden */
  34129. _uniformBuffers: UniformBuffer[];
  34130. /**
  34131. * Gets a boolean indicating that the engine supports uniform buffers
  34132. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34133. */
  34134. get supportsUniformBuffers(): boolean;
  34135. /** @hidden */
  34136. _gl: WebGLRenderingContext;
  34137. /** @hidden */
  34138. _webGLVersion: number;
  34139. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34140. protected _windowIsBackground: boolean;
  34141. protected _creationOptions: EngineOptions;
  34142. protected _highPrecisionShadersAllowed: boolean;
  34143. /** @hidden */
  34144. get _shouldUseHighPrecisionShader(): boolean;
  34145. /**
  34146. * Gets a boolean indicating that only power of 2 textures are supported
  34147. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34148. */
  34149. get needPOTTextures(): boolean;
  34150. /** @hidden */
  34151. _badOS: boolean;
  34152. /** @hidden */
  34153. _badDesktopOS: boolean;
  34154. private _hardwareScalingLevel;
  34155. /** @hidden */
  34156. _caps: EngineCapabilities;
  34157. private _isStencilEnable;
  34158. private _glVersion;
  34159. private _glRenderer;
  34160. private _glVendor;
  34161. /** @hidden */
  34162. _videoTextureSupported: boolean;
  34163. protected _renderingQueueLaunched: boolean;
  34164. protected _activeRenderLoops: (() => void)[];
  34165. /**
  34166. * Observable signaled when a context lost event is raised
  34167. */
  34168. onContextLostObservable: Observable<ThinEngine>;
  34169. /**
  34170. * Observable signaled when a context restored event is raised
  34171. */
  34172. onContextRestoredObservable: Observable<ThinEngine>;
  34173. private _onContextLost;
  34174. private _onContextRestored;
  34175. protected _contextWasLost: boolean;
  34176. /** @hidden */
  34177. _doNotHandleContextLost: boolean;
  34178. /**
  34179. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34181. */
  34182. get doNotHandleContextLost(): boolean;
  34183. set doNotHandleContextLost(value: boolean);
  34184. /**
  34185. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34186. */
  34187. disableVertexArrayObjects: boolean;
  34188. /** @hidden */
  34189. protected _colorWrite: boolean;
  34190. /** @hidden */
  34191. protected _colorWriteChanged: boolean;
  34192. /** @hidden */
  34193. protected _depthCullingState: DepthCullingState;
  34194. /** @hidden */
  34195. protected _stencilState: StencilState;
  34196. /** @hidden */
  34197. _alphaState: AlphaState;
  34198. /** @hidden */
  34199. _alphaMode: number;
  34200. /** @hidden */
  34201. _alphaEquation: number;
  34202. /** @hidden */
  34203. _internalTexturesCache: InternalTexture[];
  34204. /** @hidden */
  34205. protected _activeChannel: number;
  34206. private _currentTextureChannel;
  34207. /** @hidden */
  34208. protected _boundTexturesCache: {
  34209. [key: string]: Nullable<InternalTexture>;
  34210. };
  34211. /** @hidden */
  34212. protected _currentEffect: Nullable<Effect>;
  34213. /** @hidden */
  34214. protected _currentProgram: Nullable<WebGLProgram>;
  34215. private _compiledEffects;
  34216. private _vertexAttribArraysEnabled;
  34217. /** @hidden */
  34218. protected _cachedViewport: Nullable<IViewportLike>;
  34219. private _cachedVertexArrayObject;
  34220. /** @hidden */
  34221. protected _cachedVertexBuffers: any;
  34222. /** @hidden */
  34223. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34224. /** @hidden */
  34225. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34226. /** @hidden */
  34227. _currentRenderTarget: Nullable<InternalTexture>;
  34228. private _uintIndicesCurrentlySet;
  34229. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34230. /** @hidden */
  34231. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34232. /** @hidden */
  34233. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34234. private _currentBufferPointers;
  34235. private _currentInstanceLocations;
  34236. private _currentInstanceBuffers;
  34237. private _textureUnits;
  34238. /** @hidden */
  34239. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34240. /** @hidden */
  34241. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34242. /** @hidden */
  34243. _boundRenderFunction: any;
  34244. private _vaoRecordInProgress;
  34245. private _mustWipeVertexAttributes;
  34246. private _emptyTexture;
  34247. private _emptyCubeTexture;
  34248. private _emptyTexture3D;
  34249. private _emptyTexture2DArray;
  34250. /** @hidden */
  34251. _frameHandler: number;
  34252. private _nextFreeTextureSlots;
  34253. private _maxSimultaneousTextures;
  34254. private _activeRequests;
  34255. /** @hidden */
  34256. _transformTextureUrl: Nullable<(url: string) => string>;
  34257. protected get _supportsHardwareTextureRescaling(): boolean;
  34258. private _framebufferDimensionsObject;
  34259. /**
  34260. * sets the object from which width and height will be taken from when getting render width and height
  34261. * Will fallback to the gl object
  34262. * @param dimensions the framebuffer width and height that will be used.
  34263. */
  34264. set framebufferDimensionsObject(dimensions: Nullable<{
  34265. framebufferWidth: number;
  34266. framebufferHeight: number;
  34267. }>);
  34268. /**
  34269. * Gets the current viewport
  34270. */
  34271. get currentViewport(): Nullable<IViewportLike>;
  34272. /**
  34273. * Gets the default empty texture
  34274. */
  34275. get emptyTexture(): InternalTexture;
  34276. /**
  34277. * Gets the default empty 3D texture
  34278. */
  34279. get emptyTexture3D(): InternalTexture;
  34280. /**
  34281. * Gets the default empty 2D array texture
  34282. */
  34283. get emptyTexture2DArray(): InternalTexture;
  34284. /**
  34285. * Gets the default empty cube texture
  34286. */
  34287. get emptyCubeTexture(): InternalTexture;
  34288. /**
  34289. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34290. */
  34291. readonly premultipliedAlpha: boolean;
  34292. /**
  34293. * Observable event triggered before each texture is initialized
  34294. */
  34295. onBeforeTextureInitObservable: Observable<Texture>;
  34296. /**
  34297. * Creates a new engine
  34298. * @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
  34299. * @param antialias defines enable antialiasing (default: false)
  34300. * @param options defines further options to be sent to the getContext() function
  34301. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34302. */
  34303. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34304. private _rebuildInternalTextures;
  34305. private _rebuildEffects;
  34306. /**
  34307. * Gets a boolean indicating if all created effects are ready
  34308. * @returns true if all effects are ready
  34309. */
  34310. areAllEffectsReady(): boolean;
  34311. protected _rebuildBuffers(): void;
  34312. protected _initGLContext(): void;
  34313. /**
  34314. * Gets version of the current webGL context
  34315. */
  34316. get webGLVersion(): number;
  34317. /**
  34318. * Gets a string idenfifying the name of the class
  34319. * @returns "Engine" string
  34320. */
  34321. getClassName(): string;
  34322. /**
  34323. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34324. */
  34325. get isStencilEnable(): boolean;
  34326. /** @hidden */
  34327. _prepareWorkingCanvas(): void;
  34328. /**
  34329. * Reset the texture cache to empty state
  34330. */
  34331. resetTextureCache(): void;
  34332. /**
  34333. * Gets an object containing information about the current webGL context
  34334. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34335. */
  34336. getGlInfo(): {
  34337. vendor: string;
  34338. renderer: string;
  34339. version: string;
  34340. };
  34341. /**
  34342. * Defines the hardware scaling level.
  34343. * By default the hardware scaling level is computed from the window device ratio.
  34344. * 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.
  34345. * @param level defines the level to use
  34346. */
  34347. setHardwareScalingLevel(level: number): void;
  34348. /**
  34349. * Gets the current hardware scaling level.
  34350. * By default the hardware scaling level is computed from the window device ratio.
  34351. * 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.
  34352. * @returns a number indicating the current hardware scaling level
  34353. */
  34354. getHardwareScalingLevel(): number;
  34355. /**
  34356. * Gets the list of loaded textures
  34357. * @returns an array containing all loaded textures
  34358. */
  34359. getLoadedTexturesCache(): InternalTexture[];
  34360. /**
  34361. * Gets the object containing all engine capabilities
  34362. * @returns the EngineCapabilities object
  34363. */
  34364. getCaps(): EngineCapabilities;
  34365. /**
  34366. * stop executing a render loop function and remove it from the execution array
  34367. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34368. */
  34369. stopRenderLoop(renderFunction?: () => void): void;
  34370. /** @hidden */
  34371. _renderLoop(): void;
  34372. /**
  34373. * Gets the HTML canvas attached with the current webGL context
  34374. * @returns a HTML canvas
  34375. */
  34376. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34377. /**
  34378. * Gets host window
  34379. * @returns the host window object
  34380. */
  34381. getHostWindow(): Nullable<Window>;
  34382. /**
  34383. * Gets the current render width
  34384. * @param useScreen defines if screen size must be used (or the current render target if any)
  34385. * @returns a number defining the current render width
  34386. */
  34387. getRenderWidth(useScreen?: boolean): number;
  34388. /**
  34389. * Gets the current render height
  34390. * @param useScreen defines if screen size must be used (or the current render target if any)
  34391. * @returns a number defining the current render height
  34392. */
  34393. getRenderHeight(useScreen?: boolean): number;
  34394. /**
  34395. * Can be used to override the current requestAnimationFrame requester.
  34396. * @hidden
  34397. */
  34398. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34399. /**
  34400. * Register and execute a render loop. The engine can have more than one render function
  34401. * @param renderFunction defines the function to continuously execute
  34402. */
  34403. runRenderLoop(renderFunction: () => void): void;
  34404. /**
  34405. * Clear the current render buffer or the current render target (if any is set up)
  34406. * @param color defines the color to use
  34407. * @param backBuffer defines if the back buffer must be cleared
  34408. * @param depth defines if the depth buffer must be cleared
  34409. * @param stencil defines if the stencil buffer must be cleared
  34410. */
  34411. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34412. private _viewportCached;
  34413. /** @hidden */
  34414. _viewport(x: number, y: number, width: number, height: number): void;
  34415. /**
  34416. * Set the WebGL's viewport
  34417. * @param viewport defines the viewport element to be used
  34418. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34419. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34420. */
  34421. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34422. /**
  34423. * Begin a new frame
  34424. */
  34425. beginFrame(): void;
  34426. /**
  34427. * Enf the current frame
  34428. */
  34429. endFrame(): void;
  34430. /**
  34431. * Resize the view according to the canvas' size
  34432. */
  34433. resize(): void;
  34434. /**
  34435. * Force a specific size of the canvas
  34436. * @param width defines the new canvas' width
  34437. * @param height defines the new canvas' height
  34438. */
  34439. setSize(width: number, height: number): void;
  34440. /**
  34441. * Binds the frame buffer to the specified texture.
  34442. * @param texture The texture to render to or null for the default canvas
  34443. * @param faceIndex The face of the texture to render to in case of cube texture
  34444. * @param requiredWidth The width of the target to render to
  34445. * @param requiredHeight The height of the target to render to
  34446. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34447. * @param lodLevel defines the lod level to bind to the frame buffer
  34448. * @param layer defines the 2d array index to bind to frame buffer to
  34449. */
  34450. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34451. /** @hidden */
  34452. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34453. /**
  34454. * Unbind the current render target texture from the webGL context
  34455. * @param texture defines the render target texture to unbind
  34456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34458. */
  34459. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34460. /**
  34461. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34462. */
  34463. flushFramebuffer(): void;
  34464. /**
  34465. * Unbind the current render target and bind the default framebuffer
  34466. */
  34467. restoreDefaultFramebuffer(): void;
  34468. /** @hidden */
  34469. protected _resetVertexBufferBinding(): void;
  34470. /**
  34471. * Creates a vertex buffer
  34472. * @param data the data for the vertex buffer
  34473. * @returns the new WebGL static buffer
  34474. */
  34475. createVertexBuffer(data: DataArray): DataBuffer;
  34476. private _createVertexBuffer;
  34477. /**
  34478. * Creates a dynamic vertex buffer
  34479. * @param data the data for the dynamic vertex buffer
  34480. * @returns the new WebGL dynamic buffer
  34481. */
  34482. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34483. protected _resetIndexBufferBinding(): void;
  34484. /**
  34485. * Creates a new index buffer
  34486. * @param indices defines the content of the index buffer
  34487. * @param updatable defines if the index buffer must be updatable
  34488. * @returns a new webGL buffer
  34489. */
  34490. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34491. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34492. /**
  34493. * Bind a webGL buffer to the webGL context
  34494. * @param buffer defines the buffer to bind
  34495. */
  34496. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34497. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34498. private bindBuffer;
  34499. /**
  34500. * update the bound buffer with the given data
  34501. * @param data defines the data to update
  34502. */
  34503. updateArrayBuffer(data: Float32Array): void;
  34504. private _vertexAttribPointer;
  34505. /** @hidden */
  34506. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34507. private _bindVertexBuffersAttributes;
  34508. /**
  34509. * Records a vertex array object
  34510. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34511. * @param vertexBuffers defines the list of vertex buffers to store
  34512. * @param indexBuffer defines the index buffer to store
  34513. * @param effect defines the effect to store
  34514. * @returns the new vertex array object
  34515. */
  34516. recordVertexArrayObject(vertexBuffers: {
  34517. [key: string]: VertexBuffer;
  34518. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34519. /**
  34520. * Bind a specific vertex array object
  34521. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34522. * @param vertexArrayObject defines the vertex array object to bind
  34523. * @param indexBuffer defines the index buffer to bind
  34524. */
  34525. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34526. /**
  34527. * Bind webGl buffers directly to the webGL context
  34528. * @param vertexBuffer defines the vertex buffer to bind
  34529. * @param indexBuffer defines the index buffer to bind
  34530. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34531. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34532. * @param effect defines the effect associated with the vertex buffer
  34533. */
  34534. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34535. private _unbindVertexArrayObject;
  34536. /**
  34537. * Bind a list of vertex buffers to the webGL context
  34538. * @param vertexBuffers defines the list of vertex buffers to bind
  34539. * @param indexBuffer defines the index buffer to bind
  34540. * @param effect defines the effect associated with the vertex buffers
  34541. */
  34542. bindBuffers(vertexBuffers: {
  34543. [key: string]: Nullable<VertexBuffer>;
  34544. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34545. /**
  34546. * Unbind all instance attributes
  34547. */
  34548. unbindInstanceAttributes(): void;
  34549. /**
  34550. * Release and free the memory of a vertex array object
  34551. * @param vao defines the vertex array object to delete
  34552. */
  34553. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34554. /** @hidden */
  34555. _releaseBuffer(buffer: DataBuffer): boolean;
  34556. protected _deleteBuffer(buffer: DataBuffer): void;
  34557. /**
  34558. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34559. * @param instancesBuffer defines the webGL buffer to update and bind
  34560. * @param data defines the data to store in the buffer
  34561. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34562. */
  34563. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34564. /**
  34565. * Bind the content of a webGL buffer used with instantiation
  34566. * @param instancesBuffer defines the webGL buffer to bind
  34567. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34568. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34569. */
  34570. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34571. /**
  34572. * Disable the instance attribute corresponding to the name in parameter
  34573. * @param name defines the name of the attribute to disable
  34574. */
  34575. disableInstanceAttributeByName(name: string): void;
  34576. /**
  34577. * Disable the instance attribute corresponding to the location in parameter
  34578. * @param attributeLocation defines the attribute location of the attribute to disable
  34579. */
  34580. disableInstanceAttribute(attributeLocation: number): void;
  34581. /**
  34582. * Disable the attribute corresponding to the location in parameter
  34583. * @param attributeLocation defines the attribute location of the attribute to disable
  34584. */
  34585. disableAttributeByIndex(attributeLocation: number): void;
  34586. /**
  34587. * Send a draw order
  34588. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34589. * @param indexStart defines the starting index
  34590. * @param indexCount defines the number of index to draw
  34591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34592. */
  34593. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34594. /**
  34595. * Draw a list of points
  34596. * @param verticesStart defines the index of first vertex to draw
  34597. * @param verticesCount defines the count of vertices to draw
  34598. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34599. */
  34600. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34601. /**
  34602. * Draw a list of unindexed primitives
  34603. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34604. * @param verticesStart defines the index of first vertex to draw
  34605. * @param verticesCount defines the count of vertices to draw
  34606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34607. */
  34608. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34609. /**
  34610. * Draw a list of indexed primitives
  34611. * @param fillMode defines the primitive to use
  34612. * @param indexStart defines the starting index
  34613. * @param indexCount defines the number of index to draw
  34614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34615. */
  34616. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34617. /**
  34618. * Draw a list of unindexed primitives
  34619. * @param fillMode defines the primitive to use
  34620. * @param verticesStart defines the index of first vertex to draw
  34621. * @param verticesCount defines the count of vertices to draw
  34622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34623. */
  34624. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34625. private _drawMode;
  34626. /** @hidden */
  34627. protected _reportDrawCall(): void;
  34628. /** @hidden */
  34629. _releaseEffect(effect: Effect): void;
  34630. /** @hidden */
  34631. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34632. /**
  34633. * Create a new effect (used to store vertex/fragment shaders)
  34634. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34635. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34636. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34637. * @param samplers defines an array of string used to represent textures
  34638. * @param defines defines the string containing the defines to use to compile the shaders
  34639. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34640. * @param onCompiled defines a function to call when the effect creation is successful
  34641. * @param onError defines a function to call when the effect creation has failed
  34642. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34643. * @returns the new Effect
  34644. */
  34645. 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;
  34646. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34647. private _compileShader;
  34648. private _compileRawShader;
  34649. /** @hidden */
  34650. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34651. /**
  34652. * Directly creates a webGL program
  34653. * @param pipelineContext defines the pipeline context to attach to
  34654. * @param vertexCode defines the vertex shader code to use
  34655. * @param fragmentCode defines the fragment shader code to use
  34656. * @param context defines the webGL context to use (if not set, the current one will be used)
  34657. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34658. * @returns the new webGL program
  34659. */
  34660. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34661. /**
  34662. * Creates a webGL program
  34663. * @param pipelineContext defines the pipeline context to attach to
  34664. * @param vertexCode defines the vertex shader code to use
  34665. * @param fragmentCode defines the fragment shader code to use
  34666. * @param defines defines the string containing the defines to use to compile the shaders
  34667. * @param context defines the webGL context to use (if not set, the current one will be used)
  34668. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34669. * @returns the new webGL program
  34670. */
  34671. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34672. /**
  34673. * Creates a new pipeline context
  34674. * @returns the new pipeline
  34675. */
  34676. createPipelineContext(): IPipelineContext;
  34677. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34678. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34679. /** @hidden */
  34680. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34681. /** @hidden */
  34682. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34683. /** @hidden */
  34684. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34685. /**
  34686. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34687. * @param pipelineContext defines the pipeline context to use
  34688. * @param uniformsNames defines the list of uniform names
  34689. * @returns an array of webGL uniform locations
  34690. */
  34691. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34692. /**
  34693. * Gets the lsit of active attributes for a given webGL program
  34694. * @param pipelineContext defines the pipeline context to use
  34695. * @param attributesNames defines the list of attribute names to get
  34696. * @returns an array of indices indicating the offset of each attribute
  34697. */
  34698. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34699. /**
  34700. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34701. * @param effect defines the effect to activate
  34702. */
  34703. enableEffect(effect: Nullable<Effect>): void;
  34704. /**
  34705. * Set the value of an uniform to a number (int)
  34706. * @param uniform defines the webGL uniform location where to store the value
  34707. * @param value defines the int number to store
  34708. */
  34709. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34710. /**
  34711. * Set the value of an uniform to an array of int32
  34712. * @param uniform defines the webGL uniform location where to store the value
  34713. * @param array defines the array of int32 to store
  34714. */
  34715. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34716. /**
  34717. * Set the value of an uniform to an array of int32 (stored as vec2)
  34718. * @param uniform defines the webGL uniform location where to store the value
  34719. * @param array defines the array of int32 to store
  34720. */
  34721. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34722. /**
  34723. * Set the value of an uniform to an array of int32 (stored as vec3)
  34724. * @param uniform defines the webGL uniform location where to store the value
  34725. * @param array defines the array of int32 to store
  34726. */
  34727. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34728. /**
  34729. * Set the value of an uniform to an array of int32 (stored as vec4)
  34730. * @param uniform defines the webGL uniform location where to store the value
  34731. * @param array defines the array of int32 to store
  34732. */
  34733. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34734. /**
  34735. * Set the value of an uniform to an array of number
  34736. * @param uniform defines the webGL uniform location where to store the value
  34737. * @param array defines the array of number to store
  34738. */
  34739. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34740. /**
  34741. * Set the value of an uniform to an array of number (stored as vec2)
  34742. * @param uniform defines the webGL uniform location where to store the value
  34743. * @param array defines the array of number to store
  34744. */
  34745. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34746. /**
  34747. * Set the value of an uniform to an array of number (stored as vec3)
  34748. * @param uniform defines the webGL uniform location where to store the value
  34749. * @param array defines the array of number to store
  34750. */
  34751. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34752. /**
  34753. * Set the value of an uniform to an array of number (stored as vec4)
  34754. * @param uniform defines the webGL uniform location where to store the value
  34755. * @param array defines the array of number to store
  34756. */
  34757. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34758. /**
  34759. * Set the value of an uniform to an array of float32 (stored as matrices)
  34760. * @param uniform defines the webGL uniform location where to store the value
  34761. * @param matrices defines the array of float32 to store
  34762. */
  34763. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34764. /**
  34765. * Set the value of an uniform to a matrix (3x3)
  34766. * @param uniform defines the webGL uniform location where to store the value
  34767. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34768. */
  34769. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34770. /**
  34771. * Set the value of an uniform to a matrix (2x2)
  34772. * @param uniform defines the webGL uniform location where to store the value
  34773. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34774. */
  34775. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34776. /**
  34777. * Set the value of an uniform to a number (float)
  34778. * @param uniform defines the webGL uniform location where to store the value
  34779. * @param value defines the float number to store
  34780. */
  34781. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34782. /**
  34783. * Set the value of an uniform to a vec2
  34784. * @param uniform defines the webGL uniform location where to store the value
  34785. * @param x defines the 1st component of the value
  34786. * @param y defines the 2nd component of the value
  34787. */
  34788. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34789. /**
  34790. * Set the value of an uniform to a vec3
  34791. * @param uniform defines the webGL uniform location where to store the value
  34792. * @param x defines the 1st component of the value
  34793. * @param y defines the 2nd component of the value
  34794. * @param z defines the 3rd component of the value
  34795. */
  34796. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34797. /**
  34798. * Set the value of an uniform to a vec4
  34799. * @param uniform defines the webGL uniform location where to store the value
  34800. * @param x defines the 1st component of the value
  34801. * @param y defines the 2nd component of the value
  34802. * @param z defines the 3rd component of the value
  34803. * @param w defines the 4th component of the value
  34804. */
  34805. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34806. /**
  34807. * Apply all cached states (depth, culling, stencil and alpha)
  34808. */
  34809. applyStates(): void;
  34810. /**
  34811. * Enable or disable color writing
  34812. * @param enable defines the state to set
  34813. */
  34814. setColorWrite(enable: boolean): void;
  34815. /**
  34816. * Gets a boolean indicating if color writing is enabled
  34817. * @returns the current color writing state
  34818. */
  34819. getColorWrite(): boolean;
  34820. /**
  34821. * Gets the depth culling state manager
  34822. */
  34823. get depthCullingState(): DepthCullingState;
  34824. /**
  34825. * Gets the alpha state manager
  34826. */
  34827. get alphaState(): AlphaState;
  34828. /**
  34829. * Gets the stencil state manager
  34830. */
  34831. get stencilState(): StencilState;
  34832. /**
  34833. * Clears the list of texture accessible through engine.
  34834. * This can help preventing texture load conflict due to name collision.
  34835. */
  34836. clearInternalTexturesCache(): void;
  34837. /**
  34838. * Force the entire cache to be cleared
  34839. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34840. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34841. */
  34842. wipeCaches(bruteForce?: boolean): void;
  34843. /** @hidden */
  34844. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34845. min: number;
  34846. mag: number;
  34847. };
  34848. /** @hidden */
  34849. _createTexture(): WebGLTexture;
  34850. /**
  34851. * Usually called from Texture.ts.
  34852. * Passed information to create a WebGLTexture
  34853. * @param url defines a value which contains one of the following:
  34854. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34855. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34856. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34857. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34858. * @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)
  34859. * @param scene needed for loading to the correct scene
  34860. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34861. * @param onLoad optional callback to be called upon successful completion
  34862. * @param onError optional callback to be called upon failure
  34863. * @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
  34864. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34865. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34866. * @param forcedExtension defines the extension to use to pick the right loader
  34867. * @param mimeType defines an optional mime type
  34868. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34869. */
  34870. 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;
  34871. /**
  34872. * Loads an image as an HTMLImageElement.
  34873. * @param input url string, ArrayBuffer, or Blob to load
  34874. * @param onLoad callback called when the image successfully loads
  34875. * @param onError callback called when the image fails to load
  34876. * @param offlineProvider offline provider for caching
  34877. * @param mimeType optional mime type
  34878. * @returns the HTMLImageElement of the loaded image
  34879. * @hidden
  34880. */
  34881. 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>;
  34882. /**
  34883. * @hidden
  34884. */
  34885. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34886. private _unpackFlipYCached;
  34887. /**
  34888. * In case you are sharing the context with other applications, it might
  34889. * be interested to not cache the unpack flip y state to ensure a consistent
  34890. * value would be set.
  34891. */
  34892. enableUnpackFlipYCached: boolean;
  34893. /** @hidden */
  34894. _unpackFlipY(value: boolean): void;
  34895. /** @hidden */
  34896. _getUnpackAlignement(): number;
  34897. private _getTextureTarget;
  34898. /**
  34899. * Update the sampling mode of a given texture
  34900. * @param samplingMode defines the required sampling mode
  34901. * @param texture defines the texture to update
  34902. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34903. */
  34904. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34905. /**
  34906. * Update the sampling mode of a given texture
  34907. * @param texture defines the texture to update
  34908. * @param wrapU defines the texture wrap mode of the u coordinates
  34909. * @param wrapV defines the texture wrap mode of the v coordinates
  34910. * @param wrapR defines the texture wrap mode of the r coordinates
  34911. */
  34912. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34913. /** @hidden */
  34914. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34915. width: number;
  34916. height: number;
  34917. layers?: number;
  34918. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34919. /** @hidden */
  34920. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34921. /** @hidden */
  34922. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34923. /**
  34924. * Update a portion of an internal texture
  34925. * @param texture defines the texture to update
  34926. * @param imageData defines the data to store into the texture
  34927. * @param xOffset defines the x coordinates of the update rectangle
  34928. * @param yOffset defines the y coordinates of the update rectangle
  34929. * @param width defines the width of the update rectangle
  34930. * @param height defines the height of the update rectangle
  34931. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34932. * @param lod defines the lod level to update (0 by default)
  34933. */
  34934. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34935. /** @hidden */
  34936. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34937. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34938. private _prepareWebGLTexture;
  34939. /** @hidden */
  34940. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34941. private _getDepthStencilBuffer;
  34942. /** @hidden */
  34943. _releaseFramebufferObjects(texture: InternalTexture): void;
  34944. /** @hidden */
  34945. _releaseTexture(texture: InternalTexture): void;
  34946. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34947. protected _setProgram(program: WebGLProgram): void;
  34948. protected _boundUniforms: {
  34949. [key: number]: WebGLUniformLocation;
  34950. };
  34951. /**
  34952. * Binds an effect to the webGL context
  34953. * @param effect defines the effect to bind
  34954. */
  34955. bindSamplers(effect: Effect): void;
  34956. private _activateCurrentTexture;
  34957. /** @hidden */
  34958. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34959. /** @hidden */
  34960. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34961. /**
  34962. * Unbind all textures from the webGL context
  34963. */
  34964. unbindAllTextures(): void;
  34965. /**
  34966. * Sets a texture to the according uniform.
  34967. * @param channel The texture channel
  34968. * @param uniform The uniform to set
  34969. * @param texture The texture to apply
  34970. */
  34971. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34972. private _bindSamplerUniformToChannel;
  34973. private _getTextureWrapMode;
  34974. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34975. /**
  34976. * Sets an array of texture to the webGL context
  34977. * @param channel defines the channel where the texture array must be set
  34978. * @param uniform defines the associated uniform location
  34979. * @param textures defines the array of textures to bind
  34980. */
  34981. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34982. /** @hidden */
  34983. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34984. private _setTextureParameterFloat;
  34985. private _setTextureParameterInteger;
  34986. /**
  34987. * Unbind all vertex attributes from the webGL context
  34988. */
  34989. unbindAllAttributes(): void;
  34990. /**
  34991. * 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
  34992. */
  34993. releaseEffects(): void;
  34994. /**
  34995. * Dispose and release all associated resources
  34996. */
  34997. dispose(): void;
  34998. /**
  34999. * Attach a new callback raised when context lost event is fired
  35000. * @param callback defines the callback to call
  35001. */
  35002. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35003. /**
  35004. * Attach a new callback raised when context restored event is fired
  35005. * @param callback defines the callback to call
  35006. */
  35007. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35008. /**
  35009. * Get the current error code of the webGL context
  35010. * @returns the error code
  35011. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35012. */
  35013. getError(): number;
  35014. private _canRenderToFloatFramebuffer;
  35015. private _canRenderToHalfFloatFramebuffer;
  35016. private _canRenderToFramebuffer;
  35017. /** @hidden */
  35018. _getWebGLTextureType(type: number): number;
  35019. /** @hidden */
  35020. _getInternalFormat(format: number): number;
  35021. /** @hidden */
  35022. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35023. /** @hidden */
  35024. _getRGBAMultiSampleBufferFormat(type: number): number;
  35025. /** @hidden */
  35026. _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;
  35027. /**
  35028. * Loads a file from a url
  35029. * @param url url to load
  35030. * @param onSuccess callback called when the file successfully loads
  35031. * @param onProgress callback called while file is loading (if the server supports this mode)
  35032. * @param offlineProvider defines the offline provider for caching
  35033. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35034. * @param onError callback called when the file fails to load
  35035. * @returns a file request object
  35036. * @hidden
  35037. */
  35038. 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;
  35039. /**
  35040. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35041. * @param x defines the x coordinate of the rectangle where pixels must be read
  35042. * @param y defines the y coordinate of the rectangle where pixels must be read
  35043. * @param width defines the width of the rectangle where pixels must be read
  35044. * @param height defines the height of the rectangle where pixels must be read
  35045. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35046. * @returns a Uint8Array containing RGBA colors
  35047. */
  35048. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35049. private static _isSupported;
  35050. /**
  35051. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35052. * @returns true if the engine can be created
  35053. * @ignorenaming
  35054. */
  35055. static isSupported(): boolean;
  35056. /**
  35057. * Find the next highest power of two.
  35058. * @param x Number to start search from.
  35059. * @return Next highest power of two.
  35060. */
  35061. static CeilingPOT(x: number): number;
  35062. /**
  35063. * Find the next lowest power of two.
  35064. * @param x Number to start search from.
  35065. * @return Next lowest power of two.
  35066. */
  35067. static FloorPOT(x: number): number;
  35068. /**
  35069. * Find the nearest power of two.
  35070. * @param x Number to start search from.
  35071. * @return Next nearest power of two.
  35072. */
  35073. static NearestPOT(x: number): number;
  35074. /**
  35075. * Get the closest exponent of two
  35076. * @param value defines the value to approximate
  35077. * @param max defines the maximum value to return
  35078. * @param mode defines how to define the closest value
  35079. * @returns closest exponent of two of the given value
  35080. */
  35081. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35082. /**
  35083. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35084. * @param func - the function to be called
  35085. * @param requester - the object that will request the next frame. Falls back to window.
  35086. * @returns frame number
  35087. */
  35088. static QueueNewFrame(func: () => void, requester?: any): number;
  35089. /**
  35090. * Gets host document
  35091. * @returns the host document object
  35092. */
  35093. getHostDocument(): Nullable<Document>;
  35094. }
  35095. }
  35096. declare module BABYLON {
  35097. /**
  35098. * Class representing spherical harmonics coefficients to the 3rd degree
  35099. */
  35100. export class SphericalHarmonics {
  35101. /**
  35102. * Defines whether or not the harmonics have been prescaled for rendering.
  35103. */
  35104. preScaled: boolean;
  35105. /**
  35106. * The l0,0 coefficients of the spherical harmonics
  35107. */
  35108. l00: Vector3;
  35109. /**
  35110. * The l1,-1 coefficients of the spherical harmonics
  35111. */
  35112. l1_1: Vector3;
  35113. /**
  35114. * The l1,0 coefficients of the spherical harmonics
  35115. */
  35116. l10: Vector3;
  35117. /**
  35118. * The l1,1 coefficients of the spherical harmonics
  35119. */
  35120. l11: Vector3;
  35121. /**
  35122. * The l2,-2 coefficients of the spherical harmonics
  35123. */
  35124. l2_2: Vector3;
  35125. /**
  35126. * The l2,-1 coefficients of the spherical harmonics
  35127. */
  35128. l2_1: Vector3;
  35129. /**
  35130. * The l2,0 coefficients of the spherical harmonics
  35131. */
  35132. l20: Vector3;
  35133. /**
  35134. * The l2,1 coefficients of the spherical harmonics
  35135. */
  35136. l21: Vector3;
  35137. /**
  35138. * The l2,2 coefficients of the spherical harmonics
  35139. */
  35140. l22: Vector3;
  35141. /**
  35142. * Adds a light to the spherical harmonics
  35143. * @param direction the direction of the light
  35144. * @param color the color of the light
  35145. * @param deltaSolidAngle the delta solid angle of the light
  35146. */
  35147. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35148. /**
  35149. * Scales the spherical harmonics by the given amount
  35150. * @param scale the amount to scale
  35151. */
  35152. scaleInPlace(scale: number): void;
  35153. /**
  35154. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35155. *
  35156. * ```
  35157. * E_lm = A_l * L_lm
  35158. * ```
  35159. *
  35160. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35161. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35162. * the scaling factors are given in equation 9.
  35163. */
  35164. convertIncidentRadianceToIrradiance(): void;
  35165. /**
  35166. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35167. *
  35168. * ```
  35169. * L = (1/pi) * E * rho
  35170. * ```
  35171. *
  35172. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35173. */
  35174. convertIrradianceToLambertianRadiance(): void;
  35175. /**
  35176. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35177. * required operations at run time.
  35178. *
  35179. * This is simply done by scaling back the SH with Ylm constants parameter.
  35180. * The trigonometric part being applied by the shader at run time.
  35181. */
  35182. preScaleForRendering(): void;
  35183. /**
  35184. * Constructs a spherical harmonics from an array.
  35185. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35186. * @returns the spherical harmonics
  35187. */
  35188. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35189. /**
  35190. * Gets the spherical harmonics from polynomial
  35191. * @param polynomial the spherical polynomial
  35192. * @returns the spherical harmonics
  35193. */
  35194. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35195. }
  35196. /**
  35197. * Class representing spherical polynomial coefficients to the 3rd degree
  35198. */
  35199. export class SphericalPolynomial {
  35200. private _harmonics;
  35201. /**
  35202. * The spherical harmonics used to create the polynomials.
  35203. */
  35204. get preScaledHarmonics(): SphericalHarmonics;
  35205. /**
  35206. * The x coefficients of the spherical polynomial
  35207. */
  35208. x: Vector3;
  35209. /**
  35210. * The y coefficients of the spherical polynomial
  35211. */
  35212. y: Vector3;
  35213. /**
  35214. * The z coefficients of the spherical polynomial
  35215. */
  35216. z: Vector3;
  35217. /**
  35218. * The xx coefficients of the spherical polynomial
  35219. */
  35220. xx: Vector3;
  35221. /**
  35222. * The yy coefficients of the spherical polynomial
  35223. */
  35224. yy: Vector3;
  35225. /**
  35226. * The zz coefficients of the spherical polynomial
  35227. */
  35228. zz: Vector3;
  35229. /**
  35230. * The xy coefficients of the spherical polynomial
  35231. */
  35232. xy: Vector3;
  35233. /**
  35234. * The yz coefficients of the spherical polynomial
  35235. */
  35236. yz: Vector3;
  35237. /**
  35238. * The zx coefficients of the spherical polynomial
  35239. */
  35240. zx: Vector3;
  35241. /**
  35242. * Adds an ambient color to the spherical polynomial
  35243. * @param color the color to add
  35244. */
  35245. addAmbient(color: Color3): void;
  35246. /**
  35247. * Scales the spherical polynomial by the given amount
  35248. * @param scale the amount to scale
  35249. */
  35250. scaleInPlace(scale: number): void;
  35251. /**
  35252. * Gets the spherical polynomial from harmonics
  35253. * @param harmonics the spherical harmonics
  35254. * @returns the spherical polynomial
  35255. */
  35256. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35257. /**
  35258. * Constructs a spherical polynomial from an array.
  35259. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35260. * @returns the spherical polynomial
  35261. */
  35262. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35263. }
  35264. }
  35265. declare module BABYLON {
  35266. /**
  35267. * Defines the source of the internal texture
  35268. */
  35269. export enum InternalTextureSource {
  35270. /**
  35271. * The source of the texture data is unknown
  35272. */
  35273. Unknown = 0,
  35274. /**
  35275. * Texture data comes from an URL
  35276. */
  35277. Url = 1,
  35278. /**
  35279. * Texture data is only used for temporary storage
  35280. */
  35281. Temp = 2,
  35282. /**
  35283. * Texture data comes from raw data (ArrayBuffer)
  35284. */
  35285. Raw = 3,
  35286. /**
  35287. * Texture content is dynamic (video or dynamic texture)
  35288. */
  35289. Dynamic = 4,
  35290. /**
  35291. * Texture content is generated by rendering to it
  35292. */
  35293. RenderTarget = 5,
  35294. /**
  35295. * Texture content is part of a multi render target process
  35296. */
  35297. MultiRenderTarget = 6,
  35298. /**
  35299. * Texture data comes from a cube data file
  35300. */
  35301. Cube = 7,
  35302. /**
  35303. * Texture data comes from a raw cube data
  35304. */
  35305. CubeRaw = 8,
  35306. /**
  35307. * Texture data come from a prefiltered cube data file
  35308. */
  35309. CubePrefiltered = 9,
  35310. /**
  35311. * Texture content is raw 3D data
  35312. */
  35313. Raw3D = 10,
  35314. /**
  35315. * Texture content is raw 2D array data
  35316. */
  35317. Raw2DArray = 11,
  35318. /**
  35319. * Texture content is a depth texture
  35320. */
  35321. Depth = 12,
  35322. /**
  35323. * Texture data comes from a raw cube data encoded with RGBD
  35324. */
  35325. CubeRawRGBD = 13
  35326. }
  35327. /**
  35328. * Class used to store data associated with WebGL texture data for the engine
  35329. * This class should not be used directly
  35330. */
  35331. export class InternalTexture {
  35332. /** @hidden */
  35333. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35334. /**
  35335. * Defines if the texture is ready
  35336. */
  35337. isReady: boolean;
  35338. /**
  35339. * Defines if the texture is a cube texture
  35340. */
  35341. isCube: boolean;
  35342. /**
  35343. * Defines if the texture contains 3D data
  35344. */
  35345. is3D: boolean;
  35346. /**
  35347. * Defines if the texture contains 2D array data
  35348. */
  35349. is2DArray: boolean;
  35350. /**
  35351. * Defines if the texture contains multiview data
  35352. */
  35353. isMultiview: boolean;
  35354. /**
  35355. * Gets the URL used to load this texture
  35356. */
  35357. url: string;
  35358. /**
  35359. * Gets the sampling mode of the texture
  35360. */
  35361. samplingMode: number;
  35362. /**
  35363. * Gets a boolean indicating if the texture needs mipmaps generation
  35364. */
  35365. generateMipMaps: boolean;
  35366. /**
  35367. * Gets the number of samples used by the texture (WebGL2+ only)
  35368. */
  35369. samples: number;
  35370. /**
  35371. * Gets the type of the texture (int, float...)
  35372. */
  35373. type: number;
  35374. /**
  35375. * Gets the format of the texture (RGB, RGBA...)
  35376. */
  35377. format: number;
  35378. /**
  35379. * Observable called when the texture is loaded
  35380. */
  35381. onLoadedObservable: Observable<InternalTexture>;
  35382. /**
  35383. * Gets the width of the texture
  35384. */
  35385. width: number;
  35386. /**
  35387. * Gets the height of the texture
  35388. */
  35389. height: number;
  35390. /**
  35391. * Gets the depth of the texture
  35392. */
  35393. depth: number;
  35394. /**
  35395. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35396. */
  35397. baseWidth: number;
  35398. /**
  35399. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35400. */
  35401. baseHeight: number;
  35402. /**
  35403. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35404. */
  35405. baseDepth: number;
  35406. /**
  35407. * Gets a boolean indicating if the texture is inverted on Y axis
  35408. */
  35409. invertY: boolean;
  35410. /** @hidden */
  35411. _invertVScale: boolean;
  35412. /** @hidden */
  35413. _associatedChannel: number;
  35414. /** @hidden */
  35415. _source: InternalTextureSource;
  35416. /** @hidden */
  35417. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35418. /** @hidden */
  35419. _bufferView: Nullable<ArrayBufferView>;
  35420. /** @hidden */
  35421. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35422. /** @hidden */
  35423. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35424. /** @hidden */
  35425. _size: number;
  35426. /** @hidden */
  35427. _extension: string;
  35428. /** @hidden */
  35429. _files: Nullable<string[]>;
  35430. /** @hidden */
  35431. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35432. /** @hidden */
  35433. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35434. /** @hidden */
  35435. _framebuffer: Nullable<WebGLFramebuffer>;
  35436. /** @hidden */
  35437. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35438. /** @hidden */
  35439. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35440. /** @hidden */
  35441. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35442. /** @hidden */
  35443. _attachments: Nullable<number[]>;
  35444. /** @hidden */
  35445. _cachedCoordinatesMode: Nullable<number>;
  35446. /** @hidden */
  35447. _cachedWrapU: Nullable<number>;
  35448. /** @hidden */
  35449. _cachedWrapV: Nullable<number>;
  35450. /** @hidden */
  35451. _cachedWrapR: Nullable<number>;
  35452. /** @hidden */
  35453. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35454. /** @hidden */
  35455. _isDisabled: boolean;
  35456. /** @hidden */
  35457. _compression: Nullable<string>;
  35458. /** @hidden */
  35459. _generateStencilBuffer: boolean;
  35460. /** @hidden */
  35461. _generateDepthBuffer: boolean;
  35462. /** @hidden */
  35463. _comparisonFunction: number;
  35464. /** @hidden */
  35465. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35466. /** @hidden */
  35467. _lodGenerationScale: number;
  35468. /** @hidden */
  35469. _lodGenerationOffset: number;
  35470. /** @hidden */
  35471. _depthStencilTexture: Nullable<InternalTexture>;
  35472. /** @hidden */
  35473. _colorTextureArray: Nullable<WebGLTexture>;
  35474. /** @hidden */
  35475. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35476. /** @hidden */
  35477. _lodTextureHigh: Nullable<BaseTexture>;
  35478. /** @hidden */
  35479. _lodTextureMid: Nullable<BaseTexture>;
  35480. /** @hidden */
  35481. _lodTextureLow: Nullable<BaseTexture>;
  35482. /** @hidden */
  35483. _isRGBD: boolean;
  35484. /** @hidden */
  35485. _linearSpecularLOD: boolean;
  35486. /** @hidden */
  35487. _irradianceTexture: Nullable<BaseTexture>;
  35488. /** @hidden */
  35489. _webGLTexture: Nullable<WebGLTexture>;
  35490. /** @hidden */
  35491. _references: number;
  35492. private _engine;
  35493. /**
  35494. * Gets the Engine the texture belongs to.
  35495. * @returns The babylon engine
  35496. */
  35497. getEngine(): ThinEngine;
  35498. /**
  35499. * Gets the data source type of the texture
  35500. */
  35501. get source(): InternalTextureSource;
  35502. /**
  35503. * Creates a new InternalTexture
  35504. * @param engine defines the engine to use
  35505. * @param source defines the type of data that will be used
  35506. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35507. */
  35508. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35509. /**
  35510. * Increments the number of references (ie. the number of Texture that point to it)
  35511. */
  35512. incrementReferences(): void;
  35513. /**
  35514. * Change the size of the texture (not the size of the content)
  35515. * @param width defines the new width
  35516. * @param height defines the new height
  35517. * @param depth defines the new depth (1 by default)
  35518. */
  35519. updateSize(width: int, height: int, depth?: int): void;
  35520. /** @hidden */
  35521. _rebuild(): void;
  35522. /** @hidden */
  35523. _swapAndDie(target: InternalTexture): void;
  35524. /**
  35525. * Dispose the current allocated resources
  35526. */
  35527. dispose(): void;
  35528. }
  35529. }
  35530. declare module BABYLON {
  35531. /**
  35532. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35534. */
  35535. export class Analyser {
  35536. /**
  35537. * Gets or sets the smoothing
  35538. * @ignorenaming
  35539. */
  35540. SMOOTHING: number;
  35541. /**
  35542. * Gets or sets the FFT table size
  35543. * @ignorenaming
  35544. */
  35545. FFT_SIZE: number;
  35546. /**
  35547. * Gets or sets the bar graph amplitude
  35548. * @ignorenaming
  35549. */
  35550. BARGRAPHAMPLITUDE: number;
  35551. /**
  35552. * Gets or sets the position of the debug canvas
  35553. * @ignorenaming
  35554. */
  35555. DEBUGCANVASPOS: {
  35556. x: number;
  35557. y: number;
  35558. };
  35559. /**
  35560. * Gets or sets the debug canvas size
  35561. * @ignorenaming
  35562. */
  35563. DEBUGCANVASSIZE: {
  35564. width: number;
  35565. height: number;
  35566. };
  35567. private _byteFreqs;
  35568. private _byteTime;
  35569. private _floatFreqs;
  35570. private _webAudioAnalyser;
  35571. private _debugCanvas;
  35572. private _debugCanvasContext;
  35573. private _scene;
  35574. private _registerFunc;
  35575. private _audioEngine;
  35576. /**
  35577. * Creates a new analyser
  35578. * @param scene defines hosting scene
  35579. */
  35580. constructor(scene: Scene);
  35581. /**
  35582. * Get the number of data values you will have to play with for the visualization
  35583. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35584. * @returns a number
  35585. */
  35586. getFrequencyBinCount(): number;
  35587. /**
  35588. * Gets the current frequency data as a byte array
  35589. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35590. * @returns a Uint8Array
  35591. */
  35592. getByteFrequencyData(): Uint8Array;
  35593. /**
  35594. * Gets the current waveform as a byte array
  35595. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35596. * @returns a Uint8Array
  35597. */
  35598. getByteTimeDomainData(): Uint8Array;
  35599. /**
  35600. * Gets the current frequency data as a float array
  35601. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35602. * @returns a Float32Array
  35603. */
  35604. getFloatFrequencyData(): Float32Array;
  35605. /**
  35606. * Renders the debug canvas
  35607. */
  35608. drawDebugCanvas(): void;
  35609. /**
  35610. * Stops rendering the debug canvas and removes it
  35611. */
  35612. stopDebugCanvas(): void;
  35613. /**
  35614. * Connects two audio nodes
  35615. * @param inputAudioNode defines first node to connect
  35616. * @param outputAudioNode defines second node to connect
  35617. */
  35618. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35619. /**
  35620. * Releases all associated resources
  35621. */
  35622. dispose(): void;
  35623. }
  35624. }
  35625. declare module BABYLON {
  35626. /**
  35627. * This represents an audio engine and it is responsible
  35628. * to play, synchronize and analyse sounds throughout the application.
  35629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35630. */
  35631. export interface IAudioEngine extends IDisposable {
  35632. /**
  35633. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35634. */
  35635. readonly canUseWebAudio: boolean;
  35636. /**
  35637. * Gets the current AudioContext if available.
  35638. */
  35639. readonly audioContext: Nullable<AudioContext>;
  35640. /**
  35641. * The master gain node defines the global audio volume of your audio engine.
  35642. */
  35643. readonly masterGain: GainNode;
  35644. /**
  35645. * Gets whether or not mp3 are supported by your browser.
  35646. */
  35647. readonly isMP3supported: boolean;
  35648. /**
  35649. * Gets whether or not ogg are supported by your browser.
  35650. */
  35651. readonly isOGGsupported: boolean;
  35652. /**
  35653. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35654. * @ignoreNaming
  35655. */
  35656. WarnedWebAudioUnsupported: boolean;
  35657. /**
  35658. * Defines if the audio engine relies on a custom unlocked button.
  35659. * In this case, the embedded button will not be displayed.
  35660. */
  35661. useCustomUnlockedButton: boolean;
  35662. /**
  35663. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35664. */
  35665. readonly unlocked: boolean;
  35666. /**
  35667. * Event raised when audio has been unlocked on the browser.
  35668. */
  35669. onAudioUnlockedObservable: Observable<AudioEngine>;
  35670. /**
  35671. * Event raised when audio has been locked on the browser.
  35672. */
  35673. onAudioLockedObservable: Observable<AudioEngine>;
  35674. /**
  35675. * Flags the audio engine in Locked state.
  35676. * This happens due to new browser policies preventing audio to autoplay.
  35677. */
  35678. lock(): void;
  35679. /**
  35680. * Unlocks the audio engine once a user action has been done on the dom.
  35681. * This is helpful to resume play once browser policies have been satisfied.
  35682. */
  35683. unlock(): void;
  35684. /**
  35685. * Gets the global volume sets on the master gain.
  35686. * @returns the global volume if set or -1 otherwise
  35687. */
  35688. getGlobalVolume(): number;
  35689. /**
  35690. * Sets the global volume of your experience (sets on the master gain).
  35691. * @param newVolume Defines the new global volume of the application
  35692. */
  35693. setGlobalVolume(newVolume: number): void;
  35694. /**
  35695. * Connect the audio engine to an audio analyser allowing some amazing
  35696. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35698. * @param analyser The analyser to connect to the engine
  35699. */
  35700. connectToAnalyser(analyser: Analyser): void;
  35701. }
  35702. /**
  35703. * This represents the default audio engine used in babylon.
  35704. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35706. */
  35707. export class AudioEngine implements IAudioEngine {
  35708. private _audioContext;
  35709. private _audioContextInitialized;
  35710. private _muteButton;
  35711. private _hostElement;
  35712. /**
  35713. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35714. */
  35715. canUseWebAudio: boolean;
  35716. /**
  35717. * The master gain node defines the global audio volume of your audio engine.
  35718. */
  35719. masterGain: GainNode;
  35720. /**
  35721. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35722. * @ignoreNaming
  35723. */
  35724. WarnedWebAudioUnsupported: boolean;
  35725. /**
  35726. * Gets whether or not mp3 are supported by your browser.
  35727. */
  35728. isMP3supported: boolean;
  35729. /**
  35730. * Gets whether or not ogg are supported by your browser.
  35731. */
  35732. isOGGsupported: boolean;
  35733. /**
  35734. * Gets whether audio has been unlocked on the device.
  35735. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35736. * a user interaction has happened.
  35737. */
  35738. unlocked: boolean;
  35739. /**
  35740. * Defines if the audio engine relies on a custom unlocked button.
  35741. * In this case, the embedded button will not be displayed.
  35742. */
  35743. useCustomUnlockedButton: boolean;
  35744. /**
  35745. * Event raised when audio has been unlocked on the browser.
  35746. */
  35747. onAudioUnlockedObservable: Observable<AudioEngine>;
  35748. /**
  35749. * Event raised when audio has been locked on the browser.
  35750. */
  35751. onAudioLockedObservable: Observable<AudioEngine>;
  35752. /**
  35753. * Gets the current AudioContext if available.
  35754. */
  35755. get audioContext(): Nullable<AudioContext>;
  35756. private _connectedAnalyser;
  35757. /**
  35758. * Instantiates a new audio engine.
  35759. *
  35760. * There should be only one per page as some browsers restrict the number
  35761. * of audio contexts you can create.
  35762. * @param hostElement defines the host element where to display the mute icon if necessary
  35763. */
  35764. constructor(hostElement?: Nullable<HTMLElement>);
  35765. /**
  35766. * Flags the audio engine in Locked state.
  35767. * This happens due to new browser policies preventing audio to autoplay.
  35768. */
  35769. lock(): void;
  35770. /**
  35771. * Unlocks the audio engine once a user action has been done on the dom.
  35772. * This is helpful to resume play once browser policies have been satisfied.
  35773. */
  35774. unlock(): void;
  35775. private _resumeAudioContext;
  35776. private _initializeAudioContext;
  35777. private _tryToRun;
  35778. private _triggerRunningState;
  35779. private _triggerSuspendedState;
  35780. private _displayMuteButton;
  35781. private _moveButtonToTopLeft;
  35782. private _onResize;
  35783. private _hideMuteButton;
  35784. /**
  35785. * Destroy and release the resources associated with the audio ccontext.
  35786. */
  35787. dispose(): void;
  35788. /**
  35789. * Gets the global volume sets on the master gain.
  35790. * @returns the global volume if set or -1 otherwise
  35791. */
  35792. getGlobalVolume(): number;
  35793. /**
  35794. * Sets the global volume of your experience (sets on the master gain).
  35795. * @param newVolume Defines the new global volume of the application
  35796. */
  35797. setGlobalVolume(newVolume: number): void;
  35798. /**
  35799. * Connect the audio engine to an audio analyser allowing some amazing
  35800. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35802. * @param analyser The analyser to connect to the engine
  35803. */
  35804. connectToAnalyser(analyser: Analyser): void;
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /**
  35809. * Interface used to present a loading screen while loading a scene
  35810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35811. */
  35812. export interface ILoadingScreen {
  35813. /**
  35814. * Function called to display the loading screen
  35815. */
  35816. displayLoadingUI: () => void;
  35817. /**
  35818. * Function called to hide the loading screen
  35819. */
  35820. hideLoadingUI: () => void;
  35821. /**
  35822. * Gets or sets the color to use for the background
  35823. */
  35824. loadingUIBackgroundColor: string;
  35825. /**
  35826. * Gets or sets the text to display while loading
  35827. */
  35828. loadingUIText: string;
  35829. }
  35830. /**
  35831. * Class used for the default loading screen
  35832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35833. */
  35834. export class DefaultLoadingScreen implements ILoadingScreen {
  35835. private _renderingCanvas;
  35836. private _loadingText;
  35837. private _loadingDivBackgroundColor;
  35838. private _loadingDiv;
  35839. private _loadingTextDiv;
  35840. /** Gets or sets the logo url to use for the default loading screen */
  35841. static DefaultLogoUrl: string;
  35842. /** Gets or sets the spinner url to use for the default loading screen */
  35843. static DefaultSpinnerUrl: string;
  35844. /**
  35845. * Creates a new default loading screen
  35846. * @param _renderingCanvas defines the canvas used to render the scene
  35847. * @param _loadingText defines the default text to display
  35848. * @param _loadingDivBackgroundColor defines the default background color
  35849. */
  35850. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35851. /**
  35852. * Function called to display the loading screen
  35853. */
  35854. displayLoadingUI(): void;
  35855. /**
  35856. * Function called to hide the loading screen
  35857. */
  35858. hideLoadingUI(): void;
  35859. /**
  35860. * Gets or sets the text to display while loading
  35861. */
  35862. set loadingUIText(text: string);
  35863. get loadingUIText(): string;
  35864. /**
  35865. * Gets or sets the color to use for the background
  35866. */
  35867. get loadingUIBackgroundColor(): string;
  35868. set loadingUIBackgroundColor(color: string);
  35869. private _resizeLoadingUI;
  35870. }
  35871. }
  35872. declare module BABYLON {
  35873. /**
  35874. * Interface for any object that can request an animation frame
  35875. */
  35876. export interface ICustomAnimationFrameRequester {
  35877. /**
  35878. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35879. */
  35880. renderFunction?: Function;
  35881. /**
  35882. * Called to request the next frame to render to
  35883. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35884. */
  35885. requestAnimationFrame: Function;
  35886. /**
  35887. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35888. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35889. */
  35890. requestID?: number;
  35891. }
  35892. }
  35893. declare module BABYLON {
  35894. /**
  35895. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35896. */
  35897. export class PerformanceMonitor {
  35898. private _enabled;
  35899. private _rollingFrameTime;
  35900. private _lastFrameTimeMs;
  35901. /**
  35902. * constructor
  35903. * @param frameSampleSize The number of samples required to saturate the sliding window
  35904. */
  35905. constructor(frameSampleSize?: number);
  35906. /**
  35907. * Samples current frame
  35908. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35909. */
  35910. sampleFrame(timeMs?: number): void;
  35911. /**
  35912. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35913. */
  35914. get averageFrameTime(): number;
  35915. /**
  35916. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35917. */
  35918. get averageFrameTimeVariance(): number;
  35919. /**
  35920. * Returns the frame time of the most recent frame
  35921. */
  35922. get instantaneousFrameTime(): number;
  35923. /**
  35924. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35925. */
  35926. get averageFPS(): number;
  35927. /**
  35928. * Returns the average framerate in frames per second using the most recent frame time
  35929. */
  35930. get instantaneousFPS(): number;
  35931. /**
  35932. * Returns true if enough samples have been taken to completely fill the sliding window
  35933. */
  35934. get isSaturated(): boolean;
  35935. /**
  35936. * Enables contributions to the sliding window sample set
  35937. */
  35938. enable(): void;
  35939. /**
  35940. * Disables contributions to the sliding window sample set
  35941. * Samples will not be interpolated over the disabled period
  35942. */
  35943. disable(): void;
  35944. /**
  35945. * Returns true if sampling is enabled
  35946. */
  35947. get isEnabled(): boolean;
  35948. /**
  35949. * Resets performance monitor
  35950. */
  35951. reset(): void;
  35952. }
  35953. /**
  35954. * RollingAverage
  35955. *
  35956. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35957. */
  35958. export class RollingAverage {
  35959. /**
  35960. * Current average
  35961. */
  35962. average: number;
  35963. /**
  35964. * Current variance
  35965. */
  35966. variance: number;
  35967. protected _samples: Array<number>;
  35968. protected _sampleCount: number;
  35969. protected _pos: number;
  35970. protected _m2: number;
  35971. /**
  35972. * constructor
  35973. * @param length The number of samples required to saturate the sliding window
  35974. */
  35975. constructor(length: number);
  35976. /**
  35977. * Adds a sample to the sample set
  35978. * @param v The sample value
  35979. */
  35980. add(v: number): void;
  35981. /**
  35982. * Returns previously added values or null if outside of history or outside the sliding window domain
  35983. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35984. * @return Value previously recorded with add() or null if outside of range
  35985. */
  35986. history(i: number): number;
  35987. /**
  35988. * Returns true if enough samples have been taken to completely fill the sliding window
  35989. * @return true if sample-set saturated
  35990. */
  35991. isSaturated(): boolean;
  35992. /**
  35993. * Resets the rolling average (equivalent to 0 samples taken so far)
  35994. */
  35995. reset(): void;
  35996. /**
  35997. * Wraps a value around the sample range boundaries
  35998. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35999. * @return Wrapped position in sample range
  36000. */
  36001. protected _wrapPosition(i: number): number;
  36002. }
  36003. }
  36004. declare module BABYLON {
  36005. /**
  36006. * This class is used to track a performance counter which is number based.
  36007. * The user has access to many properties which give statistics of different nature.
  36008. *
  36009. * The implementer can track two kinds of Performance Counter: time and count.
  36010. * 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.
  36011. * 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.
  36012. */
  36013. export class PerfCounter {
  36014. /**
  36015. * Gets or sets a global boolean to turn on and off all the counters
  36016. */
  36017. static Enabled: boolean;
  36018. /**
  36019. * Returns the smallest value ever
  36020. */
  36021. get min(): number;
  36022. /**
  36023. * Returns the biggest value ever
  36024. */
  36025. get max(): number;
  36026. /**
  36027. * Returns the average value since the performance counter is running
  36028. */
  36029. get average(): number;
  36030. /**
  36031. * Returns the average value of the last second the counter was monitored
  36032. */
  36033. get lastSecAverage(): number;
  36034. /**
  36035. * Returns the current value
  36036. */
  36037. get current(): number;
  36038. /**
  36039. * Gets the accumulated total
  36040. */
  36041. get total(): number;
  36042. /**
  36043. * Gets the total value count
  36044. */
  36045. get count(): number;
  36046. /**
  36047. * Creates a new counter
  36048. */
  36049. constructor();
  36050. /**
  36051. * Call this method to start monitoring a new frame.
  36052. * 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.
  36053. */
  36054. fetchNewFrame(): void;
  36055. /**
  36056. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36057. * @param newCount the count value to add to the monitored count
  36058. * @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.
  36059. */
  36060. addCount(newCount: number, fetchResult: boolean): void;
  36061. /**
  36062. * Start monitoring this performance counter
  36063. */
  36064. beginMonitoring(): void;
  36065. /**
  36066. * Compute the time lapsed since the previous beginMonitoring() call.
  36067. * @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
  36068. */
  36069. endMonitoring(newFrame?: boolean): void;
  36070. private _fetchResult;
  36071. private _startMonitoringTime;
  36072. private _min;
  36073. private _max;
  36074. private _average;
  36075. private _current;
  36076. private _totalValueCount;
  36077. private _totalAccumulated;
  36078. private _lastSecAverage;
  36079. private _lastSecAccumulated;
  36080. private _lastSecTime;
  36081. private _lastSecValueCount;
  36082. }
  36083. }
  36084. declare module BABYLON {
  36085. interface ThinEngine {
  36086. /**
  36087. * Sets alpha constants used by some alpha blending modes
  36088. * @param r defines the red component
  36089. * @param g defines the green component
  36090. * @param b defines the blue component
  36091. * @param a defines the alpha component
  36092. */
  36093. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36094. /**
  36095. * Sets the current alpha mode
  36096. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36097. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36099. */
  36100. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36101. /**
  36102. * Gets the current alpha mode
  36103. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36104. * @returns the current alpha mode
  36105. */
  36106. getAlphaMode(): number;
  36107. /**
  36108. * Sets the current alpha equation
  36109. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36110. */
  36111. setAlphaEquation(equation: number): void;
  36112. /**
  36113. * Gets the current alpha equation.
  36114. * @returns the current alpha equation
  36115. */
  36116. getAlphaEquation(): number;
  36117. }
  36118. }
  36119. declare module BABYLON {
  36120. interface ThinEngine {
  36121. /** @hidden */
  36122. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36123. }
  36124. }
  36125. declare module BABYLON {
  36126. /**
  36127. * Defines the interface used by display changed events
  36128. */
  36129. export interface IDisplayChangedEventArgs {
  36130. /** Gets the vrDisplay object (if any) */
  36131. vrDisplay: Nullable<any>;
  36132. /** Gets a boolean indicating if webVR is supported */
  36133. vrSupported: boolean;
  36134. }
  36135. /**
  36136. * Defines the interface used by objects containing a viewport (like a camera)
  36137. */
  36138. interface IViewportOwnerLike {
  36139. /**
  36140. * Gets or sets the viewport
  36141. */
  36142. viewport: IViewportLike;
  36143. }
  36144. /**
  36145. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36146. */
  36147. export class Engine extends ThinEngine {
  36148. /** Defines that alpha blending is disabled */
  36149. static readonly ALPHA_DISABLE: number;
  36150. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36151. static readonly ALPHA_ADD: number;
  36152. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36153. static readonly ALPHA_COMBINE: number;
  36154. /** Defines that alpha blending to DEST - SRC * DEST */
  36155. static readonly ALPHA_SUBTRACT: number;
  36156. /** Defines that alpha blending to SRC * DEST */
  36157. static readonly ALPHA_MULTIPLY: number;
  36158. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36159. static readonly ALPHA_MAXIMIZED: number;
  36160. /** Defines that alpha blending to SRC + DEST */
  36161. static readonly ALPHA_ONEONE: number;
  36162. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36163. static readonly ALPHA_PREMULTIPLIED: number;
  36164. /**
  36165. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36166. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36167. */
  36168. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36169. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36170. static readonly ALPHA_INTERPOLATE: number;
  36171. /**
  36172. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36173. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36174. */
  36175. static readonly ALPHA_SCREENMODE: number;
  36176. /** Defines that the ressource is not delayed*/
  36177. static readonly DELAYLOADSTATE_NONE: number;
  36178. /** Defines that the ressource was successfully delay loaded */
  36179. static readonly DELAYLOADSTATE_LOADED: number;
  36180. /** Defines that the ressource is currently delay loading */
  36181. static readonly DELAYLOADSTATE_LOADING: number;
  36182. /** Defines that the ressource is delayed and has not started loading */
  36183. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36184. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36185. static readonly NEVER: number;
  36186. /** 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 */
  36187. static readonly ALWAYS: number;
  36188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36189. static readonly LESS: number;
  36190. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36191. static readonly EQUAL: number;
  36192. /** 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 */
  36193. static readonly LEQUAL: number;
  36194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36195. static readonly GREATER: number;
  36196. /** 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 */
  36197. static readonly GEQUAL: number;
  36198. /** 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 */
  36199. static readonly NOTEQUAL: number;
  36200. /** Passed to stencilOperation to specify that stencil value must be kept */
  36201. static readonly KEEP: number;
  36202. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36203. static readonly REPLACE: number;
  36204. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36205. static readonly INCR: number;
  36206. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36207. static readonly DECR: number;
  36208. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36209. static readonly INVERT: number;
  36210. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36211. static readonly INCR_WRAP: number;
  36212. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36213. static readonly DECR_WRAP: number;
  36214. /** Texture is not repeating outside of 0..1 UVs */
  36215. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36216. /** Texture is repeating outside of 0..1 UVs */
  36217. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36218. /** Texture is repeating and mirrored */
  36219. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36220. /** ALPHA */
  36221. static readonly TEXTUREFORMAT_ALPHA: number;
  36222. /** LUMINANCE */
  36223. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36224. /** LUMINANCE_ALPHA */
  36225. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36226. /** RGB */
  36227. static readonly TEXTUREFORMAT_RGB: number;
  36228. /** RGBA */
  36229. static readonly TEXTUREFORMAT_RGBA: number;
  36230. /** RED */
  36231. static readonly TEXTUREFORMAT_RED: number;
  36232. /** RED (2nd reference) */
  36233. static readonly TEXTUREFORMAT_R: number;
  36234. /** RG */
  36235. static readonly TEXTUREFORMAT_RG: number;
  36236. /** RED_INTEGER */
  36237. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36238. /** RED_INTEGER (2nd reference) */
  36239. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36240. /** RG_INTEGER */
  36241. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36242. /** RGB_INTEGER */
  36243. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36244. /** RGBA_INTEGER */
  36245. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36246. /** UNSIGNED_BYTE */
  36247. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36248. /** UNSIGNED_BYTE (2nd reference) */
  36249. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36250. /** FLOAT */
  36251. static readonly TEXTURETYPE_FLOAT: number;
  36252. /** HALF_FLOAT */
  36253. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36254. /** BYTE */
  36255. static readonly TEXTURETYPE_BYTE: number;
  36256. /** SHORT */
  36257. static readonly TEXTURETYPE_SHORT: number;
  36258. /** UNSIGNED_SHORT */
  36259. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36260. /** INT */
  36261. static readonly TEXTURETYPE_INT: number;
  36262. /** UNSIGNED_INT */
  36263. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36264. /** UNSIGNED_SHORT_4_4_4_4 */
  36265. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36266. /** UNSIGNED_SHORT_5_5_5_1 */
  36267. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36268. /** UNSIGNED_SHORT_5_6_5 */
  36269. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36270. /** UNSIGNED_INT_2_10_10_10_REV */
  36271. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36272. /** UNSIGNED_INT_24_8 */
  36273. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36274. /** UNSIGNED_INT_10F_11F_11F_REV */
  36275. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36276. /** UNSIGNED_INT_5_9_9_9_REV */
  36277. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36278. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36279. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36280. /** nearest is mag = nearest and min = nearest and mip = linear */
  36281. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36282. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36283. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36284. /** Trilinear is mag = linear and min = linear and mip = linear */
  36285. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36286. /** nearest is mag = nearest and min = nearest and mip = linear */
  36287. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36288. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36289. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36290. /** Trilinear is mag = linear and min = linear and mip = linear */
  36291. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36292. /** mag = nearest and min = nearest and mip = nearest */
  36293. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36294. /** mag = nearest and min = linear and mip = nearest */
  36295. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36296. /** mag = nearest and min = linear and mip = linear */
  36297. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36298. /** mag = nearest and min = linear and mip = none */
  36299. static readonly TEXTURE_NEAREST_LINEAR: number;
  36300. /** mag = nearest and min = nearest and mip = none */
  36301. static readonly TEXTURE_NEAREST_NEAREST: number;
  36302. /** mag = linear and min = nearest and mip = nearest */
  36303. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36304. /** mag = linear and min = nearest and mip = linear */
  36305. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36306. /** mag = linear and min = linear and mip = none */
  36307. static readonly TEXTURE_LINEAR_LINEAR: number;
  36308. /** mag = linear and min = nearest and mip = none */
  36309. static readonly TEXTURE_LINEAR_NEAREST: number;
  36310. /** Explicit coordinates mode */
  36311. static readonly TEXTURE_EXPLICIT_MODE: number;
  36312. /** Spherical coordinates mode */
  36313. static readonly TEXTURE_SPHERICAL_MODE: number;
  36314. /** Planar coordinates mode */
  36315. static readonly TEXTURE_PLANAR_MODE: number;
  36316. /** Cubic coordinates mode */
  36317. static readonly TEXTURE_CUBIC_MODE: number;
  36318. /** Projection coordinates mode */
  36319. static readonly TEXTURE_PROJECTION_MODE: number;
  36320. /** Skybox coordinates mode */
  36321. static readonly TEXTURE_SKYBOX_MODE: number;
  36322. /** Inverse Cubic coordinates mode */
  36323. static readonly TEXTURE_INVCUBIC_MODE: number;
  36324. /** Equirectangular coordinates mode */
  36325. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36326. /** Equirectangular Fixed coordinates mode */
  36327. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36328. /** Equirectangular Fixed Mirrored coordinates mode */
  36329. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36330. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36331. static readonly SCALEMODE_FLOOR: number;
  36332. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36333. static readonly SCALEMODE_NEAREST: number;
  36334. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36335. static readonly SCALEMODE_CEILING: number;
  36336. /**
  36337. * Returns the current npm package of the sdk
  36338. */
  36339. static get NpmPackage(): string;
  36340. /**
  36341. * Returns the current version of the framework
  36342. */
  36343. static get Version(): string;
  36344. /** Gets the list of created engines */
  36345. static get Instances(): Engine[];
  36346. /**
  36347. * Gets the latest created engine
  36348. */
  36349. static get LastCreatedEngine(): Nullable<Engine>;
  36350. /**
  36351. * Gets the latest created scene
  36352. */
  36353. static get LastCreatedScene(): Nullable<Scene>;
  36354. /**
  36355. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36356. * @param flag defines which part of the materials must be marked as dirty
  36357. * @param predicate defines a predicate used to filter which materials should be affected
  36358. */
  36359. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36360. /**
  36361. * Method called to create the default loading screen.
  36362. * This can be overriden in your own app.
  36363. * @param canvas The rendering canvas element
  36364. * @returns The loading screen
  36365. */
  36366. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36367. /**
  36368. * Method called to create the default rescale post process on each engine.
  36369. */
  36370. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36371. /**
  36372. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36373. **/
  36374. enableOfflineSupport: boolean;
  36375. /**
  36376. * 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)
  36377. **/
  36378. disableManifestCheck: boolean;
  36379. /**
  36380. * Gets the list of created scenes
  36381. */
  36382. scenes: Scene[];
  36383. /**
  36384. * Event raised when a new scene is created
  36385. */
  36386. onNewSceneAddedObservable: Observable<Scene>;
  36387. /**
  36388. * Gets the list of created postprocesses
  36389. */
  36390. postProcesses: PostProcess[];
  36391. /**
  36392. * Gets a boolean indicating if the pointer is currently locked
  36393. */
  36394. isPointerLock: boolean;
  36395. /**
  36396. * Observable event triggered each time the rendering canvas is resized
  36397. */
  36398. onResizeObservable: Observable<Engine>;
  36399. /**
  36400. * Observable event triggered each time the canvas loses focus
  36401. */
  36402. onCanvasBlurObservable: Observable<Engine>;
  36403. /**
  36404. * Observable event triggered each time the canvas gains focus
  36405. */
  36406. onCanvasFocusObservable: Observable<Engine>;
  36407. /**
  36408. * Observable event triggered each time the canvas receives pointerout event
  36409. */
  36410. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36411. /**
  36412. * Observable raised when the engine begins a new frame
  36413. */
  36414. onBeginFrameObservable: Observable<Engine>;
  36415. /**
  36416. * If set, will be used to request the next animation frame for the render loop
  36417. */
  36418. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36419. /**
  36420. * Observable raised when the engine ends the current frame
  36421. */
  36422. onEndFrameObservable: Observable<Engine>;
  36423. /**
  36424. * Observable raised when the engine is about to compile a shader
  36425. */
  36426. onBeforeShaderCompilationObservable: Observable<Engine>;
  36427. /**
  36428. * Observable raised when the engine has jsut compiled a shader
  36429. */
  36430. onAfterShaderCompilationObservable: Observable<Engine>;
  36431. /**
  36432. * Gets the audio engine
  36433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36434. * @ignorenaming
  36435. */
  36436. static audioEngine: IAudioEngine;
  36437. /**
  36438. * Default AudioEngine factory responsible of creating the Audio Engine.
  36439. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36440. */
  36441. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36442. /**
  36443. * Default offline support factory responsible of creating a tool used to store data locally.
  36444. * By default, this will create a Database object if the workload has been embedded.
  36445. */
  36446. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36447. private _loadingScreen;
  36448. private _pointerLockRequested;
  36449. private _rescalePostProcess;
  36450. private _deterministicLockstep;
  36451. private _lockstepMaxSteps;
  36452. private _timeStep;
  36453. protected get _supportsHardwareTextureRescaling(): boolean;
  36454. private _fps;
  36455. private _deltaTime;
  36456. /** @hidden */
  36457. _drawCalls: PerfCounter;
  36458. /** 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 */
  36459. canvasTabIndex: number;
  36460. /**
  36461. * Turn this value on if you want to pause FPS computation when in background
  36462. */
  36463. disablePerformanceMonitorInBackground: boolean;
  36464. private _performanceMonitor;
  36465. /**
  36466. * Gets the performance monitor attached to this engine
  36467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36468. */
  36469. get performanceMonitor(): PerformanceMonitor;
  36470. private _onFocus;
  36471. private _onBlur;
  36472. private _onCanvasPointerOut;
  36473. private _onCanvasBlur;
  36474. private _onCanvasFocus;
  36475. private _onFullscreenChange;
  36476. private _onPointerLockChange;
  36477. /**
  36478. * Gets the HTML element used to attach event listeners
  36479. * @returns a HTML element
  36480. */
  36481. getInputElement(): Nullable<HTMLElement>;
  36482. /**
  36483. * Creates a new engine
  36484. * @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
  36485. * @param antialias defines enable antialiasing (default: false)
  36486. * @param options defines further options to be sent to the getContext() function
  36487. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36488. */
  36489. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36490. /**
  36491. * Gets current aspect ratio
  36492. * @param viewportOwner defines the camera to use to get the aspect ratio
  36493. * @param useScreen defines if screen size must be used (or the current render target if any)
  36494. * @returns a number defining the aspect ratio
  36495. */
  36496. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36497. /**
  36498. * Gets current screen aspect ratio
  36499. * @returns a number defining the aspect ratio
  36500. */
  36501. getScreenAspectRatio(): number;
  36502. /**
  36503. * Gets the client rect of the HTML canvas attached with the current webGL context
  36504. * @returns a client rectanglee
  36505. */
  36506. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36507. /**
  36508. * Gets the client rect of the HTML element used for events
  36509. * @returns a client rectanglee
  36510. */
  36511. getInputElementClientRect(): Nullable<ClientRect>;
  36512. /**
  36513. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36514. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36515. * @returns true if engine is in deterministic lock step mode
  36516. */
  36517. isDeterministicLockStep(): boolean;
  36518. /**
  36519. * Gets the max steps when engine is running in deterministic lock step
  36520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36521. * @returns the max steps
  36522. */
  36523. getLockstepMaxSteps(): number;
  36524. /**
  36525. * Returns the time in ms between steps when using deterministic lock step.
  36526. * @returns time step in (ms)
  36527. */
  36528. getTimeStep(): number;
  36529. /**
  36530. * Force the mipmap generation for the given render target texture
  36531. * @param texture defines the render target texture to use
  36532. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36533. */
  36534. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36535. /** States */
  36536. /**
  36537. * Set various states to the webGL context
  36538. * @param culling defines backface culling state
  36539. * @param zOffset defines the value to apply to zOffset (0 by default)
  36540. * @param force defines if states must be applied even if cache is up to date
  36541. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36542. */
  36543. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36544. /**
  36545. * Set the z offset to apply to current rendering
  36546. * @param value defines the offset to apply
  36547. */
  36548. setZOffset(value: number): void;
  36549. /**
  36550. * Gets the current value of the zOffset
  36551. * @returns the current zOffset state
  36552. */
  36553. getZOffset(): number;
  36554. /**
  36555. * Enable or disable depth buffering
  36556. * @param enable defines the state to set
  36557. */
  36558. setDepthBuffer(enable: boolean): void;
  36559. /**
  36560. * Gets a boolean indicating if depth writing is enabled
  36561. * @returns the current depth writing state
  36562. */
  36563. getDepthWrite(): boolean;
  36564. /**
  36565. * Enable or disable depth writing
  36566. * @param enable defines the state to set
  36567. */
  36568. setDepthWrite(enable: boolean): void;
  36569. /**
  36570. * Gets a boolean indicating if stencil buffer is enabled
  36571. * @returns the current stencil buffer state
  36572. */
  36573. getStencilBuffer(): boolean;
  36574. /**
  36575. * Enable or disable the stencil buffer
  36576. * @param enable defines if the stencil buffer must be enabled or disabled
  36577. */
  36578. setStencilBuffer(enable: boolean): void;
  36579. /**
  36580. * Gets the current stencil mask
  36581. * @returns a number defining the new stencil mask to use
  36582. */
  36583. getStencilMask(): number;
  36584. /**
  36585. * Sets the current stencil mask
  36586. * @param mask defines the new stencil mask to use
  36587. */
  36588. setStencilMask(mask: number): void;
  36589. /**
  36590. * Gets the current stencil function
  36591. * @returns a number defining the stencil function to use
  36592. */
  36593. getStencilFunction(): number;
  36594. /**
  36595. * Gets the current stencil reference value
  36596. * @returns a number defining the stencil reference value to use
  36597. */
  36598. getStencilFunctionReference(): number;
  36599. /**
  36600. * Gets the current stencil mask
  36601. * @returns a number defining the stencil mask to use
  36602. */
  36603. getStencilFunctionMask(): number;
  36604. /**
  36605. * Sets the current stencil function
  36606. * @param stencilFunc defines the new stencil function to use
  36607. */
  36608. setStencilFunction(stencilFunc: number): void;
  36609. /**
  36610. * Sets the current stencil reference
  36611. * @param reference defines the new stencil reference to use
  36612. */
  36613. setStencilFunctionReference(reference: number): void;
  36614. /**
  36615. * Sets the current stencil mask
  36616. * @param mask defines the new stencil mask to use
  36617. */
  36618. setStencilFunctionMask(mask: number): void;
  36619. /**
  36620. * Gets the current stencil operation when stencil fails
  36621. * @returns a number defining stencil operation to use when stencil fails
  36622. */
  36623. getStencilOperationFail(): number;
  36624. /**
  36625. * Gets the current stencil operation when depth fails
  36626. * @returns a number defining stencil operation to use when depth fails
  36627. */
  36628. getStencilOperationDepthFail(): number;
  36629. /**
  36630. * Gets the current stencil operation when stencil passes
  36631. * @returns a number defining stencil operation to use when stencil passes
  36632. */
  36633. getStencilOperationPass(): number;
  36634. /**
  36635. * Sets the stencil operation to use when stencil fails
  36636. * @param operation defines the stencil operation to use when stencil fails
  36637. */
  36638. setStencilOperationFail(operation: number): void;
  36639. /**
  36640. * Sets the stencil operation to use when depth fails
  36641. * @param operation defines the stencil operation to use when depth fails
  36642. */
  36643. setStencilOperationDepthFail(operation: number): void;
  36644. /**
  36645. * Sets the stencil operation to use when stencil passes
  36646. * @param operation defines the stencil operation to use when stencil passes
  36647. */
  36648. setStencilOperationPass(operation: number): void;
  36649. /**
  36650. * Sets a boolean indicating if the dithering state is enabled or disabled
  36651. * @param value defines the dithering state
  36652. */
  36653. setDitheringState(value: boolean): void;
  36654. /**
  36655. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36656. * @param value defines the rasterizer state
  36657. */
  36658. setRasterizerState(value: boolean): void;
  36659. /**
  36660. * Gets the current depth function
  36661. * @returns a number defining the depth function
  36662. */
  36663. getDepthFunction(): Nullable<number>;
  36664. /**
  36665. * Sets the current depth function
  36666. * @param depthFunc defines the function to use
  36667. */
  36668. setDepthFunction(depthFunc: number): void;
  36669. /**
  36670. * Sets the current depth function to GREATER
  36671. */
  36672. setDepthFunctionToGreater(): void;
  36673. /**
  36674. * Sets the current depth function to GEQUAL
  36675. */
  36676. setDepthFunctionToGreaterOrEqual(): void;
  36677. /**
  36678. * Sets the current depth function to LESS
  36679. */
  36680. setDepthFunctionToLess(): void;
  36681. /**
  36682. * Sets the current depth function to LEQUAL
  36683. */
  36684. setDepthFunctionToLessOrEqual(): void;
  36685. private _cachedStencilBuffer;
  36686. private _cachedStencilFunction;
  36687. private _cachedStencilMask;
  36688. private _cachedStencilOperationPass;
  36689. private _cachedStencilOperationFail;
  36690. private _cachedStencilOperationDepthFail;
  36691. private _cachedStencilReference;
  36692. /**
  36693. * Caches the the state of the stencil buffer
  36694. */
  36695. cacheStencilState(): void;
  36696. /**
  36697. * Restores the state of the stencil buffer
  36698. */
  36699. restoreStencilState(): void;
  36700. /**
  36701. * Directly set the WebGL Viewport
  36702. * @param x defines the x coordinate of the viewport (in screen space)
  36703. * @param y defines the y coordinate of the viewport (in screen space)
  36704. * @param width defines the width of the viewport (in screen space)
  36705. * @param height defines the height of the viewport (in screen space)
  36706. * @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
  36707. */
  36708. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36709. /**
  36710. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36711. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36712. * @param y defines the y-coordinate of the corner of the clear rectangle
  36713. * @param width defines the width of the clear rectangle
  36714. * @param height defines the height of the clear rectangle
  36715. * @param clearColor defines the clear color
  36716. */
  36717. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36718. /**
  36719. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36720. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36721. * @param y defines the y-coordinate of the corner of the clear rectangle
  36722. * @param width defines the width of the clear rectangle
  36723. * @param height defines the height of the clear rectangle
  36724. */
  36725. enableScissor(x: number, y: number, width: number, height: number): void;
  36726. /**
  36727. * Disable previously set scissor test rectangle
  36728. */
  36729. disableScissor(): void;
  36730. protected _reportDrawCall(): void;
  36731. /**
  36732. * Initializes a webVR display and starts listening to display change events
  36733. * The onVRDisplayChangedObservable will be notified upon these changes
  36734. * @returns The onVRDisplayChangedObservable
  36735. */
  36736. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36737. /** @hidden */
  36738. _prepareVRComponent(): void;
  36739. /** @hidden */
  36740. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36741. /** @hidden */
  36742. _submitVRFrame(): void;
  36743. /**
  36744. * Call this function to leave webVR mode
  36745. * Will do nothing if webVR is not supported or if there is no webVR device
  36746. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36747. */
  36748. disableVR(): void;
  36749. /**
  36750. * Gets a boolean indicating that the system is in VR mode and is presenting
  36751. * @returns true if VR mode is engaged
  36752. */
  36753. isVRPresenting(): boolean;
  36754. /** @hidden */
  36755. _requestVRFrame(): void;
  36756. /** @hidden */
  36757. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36758. /**
  36759. * Gets the source code of the vertex shader associated with a specific webGL program
  36760. * @param program defines the program to use
  36761. * @returns a string containing the source code of the vertex shader associated with the program
  36762. */
  36763. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36764. /**
  36765. * Gets the source code of the fragment shader associated with a specific webGL program
  36766. * @param program defines the program to use
  36767. * @returns a string containing the source code of the fragment shader associated with the program
  36768. */
  36769. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36770. /**
  36771. * Sets a depth stencil texture from a render target to the according uniform.
  36772. * @param channel The texture channel
  36773. * @param uniform The uniform to set
  36774. * @param texture The render target texture containing the depth stencil texture to apply
  36775. */
  36776. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36777. /**
  36778. * Sets a texture to the webGL context from a postprocess
  36779. * @param channel defines the channel to use
  36780. * @param postProcess defines the source postprocess
  36781. */
  36782. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36783. /**
  36784. * Binds the output of the passed in post process to the texture channel specified
  36785. * @param channel The channel the texture should be bound to
  36786. * @param postProcess The post process which's output should be bound
  36787. */
  36788. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36789. protected _rebuildBuffers(): void;
  36790. /** @hidden */
  36791. _renderFrame(): void;
  36792. _renderLoop(): void;
  36793. /** @hidden */
  36794. _renderViews(): boolean;
  36795. /**
  36796. * Toggle full screen mode
  36797. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36798. */
  36799. switchFullscreen(requestPointerLock: boolean): void;
  36800. /**
  36801. * Enters full screen mode
  36802. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36803. */
  36804. enterFullscreen(requestPointerLock: boolean): void;
  36805. /**
  36806. * Exits full screen mode
  36807. */
  36808. exitFullscreen(): void;
  36809. /**
  36810. * Enters Pointerlock mode
  36811. */
  36812. enterPointerlock(): void;
  36813. /**
  36814. * Exits Pointerlock mode
  36815. */
  36816. exitPointerlock(): void;
  36817. /**
  36818. * Begin a new frame
  36819. */
  36820. beginFrame(): void;
  36821. /**
  36822. * Enf the current frame
  36823. */
  36824. endFrame(): void;
  36825. resize(): void;
  36826. /**
  36827. * Force a specific size of the canvas
  36828. * @param width defines the new canvas' width
  36829. * @param height defines the new canvas' height
  36830. */
  36831. setSize(width: number, height: number): void;
  36832. /**
  36833. * Updates a dynamic vertex buffer.
  36834. * @param vertexBuffer the vertex buffer to update
  36835. * @param data the data used to update the vertex buffer
  36836. * @param byteOffset the byte offset of the data
  36837. * @param byteLength the byte length of the data
  36838. */
  36839. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36840. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36841. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36842. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36843. _releaseTexture(texture: InternalTexture): void;
  36844. /**
  36845. * @hidden
  36846. * Rescales a texture
  36847. * @param source input texutre
  36848. * @param destination destination texture
  36849. * @param scene scene to use to render the resize
  36850. * @param internalFormat format to use when resizing
  36851. * @param onComplete callback to be called when resize has completed
  36852. */
  36853. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36854. /**
  36855. * Gets the current framerate
  36856. * @returns a number representing the framerate
  36857. */
  36858. getFps(): number;
  36859. /**
  36860. * Gets the time spent between current and previous frame
  36861. * @returns a number representing the delta time in ms
  36862. */
  36863. getDeltaTime(): number;
  36864. private _measureFps;
  36865. /** @hidden */
  36866. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36867. /**
  36868. * Update a dynamic index buffer
  36869. * @param indexBuffer defines the target index buffer
  36870. * @param indices defines the data to update
  36871. * @param offset defines the offset in the target index buffer where update should start
  36872. */
  36873. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36874. /**
  36875. * Updates the sample count of a render target texture
  36876. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36877. * @param texture defines the texture to update
  36878. * @param samples defines the sample count to set
  36879. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36880. */
  36881. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36882. /**
  36883. * Updates a depth texture Comparison Mode and Function.
  36884. * If the comparison Function is equal to 0, the mode will be set to none.
  36885. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36886. * @param texture The texture to set the comparison function for
  36887. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36888. */
  36889. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36890. /**
  36891. * Creates a webGL buffer to use with instanciation
  36892. * @param capacity defines the size of the buffer
  36893. * @returns the webGL buffer
  36894. */
  36895. createInstancesBuffer(capacity: number): DataBuffer;
  36896. /**
  36897. * Delete a webGL buffer used with instanciation
  36898. * @param buffer defines the webGL buffer to delete
  36899. */
  36900. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36901. private _clientWaitAsync;
  36902. /** @hidden */
  36903. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36904. dispose(): void;
  36905. private _disableTouchAction;
  36906. /**
  36907. * Display the loading screen
  36908. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36909. */
  36910. displayLoadingUI(): void;
  36911. /**
  36912. * Hide the loading screen
  36913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36914. */
  36915. hideLoadingUI(): void;
  36916. /**
  36917. * Gets the current loading screen object
  36918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36919. */
  36920. get loadingScreen(): ILoadingScreen;
  36921. /**
  36922. * Sets the current loading screen object
  36923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36924. */
  36925. set loadingScreen(loadingScreen: ILoadingScreen);
  36926. /**
  36927. * Sets the current loading screen text
  36928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36929. */
  36930. set loadingUIText(text: string);
  36931. /**
  36932. * Sets the current loading screen background color
  36933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36934. */
  36935. set loadingUIBackgroundColor(color: string);
  36936. /** Pointerlock and fullscreen */
  36937. /**
  36938. * Ask the browser to promote the current element to pointerlock mode
  36939. * @param element defines the DOM element to promote
  36940. */
  36941. static _RequestPointerlock(element: HTMLElement): void;
  36942. /**
  36943. * Asks the browser to exit pointerlock mode
  36944. */
  36945. static _ExitPointerlock(): void;
  36946. /**
  36947. * Ask the browser to promote the current element to fullscreen rendering mode
  36948. * @param element defines the DOM element to promote
  36949. */
  36950. static _RequestFullscreen(element: HTMLElement): void;
  36951. /**
  36952. * Asks the browser to exit fullscreen mode
  36953. */
  36954. static _ExitFullscreen(): void;
  36955. }
  36956. }
  36957. declare module BABYLON {
  36958. /**
  36959. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36960. * during the life time of the application.
  36961. */
  36962. export class EngineStore {
  36963. /** Gets the list of created engines */
  36964. static Instances: Engine[];
  36965. /** @hidden */
  36966. static _LastCreatedScene: Nullable<Scene>;
  36967. /**
  36968. * Gets the latest created engine
  36969. */
  36970. static get LastCreatedEngine(): Nullable<Engine>;
  36971. /**
  36972. * Gets the latest created scene
  36973. */
  36974. static get LastCreatedScene(): Nullable<Scene>;
  36975. /**
  36976. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36977. * @ignorenaming
  36978. */
  36979. static UseFallbackTexture: boolean;
  36980. /**
  36981. * Texture content used if a texture cannot loaded
  36982. * @ignorenaming
  36983. */
  36984. static FallbackTexture: string;
  36985. }
  36986. }
  36987. declare module BABYLON {
  36988. /**
  36989. * Helper class that provides a small promise polyfill
  36990. */
  36991. export class PromisePolyfill {
  36992. /**
  36993. * Static function used to check if the polyfill is required
  36994. * If this is the case then the function will inject the polyfill to window.Promise
  36995. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36996. */
  36997. static Apply(force?: boolean): void;
  36998. }
  36999. }
  37000. declare module BABYLON {
  37001. /**
  37002. * Interface for screenshot methods with describe argument called `size` as object with options
  37003. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37004. */
  37005. export interface IScreenshotSize {
  37006. /**
  37007. * number in pixels for canvas height
  37008. */
  37009. height?: number;
  37010. /**
  37011. * multiplier allowing render at a higher or lower resolution
  37012. * If value is defined then height and width will be ignored and taken from camera
  37013. */
  37014. precision?: number;
  37015. /**
  37016. * number in pixels for canvas width
  37017. */
  37018. width?: number;
  37019. }
  37020. }
  37021. declare module BABYLON {
  37022. interface IColor4Like {
  37023. r: float;
  37024. g: float;
  37025. b: float;
  37026. a: float;
  37027. }
  37028. /**
  37029. * Class containing a set of static utilities functions
  37030. */
  37031. export class Tools {
  37032. /**
  37033. * Gets or sets the base URL to use to load assets
  37034. */
  37035. static get BaseUrl(): string;
  37036. static set BaseUrl(value: string);
  37037. /**
  37038. * Enable/Disable Custom HTTP Request Headers globally.
  37039. * default = false
  37040. * @see CustomRequestHeaders
  37041. */
  37042. static UseCustomRequestHeaders: boolean;
  37043. /**
  37044. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37045. * i.e. when loading files, where the server/service expects an Authorization header
  37046. */
  37047. static CustomRequestHeaders: {
  37048. [key: string]: string;
  37049. };
  37050. /**
  37051. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37052. */
  37053. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37054. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37055. /**
  37056. * Default behaviour for cors in the application.
  37057. * It can be a string if the expected behavior is identical in the entire app.
  37058. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37059. */
  37060. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37061. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37062. /**
  37063. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37064. * @ignorenaming
  37065. */
  37066. static get UseFallbackTexture(): boolean;
  37067. static set UseFallbackTexture(value: boolean);
  37068. /**
  37069. * Use this object to register external classes like custom textures or material
  37070. * to allow the laoders to instantiate them
  37071. */
  37072. static get RegisteredExternalClasses(): {
  37073. [key: string]: Object;
  37074. };
  37075. static set RegisteredExternalClasses(classes: {
  37076. [key: string]: Object;
  37077. });
  37078. /**
  37079. * Texture content used if a texture cannot loaded
  37080. * @ignorenaming
  37081. */
  37082. static get fallbackTexture(): string;
  37083. static set fallbackTexture(value: string);
  37084. /**
  37085. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37086. * @param u defines the coordinate on X axis
  37087. * @param v defines the coordinate on Y axis
  37088. * @param width defines the width of the source data
  37089. * @param height defines the height of the source data
  37090. * @param pixels defines the source byte array
  37091. * @param color defines the output color
  37092. */
  37093. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37094. /**
  37095. * Interpolates between a and b via alpha
  37096. * @param a The lower value (returned when alpha = 0)
  37097. * @param b The upper value (returned when alpha = 1)
  37098. * @param alpha The interpolation-factor
  37099. * @return The mixed value
  37100. */
  37101. static Mix(a: number, b: number, alpha: number): number;
  37102. /**
  37103. * Tries to instantiate a new object from a given class name
  37104. * @param className defines the class name to instantiate
  37105. * @returns the new object or null if the system was not able to do the instantiation
  37106. */
  37107. static Instantiate(className: string): any;
  37108. /**
  37109. * Provides a slice function that will work even on IE
  37110. * @param data defines the array to slice
  37111. * @param start defines the start of the data (optional)
  37112. * @param end defines the end of the data (optional)
  37113. * @returns the new sliced array
  37114. */
  37115. static Slice<T>(data: T, start?: number, end?: number): T;
  37116. /**
  37117. * Polyfill for setImmediate
  37118. * @param action defines the action to execute after the current execution block
  37119. */
  37120. static SetImmediate(action: () => void): void;
  37121. /**
  37122. * Function indicating if a number is an exponent of 2
  37123. * @param value defines the value to test
  37124. * @returns true if the value is an exponent of 2
  37125. */
  37126. static IsExponentOfTwo(value: number): boolean;
  37127. private static _tmpFloatArray;
  37128. /**
  37129. * Returns the nearest 32-bit single precision float representation of a Number
  37130. * @param value A Number. If the parameter is of a different type, it will get converted
  37131. * to a number or to NaN if it cannot be converted
  37132. * @returns number
  37133. */
  37134. static FloatRound(value: number): number;
  37135. /**
  37136. * Extracts the filename from a path
  37137. * @param path defines the path to use
  37138. * @returns the filename
  37139. */
  37140. static GetFilename(path: string): string;
  37141. /**
  37142. * Extracts the "folder" part of a path (everything before the filename).
  37143. * @param uri The URI to extract the info from
  37144. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37145. * @returns The "folder" part of the path
  37146. */
  37147. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37148. /**
  37149. * Extracts text content from a DOM element hierarchy
  37150. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37151. */
  37152. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37153. /**
  37154. * Convert an angle in radians to degrees
  37155. * @param angle defines the angle to convert
  37156. * @returns the angle in degrees
  37157. */
  37158. static ToDegrees(angle: number): number;
  37159. /**
  37160. * Convert an angle in degrees to radians
  37161. * @param angle defines the angle to convert
  37162. * @returns the angle in radians
  37163. */
  37164. static ToRadians(angle: number): number;
  37165. /**
  37166. * Returns an array if obj is not an array
  37167. * @param obj defines the object to evaluate as an array
  37168. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37169. * @returns either obj directly if obj is an array or a new array containing obj
  37170. */
  37171. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37172. /**
  37173. * Gets the pointer prefix to use
  37174. * @param engine defines the engine we are finding the prefix for
  37175. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37176. */
  37177. static GetPointerPrefix(engine: Engine): string;
  37178. /**
  37179. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37180. * @param url define the url we are trying
  37181. * @param element define the dom element where to configure the cors policy
  37182. */
  37183. static SetCorsBehavior(url: string | string[], element: {
  37184. crossOrigin: string | null;
  37185. }): void;
  37186. /**
  37187. * Removes unwanted characters from an url
  37188. * @param url defines the url to clean
  37189. * @returns the cleaned url
  37190. */
  37191. static CleanUrl(url: string): string;
  37192. /**
  37193. * Gets or sets a function used to pre-process url before using them to load assets
  37194. */
  37195. static get PreprocessUrl(): (url: string) => string;
  37196. static set PreprocessUrl(processor: (url: string) => string);
  37197. /**
  37198. * Loads an image as an HTMLImageElement.
  37199. * @param input url string, ArrayBuffer, or Blob to load
  37200. * @param onLoad callback called when the image successfully loads
  37201. * @param onError callback called when the image fails to load
  37202. * @param offlineProvider offline provider for caching
  37203. * @param mimeType optional mime type
  37204. * @returns the HTMLImageElement of the loaded image
  37205. */
  37206. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37207. /**
  37208. * Loads a file from a url
  37209. * @param url url string, ArrayBuffer, or Blob to load
  37210. * @param onSuccess callback called when the file successfully loads
  37211. * @param onProgress callback called while file is loading (if the server supports this mode)
  37212. * @param offlineProvider defines the offline provider for caching
  37213. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37214. * @param onError callback called when the file fails to load
  37215. * @returns a file request object
  37216. */
  37217. 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;
  37218. /**
  37219. * Loads a file from a url
  37220. * @param url the file url to load
  37221. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37222. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37223. */
  37224. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37225. /**
  37226. * Load a script (identified by an url). When the url returns, the
  37227. * content of this file is added into a new script element, attached to the DOM (body element)
  37228. * @param scriptUrl defines the url of the script to laod
  37229. * @param onSuccess defines the callback called when the script is loaded
  37230. * @param onError defines the callback to call if an error occurs
  37231. * @param scriptId defines the id of the script element
  37232. */
  37233. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37234. /**
  37235. * Load an asynchronous script (identified by an url). When the url returns, the
  37236. * content of this file is added into a new script element, attached to the DOM (body element)
  37237. * @param scriptUrl defines the url of the script to laod
  37238. * @param scriptId defines the id of the script element
  37239. * @returns a promise request object
  37240. */
  37241. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37242. /**
  37243. * Loads a file from a blob
  37244. * @param fileToLoad defines the blob to use
  37245. * @param callback defines the callback to call when data is loaded
  37246. * @param progressCallback defines the callback to call during loading process
  37247. * @returns a file request object
  37248. */
  37249. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37250. /**
  37251. * Reads a file from a File object
  37252. * @param file defines the file to load
  37253. * @param onSuccess defines the callback to call when data is loaded
  37254. * @param onProgress defines the callback to call during loading process
  37255. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37256. * @param onError defines the callback to call when an error occurs
  37257. * @returns a file request object
  37258. */
  37259. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37260. /**
  37261. * Creates a data url from a given string content
  37262. * @param content defines the content to convert
  37263. * @returns the new data url link
  37264. */
  37265. static FileAsURL(content: string): string;
  37266. /**
  37267. * Format the given number to a specific decimal format
  37268. * @param value defines the number to format
  37269. * @param decimals defines the number of decimals to use
  37270. * @returns the formatted string
  37271. */
  37272. static Format(value: number, decimals?: number): string;
  37273. /**
  37274. * Tries to copy an object by duplicating every property
  37275. * @param source defines the source object
  37276. * @param destination defines the target object
  37277. * @param doNotCopyList defines a list of properties to avoid
  37278. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37279. */
  37280. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37281. /**
  37282. * Gets a boolean indicating if the given object has no own property
  37283. * @param obj defines the object to test
  37284. * @returns true if object has no own property
  37285. */
  37286. static IsEmpty(obj: any): boolean;
  37287. /**
  37288. * Function used to register events at window level
  37289. * @param windowElement defines the Window object to use
  37290. * @param events defines the events to register
  37291. */
  37292. static RegisterTopRootEvents(windowElement: Window, events: {
  37293. name: string;
  37294. handler: Nullable<(e: FocusEvent) => any>;
  37295. }[]): void;
  37296. /**
  37297. * Function used to unregister events from window level
  37298. * @param windowElement defines the Window object to use
  37299. * @param events defines the events to unregister
  37300. */
  37301. static UnregisterTopRootEvents(windowElement: Window, events: {
  37302. name: string;
  37303. handler: Nullable<(e: FocusEvent) => any>;
  37304. }[]): void;
  37305. /**
  37306. * @ignore
  37307. */
  37308. static _ScreenshotCanvas: HTMLCanvasElement;
  37309. /**
  37310. * Dumps the current bound framebuffer
  37311. * @param width defines the rendering width
  37312. * @param height defines the rendering height
  37313. * @param engine defines the hosting engine
  37314. * @param successCallback defines the callback triggered once the data are available
  37315. * @param mimeType defines the mime type of the result
  37316. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37317. */
  37318. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37319. /**
  37320. * Converts the canvas data to blob.
  37321. * This acts as a polyfill for browsers not supporting the to blob function.
  37322. * @param canvas Defines the canvas to extract the data from
  37323. * @param successCallback Defines the callback triggered once the data are available
  37324. * @param mimeType Defines the mime type of the result
  37325. */
  37326. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37327. /**
  37328. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37329. * @param successCallback defines the callback triggered once the data are available
  37330. * @param mimeType defines the mime type of the result
  37331. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37332. */
  37333. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37334. /**
  37335. * Downloads a blob in the browser
  37336. * @param blob defines the blob to download
  37337. * @param fileName defines the name of the downloaded file
  37338. */
  37339. static Download(blob: Blob, fileName: string): void;
  37340. /**
  37341. * Captures a screenshot of the current rendering
  37342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37343. * @param engine defines the rendering engine
  37344. * @param camera defines the source camera
  37345. * @param size This parameter can be set to a single number or to an object with the
  37346. * following (optional) properties: precision, width, height. If a single number is passed,
  37347. * it will be used for both width and height. If an object is passed, the screenshot size
  37348. * will be derived from the parameters. The precision property is a multiplier allowing
  37349. * rendering at a higher or lower resolution
  37350. * @param successCallback defines the callback receives a single parameter which contains the
  37351. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37352. * src parameter of an <img> to display it
  37353. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37354. * Check your browser for supported MIME types
  37355. */
  37356. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37357. /**
  37358. * Captures a screenshot of the current rendering
  37359. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37360. * @param engine defines the rendering engine
  37361. * @param camera defines the source camera
  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 defines the MIME type of the screenshot image (default: image/png).
  37368. * Check your browser for supported MIME types
  37369. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37370. * to the src parameter of an <img> to display it
  37371. */
  37372. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37373. /**
  37374. * Generates an image screenshot from the specified camera.
  37375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37376. * @param engine The engine to use for rendering
  37377. * @param camera The camera to use for rendering
  37378. * @param size This parameter can be set to a single number or to an object with the
  37379. * following (optional) properties: precision, width, height. If a single number is passed,
  37380. * it will be used for both width and height. If an object is passed, the screenshot size
  37381. * will be derived from the parameters. The precision property is a multiplier allowing
  37382. * rendering at a higher or lower resolution
  37383. * @param successCallback The callback receives a single parameter which contains the
  37384. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37385. * src parameter of an <img> to display it
  37386. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37387. * Check your browser for supported MIME types
  37388. * @param samples Texture samples (default: 1)
  37389. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37390. * @param fileName A name for for the downloaded file.
  37391. */
  37392. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37393. /**
  37394. * Generates an image screenshot from the specified camera.
  37395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37396. * @param engine The engine to use for rendering
  37397. * @param camera The camera to use for rendering
  37398. * @param size This parameter can be set to a single number or to an object with the
  37399. * following (optional) properties: precision, width, height. If a single number is passed,
  37400. * it will be used for both width and height. If an object is passed, the screenshot size
  37401. * will be derived from the parameters. The precision property is a multiplier allowing
  37402. * rendering at a higher or lower resolution
  37403. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37404. * Check your browser for supported MIME types
  37405. * @param samples Texture samples (default: 1)
  37406. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37407. * @param fileName A name for for the downloaded file.
  37408. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37409. * to the src parameter of an <img> to display it
  37410. */
  37411. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37412. /**
  37413. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37414. * Be aware Math.random() could cause collisions, but:
  37415. * "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"
  37416. * @returns a pseudo random id
  37417. */
  37418. static RandomId(): string;
  37419. /**
  37420. * Test if the given uri is a base64 string
  37421. * @param uri The uri to test
  37422. * @return True if the uri is a base64 string or false otherwise
  37423. */
  37424. static IsBase64(uri: string): boolean;
  37425. /**
  37426. * Decode the given base64 uri.
  37427. * @param uri The uri to decode
  37428. * @return The decoded base64 data.
  37429. */
  37430. static DecodeBase64(uri: string): ArrayBuffer;
  37431. /**
  37432. * Gets the absolute url.
  37433. * @param url the input url
  37434. * @return the absolute url
  37435. */
  37436. static GetAbsoluteUrl(url: string): string;
  37437. /**
  37438. * No log
  37439. */
  37440. static readonly NoneLogLevel: number;
  37441. /**
  37442. * Only message logs
  37443. */
  37444. static readonly MessageLogLevel: number;
  37445. /**
  37446. * Only warning logs
  37447. */
  37448. static readonly WarningLogLevel: number;
  37449. /**
  37450. * Only error logs
  37451. */
  37452. static readonly ErrorLogLevel: number;
  37453. /**
  37454. * All logs
  37455. */
  37456. static readonly AllLogLevel: number;
  37457. /**
  37458. * Gets a value indicating the number of loading errors
  37459. * @ignorenaming
  37460. */
  37461. static get errorsCount(): number;
  37462. /**
  37463. * Callback called when a new log is added
  37464. */
  37465. static OnNewCacheEntry: (entry: string) => void;
  37466. /**
  37467. * Log a message to the console
  37468. * @param message defines the message to log
  37469. */
  37470. static Log(message: string): void;
  37471. /**
  37472. * Write a warning message to the console
  37473. * @param message defines the message to log
  37474. */
  37475. static Warn(message: string): void;
  37476. /**
  37477. * Write an error message to the console
  37478. * @param message defines the message to log
  37479. */
  37480. static Error(message: string): void;
  37481. /**
  37482. * Gets current log cache (list of logs)
  37483. */
  37484. static get LogCache(): string;
  37485. /**
  37486. * Clears the log cache
  37487. */
  37488. static ClearLogCache(): void;
  37489. /**
  37490. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37491. */
  37492. static set LogLevels(level: number);
  37493. /**
  37494. * Checks if the window object exists
  37495. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37496. */
  37497. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37498. /**
  37499. * No performance log
  37500. */
  37501. static readonly PerformanceNoneLogLevel: number;
  37502. /**
  37503. * Use user marks to log performance
  37504. */
  37505. static readonly PerformanceUserMarkLogLevel: number;
  37506. /**
  37507. * Log performance to the console
  37508. */
  37509. static readonly PerformanceConsoleLogLevel: number;
  37510. private static _performance;
  37511. /**
  37512. * Sets the current performance log level
  37513. */
  37514. static set PerformanceLogLevel(level: number);
  37515. private static _StartPerformanceCounterDisabled;
  37516. private static _EndPerformanceCounterDisabled;
  37517. private static _StartUserMark;
  37518. private static _EndUserMark;
  37519. private static _StartPerformanceConsole;
  37520. private static _EndPerformanceConsole;
  37521. /**
  37522. * Starts a performance counter
  37523. */
  37524. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37525. /**
  37526. * Ends a specific performance coutner
  37527. */
  37528. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37529. /**
  37530. * Gets either window.performance.now() if supported or Date.now() else
  37531. */
  37532. static get Now(): number;
  37533. /**
  37534. * This method will return the name of the class used to create the instance of the given object.
  37535. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37536. * @param object the object to get the class name from
  37537. * @param isType defines if the object is actually a type
  37538. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37539. */
  37540. static GetClassName(object: any, isType?: boolean): string;
  37541. /**
  37542. * Gets the first element of an array satisfying a given predicate
  37543. * @param array defines the array to browse
  37544. * @param predicate defines the predicate to use
  37545. * @returns null if not found or the element
  37546. */
  37547. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37548. /**
  37549. * This method will return the name of the full name of the class, including its owning module (if any).
  37550. * 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).
  37551. * @param object the object to get the class name from
  37552. * @param isType defines if the object is actually a type
  37553. * @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.
  37554. * @ignorenaming
  37555. */
  37556. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37557. /**
  37558. * Returns a promise that resolves after the given amount of time.
  37559. * @param delay Number of milliseconds to delay
  37560. * @returns Promise that resolves after the given amount of time
  37561. */
  37562. static DelayAsync(delay: number): Promise<void>;
  37563. /**
  37564. * Utility function to detect if the current user agent is Safari
  37565. * @returns whether or not the current user agent is safari
  37566. */
  37567. static IsSafari(): boolean;
  37568. }
  37569. /**
  37570. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37571. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37572. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37573. * @param name The name of the class, case should be preserved
  37574. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37575. */
  37576. export function className(name: string, module?: string): (target: Object) => void;
  37577. /**
  37578. * An implementation of a loop for asynchronous functions.
  37579. */
  37580. export class AsyncLoop {
  37581. /**
  37582. * Defines the number of iterations for the loop
  37583. */
  37584. iterations: number;
  37585. /**
  37586. * Defines the current index of the loop.
  37587. */
  37588. index: number;
  37589. private _done;
  37590. private _fn;
  37591. private _successCallback;
  37592. /**
  37593. * Constructor.
  37594. * @param iterations the number of iterations.
  37595. * @param func the function to run each iteration
  37596. * @param successCallback the callback that will be called upon succesful execution
  37597. * @param offset starting offset.
  37598. */
  37599. constructor(
  37600. /**
  37601. * Defines the number of iterations for the loop
  37602. */
  37603. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37604. /**
  37605. * Execute the next iteration. Must be called after the last iteration was finished.
  37606. */
  37607. executeNext(): void;
  37608. /**
  37609. * Break the loop and run the success callback.
  37610. */
  37611. breakLoop(): void;
  37612. /**
  37613. * Create and run an async loop.
  37614. * @param iterations the number of iterations.
  37615. * @param fn the function to run each iteration
  37616. * @param successCallback the callback that will be called upon succesful execution
  37617. * @param offset starting offset.
  37618. * @returns the created async loop object
  37619. */
  37620. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37621. /**
  37622. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37623. * @param iterations total number of iterations
  37624. * @param syncedIterations number of synchronous iterations in each async iteration.
  37625. * @param fn the function to call each iteration.
  37626. * @param callback a success call back that will be called when iterating stops.
  37627. * @param breakFunction a break condition (optional)
  37628. * @param timeout timeout settings for the setTimeout function. default - 0.
  37629. * @returns the created async loop object
  37630. */
  37631. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /**
  37636. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37637. * The underlying implementation relies on an associative array to ensure the best performances.
  37638. * The value can be anything including 'null' but except 'undefined'
  37639. */
  37640. export class StringDictionary<T> {
  37641. /**
  37642. * This will clear this dictionary and copy the content from the 'source' one.
  37643. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37644. * @param source the dictionary to take the content from and copy to this dictionary
  37645. */
  37646. copyFrom(source: StringDictionary<T>): void;
  37647. /**
  37648. * Get a value based from its key
  37649. * @param key the given key to get the matching value from
  37650. * @return the value if found, otherwise undefined is returned
  37651. */
  37652. get(key: string): T | undefined;
  37653. /**
  37654. * Get a value from its key or add it if it doesn't exist.
  37655. * This method will ensure you that a given key/data will be present in the dictionary.
  37656. * @param key the given key to get the matching value from
  37657. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37658. * The factory will only be invoked if there's no data for the given key.
  37659. * @return the value corresponding to the key.
  37660. */
  37661. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37662. /**
  37663. * Get a value from its key if present in the dictionary otherwise add it
  37664. * @param key the key to get the value from
  37665. * @param val if there's no such key/value pair in the dictionary add it with this value
  37666. * @return the value corresponding to the key
  37667. */
  37668. getOrAdd(key: string, val: T): T;
  37669. /**
  37670. * Check if there's a given key in the dictionary
  37671. * @param key the key to check for
  37672. * @return true if the key is present, false otherwise
  37673. */
  37674. contains(key: string): boolean;
  37675. /**
  37676. * Add a new key and its corresponding value
  37677. * @param key the key to add
  37678. * @param value the value corresponding to the key
  37679. * @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
  37680. */
  37681. add(key: string, value: T): boolean;
  37682. /**
  37683. * Update a specific value associated to a key
  37684. * @param key defines the key to use
  37685. * @param value defines the value to store
  37686. * @returns true if the value was updated (or false if the key was not found)
  37687. */
  37688. set(key: string, value: T): boolean;
  37689. /**
  37690. * Get the element of the given key and remove it from the dictionary
  37691. * @param key defines the key to search
  37692. * @returns the value associated with the key or null if not found
  37693. */
  37694. getAndRemove(key: string): Nullable<T>;
  37695. /**
  37696. * Remove a key/value from the dictionary.
  37697. * @param key the key to remove
  37698. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37699. */
  37700. remove(key: string): boolean;
  37701. /**
  37702. * Clear the whole content of the dictionary
  37703. */
  37704. clear(): void;
  37705. /**
  37706. * Gets the current count
  37707. */
  37708. get count(): number;
  37709. /**
  37710. * Execute a callback on each key/val of the dictionary.
  37711. * Note that you can remove any element in this dictionary in the callback implementation
  37712. * @param callback the callback to execute on a given key/value pair
  37713. */
  37714. forEach(callback: (key: string, val: T) => void): void;
  37715. /**
  37716. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37717. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37718. * Note that you can remove any element in this dictionary in the callback implementation
  37719. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37720. * @returns the first item
  37721. */
  37722. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37723. private _count;
  37724. private _data;
  37725. }
  37726. }
  37727. declare module BABYLON {
  37728. /** @hidden */
  37729. export interface ICollisionCoordinator {
  37730. createCollider(): Collider;
  37731. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37732. init(scene: Scene): void;
  37733. }
  37734. /** @hidden */
  37735. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37736. private _scene;
  37737. private _scaledPosition;
  37738. private _scaledVelocity;
  37739. private _finalPosition;
  37740. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37741. createCollider(): Collider;
  37742. init(scene: Scene): void;
  37743. private _collideWithWorld;
  37744. }
  37745. }
  37746. declare module BABYLON {
  37747. /**
  37748. * Class used to manage all inputs for the scene.
  37749. */
  37750. export class InputManager {
  37751. /** The distance in pixel that you have to move to prevent some events */
  37752. static DragMovementThreshold: number;
  37753. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37754. static LongPressDelay: number;
  37755. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37756. static DoubleClickDelay: number;
  37757. /** If you need to check double click without raising a single click at first click, enable this flag */
  37758. static ExclusiveDoubleClickMode: boolean;
  37759. private _wheelEventName;
  37760. private _onPointerMove;
  37761. private _onPointerDown;
  37762. private _onPointerUp;
  37763. private _initClickEvent;
  37764. private _initActionManager;
  37765. private _delayedSimpleClick;
  37766. private _delayedSimpleClickTimeout;
  37767. private _previousDelayedSimpleClickTimeout;
  37768. private _meshPickProceed;
  37769. private _previousButtonPressed;
  37770. private _currentPickResult;
  37771. private _previousPickResult;
  37772. private _totalPointersPressed;
  37773. private _doubleClickOccured;
  37774. private _pointerOverMesh;
  37775. private _pickedDownMesh;
  37776. private _pickedUpMesh;
  37777. private _pointerX;
  37778. private _pointerY;
  37779. private _unTranslatedPointerX;
  37780. private _unTranslatedPointerY;
  37781. private _startingPointerPosition;
  37782. private _previousStartingPointerPosition;
  37783. private _startingPointerTime;
  37784. private _previousStartingPointerTime;
  37785. private _pointerCaptures;
  37786. private _onKeyDown;
  37787. private _onKeyUp;
  37788. private _onCanvasFocusObserver;
  37789. private _onCanvasBlurObserver;
  37790. private _scene;
  37791. /**
  37792. * Creates a new InputManager
  37793. * @param scene defines the hosting scene
  37794. */
  37795. constructor(scene: Scene);
  37796. /**
  37797. * Gets the mesh that is currently under the pointer
  37798. */
  37799. get meshUnderPointer(): Nullable<AbstractMesh>;
  37800. /**
  37801. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37802. */
  37803. get unTranslatedPointer(): Vector2;
  37804. /**
  37805. * Gets or sets the current on-screen X position of the pointer
  37806. */
  37807. get pointerX(): number;
  37808. set pointerX(value: number);
  37809. /**
  37810. * Gets or sets the current on-screen Y position of the pointer
  37811. */
  37812. get pointerY(): number;
  37813. set pointerY(value: number);
  37814. private _updatePointerPosition;
  37815. private _processPointerMove;
  37816. private _setRayOnPointerInfo;
  37817. private _checkPrePointerObservable;
  37818. /**
  37819. * Use this method to simulate a pointer move on a mesh
  37820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37823. */
  37824. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37825. /**
  37826. * Use this method to simulate a pointer down on a mesh
  37827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37830. */
  37831. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37832. private _processPointerDown;
  37833. /** @hidden */
  37834. _isPointerSwiping(): boolean;
  37835. /**
  37836. * Use this method to simulate a pointer up on a mesh
  37837. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37838. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37839. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37840. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37841. */
  37842. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37843. private _processPointerUp;
  37844. /**
  37845. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37846. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37847. * @returns true if the pointer was captured
  37848. */
  37849. isPointerCaptured(pointerId?: number): boolean;
  37850. /**
  37851. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37852. * @param attachUp defines if you want to attach events to pointerup
  37853. * @param attachDown defines if you want to attach events to pointerdown
  37854. * @param attachMove defines if you want to attach events to pointermove
  37855. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37856. */
  37857. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37858. /**
  37859. * Detaches all event handlers
  37860. */
  37861. detachControl(): void;
  37862. /**
  37863. * Force the value of meshUnderPointer
  37864. * @param mesh defines the mesh to use
  37865. */
  37866. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37867. /**
  37868. * Gets the mesh under the pointer
  37869. * @returns a Mesh or null if no mesh is under the pointer
  37870. */
  37871. getPointerOverMesh(): Nullable<AbstractMesh>;
  37872. }
  37873. }
  37874. declare module BABYLON {
  37875. /**
  37876. * This class defines the direct association between an animation and a target
  37877. */
  37878. export class TargetedAnimation {
  37879. /**
  37880. * Animation to perform
  37881. */
  37882. animation: Animation;
  37883. /**
  37884. * Target to animate
  37885. */
  37886. target: any;
  37887. /**
  37888. * Serialize the object
  37889. * @returns the JSON object representing the current entity
  37890. */
  37891. serialize(): any;
  37892. }
  37893. /**
  37894. * Use this class to create coordinated animations on multiple targets
  37895. */
  37896. export class AnimationGroup implements IDisposable {
  37897. /** The name of the animation group */
  37898. name: string;
  37899. private _scene;
  37900. private _targetedAnimations;
  37901. private _animatables;
  37902. private _from;
  37903. private _to;
  37904. private _isStarted;
  37905. private _isPaused;
  37906. private _speedRatio;
  37907. private _loopAnimation;
  37908. private _isAdditive;
  37909. /**
  37910. * Gets or sets the unique id of the node
  37911. */
  37912. uniqueId: number;
  37913. /**
  37914. * This observable will notify when one animation have ended
  37915. */
  37916. onAnimationEndObservable: Observable<TargetedAnimation>;
  37917. /**
  37918. * Observer raised when one animation loops
  37919. */
  37920. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37921. /**
  37922. * Observer raised when all animations have looped
  37923. */
  37924. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37925. /**
  37926. * This observable will notify when all animations have ended.
  37927. */
  37928. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37929. /**
  37930. * This observable will notify when all animations have paused.
  37931. */
  37932. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37933. /**
  37934. * This observable will notify when all animations are playing.
  37935. */
  37936. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37937. /**
  37938. * Gets the first frame
  37939. */
  37940. get from(): number;
  37941. /**
  37942. * Gets the last frame
  37943. */
  37944. get to(): number;
  37945. /**
  37946. * Define if the animations are started
  37947. */
  37948. get isStarted(): boolean;
  37949. /**
  37950. * Gets a value indicating that the current group is playing
  37951. */
  37952. get isPlaying(): boolean;
  37953. /**
  37954. * Gets or sets the speed ratio to use for all animations
  37955. */
  37956. get speedRatio(): number;
  37957. /**
  37958. * Gets or sets the speed ratio to use for all animations
  37959. */
  37960. set speedRatio(value: number);
  37961. /**
  37962. * Gets or sets if all animations should loop or not
  37963. */
  37964. get loopAnimation(): boolean;
  37965. set loopAnimation(value: boolean);
  37966. /**
  37967. * Gets or sets if all animations should be evaluated additively
  37968. */
  37969. get isAdditive(): boolean;
  37970. set isAdditive(value: boolean);
  37971. /**
  37972. * Gets the targeted animations for this animation group
  37973. */
  37974. get targetedAnimations(): Array<TargetedAnimation>;
  37975. /**
  37976. * returning the list of animatables controlled by this animation group.
  37977. */
  37978. get animatables(): Array<Animatable>;
  37979. /**
  37980. * Instantiates a new Animation Group.
  37981. * This helps managing several animations at once.
  37982. * @see http://doc.babylonjs.com/how_to/group
  37983. * @param name Defines the name of the group
  37984. * @param scene Defines the scene the group belongs to
  37985. */
  37986. constructor(
  37987. /** The name of the animation group */
  37988. name: string, scene?: Nullable<Scene>);
  37989. /**
  37990. * Add an animation (with its target) in the group
  37991. * @param animation defines the animation we want to add
  37992. * @param target defines the target of the animation
  37993. * @returns the TargetedAnimation object
  37994. */
  37995. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37996. /**
  37997. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37998. * It can add constant keys at begin or end
  37999. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38000. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38001. * @returns the animation group
  38002. */
  38003. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38004. private _animationLoopCount;
  38005. private _animationLoopFlags;
  38006. private _processLoop;
  38007. /**
  38008. * Start all animations on given targets
  38009. * @param loop defines if animations must loop
  38010. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38011. * @param from defines the from key (optional)
  38012. * @param to defines the to key (optional)
  38013. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38014. * @returns the current animation group
  38015. */
  38016. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38017. /**
  38018. * Pause all animations
  38019. * @returns the animation group
  38020. */
  38021. pause(): AnimationGroup;
  38022. /**
  38023. * Play all animations to initial state
  38024. * This function will start() the animations if they were not started or will restart() them if they were paused
  38025. * @param loop defines if animations must loop
  38026. * @returns the animation group
  38027. */
  38028. play(loop?: boolean): AnimationGroup;
  38029. /**
  38030. * Reset all animations to initial state
  38031. * @returns the animation group
  38032. */
  38033. reset(): AnimationGroup;
  38034. /**
  38035. * Restart animations from key 0
  38036. * @returns the animation group
  38037. */
  38038. restart(): AnimationGroup;
  38039. /**
  38040. * Stop all animations
  38041. * @returns the animation group
  38042. */
  38043. stop(): AnimationGroup;
  38044. /**
  38045. * Set animation weight for all animatables
  38046. * @param weight defines the weight to use
  38047. * @return the animationGroup
  38048. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38049. */
  38050. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38051. /**
  38052. * Synchronize and normalize all animatables with a source animatable
  38053. * @param root defines the root animatable to synchronize with
  38054. * @return the animationGroup
  38055. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38056. */
  38057. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38058. /**
  38059. * Goes to a specific frame in this animation group
  38060. * @param frame the frame number to go to
  38061. * @return the animationGroup
  38062. */
  38063. goToFrame(frame: number): AnimationGroup;
  38064. /**
  38065. * Dispose all associated resources
  38066. */
  38067. dispose(): void;
  38068. private _checkAnimationGroupEnded;
  38069. /**
  38070. * Clone the current animation group and returns a copy
  38071. * @param newName defines the name of the new group
  38072. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38073. * @returns the new aniamtion group
  38074. */
  38075. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38076. /**
  38077. * Serializes the animationGroup to an object
  38078. * @returns Serialized object
  38079. */
  38080. serialize(): any;
  38081. /**
  38082. * Returns a new AnimationGroup object parsed from the source provided.
  38083. * @param parsedAnimationGroup defines the source
  38084. * @param scene defines the scene that will receive the animationGroup
  38085. * @returns a new AnimationGroup
  38086. */
  38087. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38088. /**
  38089. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38090. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38091. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38092. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38093. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38094. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38095. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38096. */
  38097. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38098. /**
  38099. * Returns the string "AnimationGroup"
  38100. * @returns "AnimationGroup"
  38101. */
  38102. getClassName(): string;
  38103. /**
  38104. * Creates a detailled string about the object
  38105. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38106. * @returns a string representing the object
  38107. */
  38108. toString(fullDetails?: boolean): string;
  38109. }
  38110. }
  38111. declare module BABYLON {
  38112. /**
  38113. * Define an interface for all classes that will hold resources
  38114. */
  38115. export interface IDisposable {
  38116. /**
  38117. * Releases all held resources
  38118. */
  38119. dispose(): void;
  38120. }
  38121. /** Interface defining initialization parameters for Scene class */
  38122. export interface SceneOptions {
  38123. /**
  38124. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38125. * It will improve performance when the number of geometries becomes important.
  38126. */
  38127. useGeometryUniqueIdsMap?: boolean;
  38128. /**
  38129. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38130. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38131. */
  38132. useMaterialMeshMap?: boolean;
  38133. /**
  38134. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38136. */
  38137. useClonedMeshMap?: boolean;
  38138. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38139. virtual?: boolean;
  38140. }
  38141. /**
  38142. * Represents a scene to be rendered by the engine.
  38143. * @see http://doc.babylonjs.com/features/scene
  38144. */
  38145. export class Scene extends AbstractScene implements IAnimatable {
  38146. /** The fog is deactivated */
  38147. static readonly FOGMODE_NONE: number;
  38148. /** The fog density is following an exponential function */
  38149. static readonly FOGMODE_EXP: number;
  38150. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38151. static readonly FOGMODE_EXP2: number;
  38152. /** The fog density is following a linear function. */
  38153. static readonly FOGMODE_LINEAR: number;
  38154. /**
  38155. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38157. */
  38158. static MinDeltaTime: number;
  38159. /**
  38160. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38162. */
  38163. static MaxDeltaTime: number;
  38164. /**
  38165. * Factory used to create the default material.
  38166. * @param name The name of the material to create
  38167. * @param scene The scene to create the material for
  38168. * @returns The default material
  38169. */
  38170. static DefaultMaterialFactory(scene: Scene): Material;
  38171. /**
  38172. * Factory used to create the a collision coordinator.
  38173. * @returns The collision coordinator
  38174. */
  38175. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38176. /** @hidden */
  38177. _inputManager: InputManager;
  38178. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38179. cameraToUseForPointers: Nullable<Camera>;
  38180. /** @hidden */
  38181. readonly _isScene: boolean;
  38182. /** @hidden */
  38183. _blockEntityCollection: boolean;
  38184. /**
  38185. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38186. */
  38187. autoClear: boolean;
  38188. /**
  38189. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38190. */
  38191. autoClearDepthAndStencil: boolean;
  38192. /**
  38193. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38194. */
  38195. clearColor: Color4;
  38196. /**
  38197. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38198. */
  38199. ambientColor: Color3;
  38200. /**
  38201. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38202. * It should only be one of the following (if not the default embedded one):
  38203. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38204. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38205. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38206. * The material properties need to be setup according to the type of texture in use.
  38207. */
  38208. environmentBRDFTexture: BaseTexture;
  38209. /** @hidden */
  38210. protected _environmentTexture: Nullable<BaseTexture>;
  38211. /**
  38212. * Texture used in all pbr material as the reflection texture.
  38213. * As in the majority of the scene they are the same (exception for multi room and so on),
  38214. * this is easier to reference from here than from all the materials.
  38215. */
  38216. get environmentTexture(): Nullable<BaseTexture>;
  38217. /**
  38218. * Texture used in all pbr material as the reflection texture.
  38219. * As in the majority of the scene they are the same (exception for multi room and so on),
  38220. * this is easier to set here than in all the materials.
  38221. */
  38222. set environmentTexture(value: Nullable<BaseTexture>);
  38223. /** @hidden */
  38224. protected _environmentIntensity: number;
  38225. /**
  38226. * Intensity of the environment in all pbr material.
  38227. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38228. * As in the majority of the scene they are the same (exception for multi room and so on),
  38229. * this is easier to reference from here than from all the materials.
  38230. */
  38231. get environmentIntensity(): number;
  38232. /**
  38233. * Intensity of the environment in all pbr material.
  38234. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38235. * As in the majority of the scene they are the same (exception for multi room and so on),
  38236. * this is easier to set here than in all the materials.
  38237. */
  38238. set environmentIntensity(value: number);
  38239. /** @hidden */
  38240. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38241. /**
  38242. * Default image processing configuration used either in the rendering
  38243. * Forward main pass or through the imageProcessingPostProcess if present.
  38244. * As in the majority of the scene they are the same (exception for multi camera),
  38245. * this is easier to reference from here than from all the materials and post process.
  38246. *
  38247. * No setter as we it is a shared configuration, you can set the values instead.
  38248. */
  38249. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38250. private _forceWireframe;
  38251. /**
  38252. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38253. */
  38254. set forceWireframe(value: boolean);
  38255. get forceWireframe(): boolean;
  38256. private _skipFrustumClipping;
  38257. /**
  38258. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38259. */
  38260. set skipFrustumClipping(value: boolean);
  38261. get skipFrustumClipping(): boolean;
  38262. private _forcePointsCloud;
  38263. /**
  38264. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38265. */
  38266. set forcePointsCloud(value: boolean);
  38267. get forcePointsCloud(): boolean;
  38268. /**
  38269. * Gets or sets the active clipplane 1
  38270. */
  38271. clipPlane: Nullable<Plane>;
  38272. /**
  38273. * Gets or sets the active clipplane 2
  38274. */
  38275. clipPlane2: Nullable<Plane>;
  38276. /**
  38277. * Gets or sets the active clipplane 3
  38278. */
  38279. clipPlane3: Nullable<Plane>;
  38280. /**
  38281. * Gets or sets the active clipplane 4
  38282. */
  38283. clipPlane4: Nullable<Plane>;
  38284. /**
  38285. * Gets or sets the active clipplane 5
  38286. */
  38287. clipPlane5: Nullable<Plane>;
  38288. /**
  38289. * Gets or sets the active clipplane 6
  38290. */
  38291. clipPlane6: Nullable<Plane>;
  38292. /**
  38293. * Gets or sets a boolean indicating if animations are enabled
  38294. */
  38295. animationsEnabled: boolean;
  38296. private _animationPropertiesOverride;
  38297. /**
  38298. * Gets or sets the animation properties override
  38299. */
  38300. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38301. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38302. /**
  38303. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38304. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38305. */
  38306. useConstantAnimationDeltaTime: boolean;
  38307. /**
  38308. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38309. * Please note that it requires to run a ray cast through the scene on every frame
  38310. */
  38311. constantlyUpdateMeshUnderPointer: boolean;
  38312. /**
  38313. * Defines the HTML cursor to use when hovering over interactive elements
  38314. */
  38315. hoverCursor: string;
  38316. /**
  38317. * Defines the HTML default cursor to use (empty by default)
  38318. */
  38319. defaultCursor: string;
  38320. /**
  38321. * Defines whether cursors are handled by the scene.
  38322. */
  38323. doNotHandleCursors: boolean;
  38324. /**
  38325. * This is used to call preventDefault() on pointer down
  38326. * in order to block unwanted artifacts like system double clicks
  38327. */
  38328. preventDefaultOnPointerDown: boolean;
  38329. /**
  38330. * This is used to call preventDefault() on pointer up
  38331. * in order to block unwanted artifacts like system double clicks
  38332. */
  38333. preventDefaultOnPointerUp: boolean;
  38334. /**
  38335. * Gets or sets user defined metadata
  38336. */
  38337. metadata: any;
  38338. /**
  38339. * For internal use only. Please do not use.
  38340. */
  38341. reservedDataStore: any;
  38342. /**
  38343. * Gets the name of the plugin used to load this scene (null by default)
  38344. */
  38345. loadingPluginName: string;
  38346. /**
  38347. * Use this array to add regular expressions used to disable offline support for specific urls
  38348. */
  38349. disableOfflineSupportExceptionRules: RegExp[];
  38350. /**
  38351. * An event triggered when the scene is disposed.
  38352. */
  38353. onDisposeObservable: Observable<Scene>;
  38354. private _onDisposeObserver;
  38355. /** Sets a function to be executed when this scene is disposed. */
  38356. set onDispose(callback: () => void);
  38357. /**
  38358. * An event triggered before rendering the scene (right after animations and physics)
  38359. */
  38360. onBeforeRenderObservable: Observable<Scene>;
  38361. private _onBeforeRenderObserver;
  38362. /** Sets a function to be executed before rendering this scene */
  38363. set beforeRender(callback: Nullable<() => void>);
  38364. /**
  38365. * An event triggered after rendering the scene
  38366. */
  38367. onAfterRenderObservable: Observable<Scene>;
  38368. /**
  38369. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38370. */
  38371. onAfterRenderCameraObservable: Observable<Camera>;
  38372. private _onAfterRenderObserver;
  38373. /** Sets a function to be executed after rendering this scene */
  38374. set afterRender(callback: Nullable<() => void>);
  38375. /**
  38376. * An event triggered before animating the scene
  38377. */
  38378. onBeforeAnimationsObservable: Observable<Scene>;
  38379. /**
  38380. * An event triggered after animations processing
  38381. */
  38382. onAfterAnimationsObservable: Observable<Scene>;
  38383. /**
  38384. * An event triggered before draw calls are ready to be sent
  38385. */
  38386. onBeforeDrawPhaseObservable: Observable<Scene>;
  38387. /**
  38388. * An event triggered after draw calls have been sent
  38389. */
  38390. onAfterDrawPhaseObservable: Observable<Scene>;
  38391. /**
  38392. * An event triggered when the scene is ready
  38393. */
  38394. onReadyObservable: Observable<Scene>;
  38395. /**
  38396. * An event triggered before rendering a camera
  38397. */
  38398. onBeforeCameraRenderObservable: Observable<Camera>;
  38399. private _onBeforeCameraRenderObserver;
  38400. /** Sets a function to be executed before rendering a camera*/
  38401. set beforeCameraRender(callback: () => void);
  38402. /**
  38403. * An event triggered after rendering a camera
  38404. */
  38405. onAfterCameraRenderObservable: Observable<Camera>;
  38406. private _onAfterCameraRenderObserver;
  38407. /** Sets a function to be executed after rendering a camera*/
  38408. set afterCameraRender(callback: () => void);
  38409. /**
  38410. * An event triggered when active meshes evaluation is about to start
  38411. */
  38412. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38413. /**
  38414. * An event triggered when active meshes evaluation is done
  38415. */
  38416. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38417. /**
  38418. * An event triggered when particles rendering is about to start
  38419. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38420. */
  38421. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38422. /**
  38423. * An event triggered when particles rendering is done
  38424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38425. */
  38426. onAfterParticlesRenderingObservable: Observable<Scene>;
  38427. /**
  38428. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38429. */
  38430. onDataLoadedObservable: Observable<Scene>;
  38431. /**
  38432. * An event triggered when a camera is created
  38433. */
  38434. onNewCameraAddedObservable: Observable<Camera>;
  38435. /**
  38436. * An event triggered when a camera is removed
  38437. */
  38438. onCameraRemovedObservable: Observable<Camera>;
  38439. /**
  38440. * An event triggered when a light is created
  38441. */
  38442. onNewLightAddedObservable: Observable<Light>;
  38443. /**
  38444. * An event triggered when a light is removed
  38445. */
  38446. onLightRemovedObservable: Observable<Light>;
  38447. /**
  38448. * An event triggered when a geometry is created
  38449. */
  38450. onNewGeometryAddedObservable: Observable<Geometry>;
  38451. /**
  38452. * An event triggered when a geometry is removed
  38453. */
  38454. onGeometryRemovedObservable: Observable<Geometry>;
  38455. /**
  38456. * An event triggered when a transform node is created
  38457. */
  38458. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38459. /**
  38460. * An event triggered when a transform node is removed
  38461. */
  38462. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38463. /**
  38464. * An event triggered when a mesh is created
  38465. */
  38466. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38467. /**
  38468. * An event triggered when a mesh is removed
  38469. */
  38470. onMeshRemovedObservable: Observable<AbstractMesh>;
  38471. /**
  38472. * An event triggered when a skeleton is created
  38473. */
  38474. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38475. /**
  38476. * An event triggered when a skeleton is removed
  38477. */
  38478. onSkeletonRemovedObservable: Observable<Skeleton>;
  38479. /**
  38480. * An event triggered when a material is created
  38481. */
  38482. onNewMaterialAddedObservable: Observable<Material>;
  38483. /**
  38484. * An event triggered when a material is removed
  38485. */
  38486. onMaterialRemovedObservable: Observable<Material>;
  38487. /**
  38488. * An event triggered when a texture is created
  38489. */
  38490. onNewTextureAddedObservable: Observable<BaseTexture>;
  38491. /**
  38492. * An event triggered when a texture is removed
  38493. */
  38494. onTextureRemovedObservable: Observable<BaseTexture>;
  38495. /**
  38496. * An event triggered when render targets are about to be rendered
  38497. * Can happen multiple times per frame.
  38498. */
  38499. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38500. /**
  38501. * An event triggered when render targets were rendered.
  38502. * Can happen multiple times per frame.
  38503. */
  38504. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38505. /**
  38506. * An event triggered before calculating deterministic simulation step
  38507. */
  38508. onBeforeStepObservable: Observable<Scene>;
  38509. /**
  38510. * An event triggered after calculating deterministic simulation step
  38511. */
  38512. onAfterStepObservable: Observable<Scene>;
  38513. /**
  38514. * An event triggered when the activeCamera property is updated
  38515. */
  38516. onActiveCameraChanged: Observable<Scene>;
  38517. /**
  38518. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38519. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38520. * 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)
  38521. */
  38522. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38523. /**
  38524. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38525. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38526. * 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)
  38527. */
  38528. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38529. /**
  38530. * This Observable will when a mesh has been imported into the scene.
  38531. */
  38532. onMeshImportedObservable: Observable<AbstractMesh>;
  38533. /**
  38534. * This Observable will when an animation file has been imported into the scene.
  38535. */
  38536. onAnimationFileImportedObservable: Observable<Scene>;
  38537. /**
  38538. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38539. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38540. */
  38541. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38542. /** @hidden */
  38543. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38544. /**
  38545. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38546. */
  38547. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38548. /**
  38549. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38550. */
  38551. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38552. /**
  38553. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38554. */
  38555. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38556. /** Callback called when a pointer move is detected */
  38557. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38558. /** Callback called when a pointer down is detected */
  38559. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38560. /** Callback called when a pointer up is detected */
  38561. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38562. /** Callback called when a pointer pick is detected */
  38563. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38564. /**
  38565. * 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).
  38566. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38567. */
  38568. onPrePointerObservable: Observable<PointerInfoPre>;
  38569. /**
  38570. * Observable event triggered each time an input event is received from the rendering canvas
  38571. */
  38572. onPointerObservable: Observable<PointerInfo>;
  38573. /**
  38574. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38575. */
  38576. get unTranslatedPointer(): Vector2;
  38577. /**
  38578. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38579. */
  38580. static get DragMovementThreshold(): number;
  38581. static set DragMovementThreshold(value: number);
  38582. /**
  38583. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38584. */
  38585. static get LongPressDelay(): number;
  38586. static set LongPressDelay(value: number);
  38587. /**
  38588. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38589. */
  38590. static get DoubleClickDelay(): number;
  38591. static set DoubleClickDelay(value: number);
  38592. /** If you need to check double click without raising a single click at first click, enable this flag */
  38593. static get ExclusiveDoubleClickMode(): boolean;
  38594. static set ExclusiveDoubleClickMode(value: boolean);
  38595. /** @hidden */
  38596. _mirroredCameraPosition: Nullable<Vector3>;
  38597. /**
  38598. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38599. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38600. */
  38601. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38602. /**
  38603. * Observable event triggered each time an keyboard event is received from the hosting window
  38604. */
  38605. onKeyboardObservable: Observable<KeyboardInfo>;
  38606. private _useRightHandedSystem;
  38607. /**
  38608. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38609. */
  38610. set useRightHandedSystem(value: boolean);
  38611. get useRightHandedSystem(): boolean;
  38612. private _timeAccumulator;
  38613. private _currentStepId;
  38614. private _currentInternalStep;
  38615. /**
  38616. * Sets the step Id used by deterministic lock step
  38617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38618. * @param newStepId defines the step Id
  38619. */
  38620. setStepId(newStepId: number): void;
  38621. /**
  38622. * Gets the step Id used by deterministic lock step
  38623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38624. * @returns the step Id
  38625. */
  38626. getStepId(): number;
  38627. /**
  38628. * Gets the internal step used by deterministic lock step
  38629. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38630. * @returns the internal step
  38631. */
  38632. getInternalStep(): number;
  38633. private _fogEnabled;
  38634. /**
  38635. * Gets or sets a boolean indicating if fog is enabled on this scene
  38636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38637. * (Default is true)
  38638. */
  38639. set fogEnabled(value: boolean);
  38640. get fogEnabled(): boolean;
  38641. private _fogMode;
  38642. /**
  38643. * Gets or sets the fog mode to use
  38644. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38645. * | mode | value |
  38646. * | --- | --- |
  38647. * | FOGMODE_NONE | 0 |
  38648. * | FOGMODE_EXP | 1 |
  38649. * | FOGMODE_EXP2 | 2 |
  38650. * | FOGMODE_LINEAR | 3 |
  38651. */
  38652. set fogMode(value: number);
  38653. get fogMode(): number;
  38654. /**
  38655. * Gets or sets the fog color to use
  38656. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38657. * (Default is Color3(0.2, 0.2, 0.3))
  38658. */
  38659. fogColor: Color3;
  38660. /**
  38661. * Gets or sets the fog density to use
  38662. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38663. * (Default is 0.1)
  38664. */
  38665. fogDensity: number;
  38666. /**
  38667. * Gets or sets the fog start distance to use
  38668. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38669. * (Default is 0)
  38670. */
  38671. fogStart: number;
  38672. /**
  38673. * Gets or sets the fog end distance to use
  38674. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38675. * (Default is 1000)
  38676. */
  38677. fogEnd: number;
  38678. private _shadowsEnabled;
  38679. /**
  38680. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38681. */
  38682. set shadowsEnabled(value: boolean);
  38683. get shadowsEnabled(): boolean;
  38684. private _lightsEnabled;
  38685. /**
  38686. * Gets or sets a boolean indicating if lights are enabled on this scene
  38687. */
  38688. set lightsEnabled(value: boolean);
  38689. get lightsEnabled(): boolean;
  38690. /** All of the active cameras added to this scene. */
  38691. activeCameras: Camera[];
  38692. /** @hidden */
  38693. _activeCamera: Nullable<Camera>;
  38694. /** Gets or sets the current active camera */
  38695. get activeCamera(): Nullable<Camera>;
  38696. set activeCamera(value: Nullable<Camera>);
  38697. private _defaultMaterial;
  38698. /** The default material used on meshes when no material is affected */
  38699. get defaultMaterial(): Material;
  38700. /** The default material used on meshes when no material is affected */
  38701. set defaultMaterial(value: Material);
  38702. private _texturesEnabled;
  38703. /**
  38704. * Gets or sets a boolean indicating if textures are enabled on this scene
  38705. */
  38706. set texturesEnabled(value: boolean);
  38707. get texturesEnabled(): boolean;
  38708. /**
  38709. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38710. */
  38711. physicsEnabled: boolean;
  38712. /**
  38713. * Gets or sets a boolean indicating if particles are enabled on this scene
  38714. */
  38715. particlesEnabled: boolean;
  38716. /**
  38717. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38718. */
  38719. spritesEnabled: boolean;
  38720. private _skeletonsEnabled;
  38721. /**
  38722. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38723. */
  38724. set skeletonsEnabled(value: boolean);
  38725. get skeletonsEnabled(): boolean;
  38726. /**
  38727. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38728. */
  38729. lensFlaresEnabled: boolean;
  38730. /**
  38731. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38732. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38733. */
  38734. collisionsEnabled: boolean;
  38735. private _collisionCoordinator;
  38736. /** @hidden */
  38737. get collisionCoordinator(): ICollisionCoordinator;
  38738. /**
  38739. * Defines the gravity applied to this scene (used only for collisions)
  38740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38741. */
  38742. gravity: Vector3;
  38743. /**
  38744. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38745. */
  38746. postProcessesEnabled: boolean;
  38747. /**
  38748. * The list of postprocesses added to the scene
  38749. */
  38750. postProcesses: PostProcess[];
  38751. /**
  38752. * Gets the current postprocess manager
  38753. */
  38754. postProcessManager: PostProcessManager;
  38755. /**
  38756. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38757. */
  38758. renderTargetsEnabled: boolean;
  38759. /**
  38760. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38761. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38762. */
  38763. dumpNextRenderTargets: boolean;
  38764. /**
  38765. * The list of user defined render targets added to the scene
  38766. */
  38767. customRenderTargets: RenderTargetTexture[];
  38768. /**
  38769. * Defines if texture loading must be delayed
  38770. * If true, textures will only be loaded when they need to be rendered
  38771. */
  38772. useDelayedTextureLoading: boolean;
  38773. /**
  38774. * Gets the list of meshes imported to the scene through SceneLoader
  38775. */
  38776. importedMeshesFiles: String[];
  38777. /**
  38778. * Gets or sets a boolean indicating if probes are enabled on this scene
  38779. */
  38780. probesEnabled: boolean;
  38781. /**
  38782. * Gets or sets the current offline provider to use to store scene data
  38783. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38784. */
  38785. offlineProvider: IOfflineProvider;
  38786. /**
  38787. * Gets or sets the action manager associated with the scene
  38788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38789. */
  38790. actionManager: AbstractActionManager;
  38791. private _meshesForIntersections;
  38792. /**
  38793. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38794. */
  38795. proceduralTexturesEnabled: boolean;
  38796. private _engine;
  38797. private _totalVertices;
  38798. /** @hidden */
  38799. _activeIndices: PerfCounter;
  38800. /** @hidden */
  38801. _activeParticles: PerfCounter;
  38802. /** @hidden */
  38803. _activeBones: PerfCounter;
  38804. private _animationRatio;
  38805. /** @hidden */
  38806. _animationTimeLast: number;
  38807. /** @hidden */
  38808. _animationTime: number;
  38809. /**
  38810. * Gets or sets a general scale for animation speed
  38811. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38812. */
  38813. animationTimeScale: number;
  38814. /** @hidden */
  38815. _cachedMaterial: Nullable<Material>;
  38816. /** @hidden */
  38817. _cachedEffect: Nullable<Effect>;
  38818. /** @hidden */
  38819. _cachedVisibility: Nullable<number>;
  38820. private _renderId;
  38821. private _frameId;
  38822. private _executeWhenReadyTimeoutId;
  38823. private _intermediateRendering;
  38824. private _viewUpdateFlag;
  38825. private _projectionUpdateFlag;
  38826. /** @hidden */
  38827. _toBeDisposed: Nullable<IDisposable>[];
  38828. private _activeRequests;
  38829. /** @hidden */
  38830. _pendingData: any[];
  38831. private _isDisposed;
  38832. /**
  38833. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38834. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38835. */
  38836. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38837. private _activeMeshes;
  38838. private _processedMaterials;
  38839. private _renderTargets;
  38840. /** @hidden */
  38841. _activeParticleSystems: SmartArray<IParticleSystem>;
  38842. private _activeSkeletons;
  38843. private _softwareSkinnedMeshes;
  38844. private _renderingManager;
  38845. /** @hidden */
  38846. _activeAnimatables: Animatable[];
  38847. private _transformMatrix;
  38848. private _sceneUbo;
  38849. /** @hidden */
  38850. _viewMatrix: Matrix;
  38851. private _projectionMatrix;
  38852. /** @hidden */
  38853. _forcedViewPosition: Nullable<Vector3>;
  38854. /** @hidden */
  38855. _frustumPlanes: Plane[];
  38856. /**
  38857. * Gets the list of frustum planes (built from the active camera)
  38858. */
  38859. get frustumPlanes(): Plane[];
  38860. /**
  38861. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38862. * This is useful if there are more lights that the maximum simulteanous authorized
  38863. */
  38864. requireLightSorting: boolean;
  38865. /** @hidden */
  38866. readonly useMaterialMeshMap: boolean;
  38867. /** @hidden */
  38868. readonly useClonedMeshMap: boolean;
  38869. private _externalData;
  38870. private _uid;
  38871. /**
  38872. * @hidden
  38873. * Backing store of defined scene components.
  38874. */
  38875. _components: ISceneComponent[];
  38876. /**
  38877. * @hidden
  38878. * Backing store of defined scene components.
  38879. */
  38880. _serializableComponents: ISceneSerializableComponent[];
  38881. /**
  38882. * List of components to register on the next registration step.
  38883. */
  38884. private _transientComponents;
  38885. /**
  38886. * Registers the transient components if needed.
  38887. */
  38888. private _registerTransientComponents;
  38889. /**
  38890. * @hidden
  38891. * Add a component to the scene.
  38892. * Note that the ccomponent could be registered on th next frame if this is called after
  38893. * the register component stage.
  38894. * @param component Defines the component to add to the scene
  38895. */
  38896. _addComponent(component: ISceneComponent): void;
  38897. /**
  38898. * @hidden
  38899. * Gets a component from the scene.
  38900. * @param name defines the name of the component to retrieve
  38901. * @returns the component or null if not present
  38902. */
  38903. _getComponent(name: string): Nullable<ISceneComponent>;
  38904. /**
  38905. * @hidden
  38906. * Defines the actions happening before camera updates.
  38907. */
  38908. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38909. /**
  38910. * @hidden
  38911. * Defines the actions happening before clear the canvas.
  38912. */
  38913. _beforeClearStage: Stage<SimpleStageAction>;
  38914. /**
  38915. * @hidden
  38916. * Defines the actions when collecting render targets for the frame.
  38917. */
  38918. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38919. /**
  38920. * @hidden
  38921. * Defines the actions happening for one camera in the frame.
  38922. */
  38923. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38924. /**
  38925. * @hidden
  38926. * Defines the actions happening during the per mesh ready checks.
  38927. */
  38928. _isReadyForMeshStage: Stage<MeshStageAction>;
  38929. /**
  38930. * @hidden
  38931. * Defines the actions happening before evaluate active mesh checks.
  38932. */
  38933. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38934. /**
  38935. * @hidden
  38936. * Defines the actions happening during the evaluate sub mesh checks.
  38937. */
  38938. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38939. /**
  38940. * @hidden
  38941. * Defines the actions happening during the active mesh stage.
  38942. */
  38943. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38944. /**
  38945. * @hidden
  38946. * Defines the actions happening during the per camera render target step.
  38947. */
  38948. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38949. /**
  38950. * @hidden
  38951. * Defines the actions happening just before the active camera is drawing.
  38952. */
  38953. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38954. /**
  38955. * @hidden
  38956. * Defines the actions happening just before a render target is drawing.
  38957. */
  38958. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38959. /**
  38960. * @hidden
  38961. * Defines the actions happening just before a rendering group is drawing.
  38962. */
  38963. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38964. /**
  38965. * @hidden
  38966. * Defines the actions happening just before a mesh is drawing.
  38967. */
  38968. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38969. /**
  38970. * @hidden
  38971. * Defines the actions happening just after a mesh has been drawn.
  38972. */
  38973. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38974. /**
  38975. * @hidden
  38976. * Defines the actions happening just after a rendering group has been drawn.
  38977. */
  38978. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38979. /**
  38980. * @hidden
  38981. * Defines the actions happening just after the active camera has been drawn.
  38982. */
  38983. _afterCameraDrawStage: Stage<CameraStageAction>;
  38984. /**
  38985. * @hidden
  38986. * Defines the actions happening just after a render target has been drawn.
  38987. */
  38988. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38989. /**
  38990. * @hidden
  38991. * Defines the actions happening just after rendering all cameras and computing intersections.
  38992. */
  38993. _afterRenderStage: Stage<SimpleStageAction>;
  38994. /**
  38995. * @hidden
  38996. * Defines the actions happening when a pointer move event happens.
  38997. */
  38998. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38999. /**
  39000. * @hidden
  39001. * Defines the actions happening when a pointer down event happens.
  39002. */
  39003. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39004. /**
  39005. * @hidden
  39006. * Defines the actions happening when a pointer up event happens.
  39007. */
  39008. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39009. /**
  39010. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39011. */
  39012. private geometriesByUniqueId;
  39013. /**
  39014. * Creates a new Scene
  39015. * @param engine defines the engine to use to render this scene
  39016. * @param options defines the scene options
  39017. */
  39018. constructor(engine: Engine, options?: SceneOptions);
  39019. /**
  39020. * Gets a string idenfifying the name of the class
  39021. * @returns "Scene" string
  39022. */
  39023. getClassName(): string;
  39024. private _defaultMeshCandidates;
  39025. /**
  39026. * @hidden
  39027. */
  39028. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39029. private _defaultSubMeshCandidates;
  39030. /**
  39031. * @hidden
  39032. */
  39033. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39034. /**
  39035. * Sets the default candidate providers for the scene.
  39036. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39037. * and getCollidingSubMeshCandidates to their default function
  39038. */
  39039. setDefaultCandidateProviders(): void;
  39040. /**
  39041. * Gets the mesh that is currently under the pointer
  39042. */
  39043. get meshUnderPointer(): Nullable<AbstractMesh>;
  39044. /**
  39045. * Gets or sets the current on-screen X position of the pointer
  39046. */
  39047. get pointerX(): number;
  39048. set pointerX(value: number);
  39049. /**
  39050. * Gets or sets the current on-screen Y position of the pointer
  39051. */
  39052. get pointerY(): number;
  39053. set pointerY(value: number);
  39054. /**
  39055. * Gets the cached material (ie. the latest rendered one)
  39056. * @returns the cached material
  39057. */
  39058. getCachedMaterial(): Nullable<Material>;
  39059. /**
  39060. * Gets the cached effect (ie. the latest rendered one)
  39061. * @returns the cached effect
  39062. */
  39063. getCachedEffect(): Nullable<Effect>;
  39064. /**
  39065. * Gets the cached visibility state (ie. the latest rendered one)
  39066. * @returns the cached visibility state
  39067. */
  39068. getCachedVisibility(): Nullable<number>;
  39069. /**
  39070. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39071. * @param material defines the current material
  39072. * @param effect defines the current effect
  39073. * @param visibility defines the current visibility state
  39074. * @returns true if one parameter is not cached
  39075. */
  39076. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39077. /**
  39078. * Gets the engine associated with the scene
  39079. * @returns an Engine
  39080. */
  39081. getEngine(): Engine;
  39082. /**
  39083. * Gets the total number of vertices rendered per frame
  39084. * @returns the total number of vertices rendered per frame
  39085. */
  39086. getTotalVertices(): number;
  39087. /**
  39088. * Gets the performance counter for total vertices
  39089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39090. */
  39091. get totalVerticesPerfCounter(): PerfCounter;
  39092. /**
  39093. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39094. * @returns the total number of active indices rendered per frame
  39095. */
  39096. getActiveIndices(): number;
  39097. /**
  39098. * Gets the performance counter for active indices
  39099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39100. */
  39101. get totalActiveIndicesPerfCounter(): PerfCounter;
  39102. /**
  39103. * Gets the total number of active particles rendered per frame
  39104. * @returns the total number of active particles rendered per frame
  39105. */
  39106. getActiveParticles(): number;
  39107. /**
  39108. * Gets the performance counter for active particles
  39109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39110. */
  39111. get activeParticlesPerfCounter(): PerfCounter;
  39112. /**
  39113. * Gets the total number of active bones rendered per frame
  39114. * @returns the total number of active bones rendered per frame
  39115. */
  39116. getActiveBones(): number;
  39117. /**
  39118. * Gets the performance counter for active bones
  39119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39120. */
  39121. get activeBonesPerfCounter(): PerfCounter;
  39122. /**
  39123. * Gets the array of active meshes
  39124. * @returns an array of AbstractMesh
  39125. */
  39126. getActiveMeshes(): SmartArray<AbstractMesh>;
  39127. /**
  39128. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39129. * @returns a number
  39130. */
  39131. getAnimationRatio(): number;
  39132. /**
  39133. * Gets an unique Id for the current render phase
  39134. * @returns a number
  39135. */
  39136. getRenderId(): number;
  39137. /**
  39138. * Gets an unique Id for the current frame
  39139. * @returns a number
  39140. */
  39141. getFrameId(): number;
  39142. /** Call this function if you want to manually increment the render Id*/
  39143. incrementRenderId(): void;
  39144. private _createUbo;
  39145. /**
  39146. * Use this method to simulate a pointer move on a mesh
  39147. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39148. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39149. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39150. * @returns the current scene
  39151. */
  39152. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39153. /**
  39154. * Use this method to simulate a pointer down on a mesh
  39155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39158. * @returns the current scene
  39159. */
  39160. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39161. /**
  39162. * Use this method to simulate a pointer up on a mesh
  39163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39166. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39167. * @returns the current scene
  39168. */
  39169. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39170. /**
  39171. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39172. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39173. * @returns true if the pointer was captured
  39174. */
  39175. isPointerCaptured(pointerId?: number): boolean;
  39176. /**
  39177. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39178. * @param attachUp defines if you want to attach events to pointerup
  39179. * @param attachDown defines if you want to attach events to pointerdown
  39180. * @param attachMove defines if you want to attach events to pointermove
  39181. */
  39182. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39183. /** Detaches all event handlers*/
  39184. detachControl(): void;
  39185. /**
  39186. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39187. * Delay loaded resources are not taking in account
  39188. * @return true if all required resources are ready
  39189. */
  39190. isReady(): boolean;
  39191. /** Resets all cached information relative to material (including effect and visibility) */
  39192. resetCachedMaterial(): void;
  39193. /**
  39194. * Registers a function to be called before every frame render
  39195. * @param func defines the function to register
  39196. */
  39197. registerBeforeRender(func: () => void): void;
  39198. /**
  39199. * Unregisters a function called before every frame render
  39200. * @param func defines the function to unregister
  39201. */
  39202. unregisterBeforeRender(func: () => void): void;
  39203. /**
  39204. * Registers a function to be called after every frame render
  39205. * @param func defines the function to register
  39206. */
  39207. registerAfterRender(func: () => void): void;
  39208. /**
  39209. * Unregisters a function called after every frame render
  39210. * @param func defines the function to unregister
  39211. */
  39212. unregisterAfterRender(func: () => void): void;
  39213. private _executeOnceBeforeRender;
  39214. /**
  39215. * The provided function will run before render once and will be disposed afterwards.
  39216. * A timeout delay can be provided so that the function will be executed in N ms.
  39217. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39218. * @param func The function to be executed.
  39219. * @param timeout optional delay in ms
  39220. */
  39221. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39222. /** @hidden */
  39223. _addPendingData(data: any): void;
  39224. /** @hidden */
  39225. _removePendingData(data: any): void;
  39226. /**
  39227. * Returns the number of items waiting to be loaded
  39228. * @returns the number of items waiting to be loaded
  39229. */
  39230. getWaitingItemsCount(): number;
  39231. /**
  39232. * Returns a boolean indicating if the scene is still loading data
  39233. */
  39234. get isLoading(): boolean;
  39235. /**
  39236. * Registers a function to be executed when the scene is ready
  39237. * @param {Function} func - the function to be executed
  39238. */
  39239. executeWhenReady(func: () => void): void;
  39240. /**
  39241. * Returns a promise that resolves when the scene is ready
  39242. * @returns A promise that resolves when the scene is ready
  39243. */
  39244. whenReadyAsync(): Promise<void>;
  39245. /** @hidden */
  39246. _checkIsReady(): void;
  39247. /**
  39248. * Gets all animatable attached to the scene
  39249. */
  39250. get animatables(): Animatable[];
  39251. /**
  39252. * Resets the last animation time frame.
  39253. * Useful to override when animations start running when loading a scene for the first time.
  39254. */
  39255. resetLastAnimationTimeFrame(): void;
  39256. /**
  39257. * Gets the current view matrix
  39258. * @returns a Matrix
  39259. */
  39260. getViewMatrix(): Matrix;
  39261. /**
  39262. * Gets the current projection matrix
  39263. * @returns a Matrix
  39264. */
  39265. getProjectionMatrix(): Matrix;
  39266. /**
  39267. * Gets the current transform matrix
  39268. * @returns a Matrix made of View * Projection
  39269. */
  39270. getTransformMatrix(): Matrix;
  39271. /**
  39272. * Sets the current transform matrix
  39273. * @param viewL defines the View matrix to use
  39274. * @param projectionL defines the Projection matrix to use
  39275. * @param viewR defines the right View matrix to use (if provided)
  39276. * @param projectionR defines the right Projection matrix to use (if provided)
  39277. */
  39278. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39279. /**
  39280. * Gets the uniform buffer used to store scene data
  39281. * @returns a UniformBuffer
  39282. */
  39283. getSceneUniformBuffer(): UniformBuffer;
  39284. /**
  39285. * Gets an unique (relatively to the current scene) Id
  39286. * @returns an unique number for the scene
  39287. */
  39288. getUniqueId(): number;
  39289. /**
  39290. * Add a mesh to the list of scene's meshes
  39291. * @param newMesh defines the mesh to add
  39292. * @param recursive if all child meshes should also be added to the scene
  39293. */
  39294. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39295. /**
  39296. * Remove a mesh for the list of scene's meshes
  39297. * @param toRemove defines the mesh to remove
  39298. * @param recursive if all child meshes should also be removed from the scene
  39299. * @returns the index where the mesh was in the mesh list
  39300. */
  39301. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39302. /**
  39303. * Add a transform node to the list of scene's transform nodes
  39304. * @param newTransformNode defines the transform node to add
  39305. */
  39306. addTransformNode(newTransformNode: TransformNode): void;
  39307. /**
  39308. * Remove a transform node for the list of scene's transform nodes
  39309. * @param toRemove defines the transform node to remove
  39310. * @returns the index where the transform node was in the transform node list
  39311. */
  39312. removeTransformNode(toRemove: TransformNode): number;
  39313. /**
  39314. * Remove a skeleton for the list of scene's skeletons
  39315. * @param toRemove defines the skeleton to remove
  39316. * @returns the index where the skeleton was in the skeleton list
  39317. */
  39318. removeSkeleton(toRemove: Skeleton): number;
  39319. /**
  39320. * Remove a morph target for the list of scene's morph targets
  39321. * @param toRemove defines the morph target to remove
  39322. * @returns the index where the morph target was in the morph target list
  39323. */
  39324. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39325. /**
  39326. * Remove a light for the list of scene's lights
  39327. * @param toRemove defines the light to remove
  39328. * @returns the index where the light was in the light list
  39329. */
  39330. removeLight(toRemove: Light): number;
  39331. /**
  39332. * Remove a camera for the list of scene's cameras
  39333. * @param toRemove defines the camera to remove
  39334. * @returns the index where the camera was in the camera list
  39335. */
  39336. removeCamera(toRemove: Camera): number;
  39337. /**
  39338. * Remove a particle system for the list of scene's particle systems
  39339. * @param toRemove defines the particle system to remove
  39340. * @returns the index where the particle system was in the particle system list
  39341. */
  39342. removeParticleSystem(toRemove: IParticleSystem): number;
  39343. /**
  39344. * Remove a animation for the list of scene's animations
  39345. * @param toRemove defines the animation to remove
  39346. * @returns the index where the animation was in the animation list
  39347. */
  39348. removeAnimation(toRemove: Animation): number;
  39349. /**
  39350. * Will stop the animation of the given target
  39351. * @param target - the target
  39352. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39353. * @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)
  39354. */
  39355. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39356. /**
  39357. * Removes the given animation group from this scene.
  39358. * @param toRemove The animation group to remove
  39359. * @returns The index of the removed animation group
  39360. */
  39361. removeAnimationGroup(toRemove: AnimationGroup): number;
  39362. /**
  39363. * Removes the given multi-material from this scene.
  39364. * @param toRemove The multi-material to remove
  39365. * @returns The index of the removed multi-material
  39366. */
  39367. removeMultiMaterial(toRemove: MultiMaterial): number;
  39368. /**
  39369. * Removes the given material from this scene.
  39370. * @param toRemove The material to remove
  39371. * @returns The index of the removed material
  39372. */
  39373. removeMaterial(toRemove: Material): number;
  39374. /**
  39375. * Removes the given action manager from this scene.
  39376. * @param toRemove The action manager to remove
  39377. * @returns The index of the removed action manager
  39378. */
  39379. removeActionManager(toRemove: AbstractActionManager): number;
  39380. /**
  39381. * Removes the given texture from this scene.
  39382. * @param toRemove The texture to remove
  39383. * @returns The index of the removed texture
  39384. */
  39385. removeTexture(toRemove: BaseTexture): number;
  39386. /**
  39387. * Adds the given light to this scene
  39388. * @param newLight The light to add
  39389. */
  39390. addLight(newLight: Light): void;
  39391. /**
  39392. * Sorts the list list based on light priorities
  39393. */
  39394. sortLightsByPriority(): void;
  39395. /**
  39396. * Adds the given camera to this scene
  39397. * @param newCamera The camera to add
  39398. */
  39399. addCamera(newCamera: Camera): void;
  39400. /**
  39401. * Adds the given skeleton to this scene
  39402. * @param newSkeleton The skeleton to add
  39403. */
  39404. addSkeleton(newSkeleton: Skeleton): void;
  39405. /**
  39406. * Adds the given particle system to this scene
  39407. * @param newParticleSystem The particle system to add
  39408. */
  39409. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39410. /**
  39411. * Adds the given animation to this scene
  39412. * @param newAnimation The animation to add
  39413. */
  39414. addAnimation(newAnimation: Animation): void;
  39415. /**
  39416. * Adds the given animation group to this scene.
  39417. * @param newAnimationGroup The animation group to add
  39418. */
  39419. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39420. /**
  39421. * Adds the given multi-material to this scene
  39422. * @param newMultiMaterial The multi-material to add
  39423. */
  39424. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39425. /**
  39426. * Adds the given material to this scene
  39427. * @param newMaterial The material to add
  39428. */
  39429. addMaterial(newMaterial: Material): void;
  39430. /**
  39431. * Adds the given morph target to this scene
  39432. * @param newMorphTargetManager The morph target to add
  39433. */
  39434. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39435. /**
  39436. * Adds the given geometry to this scene
  39437. * @param newGeometry The geometry to add
  39438. */
  39439. addGeometry(newGeometry: Geometry): void;
  39440. /**
  39441. * Adds the given action manager to this scene
  39442. * @param newActionManager The action manager to add
  39443. */
  39444. addActionManager(newActionManager: AbstractActionManager): void;
  39445. /**
  39446. * Adds the given texture to this scene.
  39447. * @param newTexture The texture to add
  39448. */
  39449. addTexture(newTexture: BaseTexture): void;
  39450. /**
  39451. * Switch active camera
  39452. * @param newCamera defines the new active camera
  39453. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39454. */
  39455. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39456. /**
  39457. * sets the active camera of the scene using its ID
  39458. * @param id defines the camera's ID
  39459. * @return the new active camera or null if none found.
  39460. */
  39461. setActiveCameraByID(id: string): Nullable<Camera>;
  39462. /**
  39463. * sets the active camera of the scene using its name
  39464. * @param name defines the camera's name
  39465. * @returns the new active camera or null if none found.
  39466. */
  39467. setActiveCameraByName(name: string): Nullable<Camera>;
  39468. /**
  39469. * get an animation group using its name
  39470. * @param name defines the material's name
  39471. * @return the animation group or null if none found.
  39472. */
  39473. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39474. /**
  39475. * Get a material using its unique id
  39476. * @param uniqueId defines the material's unique id
  39477. * @return the material or null if none found.
  39478. */
  39479. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39480. /**
  39481. * get a material using its id
  39482. * @param id defines the material's ID
  39483. * @return the material or null if none found.
  39484. */
  39485. getMaterialByID(id: string): Nullable<Material>;
  39486. /**
  39487. * Gets a the last added material using a given id
  39488. * @param id defines the material's ID
  39489. * @return the last material with the given id or null if none found.
  39490. */
  39491. getLastMaterialByID(id: string): Nullable<Material>;
  39492. /**
  39493. * Gets a material using its name
  39494. * @param name defines the material's name
  39495. * @return the material or null if none found.
  39496. */
  39497. getMaterialByName(name: string): Nullable<Material>;
  39498. /**
  39499. * Get a texture using its unique id
  39500. * @param uniqueId defines the texture's unique id
  39501. * @return the texture or null if none found.
  39502. */
  39503. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39504. /**
  39505. * Gets a camera using its id
  39506. * @param id defines the id to look for
  39507. * @returns the camera or null if not found
  39508. */
  39509. getCameraByID(id: string): Nullable<Camera>;
  39510. /**
  39511. * Gets a camera using its unique id
  39512. * @param uniqueId defines the unique id to look for
  39513. * @returns the camera or null if not found
  39514. */
  39515. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39516. /**
  39517. * Gets a camera using its name
  39518. * @param name defines the camera's name
  39519. * @return the camera or null if none found.
  39520. */
  39521. getCameraByName(name: string): Nullable<Camera>;
  39522. /**
  39523. * Gets a bone using its id
  39524. * @param id defines the bone's id
  39525. * @return the bone or null if not found
  39526. */
  39527. getBoneByID(id: string): Nullable<Bone>;
  39528. /**
  39529. * Gets a bone using its id
  39530. * @param name defines the bone's name
  39531. * @return the bone or null if not found
  39532. */
  39533. getBoneByName(name: string): Nullable<Bone>;
  39534. /**
  39535. * Gets a light node using its name
  39536. * @param name defines the the light's name
  39537. * @return the light or null if none found.
  39538. */
  39539. getLightByName(name: string): Nullable<Light>;
  39540. /**
  39541. * Gets a light node using its id
  39542. * @param id defines the light's id
  39543. * @return the light or null if none found.
  39544. */
  39545. getLightByID(id: string): Nullable<Light>;
  39546. /**
  39547. * Gets a light node using its scene-generated unique ID
  39548. * @param uniqueId defines the light's unique id
  39549. * @return the light or null if none found.
  39550. */
  39551. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39552. /**
  39553. * Gets a particle system by id
  39554. * @param id defines the particle system id
  39555. * @return the corresponding system or null if none found
  39556. */
  39557. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39558. /**
  39559. * Gets a geometry using its ID
  39560. * @param id defines the geometry's id
  39561. * @return the geometry or null if none found.
  39562. */
  39563. getGeometryByID(id: string): Nullable<Geometry>;
  39564. private _getGeometryByUniqueID;
  39565. /**
  39566. * Add a new geometry to this scene
  39567. * @param geometry defines the geometry to be added to the scene.
  39568. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39569. * @return a boolean defining if the geometry was added or not
  39570. */
  39571. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39572. /**
  39573. * Removes an existing geometry
  39574. * @param geometry defines the geometry to be removed from the scene
  39575. * @return a boolean defining if the geometry was removed or not
  39576. */
  39577. removeGeometry(geometry: Geometry): boolean;
  39578. /**
  39579. * Gets the list of geometries attached to the scene
  39580. * @returns an array of Geometry
  39581. */
  39582. getGeometries(): Geometry[];
  39583. /**
  39584. * Gets the first added mesh found of a given ID
  39585. * @param id defines the id to search for
  39586. * @return the mesh found or null if not found at all
  39587. */
  39588. getMeshByID(id: string): Nullable<AbstractMesh>;
  39589. /**
  39590. * Gets a list of meshes using their id
  39591. * @param id defines the id to search for
  39592. * @returns a list of meshes
  39593. */
  39594. getMeshesByID(id: string): Array<AbstractMesh>;
  39595. /**
  39596. * Gets the first added transform node found of a given ID
  39597. * @param id defines the id to search for
  39598. * @return the found transform node or null if not found at all.
  39599. */
  39600. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39601. /**
  39602. * Gets a transform node with its auto-generated unique id
  39603. * @param uniqueId efines the unique id to search for
  39604. * @return the found transform node or null if not found at all.
  39605. */
  39606. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39607. /**
  39608. * Gets a list of transform nodes using their id
  39609. * @param id defines the id to search for
  39610. * @returns a list of transform nodes
  39611. */
  39612. getTransformNodesByID(id: string): Array<TransformNode>;
  39613. /**
  39614. * Gets a mesh with its auto-generated unique id
  39615. * @param uniqueId defines the unique id to search for
  39616. * @return the found mesh or null if not found at all.
  39617. */
  39618. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39619. /**
  39620. * Gets a the last added mesh using a given id
  39621. * @param id defines the id to search for
  39622. * @return the found mesh or null if not found at all.
  39623. */
  39624. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39625. /**
  39626. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39627. * @param id defines the id to search for
  39628. * @return the found node or null if not found at all
  39629. */
  39630. getLastEntryByID(id: string): Nullable<Node>;
  39631. /**
  39632. * Gets a node (Mesh, Camera, Light) using a given id
  39633. * @param id defines the id to search for
  39634. * @return the found node or null if not found at all
  39635. */
  39636. getNodeByID(id: string): Nullable<Node>;
  39637. /**
  39638. * Gets a node (Mesh, Camera, Light) using a given name
  39639. * @param name defines the name to search for
  39640. * @return the found node or null if not found at all.
  39641. */
  39642. getNodeByName(name: string): Nullable<Node>;
  39643. /**
  39644. * Gets a mesh using a given name
  39645. * @param name defines the name to search for
  39646. * @return the found mesh or null if not found at all.
  39647. */
  39648. getMeshByName(name: string): Nullable<AbstractMesh>;
  39649. /**
  39650. * Gets a transform node using a given name
  39651. * @param name defines the name to search for
  39652. * @return the found transform node or null if not found at all.
  39653. */
  39654. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39655. /**
  39656. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39657. * @param id defines the id to search for
  39658. * @return the found skeleton or null if not found at all.
  39659. */
  39660. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39661. /**
  39662. * Gets a skeleton using a given auto generated unique id
  39663. * @param uniqueId defines the unique id to search for
  39664. * @return the found skeleton or null if not found at all.
  39665. */
  39666. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39667. /**
  39668. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39669. * @param id defines the id to search for
  39670. * @return the found skeleton or null if not found at all.
  39671. */
  39672. getSkeletonById(id: string): Nullable<Skeleton>;
  39673. /**
  39674. * Gets a skeleton using a given name
  39675. * @param name defines the name to search for
  39676. * @return the found skeleton or null if not found at all.
  39677. */
  39678. getSkeletonByName(name: string): Nullable<Skeleton>;
  39679. /**
  39680. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39681. * @param id defines the id to search for
  39682. * @return the found morph target manager or null if not found at all.
  39683. */
  39684. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39685. /**
  39686. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39687. * @param id defines the id to search for
  39688. * @return the found morph target or null if not found at all.
  39689. */
  39690. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39691. /**
  39692. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39693. * @param name defines the name to search for
  39694. * @return the found morph target or null if not found at all.
  39695. */
  39696. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39697. /**
  39698. * Gets a boolean indicating if the given mesh is active
  39699. * @param mesh defines the mesh to look for
  39700. * @returns true if the mesh is in the active list
  39701. */
  39702. isActiveMesh(mesh: AbstractMesh): boolean;
  39703. /**
  39704. * Return a unique id as a string which can serve as an identifier for the scene
  39705. */
  39706. get uid(): string;
  39707. /**
  39708. * Add an externaly attached data from its key.
  39709. * This method call will fail and return false, if such key already exists.
  39710. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39711. * @param key the unique key that identifies the data
  39712. * @param data the data object to associate to the key for this Engine instance
  39713. * @return true if no such key were already present and the data was added successfully, false otherwise
  39714. */
  39715. addExternalData<T>(key: string, data: T): boolean;
  39716. /**
  39717. * Get an externaly attached data from its key
  39718. * @param key the unique key that identifies the data
  39719. * @return the associated data, if present (can be null), or undefined if not present
  39720. */
  39721. getExternalData<T>(key: string): Nullable<T>;
  39722. /**
  39723. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39724. * @param key the unique key that identifies the data
  39725. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39726. * @return the associated data, can be null if the factory returned null.
  39727. */
  39728. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39729. /**
  39730. * Remove an externaly attached data from the Engine instance
  39731. * @param key the unique key that identifies the data
  39732. * @return true if the data was successfully removed, false if it doesn't exist
  39733. */
  39734. removeExternalData(key: string): boolean;
  39735. private _evaluateSubMesh;
  39736. /**
  39737. * Clear the processed materials smart array preventing retention point in material dispose.
  39738. */
  39739. freeProcessedMaterials(): void;
  39740. private _preventFreeActiveMeshesAndRenderingGroups;
  39741. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39742. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39743. * when disposing several meshes in a row or a hierarchy of meshes.
  39744. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39745. */
  39746. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39747. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39748. /**
  39749. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39750. */
  39751. freeActiveMeshes(): void;
  39752. /**
  39753. * Clear the info related to rendering groups preventing retention points during dispose.
  39754. */
  39755. freeRenderingGroups(): void;
  39756. /** @hidden */
  39757. _isInIntermediateRendering(): boolean;
  39758. /**
  39759. * Lambda returning the list of potentially active meshes.
  39760. */
  39761. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39762. /**
  39763. * Lambda returning the list of potentially active sub meshes.
  39764. */
  39765. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39766. /**
  39767. * Lambda returning the list of potentially intersecting sub meshes.
  39768. */
  39769. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39770. /**
  39771. * Lambda returning the list of potentially colliding sub meshes.
  39772. */
  39773. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39774. private _activeMeshesFrozen;
  39775. private _skipEvaluateActiveMeshesCompletely;
  39776. /**
  39777. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39778. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39779. * @returns the current scene
  39780. */
  39781. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39782. /**
  39783. * Use this function to restart evaluating active meshes on every frame
  39784. * @returns the current scene
  39785. */
  39786. unfreezeActiveMeshes(): Scene;
  39787. private _evaluateActiveMeshes;
  39788. private _activeMesh;
  39789. /**
  39790. * Update the transform matrix to update from the current active camera
  39791. * @param force defines a boolean used to force the update even if cache is up to date
  39792. */
  39793. updateTransformMatrix(force?: boolean): void;
  39794. private _bindFrameBuffer;
  39795. /** @hidden */
  39796. _allowPostProcessClearColor: boolean;
  39797. /** @hidden */
  39798. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39799. private _processSubCameras;
  39800. private _checkIntersections;
  39801. /** @hidden */
  39802. _advancePhysicsEngineStep(step: number): void;
  39803. /**
  39804. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39805. */
  39806. getDeterministicFrameTime: () => number;
  39807. /** @hidden */
  39808. _animate(): void;
  39809. /** Execute all animations (for a frame) */
  39810. animate(): void;
  39811. /**
  39812. * Render the scene
  39813. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39814. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39815. */
  39816. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39817. /**
  39818. * Freeze all materials
  39819. * A frozen material will not be updatable but should be faster to render
  39820. */
  39821. freezeMaterials(): void;
  39822. /**
  39823. * Unfreeze all materials
  39824. * A frozen material will not be updatable but should be faster to render
  39825. */
  39826. unfreezeMaterials(): void;
  39827. /**
  39828. * Releases all held ressources
  39829. */
  39830. dispose(): void;
  39831. /**
  39832. * Gets if the scene is already disposed
  39833. */
  39834. get isDisposed(): boolean;
  39835. /**
  39836. * Call this function to reduce memory footprint of the scene.
  39837. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39838. */
  39839. clearCachedVertexData(): void;
  39840. /**
  39841. * This function will remove the local cached buffer data from texture.
  39842. * It will save memory but will prevent the texture from being rebuilt
  39843. */
  39844. cleanCachedTextureBuffer(): void;
  39845. /**
  39846. * Get the world extend vectors with an optional filter
  39847. *
  39848. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39849. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39850. */
  39851. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39852. min: Vector3;
  39853. max: Vector3;
  39854. };
  39855. /**
  39856. * Creates a ray that can be used to pick in the scene
  39857. * @param x defines the x coordinate of the origin (on-screen)
  39858. * @param y defines the y coordinate of the origin (on-screen)
  39859. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39860. * @param camera defines the camera to use for the picking
  39861. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39862. * @returns a Ray
  39863. */
  39864. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39865. /**
  39866. * Creates a ray that can be used to pick in the scene
  39867. * @param x defines the x coordinate of the origin (on-screen)
  39868. * @param y defines the y coordinate of the origin (on-screen)
  39869. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39870. * @param result defines the ray where to store the picking ray
  39871. * @param camera defines the camera to use for the picking
  39872. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39873. * @returns the current scene
  39874. */
  39875. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39876. /**
  39877. * Creates a ray that can be used to pick in the scene
  39878. * @param x defines the x coordinate of the origin (on-screen)
  39879. * @param y defines the y coordinate of the origin (on-screen)
  39880. * @param camera defines the camera to use for the picking
  39881. * @returns a Ray
  39882. */
  39883. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39884. /**
  39885. * Creates a ray that can be used to pick in the scene
  39886. * @param x defines the x coordinate of the origin (on-screen)
  39887. * @param y defines the y coordinate of the origin (on-screen)
  39888. * @param result defines the ray where to store the picking ray
  39889. * @param camera defines the camera to use for the picking
  39890. * @returns the current scene
  39891. */
  39892. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39893. /** Launch a ray to try to pick a mesh in the scene
  39894. * @param x position on screen
  39895. * @param y position on screen
  39896. * @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
  39897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39898. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39900. * @returns a PickingInfo
  39901. */
  39902. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39903. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39904. * @param x position on screen
  39905. * @param y position on screen
  39906. * @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
  39907. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39908. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39909. * @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)
  39910. */
  39911. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39912. /** Use the given ray to pick a mesh in the scene
  39913. * @param ray The ray to use to pick meshes
  39914. * @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
  39915. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39916. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39917. * @returns a PickingInfo
  39918. */
  39919. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39920. /**
  39921. * Launch a ray to try to pick a mesh in the scene
  39922. * @param x X position on screen
  39923. * @param y Y position on screen
  39924. * @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
  39925. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39926. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39927. * @returns an array of PickingInfo
  39928. */
  39929. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39930. /**
  39931. * Launch a ray to try to pick a mesh in the scene
  39932. * @param ray Ray to use
  39933. * @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
  39934. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39935. * @returns an array of PickingInfo
  39936. */
  39937. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39938. /**
  39939. * Force the value of meshUnderPointer
  39940. * @param mesh defines the mesh to use
  39941. */
  39942. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39943. /**
  39944. * Gets the mesh under the pointer
  39945. * @returns a Mesh or null if no mesh is under the pointer
  39946. */
  39947. getPointerOverMesh(): Nullable<AbstractMesh>;
  39948. /** @hidden */
  39949. _rebuildGeometries(): void;
  39950. /** @hidden */
  39951. _rebuildTextures(): void;
  39952. private _getByTags;
  39953. /**
  39954. * Get a list of meshes by tags
  39955. * @param tagsQuery defines the tags query to use
  39956. * @param forEach defines a predicate used to filter results
  39957. * @returns an array of Mesh
  39958. */
  39959. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39960. /**
  39961. * Get a list of cameras by tags
  39962. * @param tagsQuery defines the tags query to use
  39963. * @param forEach defines a predicate used to filter results
  39964. * @returns an array of Camera
  39965. */
  39966. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39967. /**
  39968. * Get a list of lights by tags
  39969. * @param tagsQuery defines the tags query to use
  39970. * @param forEach defines a predicate used to filter results
  39971. * @returns an array of Light
  39972. */
  39973. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39974. /**
  39975. * Get a list of materials by tags
  39976. * @param tagsQuery defines the tags query to use
  39977. * @param forEach defines a predicate used to filter results
  39978. * @returns an array of Material
  39979. */
  39980. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39981. /**
  39982. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39983. * This allowed control for front to back rendering or reversly depending of the special needs.
  39984. *
  39985. * @param renderingGroupId The rendering group id corresponding to its index
  39986. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39987. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39988. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39989. */
  39990. 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;
  39991. /**
  39992. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39993. *
  39994. * @param renderingGroupId The rendering group id corresponding to its index
  39995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39996. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39997. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39998. */
  39999. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40000. /**
  40001. * Gets the current auto clear configuration for one rendering group of the rendering
  40002. * manager.
  40003. * @param index the rendering group index to get the information for
  40004. * @returns The auto clear setup for the requested rendering group
  40005. */
  40006. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40007. private _blockMaterialDirtyMechanism;
  40008. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40009. get blockMaterialDirtyMechanism(): boolean;
  40010. set blockMaterialDirtyMechanism(value: boolean);
  40011. /**
  40012. * Will flag all materials as dirty to trigger new shader compilation
  40013. * @param flag defines the flag used to specify which material part must be marked as dirty
  40014. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40015. */
  40016. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40017. /** @hidden */
  40018. _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;
  40019. /** @hidden */
  40020. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40021. /** @hidden */
  40022. _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;
  40023. /** @hidden */
  40024. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40025. /** @hidden */
  40026. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40027. /** @hidden */
  40028. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40029. }
  40030. }
  40031. declare module BABYLON {
  40032. /**
  40033. * Set of assets to keep when moving a scene into an asset container.
  40034. */
  40035. export class KeepAssets extends AbstractScene {
  40036. }
  40037. /**
  40038. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40039. */
  40040. export class InstantiatedEntries {
  40041. /**
  40042. * List of new root nodes (eg. nodes with no parent)
  40043. */
  40044. rootNodes: TransformNode[];
  40045. /**
  40046. * List of new skeletons
  40047. */
  40048. skeletons: Skeleton[];
  40049. /**
  40050. * List of new animation groups
  40051. */
  40052. animationGroups: AnimationGroup[];
  40053. }
  40054. /**
  40055. * Container with a set of assets that can be added or removed from a scene.
  40056. */
  40057. export class AssetContainer extends AbstractScene {
  40058. private _wasAddedToScene;
  40059. /**
  40060. * The scene the AssetContainer belongs to.
  40061. */
  40062. scene: Scene;
  40063. /**
  40064. * Instantiates an AssetContainer.
  40065. * @param scene The scene the AssetContainer belongs to.
  40066. */
  40067. constructor(scene: Scene);
  40068. /**
  40069. * Instantiate or clone all meshes and add the new ones to the scene.
  40070. * Skeletons and animation groups will all be cloned
  40071. * @param nameFunction defines an optional function used to get new names for clones
  40072. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40073. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40074. */
  40075. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40076. /**
  40077. * Adds all the assets from the container to the scene.
  40078. */
  40079. addAllToScene(): void;
  40080. /**
  40081. * Removes all the assets in the container from the scene
  40082. */
  40083. removeAllFromScene(): void;
  40084. /**
  40085. * Disposes all the assets in the container
  40086. */
  40087. dispose(): void;
  40088. private _moveAssets;
  40089. /**
  40090. * Removes all the assets contained in the scene and adds them to the container.
  40091. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40092. */
  40093. moveAllFromScene(keepAssets?: KeepAssets): void;
  40094. /**
  40095. * 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.
  40096. * @returns the root mesh
  40097. */
  40098. createRootMesh(): Mesh;
  40099. /**
  40100. * Merge animations (direct and animation groups) from this asset container into a scene
  40101. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40102. * @param animatables set of animatables to retarget to a node from the scene
  40103. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40104. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40105. */
  40106. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40107. }
  40108. }
  40109. declare module BABYLON {
  40110. /**
  40111. * Defines how the parser contract is defined.
  40112. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40113. */
  40114. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40115. /**
  40116. * Defines how the individual parser contract is defined.
  40117. * These parser can parse an individual asset
  40118. */
  40119. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40120. /**
  40121. * Base class of the scene acting as a container for the different elements composing a scene.
  40122. * This class is dynamically extended by the different components of the scene increasing
  40123. * flexibility and reducing coupling
  40124. */
  40125. export abstract class AbstractScene {
  40126. /**
  40127. * Stores the list of available parsers in the application.
  40128. */
  40129. private static _BabylonFileParsers;
  40130. /**
  40131. * Stores the list of available individual parsers in the application.
  40132. */
  40133. private static _IndividualBabylonFileParsers;
  40134. /**
  40135. * Adds a parser in the list of available ones
  40136. * @param name Defines the name of the parser
  40137. * @param parser Defines the parser to add
  40138. */
  40139. static AddParser(name: string, parser: BabylonFileParser): void;
  40140. /**
  40141. * Gets a general parser from the list of avaialble ones
  40142. * @param name Defines the name of the parser
  40143. * @returns the requested parser or null
  40144. */
  40145. static GetParser(name: string): Nullable<BabylonFileParser>;
  40146. /**
  40147. * Adds n individual parser in the list of available ones
  40148. * @param name Defines the name of the parser
  40149. * @param parser Defines the parser to add
  40150. */
  40151. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40152. /**
  40153. * Gets an individual parser from the list of avaialble ones
  40154. * @param name Defines the name of the parser
  40155. * @returns the requested parser or null
  40156. */
  40157. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40158. /**
  40159. * Parser json data and populate both a scene and its associated container object
  40160. * @param jsonData Defines the data to parse
  40161. * @param scene Defines the scene to parse the data for
  40162. * @param container Defines the container attached to the parsing sequence
  40163. * @param rootUrl Defines the root url of the data
  40164. */
  40165. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40166. /**
  40167. * Gets the list of root nodes (ie. nodes with no parent)
  40168. */
  40169. rootNodes: Node[];
  40170. /** All of the cameras added to this scene
  40171. * @see http://doc.babylonjs.com/babylon101/cameras
  40172. */
  40173. cameras: Camera[];
  40174. /**
  40175. * All of the lights added to this scene
  40176. * @see http://doc.babylonjs.com/babylon101/lights
  40177. */
  40178. lights: Light[];
  40179. /**
  40180. * All of the (abstract) meshes added to this scene
  40181. */
  40182. meshes: AbstractMesh[];
  40183. /**
  40184. * The list of skeletons added to the scene
  40185. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40186. */
  40187. skeletons: Skeleton[];
  40188. /**
  40189. * All of the particle systems added to this scene
  40190. * @see http://doc.babylonjs.com/babylon101/particles
  40191. */
  40192. particleSystems: IParticleSystem[];
  40193. /**
  40194. * Gets a list of Animations associated with the scene
  40195. */
  40196. animations: Animation[];
  40197. /**
  40198. * All of the animation groups added to this scene
  40199. * @see http://doc.babylonjs.com/how_to/group
  40200. */
  40201. animationGroups: AnimationGroup[];
  40202. /**
  40203. * All of the multi-materials added to this scene
  40204. * @see http://doc.babylonjs.com/how_to/multi_materials
  40205. */
  40206. multiMaterials: MultiMaterial[];
  40207. /**
  40208. * All of the materials added to this scene
  40209. * In the context of a Scene, it is not supposed to be modified manually.
  40210. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40211. * Note also that the order of the Material within the array is not significant and might change.
  40212. * @see http://doc.babylonjs.com/babylon101/materials
  40213. */
  40214. materials: Material[];
  40215. /**
  40216. * The list of morph target managers added to the scene
  40217. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40218. */
  40219. morphTargetManagers: MorphTargetManager[];
  40220. /**
  40221. * The list of geometries used in the scene.
  40222. */
  40223. geometries: Geometry[];
  40224. /**
  40225. * All of the tranform nodes added to this scene
  40226. * In the context of a Scene, it is not supposed to be modified manually.
  40227. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40228. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40229. * @see http://doc.babylonjs.com/how_to/transformnode
  40230. */
  40231. transformNodes: TransformNode[];
  40232. /**
  40233. * ActionManagers available on the scene.
  40234. */
  40235. actionManagers: AbstractActionManager[];
  40236. /**
  40237. * Textures to keep.
  40238. */
  40239. textures: BaseTexture[];
  40240. /**
  40241. * Environment texture for the scene
  40242. */
  40243. environmentTexture: Nullable<BaseTexture>;
  40244. /**
  40245. * @returns all meshes, lights, cameras, transformNodes and bones
  40246. */
  40247. getNodes(): Array<Node>;
  40248. }
  40249. }
  40250. declare module BABYLON {
  40251. /**
  40252. * Interface used to define options for Sound class
  40253. */
  40254. export interface ISoundOptions {
  40255. /**
  40256. * Does the sound autoplay once loaded.
  40257. */
  40258. autoplay?: boolean;
  40259. /**
  40260. * Does the sound loop after it finishes playing once.
  40261. */
  40262. loop?: boolean;
  40263. /**
  40264. * Sound's volume
  40265. */
  40266. volume?: number;
  40267. /**
  40268. * Is it a spatial sound?
  40269. */
  40270. spatialSound?: boolean;
  40271. /**
  40272. * Maximum distance to hear that sound
  40273. */
  40274. maxDistance?: number;
  40275. /**
  40276. * Uses user defined attenuation function
  40277. */
  40278. useCustomAttenuation?: boolean;
  40279. /**
  40280. * Define the roll off factor of spatial sounds.
  40281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40282. */
  40283. rolloffFactor?: number;
  40284. /**
  40285. * Define the reference distance the sound should be heard perfectly.
  40286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40287. */
  40288. refDistance?: number;
  40289. /**
  40290. * Define the distance attenuation model the sound will follow.
  40291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40292. */
  40293. distanceModel?: string;
  40294. /**
  40295. * Defines the playback speed (1 by default)
  40296. */
  40297. playbackRate?: number;
  40298. /**
  40299. * Defines if the sound is from a streaming source
  40300. */
  40301. streaming?: boolean;
  40302. /**
  40303. * Defines an optional length (in seconds) inside the sound file
  40304. */
  40305. length?: number;
  40306. /**
  40307. * Defines an optional offset (in seconds) inside the sound file
  40308. */
  40309. offset?: number;
  40310. /**
  40311. * If true, URLs will not be required to state the audio file codec to use.
  40312. */
  40313. skipCodecCheck?: boolean;
  40314. }
  40315. /**
  40316. * Defines a sound that can be played in the application.
  40317. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40319. */
  40320. export class Sound {
  40321. /**
  40322. * The name of the sound in the scene.
  40323. */
  40324. name: string;
  40325. /**
  40326. * Does the sound autoplay once loaded.
  40327. */
  40328. autoplay: boolean;
  40329. /**
  40330. * Does the sound loop after it finishes playing once.
  40331. */
  40332. loop: boolean;
  40333. /**
  40334. * Does the sound use a custom attenuation curve to simulate the falloff
  40335. * happening when the source gets further away from the camera.
  40336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40337. */
  40338. useCustomAttenuation: boolean;
  40339. /**
  40340. * The sound track id this sound belongs to.
  40341. */
  40342. soundTrackId: number;
  40343. /**
  40344. * Is this sound currently played.
  40345. */
  40346. isPlaying: boolean;
  40347. /**
  40348. * Is this sound currently paused.
  40349. */
  40350. isPaused: boolean;
  40351. /**
  40352. * Does this sound enables spatial sound.
  40353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40354. */
  40355. spatialSound: boolean;
  40356. /**
  40357. * Define the reference distance the sound should be heard perfectly.
  40358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40359. */
  40360. refDistance: number;
  40361. /**
  40362. * Define the roll off factor of spatial sounds.
  40363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40364. */
  40365. rolloffFactor: number;
  40366. /**
  40367. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40369. */
  40370. maxDistance: number;
  40371. /**
  40372. * Define the distance attenuation model the sound will follow.
  40373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40374. */
  40375. distanceModel: string;
  40376. /**
  40377. * @hidden
  40378. * Back Compat
  40379. **/
  40380. onended: () => any;
  40381. /**
  40382. * Gets or sets an object used to store user defined information for the sound.
  40383. */
  40384. metadata: any;
  40385. /**
  40386. * Observable event when the current playing sound finishes.
  40387. */
  40388. onEndedObservable: Observable<Sound>;
  40389. private _panningModel;
  40390. private _playbackRate;
  40391. private _streaming;
  40392. private _startTime;
  40393. private _startOffset;
  40394. private _position;
  40395. /** @hidden */
  40396. _positionInEmitterSpace: boolean;
  40397. private _localDirection;
  40398. private _volume;
  40399. private _isReadyToPlay;
  40400. private _isDirectional;
  40401. private _readyToPlayCallback;
  40402. private _audioBuffer;
  40403. private _soundSource;
  40404. private _streamingSource;
  40405. private _soundPanner;
  40406. private _soundGain;
  40407. private _inputAudioNode;
  40408. private _outputAudioNode;
  40409. private _coneInnerAngle;
  40410. private _coneOuterAngle;
  40411. private _coneOuterGain;
  40412. private _scene;
  40413. private _connectedTransformNode;
  40414. private _customAttenuationFunction;
  40415. private _registerFunc;
  40416. private _isOutputConnected;
  40417. private _htmlAudioElement;
  40418. private _urlType;
  40419. private _length?;
  40420. private _offset?;
  40421. /** @hidden */
  40422. static _SceneComponentInitialization: (scene: Scene) => void;
  40423. /**
  40424. * Create a sound and attach it to a scene
  40425. * @param name Name of your sound
  40426. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40427. * @param scene defines the scene the sound belongs to
  40428. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40429. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40430. */
  40431. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40432. /**
  40433. * Release the sound and its associated resources
  40434. */
  40435. dispose(): void;
  40436. /**
  40437. * Gets if the sounds is ready to be played or not.
  40438. * @returns true if ready, otherwise false
  40439. */
  40440. isReady(): boolean;
  40441. private _soundLoaded;
  40442. /**
  40443. * Sets the data of the sound from an audiobuffer
  40444. * @param audioBuffer The audioBuffer containing the data
  40445. */
  40446. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40447. /**
  40448. * Updates the current sounds options such as maxdistance, loop...
  40449. * @param options A JSON object containing values named as the object properties
  40450. */
  40451. updateOptions(options: ISoundOptions): void;
  40452. private _createSpatialParameters;
  40453. private _updateSpatialParameters;
  40454. /**
  40455. * Switch the panning model to HRTF:
  40456. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40458. */
  40459. switchPanningModelToHRTF(): void;
  40460. /**
  40461. * Switch the panning model to Equal Power:
  40462. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40464. */
  40465. switchPanningModelToEqualPower(): void;
  40466. private _switchPanningModel;
  40467. /**
  40468. * Connect this sound to a sound track audio node like gain...
  40469. * @param soundTrackAudioNode the sound track audio node to connect to
  40470. */
  40471. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40472. /**
  40473. * Transform this sound into a directional source
  40474. * @param coneInnerAngle Size of the inner cone in degree
  40475. * @param coneOuterAngle Size of the outer cone in degree
  40476. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40477. */
  40478. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40479. /**
  40480. * Gets or sets the inner angle for the directional cone.
  40481. */
  40482. get directionalConeInnerAngle(): number;
  40483. /**
  40484. * Gets or sets the inner angle for the directional cone.
  40485. */
  40486. set directionalConeInnerAngle(value: number);
  40487. /**
  40488. * Gets or sets the outer angle for the directional cone.
  40489. */
  40490. get directionalConeOuterAngle(): number;
  40491. /**
  40492. * Gets or sets the outer angle for the directional cone.
  40493. */
  40494. set directionalConeOuterAngle(value: number);
  40495. /**
  40496. * Sets the position of the emitter if spatial sound is enabled
  40497. * @param newPosition Defines the new posisiton
  40498. */
  40499. setPosition(newPosition: Vector3): void;
  40500. /**
  40501. * Sets the local direction of the emitter if spatial sound is enabled
  40502. * @param newLocalDirection Defines the new local direction
  40503. */
  40504. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40505. private _updateDirection;
  40506. /** @hidden */
  40507. updateDistanceFromListener(): void;
  40508. /**
  40509. * Sets a new custom attenuation function for the sound.
  40510. * @param callback Defines the function used for the attenuation
  40511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40512. */
  40513. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40514. /**
  40515. * Play the sound
  40516. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40517. * @param offset (optional) Start the sound at a specific time in seconds
  40518. * @param length (optional) Sound duration (in seconds)
  40519. */
  40520. play(time?: number, offset?: number, length?: number): void;
  40521. private _onended;
  40522. /**
  40523. * Stop the sound
  40524. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40525. */
  40526. stop(time?: number): void;
  40527. /**
  40528. * Put the sound in pause
  40529. */
  40530. pause(): void;
  40531. /**
  40532. * Sets a dedicated volume for this sounds
  40533. * @param newVolume Define the new volume of the sound
  40534. * @param time Define time for gradual change to new volume
  40535. */
  40536. setVolume(newVolume: number, time?: number): void;
  40537. /**
  40538. * Set the sound play back rate
  40539. * @param newPlaybackRate Define the playback rate the sound should be played at
  40540. */
  40541. setPlaybackRate(newPlaybackRate: number): void;
  40542. /**
  40543. * Gets the volume of the sound.
  40544. * @returns the volume of the sound
  40545. */
  40546. getVolume(): number;
  40547. /**
  40548. * Attach the sound to a dedicated mesh
  40549. * @param transformNode The transform node to connect the sound with
  40550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40551. */
  40552. attachToMesh(transformNode: TransformNode): void;
  40553. /**
  40554. * Detach the sound from the previously attached mesh
  40555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40556. */
  40557. detachFromMesh(): void;
  40558. private _onRegisterAfterWorldMatrixUpdate;
  40559. /**
  40560. * Clone the current sound in the scene.
  40561. * @returns the new sound clone
  40562. */
  40563. clone(): Nullable<Sound>;
  40564. /**
  40565. * Gets the current underlying audio buffer containing the data
  40566. * @returns the audio buffer
  40567. */
  40568. getAudioBuffer(): Nullable<AudioBuffer>;
  40569. /**
  40570. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40571. * @returns the source node
  40572. */
  40573. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40574. /**
  40575. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40576. * @returns the gain node
  40577. */
  40578. getSoundGain(): Nullable<GainNode>;
  40579. /**
  40580. * Serializes the Sound in a JSON representation
  40581. * @returns the JSON representation of the sound
  40582. */
  40583. serialize(): any;
  40584. /**
  40585. * Parse a JSON representation of a sound to innstantiate in a given scene
  40586. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40587. * @param scene Define the scene the new parsed sound should be created in
  40588. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40589. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40590. * @returns the newly parsed sound
  40591. */
  40592. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40593. }
  40594. }
  40595. declare module BABYLON {
  40596. /**
  40597. * This defines an action helpful to play a defined sound on a triggered action.
  40598. */
  40599. export class PlaySoundAction extends Action {
  40600. private _sound;
  40601. /**
  40602. * Instantiate the action
  40603. * @param triggerOptions defines the trigger options
  40604. * @param sound defines the sound to play
  40605. * @param condition defines the trigger related conditions
  40606. */
  40607. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40608. /** @hidden */
  40609. _prepare(): void;
  40610. /**
  40611. * Execute the action and play the sound.
  40612. */
  40613. execute(): void;
  40614. /**
  40615. * Serializes the actions and its related information.
  40616. * @param parent defines the object to serialize in
  40617. * @returns the serialized object
  40618. */
  40619. serialize(parent: any): any;
  40620. }
  40621. /**
  40622. * This defines an action helpful to stop a defined sound on a triggered action.
  40623. */
  40624. export class StopSoundAction extends Action {
  40625. private _sound;
  40626. /**
  40627. * Instantiate the action
  40628. * @param triggerOptions defines the trigger options
  40629. * @param sound defines the sound to stop
  40630. * @param condition defines the trigger related conditions
  40631. */
  40632. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40633. /** @hidden */
  40634. _prepare(): void;
  40635. /**
  40636. * Execute the action and stop the sound.
  40637. */
  40638. execute(): void;
  40639. /**
  40640. * Serializes the actions and its related information.
  40641. * @param parent defines the object to serialize in
  40642. * @returns the serialized object
  40643. */
  40644. serialize(parent: any): any;
  40645. }
  40646. }
  40647. declare module BABYLON {
  40648. /**
  40649. * This defines an action responsible to change the value of a property
  40650. * by interpolating between its current value and the newly set one once triggered.
  40651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40652. */
  40653. export class InterpolateValueAction extends Action {
  40654. /**
  40655. * Defines the path of the property where the value should be interpolated
  40656. */
  40657. propertyPath: string;
  40658. /**
  40659. * Defines the target value at the end of the interpolation.
  40660. */
  40661. value: any;
  40662. /**
  40663. * Defines the time it will take for the property to interpolate to the value.
  40664. */
  40665. duration: number;
  40666. /**
  40667. * Defines if the other scene animations should be stopped when the action has been triggered
  40668. */
  40669. stopOtherAnimations?: boolean;
  40670. /**
  40671. * Defines a callback raised once the interpolation animation has been done.
  40672. */
  40673. onInterpolationDone?: () => void;
  40674. /**
  40675. * Observable triggered once the interpolation animation has been done.
  40676. */
  40677. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40678. private _target;
  40679. private _effectiveTarget;
  40680. private _property;
  40681. /**
  40682. * Instantiate the action
  40683. * @param triggerOptions defines the trigger options
  40684. * @param target defines the object containing the value to interpolate
  40685. * @param propertyPath defines the path to the property in the target object
  40686. * @param value defines the target value at the end of the interpolation
  40687. * @param duration deines the time it will take for the property to interpolate to the value.
  40688. * @param condition defines the trigger related conditions
  40689. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40690. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40691. */
  40692. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40693. /** @hidden */
  40694. _prepare(): void;
  40695. /**
  40696. * Execute the action starts the value interpolation.
  40697. */
  40698. execute(): void;
  40699. /**
  40700. * Serializes the actions and its related information.
  40701. * @param parent defines the object to serialize in
  40702. * @returns the serialized object
  40703. */
  40704. serialize(parent: any): any;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * Options allowed during the creation of a sound track.
  40710. */
  40711. export interface ISoundTrackOptions {
  40712. /**
  40713. * The volume the sound track should take during creation
  40714. */
  40715. volume?: number;
  40716. /**
  40717. * Define if the sound track is the main sound track of the scene
  40718. */
  40719. mainTrack?: boolean;
  40720. }
  40721. /**
  40722. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40723. * It will be also used in a future release to apply effects on a specific track.
  40724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40725. */
  40726. export class SoundTrack {
  40727. /**
  40728. * The unique identifier of the sound track in the scene.
  40729. */
  40730. id: number;
  40731. /**
  40732. * The list of sounds included in the sound track.
  40733. */
  40734. soundCollection: Array<Sound>;
  40735. private _outputAudioNode;
  40736. private _scene;
  40737. private _connectedAnalyser;
  40738. private _options;
  40739. private _isInitialized;
  40740. /**
  40741. * Creates a new sound track.
  40742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40743. * @param scene Define the scene the sound track belongs to
  40744. * @param options
  40745. */
  40746. constructor(scene: Scene, options?: ISoundTrackOptions);
  40747. private _initializeSoundTrackAudioGraph;
  40748. /**
  40749. * Release the sound track and its associated resources
  40750. */
  40751. dispose(): void;
  40752. /**
  40753. * Adds a sound to this sound track
  40754. * @param sound define the cound to add
  40755. * @ignoreNaming
  40756. */
  40757. AddSound(sound: Sound): void;
  40758. /**
  40759. * Removes a sound to this sound track
  40760. * @param sound define the cound to remove
  40761. * @ignoreNaming
  40762. */
  40763. RemoveSound(sound: Sound): void;
  40764. /**
  40765. * Set a global volume for the full sound track.
  40766. * @param newVolume Define the new volume of the sound track
  40767. */
  40768. setVolume(newVolume: number): void;
  40769. /**
  40770. * Switch the panning model to HRTF:
  40771. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40773. */
  40774. switchPanningModelToHRTF(): void;
  40775. /**
  40776. * Switch the panning model to Equal Power:
  40777. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40779. */
  40780. switchPanningModelToEqualPower(): void;
  40781. /**
  40782. * Connect the sound track to an audio analyser allowing some amazing
  40783. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40785. * @param analyser The analyser to connect to the engine
  40786. */
  40787. connectToAnalyser(analyser: Analyser): void;
  40788. }
  40789. }
  40790. declare module BABYLON {
  40791. interface AbstractScene {
  40792. /**
  40793. * The list of sounds used in the scene.
  40794. */
  40795. sounds: Nullable<Array<Sound>>;
  40796. }
  40797. interface Scene {
  40798. /**
  40799. * @hidden
  40800. * Backing field
  40801. */
  40802. _mainSoundTrack: SoundTrack;
  40803. /**
  40804. * The main sound track played by the scene.
  40805. * It cotains your primary collection of sounds.
  40806. */
  40807. mainSoundTrack: SoundTrack;
  40808. /**
  40809. * The list of sound tracks added to the scene
  40810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40811. */
  40812. soundTracks: Nullable<Array<SoundTrack>>;
  40813. /**
  40814. * Gets a sound using a given name
  40815. * @param name defines the name to search for
  40816. * @return the found sound or null if not found at all.
  40817. */
  40818. getSoundByName(name: string): Nullable<Sound>;
  40819. /**
  40820. * Gets or sets if audio support is enabled
  40821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40822. */
  40823. audioEnabled: boolean;
  40824. /**
  40825. * Gets or sets if audio will be output to headphones
  40826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40827. */
  40828. headphone: boolean;
  40829. /**
  40830. * Gets or sets custom audio listener position provider
  40831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40832. */
  40833. audioListenerPositionProvider: Nullable<() => Vector3>;
  40834. /**
  40835. * Gets or sets a refresh rate when using 3D audio positioning
  40836. */
  40837. audioPositioningRefreshRate: number;
  40838. }
  40839. /**
  40840. * Defines the sound scene component responsible to manage any sounds
  40841. * in a given scene.
  40842. */
  40843. export class AudioSceneComponent implements ISceneSerializableComponent {
  40844. /**
  40845. * The component name helpfull to identify the component in the list of scene components.
  40846. */
  40847. readonly name: string;
  40848. /**
  40849. * The scene the component belongs to.
  40850. */
  40851. scene: Scene;
  40852. private _audioEnabled;
  40853. /**
  40854. * Gets whether audio is enabled or not.
  40855. * Please use related enable/disable method to switch state.
  40856. */
  40857. get audioEnabled(): boolean;
  40858. private _headphone;
  40859. /**
  40860. * Gets whether audio is outputing to headphone or not.
  40861. * Please use the according Switch methods to change output.
  40862. */
  40863. get headphone(): boolean;
  40864. /**
  40865. * Gets or sets a refresh rate when using 3D audio positioning
  40866. */
  40867. audioPositioningRefreshRate: number;
  40868. private _audioListenerPositionProvider;
  40869. /**
  40870. * Gets the current audio listener position provider
  40871. */
  40872. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40873. /**
  40874. * Sets a custom listener position for all sounds in the scene
  40875. * By default, this is the position of the first active camera
  40876. */
  40877. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40878. /**
  40879. * Creates a new instance of the component for the given scene
  40880. * @param scene Defines the scene to register the component in
  40881. */
  40882. constructor(scene: Scene);
  40883. /**
  40884. * Registers the component in a given scene
  40885. */
  40886. register(): void;
  40887. /**
  40888. * Rebuilds the elements related to this component in case of
  40889. * context lost for instance.
  40890. */
  40891. rebuild(): void;
  40892. /**
  40893. * Serializes the component data to the specified json object
  40894. * @param serializationObject The object to serialize to
  40895. */
  40896. serialize(serializationObject: any): void;
  40897. /**
  40898. * Adds all the elements from the container to the scene
  40899. * @param container the container holding the elements
  40900. */
  40901. addFromContainer(container: AbstractScene): void;
  40902. /**
  40903. * Removes all the elements in the container from the scene
  40904. * @param container contains the elements to remove
  40905. * @param dispose if the removed element should be disposed (default: false)
  40906. */
  40907. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40908. /**
  40909. * Disposes the component and the associated ressources.
  40910. */
  40911. dispose(): void;
  40912. /**
  40913. * Disables audio in the associated scene.
  40914. */
  40915. disableAudio(): void;
  40916. /**
  40917. * Enables audio in the associated scene.
  40918. */
  40919. enableAudio(): void;
  40920. /**
  40921. * Switch audio to headphone output.
  40922. */
  40923. switchAudioModeForHeadphones(): void;
  40924. /**
  40925. * Switch audio to normal speakers.
  40926. */
  40927. switchAudioModeForNormalSpeakers(): void;
  40928. private _cachedCameraDirection;
  40929. private _cachedCameraPosition;
  40930. private _lastCheck;
  40931. private _afterRender;
  40932. }
  40933. }
  40934. declare module BABYLON {
  40935. /**
  40936. * Wraps one or more Sound objects and selects one with random weight for playback.
  40937. */
  40938. export class WeightedSound {
  40939. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40940. loop: boolean;
  40941. private _coneInnerAngle;
  40942. private _coneOuterAngle;
  40943. private _volume;
  40944. /** A Sound is currently playing. */
  40945. isPlaying: boolean;
  40946. /** A Sound is currently paused. */
  40947. isPaused: boolean;
  40948. private _sounds;
  40949. private _weights;
  40950. private _currentIndex?;
  40951. /**
  40952. * Creates a new WeightedSound from the list of sounds given.
  40953. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40954. * @param sounds Array of Sounds that will be selected from.
  40955. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40956. */
  40957. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40958. /**
  40959. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40960. */
  40961. get directionalConeInnerAngle(): number;
  40962. /**
  40963. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40964. */
  40965. set directionalConeInnerAngle(value: number);
  40966. /**
  40967. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40968. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40969. */
  40970. get directionalConeOuterAngle(): number;
  40971. /**
  40972. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40973. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40974. */
  40975. set directionalConeOuterAngle(value: number);
  40976. /**
  40977. * Playback volume.
  40978. */
  40979. get volume(): number;
  40980. /**
  40981. * Playback volume.
  40982. */
  40983. set volume(value: number);
  40984. private _onended;
  40985. /**
  40986. * Suspend playback
  40987. */
  40988. pause(): void;
  40989. /**
  40990. * Stop playback
  40991. */
  40992. stop(): void;
  40993. /**
  40994. * Start playback.
  40995. * @param startOffset Position the clip head at a specific time in seconds.
  40996. */
  40997. play(startOffset?: number): void;
  40998. }
  40999. }
  41000. declare module BABYLON {
  41001. /**
  41002. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41003. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41004. */
  41005. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41006. /**
  41007. * Gets the name of the behavior.
  41008. */
  41009. get name(): string;
  41010. /**
  41011. * The easing function used by animations
  41012. */
  41013. static EasingFunction: BackEase;
  41014. /**
  41015. * The easing mode used by animations
  41016. */
  41017. static EasingMode: number;
  41018. /**
  41019. * The duration of the animation, in milliseconds
  41020. */
  41021. transitionDuration: number;
  41022. /**
  41023. * Length of the distance animated by the transition when lower radius is reached
  41024. */
  41025. lowerRadiusTransitionRange: number;
  41026. /**
  41027. * Length of the distance animated by the transition when upper radius is reached
  41028. */
  41029. upperRadiusTransitionRange: number;
  41030. private _autoTransitionRange;
  41031. /**
  41032. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41033. */
  41034. get autoTransitionRange(): boolean;
  41035. /**
  41036. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41037. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41038. */
  41039. set autoTransitionRange(value: boolean);
  41040. private _attachedCamera;
  41041. private _onAfterCheckInputsObserver;
  41042. private _onMeshTargetChangedObserver;
  41043. /**
  41044. * Initializes the behavior.
  41045. */
  41046. init(): void;
  41047. /**
  41048. * Attaches the behavior to its arc rotate camera.
  41049. * @param camera Defines the camera to attach the behavior to
  41050. */
  41051. attach(camera: ArcRotateCamera): void;
  41052. /**
  41053. * Detaches the behavior from its current arc rotate camera.
  41054. */
  41055. detach(): void;
  41056. private _radiusIsAnimating;
  41057. private _radiusBounceTransition;
  41058. private _animatables;
  41059. private _cachedWheelPrecision;
  41060. /**
  41061. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41062. * @param radiusLimit The limit to check against.
  41063. * @return Bool to indicate if at limit.
  41064. */
  41065. private _isRadiusAtLimit;
  41066. /**
  41067. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41068. * @param radiusDelta The delta by which to animate to. Can be negative.
  41069. */
  41070. private _applyBoundRadiusAnimation;
  41071. /**
  41072. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41073. */
  41074. protected _clearAnimationLocks(): void;
  41075. /**
  41076. * Stops and removes all animations that have been applied to the camera
  41077. */
  41078. stopAllAnimations(): void;
  41079. }
  41080. }
  41081. declare module BABYLON {
  41082. /**
  41083. * 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.
  41084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41085. */
  41086. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41087. /**
  41088. * Gets the name of the behavior.
  41089. */
  41090. get name(): string;
  41091. private _mode;
  41092. private _radiusScale;
  41093. private _positionScale;
  41094. private _defaultElevation;
  41095. private _elevationReturnTime;
  41096. private _elevationReturnWaitTime;
  41097. private _zoomStopsAnimation;
  41098. private _framingTime;
  41099. /**
  41100. * The easing function used by animations
  41101. */
  41102. static EasingFunction: ExponentialEase;
  41103. /**
  41104. * The easing mode used by animations
  41105. */
  41106. static EasingMode: number;
  41107. /**
  41108. * Sets the current mode used by the behavior
  41109. */
  41110. set mode(mode: number);
  41111. /**
  41112. * Gets current mode used by the behavior.
  41113. */
  41114. get mode(): number;
  41115. /**
  41116. * Sets the scale applied to the radius (1 by default)
  41117. */
  41118. set radiusScale(radius: number);
  41119. /**
  41120. * Gets the scale applied to the radius
  41121. */
  41122. get radiusScale(): number;
  41123. /**
  41124. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41125. */
  41126. set positionScale(scale: number);
  41127. /**
  41128. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41129. */
  41130. get positionScale(): number;
  41131. /**
  41132. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41133. * behaviour is triggered, in radians.
  41134. */
  41135. set defaultElevation(elevation: number);
  41136. /**
  41137. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41138. * behaviour is triggered, in radians.
  41139. */
  41140. get defaultElevation(): number;
  41141. /**
  41142. * Sets the time (in milliseconds) taken to return to the default beta position.
  41143. * Negative value indicates camera should not return to default.
  41144. */
  41145. set elevationReturnTime(speed: number);
  41146. /**
  41147. * Gets the time (in milliseconds) taken to return to the default beta position.
  41148. * Negative value indicates camera should not return to default.
  41149. */
  41150. get elevationReturnTime(): number;
  41151. /**
  41152. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41153. */
  41154. set elevationReturnWaitTime(time: number);
  41155. /**
  41156. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41157. */
  41158. get elevationReturnWaitTime(): number;
  41159. /**
  41160. * Sets the flag that indicates if user zooming should stop animation.
  41161. */
  41162. set zoomStopsAnimation(flag: boolean);
  41163. /**
  41164. * Gets the flag that indicates if user zooming should stop animation.
  41165. */
  41166. get zoomStopsAnimation(): boolean;
  41167. /**
  41168. * Sets the transition time when framing the mesh, in milliseconds
  41169. */
  41170. set framingTime(time: number);
  41171. /**
  41172. * Gets the transition time when framing the mesh, in milliseconds
  41173. */
  41174. get framingTime(): number;
  41175. /**
  41176. * Define if the behavior should automatically change the configured
  41177. * camera limits and sensibilities.
  41178. */
  41179. autoCorrectCameraLimitsAndSensibility: boolean;
  41180. private _onPrePointerObservableObserver;
  41181. private _onAfterCheckInputsObserver;
  41182. private _onMeshTargetChangedObserver;
  41183. private _attachedCamera;
  41184. private _isPointerDown;
  41185. private _lastInteractionTime;
  41186. /**
  41187. * Initializes the behavior.
  41188. */
  41189. init(): void;
  41190. /**
  41191. * Attaches the behavior to its arc rotate camera.
  41192. * @param camera Defines the camera to attach the behavior to
  41193. */
  41194. attach(camera: ArcRotateCamera): void;
  41195. /**
  41196. * Detaches the behavior from its current arc rotate camera.
  41197. */
  41198. detach(): void;
  41199. private _animatables;
  41200. private _betaIsAnimating;
  41201. private _betaTransition;
  41202. private _radiusTransition;
  41203. private _vectorTransition;
  41204. /**
  41205. * Targets the given mesh and updates zoom level accordingly.
  41206. * @param mesh The mesh to target.
  41207. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41208. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41209. */
  41210. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41211. /**
  41212. * Targets the given mesh with its children and updates zoom level accordingly.
  41213. * @param mesh The mesh to target.
  41214. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41215. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41216. */
  41217. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41218. /**
  41219. * Targets the given meshes with their children and updates zoom level accordingly.
  41220. * @param meshes The mesh to target.
  41221. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41222. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41223. */
  41224. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41225. /**
  41226. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41227. * @param minimumWorld Determines the smaller position of the bounding box extend
  41228. * @param maximumWorld Determines the bigger position of the bounding box extend
  41229. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41230. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41231. */
  41232. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41233. /**
  41234. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41235. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41236. * frustum width.
  41237. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41238. * to fully enclose the mesh in the viewing frustum.
  41239. */
  41240. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41241. /**
  41242. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41243. * is automatically returned to its default position (expected to be above ground plane).
  41244. */
  41245. private _maintainCameraAboveGround;
  41246. /**
  41247. * Returns the frustum slope based on the canvas ratio and camera FOV
  41248. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41249. */
  41250. private _getFrustumSlope;
  41251. /**
  41252. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41253. */
  41254. private _clearAnimationLocks;
  41255. /**
  41256. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41257. */
  41258. private _applyUserInteraction;
  41259. /**
  41260. * Stops and removes all animations that have been applied to the camera
  41261. */
  41262. stopAllAnimations(): void;
  41263. /**
  41264. * Gets a value indicating if the user is moving the camera
  41265. */
  41266. get isUserIsMoving(): boolean;
  41267. /**
  41268. * The camera can move all the way towards the mesh.
  41269. */
  41270. static IgnoreBoundsSizeMode: number;
  41271. /**
  41272. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41273. */
  41274. static FitFrustumSidesMode: number;
  41275. }
  41276. }
  41277. declare module BABYLON {
  41278. /**
  41279. * Base class for Camera Pointer Inputs.
  41280. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41281. * for example usage.
  41282. */
  41283. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41284. /**
  41285. * Defines the camera the input is attached to.
  41286. */
  41287. abstract camera: Camera;
  41288. /**
  41289. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41290. */
  41291. protected _altKey: boolean;
  41292. protected _ctrlKey: boolean;
  41293. protected _metaKey: boolean;
  41294. protected _shiftKey: boolean;
  41295. /**
  41296. * Which mouse buttons were pressed at time of last mouse event.
  41297. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41298. */
  41299. protected _buttonsPressed: number;
  41300. /**
  41301. * Defines the buttons associated with the input to handle camera move.
  41302. */
  41303. buttons: number[];
  41304. /**
  41305. * Attach the input controls to a specific dom element to get the input from.
  41306. * @param element Defines the element the controls should be listened from
  41307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41308. */
  41309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41310. /**
  41311. * Detach the current controls from the specified dom element.
  41312. * @param element Defines the element to stop listening the inputs from
  41313. */
  41314. detachControl(element: Nullable<HTMLElement>): void;
  41315. /**
  41316. * Gets the class name of the current input.
  41317. * @returns the class name
  41318. */
  41319. getClassName(): string;
  41320. /**
  41321. * Get the friendly name associated with the input class.
  41322. * @returns the input friendly name
  41323. */
  41324. getSimpleName(): string;
  41325. /**
  41326. * Called on pointer POINTERDOUBLETAP event.
  41327. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41328. */
  41329. protected onDoubleTap(type: string): void;
  41330. /**
  41331. * Called on pointer POINTERMOVE event if only a single touch is active.
  41332. * Override this method to provide functionality.
  41333. */
  41334. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41335. /**
  41336. * Called on pointer POINTERMOVE event if multiple touches are active.
  41337. * Override this method to provide functionality.
  41338. */
  41339. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41340. /**
  41341. * Called on JS contextmenu event.
  41342. * Override this method to provide functionality.
  41343. */
  41344. protected onContextMenu(evt: PointerEvent): void;
  41345. /**
  41346. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41347. * press.
  41348. * Override this method to provide functionality.
  41349. */
  41350. protected onButtonDown(evt: PointerEvent): void;
  41351. /**
  41352. * Called each time a new POINTERUP event occurs. Ie, for each button
  41353. * release.
  41354. * Override this method to provide functionality.
  41355. */
  41356. protected onButtonUp(evt: PointerEvent): void;
  41357. /**
  41358. * Called when window becomes inactive.
  41359. * Override this method to provide functionality.
  41360. */
  41361. protected onLostFocus(): void;
  41362. private _pointerInput;
  41363. private _observer;
  41364. private _onLostFocus;
  41365. private pointA;
  41366. private pointB;
  41367. }
  41368. }
  41369. declare module BABYLON {
  41370. /**
  41371. * Manage the pointers inputs to control an arc rotate camera.
  41372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41373. */
  41374. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41375. /**
  41376. * Defines the camera the input is attached to.
  41377. */
  41378. camera: ArcRotateCamera;
  41379. /**
  41380. * Gets the class name of the current input.
  41381. * @returns the class name
  41382. */
  41383. getClassName(): string;
  41384. /**
  41385. * Defines the buttons associated with the input to handle camera move.
  41386. */
  41387. buttons: number[];
  41388. /**
  41389. * Defines the pointer angular sensibility along the X axis or how fast is
  41390. * the camera rotating.
  41391. */
  41392. angularSensibilityX: number;
  41393. /**
  41394. * Defines the pointer angular sensibility along the Y axis or how fast is
  41395. * the camera rotating.
  41396. */
  41397. angularSensibilityY: number;
  41398. /**
  41399. * Defines the pointer pinch precision or how fast is the camera zooming.
  41400. */
  41401. pinchPrecision: number;
  41402. /**
  41403. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41404. * from 0.
  41405. * It defines the percentage of current camera.radius to use as delta when
  41406. * pinch zoom is used.
  41407. */
  41408. pinchDeltaPercentage: number;
  41409. /**
  41410. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41411. * that any object in the plane at the camera's target point will scale
  41412. * perfectly with finger motion.
  41413. * Overrides pinchDeltaPercentage and pinchPrecision.
  41414. */
  41415. useNaturalPinchZoom: boolean;
  41416. /**
  41417. * Defines the pointer panning sensibility or how fast is the camera moving.
  41418. */
  41419. panningSensibility: number;
  41420. /**
  41421. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41422. */
  41423. multiTouchPanning: boolean;
  41424. /**
  41425. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41426. * zoom (pinch) through multitouch.
  41427. */
  41428. multiTouchPanAndZoom: boolean;
  41429. /**
  41430. * Revers pinch action direction.
  41431. */
  41432. pinchInwards: boolean;
  41433. private _isPanClick;
  41434. private _twoFingerActivityCount;
  41435. private _isPinching;
  41436. /**
  41437. * Called on pointer POINTERMOVE event if only a single touch is active.
  41438. */
  41439. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41440. /**
  41441. * Called on pointer POINTERDOUBLETAP event.
  41442. */
  41443. protected onDoubleTap(type: string): void;
  41444. /**
  41445. * Called on pointer POINTERMOVE event if multiple touches are active.
  41446. */
  41447. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41448. /**
  41449. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41450. * press.
  41451. */
  41452. protected onButtonDown(evt: PointerEvent): void;
  41453. /**
  41454. * Called each time a new POINTERUP event occurs. Ie, for each button
  41455. * release.
  41456. */
  41457. protected onButtonUp(evt: PointerEvent): void;
  41458. /**
  41459. * Called when window becomes inactive.
  41460. */
  41461. protected onLostFocus(): void;
  41462. }
  41463. }
  41464. declare module BABYLON {
  41465. /**
  41466. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41468. */
  41469. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41470. /**
  41471. * Defines the camera the input is attached to.
  41472. */
  41473. camera: ArcRotateCamera;
  41474. /**
  41475. * Defines the list of key codes associated with the up action (increase alpha)
  41476. */
  41477. keysUp: number[];
  41478. /**
  41479. * Defines the list of key codes associated with the down action (decrease alpha)
  41480. */
  41481. keysDown: number[];
  41482. /**
  41483. * Defines the list of key codes associated with the left action (increase beta)
  41484. */
  41485. keysLeft: number[];
  41486. /**
  41487. * Defines the list of key codes associated with the right action (decrease beta)
  41488. */
  41489. keysRight: number[];
  41490. /**
  41491. * Defines the list of key codes associated with the reset action.
  41492. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41493. */
  41494. keysReset: number[];
  41495. /**
  41496. * Defines the panning sensibility of the inputs.
  41497. * (How fast is the camera panning)
  41498. */
  41499. panningSensibility: number;
  41500. /**
  41501. * Defines the zooming sensibility of the inputs.
  41502. * (How fast is the camera zooming)
  41503. */
  41504. zoomingSensibility: number;
  41505. /**
  41506. * Defines whether maintaining the alt key down switch the movement mode from
  41507. * orientation to zoom.
  41508. */
  41509. useAltToZoom: boolean;
  41510. /**
  41511. * Rotation speed of the camera
  41512. */
  41513. angularSpeed: number;
  41514. private _keys;
  41515. private _ctrlPressed;
  41516. private _altPressed;
  41517. private _onCanvasBlurObserver;
  41518. private _onKeyboardObserver;
  41519. private _engine;
  41520. private _scene;
  41521. /**
  41522. * Attach the input controls to a specific dom element to get the input from.
  41523. * @param element Defines the element the controls should be listened from
  41524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41525. */
  41526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41527. /**
  41528. * Detach the current controls from the specified dom element.
  41529. * @param element Defines the element to stop listening the inputs from
  41530. */
  41531. detachControl(element: Nullable<HTMLElement>): void;
  41532. /**
  41533. * Update the current camera state depending on the inputs that have been used this frame.
  41534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41535. */
  41536. checkInputs(): void;
  41537. /**
  41538. * Gets the class name of the current intput.
  41539. * @returns the class name
  41540. */
  41541. getClassName(): string;
  41542. /**
  41543. * Get the friendly name associated with the input class.
  41544. * @returns the input friendly name
  41545. */
  41546. getSimpleName(): string;
  41547. }
  41548. }
  41549. declare module BABYLON {
  41550. /**
  41551. * Manage the mouse wheel inputs to control an arc rotate camera.
  41552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41553. */
  41554. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41555. /**
  41556. * Defines the camera the input is attached to.
  41557. */
  41558. camera: ArcRotateCamera;
  41559. /**
  41560. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41561. */
  41562. wheelPrecision: number;
  41563. /**
  41564. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41565. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41566. */
  41567. wheelDeltaPercentage: number;
  41568. private _wheel;
  41569. private _observer;
  41570. private computeDeltaFromMouseWheelLegacyEvent;
  41571. /**
  41572. * Attach the input controls to a specific dom element to get the input from.
  41573. * @param element Defines the element the controls should be listened from
  41574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41575. */
  41576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41577. /**
  41578. * Detach the current controls from the specified dom element.
  41579. * @param element Defines the element to stop listening the inputs from
  41580. */
  41581. detachControl(element: Nullable<HTMLElement>): void;
  41582. /**
  41583. * Gets the class name of the current intput.
  41584. * @returns the class name
  41585. */
  41586. getClassName(): string;
  41587. /**
  41588. * Get the friendly name associated with the input class.
  41589. * @returns the input friendly name
  41590. */
  41591. getSimpleName(): string;
  41592. }
  41593. }
  41594. declare module BABYLON {
  41595. /**
  41596. * Default Inputs manager for the ArcRotateCamera.
  41597. * It groups all the default supported inputs for ease of use.
  41598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41599. */
  41600. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41601. /**
  41602. * Instantiates a new ArcRotateCameraInputsManager.
  41603. * @param camera Defines the camera the inputs belong to
  41604. */
  41605. constructor(camera: ArcRotateCamera);
  41606. /**
  41607. * Add mouse wheel input support to the input manager.
  41608. * @returns the current input manager
  41609. */
  41610. addMouseWheel(): ArcRotateCameraInputsManager;
  41611. /**
  41612. * Add pointers input support to the input manager.
  41613. * @returns the current input manager
  41614. */
  41615. addPointers(): ArcRotateCameraInputsManager;
  41616. /**
  41617. * Add keyboard input support to the input manager.
  41618. * @returns the current input manager
  41619. */
  41620. addKeyboard(): ArcRotateCameraInputsManager;
  41621. }
  41622. }
  41623. declare module BABYLON {
  41624. /**
  41625. * This represents an orbital type of camera.
  41626. *
  41627. * 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.
  41628. * 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.
  41629. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41630. */
  41631. export class ArcRotateCamera extends TargetCamera {
  41632. /**
  41633. * Defines the rotation angle of the camera along the longitudinal axis.
  41634. */
  41635. alpha: number;
  41636. /**
  41637. * Defines the rotation angle of the camera along the latitudinal axis.
  41638. */
  41639. beta: number;
  41640. /**
  41641. * Defines the radius of the camera from it s target point.
  41642. */
  41643. radius: number;
  41644. protected _target: Vector3;
  41645. protected _targetHost: Nullable<AbstractMesh>;
  41646. /**
  41647. * Defines the target point of the camera.
  41648. * The camera looks towards it form the radius distance.
  41649. */
  41650. get target(): Vector3;
  41651. set target(value: Vector3);
  41652. /**
  41653. * Define the current local position of the camera in the scene
  41654. */
  41655. get position(): Vector3;
  41656. set position(newPosition: Vector3);
  41657. protected _upVector: Vector3;
  41658. protected _upToYMatrix: Matrix;
  41659. protected _YToUpMatrix: Matrix;
  41660. /**
  41661. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41662. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41663. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41664. */
  41665. set upVector(vec: Vector3);
  41666. get upVector(): Vector3;
  41667. /**
  41668. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41669. */
  41670. setMatUp(): void;
  41671. /**
  41672. * Current inertia value on the longitudinal axis.
  41673. * The bigger this number the longer it will take for the camera to stop.
  41674. */
  41675. inertialAlphaOffset: number;
  41676. /**
  41677. * Current inertia value on the latitudinal axis.
  41678. * The bigger this number the longer it will take for the camera to stop.
  41679. */
  41680. inertialBetaOffset: number;
  41681. /**
  41682. * Current inertia value on the radius axis.
  41683. * The bigger this number the longer it will take for the camera to stop.
  41684. */
  41685. inertialRadiusOffset: number;
  41686. /**
  41687. * Minimum allowed angle on the longitudinal axis.
  41688. * This can help limiting how the Camera is able to move in the scene.
  41689. */
  41690. lowerAlphaLimit: Nullable<number>;
  41691. /**
  41692. * Maximum allowed angle on the longitudinal axis.
  41693. * This can help limiting how the Camera is able to move in the scene.
  41694. */
  41695. upperAlphaLimit: Nullable<number>;
  41696. /**
  41697. * Minimum allowed angle on the latitudinal axis.
  41698. * This can help limiting how the Camera is able to move in the scene.
  41699. */
  41700. lowerBetaLimit: number;
  41701. /**
  41702. * Maximum allowed angle on the latitudinal axis.
  41703. * This can help limiting how the Camera is able to move in the scene.
  41704. */
  41705. upperBetaLimit: number;
  41706. /**
  41707. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41708. * This can help limiting how the Camera is able to move in the scene.
  41709. */
  41710. lowerRadiusLimit: Nullable<number>;
  41711. /**
  41712. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41713. * This can help limiting how the Camera is able to move in the scene.
  41714. */
  41715. upperRadiusLimit: Nullable<number>;
  41716. /**
  41717. * Defines the current inertia value used during panning of the camera along the X axis.
  41718. */
  41719. inertialPanningX: number;
  41720. /**
  41721. * Defines the current inertia value used during panning of the camera along the Y axis.
  41722. */
  41723. inertialPanningY: number;
  41724. /**
  41725. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41726. * Basically if your fingers moves away from more than this distance you will be considered
  41727. * in pinch mode.
  41728. */
  41729. pinchToPanMaxDistance: number;
  41730. /**
  41731. * Defines the maximum distance the camera can pan.
  41732. * This could help keeping the cammera always in your scene.
  41733. */
  41734. panningDistanceLimit: Nullable<number>;
  41735. /**
  41736. * Defines the target of the camera before paning.
  41737. */
  41738. panningOriginTarget: Vector3;
  41739. /**
  41740. * Defines the value of the inertia used during panning.
  41741. * 0 would mean stop inertia and one would mean no decelleration at all.
  41742. */
  41743. panningInertia: number;
  41744. /**
  41745. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41746. */
  41747. get angularSensibilityX(): number;
  41748. set angularSensibilityX(value: number);
  41749. /**
  41750. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41751. */
  41752. get angularSensibilityY(): number;
  41753. set angularSensibilityY(value: number);
  41754. /**
  41755. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41756. */
  41757. get pinchPrecision(): number;
  41758. set pinchPrecision(value: number);
  41759. /**
  41760. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41761. * It will be used instead of pinchDeltaPrecision if different from 0.
  41762. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41763. */
  41764. get pinchDeltaPercentage(): number;
  41765. set pinchDeltaPercentage(value: number);
  41766. /**
  41767. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41768. * and pinch delta percentage.
  41769. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41770. * that any object in the plane at the camera's target point will scale
  41771. * perfectly with finger motion.
  41772. */
  41773. get useNaturalPinchZoom(): boolean;
  41774. set useNaturalPinchZoom(value: boolean);
  41775. /**
  41776. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41777. */
  41778. get panningSensibility(): number;
  41779. set panningSensibility(value: number);
  41780. /**
  41781. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41782. */
  41783. get keysUp(): number[];
  41784. set keysUp(value: number[]);
  41785. /**
  41786. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41787. */
  41788. get keysDown(): number[];
  41789. set keysDown(value: number[]);
  41790. /**
  41791. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41792. */
  41793. get keysLeft(): number[];
  41794. set keysLeft(value: number[]);
  41795. /**
  41796. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41797. */
  41798. get keysRight(): number[];
  41799. set keysRight(value: number[]);
  41800. /**
  41801. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41802. */
  41803. get wheelPrecision(): number;
  41804. set wheelPrecision(value: number);
  41805. /**
  41806. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41807. * It will be used instead of pinchDeltaPrecision if different from 0.
  41808. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41809. */
  41810. get wheelDeltaPercentage(): number;
  41811. set wheelDeltaPercentage(value: number);
  41812. /**
  41813. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41814. */
  41815. zoomOnFactor: number;
  41816. /**
  41817. * Defines a screen offset for the camera position.
  41818. */
  41819. targetScreenOffset: Vector2;
  41820. /**
  41821. * Allows the camera to be completely reversed.
  41822. * If false the camera can not arrive upside down.
  41823. */
  41824. allowUpsideDown: boolean;
  41825. /**
  41826. * Define if double tap/click is used to restore the previously saved state of the camera.
  41827. */
  41828. useInputToRestoreState: boolean;
  41829. /** @hidden */
  41830. _viewMatrix: Matrix;
  41831. /** @hidden */
  41832. _useCtrlForPanning: boolean;
  41833. /** @hidden */
  41834. _panningMouseButton: number;
  41835. /**
  41836. * Defines the input associated to the camera.
  41837. */
  41838. inputs: ArcRotateCameraInputsManager;
  41839. /** @hidden */
  41840. _reset: () => void;
  41841. /**
  41842. * Defines the allowed panning axis.
  41843. */
  41844. panningAxis: Vector3;
  41845. protected _localDirection: Vector3;
  41846. protected _transformedDirection: Vector3;
  41847. private _bouncingBehavior;
  41848. /**
  41849. * Gets the bouncing behavior of the camera if it has been enabled.
  41850. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41851. */
  41852. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41853. /**
  41854. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41855. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41856. */
  41857. get useBouncingBehavior(): boolean;
  41858. set useBouncingBehavior(value: boolean);
  41859. private _framingBehavior;
  41860. /**
  41861. * Gets the framing behavior of the camera if it has been enabled.
  41862. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41863. */
  41864. get framingBehavior(): Nullable<FramingBehavior>;
  41865. /**
  41866. * Defines if the framing behavior of the camera is enabled on the camera.
  41867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41868. */
  41869. get useFramingBehavior(): boolean;
  41870. set useFramingBehavior(value: boolean);
  41871. private _autoRotationBehavior;
  41872. /**
  41873. * Gets the auto rotation behavior of the camera if it has been enabled.
  41874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41875. */
  41876. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41877. /**
  41878. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41879. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41880. */
  41881. get useAutoRotationBehavior(): boolean;
  41882. set useAutoRotationBehavior(value: boolean);
  41883. /**
  41884. * Observable triggered when the mesh target has been changed on the camera.
  41885. */
  41886. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41887. /**
  41888. * Event raised when the camera is colliding with a mesh.
  41889. */
  41890. onCollide: (collidedMesh: AbstractMesh) => void;
  41891. /**
  41892. * Defines whether the camera should check collision with the objects oh the scene.
  41893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41894. */
  41895. checkCollisions: boolean;
  41896. /**
  41897. * Defines the collision radius of the camera.
  41898. * This simulates a sphere around the camera.
  41899. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41900. */
  41901. collisionRadius: Vector3;
  41902. protected _collider: Collider;
  41903. protected _previousPosition: Vector3;
  41904. protected _collisionVelocity: Vector3;
  41905. protected _newPosition: Vector3;
  41906. protected _previousAlpha: number;
  41907. protected _previousBeta: number;
  41908. protected _previousRadius: number;
  41909. protected _collisionTriggered: boolean;
  41910. protected _targetBoundingCenter: Nullable<Vector3>;
  41911. private _computationVector;
  41912. /**
  41913. * Instantiates a new ArcRotateCamera in a given scene
  41914. * @param name Defines the name of the camera
  41915. * @param alpha Defines the camera rotation along the logitudinal axis
  41916. * @param beta Defines the camera rotation along the latitudinal axis
  41917. * @param radius Defines the camera distance from its target
  41918. * @param target Defines the camera target
  41919. * @param scene Defines the scene the camera belongs to
  41920. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41921. */
  41922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41923. /** @hidden */
  41924. _initCache(): void;
  41925. /** @hidden */
  41926. _updateCache(ignoreParentClass?: boolean): void;
  41927. protected _getTargetPosition(): Vector3;
  41928. private _storedAlpha;
  41929. private _storedBeta;
  41930. private _storedRadius;
  41931. private _storedTarget;
  41932. private _storedTargetScreenOffset;
  41933. /**
  41934. * Stores the current state of the camera (alpha, beta, radius and target)
  41935. * @returns the camera itself
  41936. */
  41937. storeState(): Camera;
  41938. /**
  41939. * @hidden
  41940. * Restored camera state. You must call storeState() first
  41941. */
  41942. _restoreStateValues(): boolean;
  41943. /** @hidden */
  41944. _isSynchronizedViewMatrix(): boolean;
  41945. /**
  41946. * Attached controls to the current camera.
  41947. * @param element Defines the element the controls should be listened from
  41948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41949. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41950. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41951. */
  41952. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41953. /**
  41954. * Detach the current controls from the camera.
  41955. * The camera will stop reacting to inputs.
  41956. * @param element Defines the element to stop listening the inputs from
  41957. */
  41958. detachControl(element: HTMLElement): void;
  41959. /** @hidden */
  41960. _checkInputs(): void;
  41961. protected _checkLimits(): void;
  41962. /**
  41963. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41964. */
  41965. rebuildAnglesAndRadius(): void;
  41966. /**
  41967. * Use a position to define the current camera related information like alpha, beta and radius
  41968. * @param position Defines the position to set the camera at
  41969. */
  41970. setPosition(position: Vector3): void;
  41971. /**
  41972. * Defines the target the camera should look at.
  41973. * This will automatically adapt alpha beta and radius to fit within the new target.
  41974. * @param target Defines the new target as a Vector or a mesh
  41975. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41976. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41977. */
  41978. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41979. /** @hidden */
  41980. _getViewMatrix(): Matrix;
  41981. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41982. /**
  41983. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41984. * @param meshes Defines the mesh to zoom on
  41985. * @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)
  41986. */
  41987. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41988. /**
  41989. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41990. * The target will be changed but the radius
  41991. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41992. * @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)
  41993. */
  41994. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41995. min: Vector3;
  41996. max: Vector3;
  41997. distance: number;
  41998. }, doNotUpdateMaxZ?: boolean): void;
  41999. /**
  42000. * @override
  42001. * Override Camera.createRigCamera
  42002. */
  42003. createRigCamera(name: string, cameraIndex: number): Camera;
  42004. /**
  42005. * @hidden
  42006. * @override
  42007. * Override Camera._updateRigCameras
  42008. */
  42009. _updateRigCameras(): void;
  42010. /**
  42011. * Destroy the camera and release the current resources hold by it.
  42012. */
  42013. dispose(): void;
  42014. /**
  42015. * Gets the current object class name.
  42016. * @return the class name
  42017. */
  42018. getClassName(): string;
  42019. }
  42020. }
  42021. declare module BABYLON {
  42022. /**
  42023. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42025. */
  42026. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42027. /**
  42028. * Gets the name of the behavior.
  42029. */
  42030. get name(): string;
  42031. private _zoomStopsAnimation;
  42032. private _idleRotationSpeed;
  42033. private _idleRotationWaitTime;
  42034. private _idleRotationSpinupTime;
  42035. /**
  42036. * Sets the flag that indicates if user zooming should stop animation.
  42037. */
  42038. set zoomStopsAnimation(flag: boolean);
  42039. /**
  42040. * Gets the flag that indicates if user zooming should stop animation.
  42041. */
  42042. get zoomStopsAnimation(): boolean;
  42043. /**
  42044. * Sets the default speed at which the camera rotates around the model.
  42045. */
  42046. set idleRotationSpeed(speed: number);
  42047. /**
  42048. * Gets the default speed at which the camera rotates around the model.
  42049. */
  42050. get idleRotationSpeed(): number;
  42051. /**
  42052. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42053. */
  42054. set idleRotationWaitTime(time: number);
  42055. /**
  42056. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42057. */
  42058. get idleRotationWaitTime(): number;
  42059. /**
  42060. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42061. */
  42062. set idleRotationSpinupTime(time: number);
  42063. /**
  42064. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42065. */
  42066. get idleRotationSpinupTime(): number;
  42067. /**
  42068. * Gets a value indicating if the camera is currently rotating because of this behavior
  42069. */
  42070. get rotationInProgress(): boolean;
  42071. private _onPrePointerObservableObserver;
  42072. private _onAfterCheckInputsObserver;
  42073. private _attachedCamera;
  42074. private _isPointerDown;
  42075. private _lastFrameTime;
  42076. private _lastInteractionTime;
  42077. private _cameraRotationSpeed;
  42078. /**
  42079. * Initializes the behavior.
  42080. */
  42081. init(): void;
  42082. /**
  42083. * Attaches the behavior to its arc rotate camera.
  42084. * @param camera Defines the camera to attach the behavior to
  42085. */
  42086. attach(camera: ArcRotateCamera): void;
  42087. /**
  42088. * Detaches the behavior from its current arc rotate camera.
  42089. */
  42090. detach(): void;
  42091. /**
  42092. * Returns true if user is scrolling.
  42093. * @return true if user is scrolling.
  42094. */
  42095. private _userIsZooming;
  42096. private _lastFrameRadius;
  42097. private _shouldAnimationStopForInteraction;
  42098. /**
  42099. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42100. */
  42101. private _applyUserInteraction;
  42102. private _userIsMoving;
  42103. }
  42104. }
  42105. declare module BABYLON {
  42106. /**
  42107. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42108. */
  42109. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42110. private ui;
  42111. /**
  42112. * The name of the behavior
  42113. */
  42114. name: string;
  42115. /**
  42116. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42117. */
  42118. distanceAwayFromFace: number;
  42119. /**
  42120. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42121. */
  42122. distanceAwayFromBottomOfFace: number;
  42123. private _faceVectors;
  42124. private _target;
  42125. private _scene;
  42126. private _onRenderObserver;
  42127. private _tmpMatrix;
  42128. private _tmpVector;
  42129. /**
  42130. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42131. * @param ui The transform node that should be attched to the mesh
  42132. */
  42133. constructor(ui: TransformNode);
  42134. /**
  42135. * Initializes the behavior
  42136. */
  42137. init(): void;
  42138. private _closestFace;
  42139. private _zeroVector;
  42140. private _lookAtTmpMatrix;
  42141. private _lookAtToRef;
  42142. /**
  42143. * Attaches the AttachToBoxBehavior to the passed in mesh
  42144. * @param target The mesh that the specified node will be attached to
  42145. */
  42146. attach(target: Mesh): void;
  42147. /**
  42148. * Detaches the behavior from the mesh
  42149. */
  42150. detach(): void;
  42151. }
  42152. }
  42153. declare module BABYLON {
  42154. /**
  42155. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42156. */
  42157. export class FadeInOutBehavior implements Behavior<Mesh> {
  42158. /**
  42159. * Time in milliseconds to delay before fading in (Default: 0)
  42160. */
  42161. delay: number;
  42162. /**
  42163. * Time in milliseconds for the mesh to fade in (Default: 300)
  42164. */
  42165. fadeInTime: number;
  42166. private _millisecondsPerFrame;
  42167. private _hovered;
  42168. private _hoverValue;
  42169. private _ownerNode;
  42170. /**
  42171. * Instatiates the FadeInOutBehavior
  42172. */
  42173. constructor();
  42174. /**
  42175. * The name of the behavior
  42176. */
  42177. get name(): string;
  42178. /**
  42179. * Initializes the behavior
  42180. */
  42181. init(): void;
  42182. /**
  42183. * Attaches the fade behavior on the passed in mesh
  42184. * @param ownerNode The mesh that will be faded in/out once attached
  42185. */
  42186. attach(ownerNode: Mesh): void;
  42187. /**
  42188. * Detaches the behavior from the mesh
  42189. */
  42190. detach(): void;
  42191. /**
  42192. * Triggers the mesh to begin fading in or out
  42193. * @param value if the object should fade in or out (true to fade in)
  42194. */
  42195. fadeIn(value: boolean): void;
  42196. private _update;
  42197. private _setAllVisibility;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Class containing a set of static utilities functions for managing Pivots
  42203. * @hidden
  42204. */
  42205. export class PivotTools {
  42206. private static _PivotCached;
  42207. private static _OldPivotPoint;
  42208. private static _PivotTranslation;
  42209. private static _PivotTmpVector;
  42210. /** @hidden */
  42211. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42212. /** @hidden */
  42213. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42214. }
  42215. }
  42216. declare module BABYLON {
  42217. /**
  42218. * Class containing static functions to help procedurally build meshes
  42219. */
  42220. export class PlaneBuilder {
  42221. /**
  42222. * Creates a plane mesh
  42223. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42224. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42225. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42227. * * 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
  42228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42229. * @param name defines the name of the mesh
  42230. * @param options defines the options used to create the mesh
  42231. * @param scene defines the hosting scene
  42232. * @returns the plane mesh
  42233. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42234. */
  42235. static CreatePlane(name: string, options: {
  42236. size?: number;
  42237. width?: number;
  42238. height?: number;
  42239. sideOrientation?: number;
  42240. frontUVs?: Vector4;
  42241. backUVs?: Vector4;
  42242. updatable?: boolean;
  42243. sourcePlane?: Plane;
  42244. }, scene?: Nullable<Scene>): Mesh;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42250. */
  42251. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42252. private static _AnyMouseID;
  42253. /**
  42254. * Abstract mesh the behavior is set on
  42255. */
  42256. attachedNode: AbstractMesh;
  42257. private _dragPlane;
  42258. private _scene;
  42259. private _pointerObserver;
  42260. private _beforeRenderObserver;
  42261. private static _planeScene;
  42262. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42263. /**
  42264. * 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)
  42265. */
  42266. maxDragAngle: number;
  42267. /**
  42268. * @hidden
  42269. */
  42270. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42271. /**
  42272. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42273. */
  42274. currentDraggingPointerID: number;
  42275. /**
  42276. * The last position where the pointer hit the drag plane in world space
  42277. */
  42278. lastDragPosition: Vector3;
  42279. /**
  42280. * If the behavior is currently in a dragging state
  42281. */
  42282. dragging: boolean;
  42283. /**
  42284. * 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)
  42285. */
  42286. dragDeltaRatio: number;
  42287. /**
  42288. * If the drag plane orientation should be updated during the dragging (Default: true)
  42289. */
  42290. updateDragPlane: boolean;
  42291. private _debugMode;
  42292. private _moving;
  42293. /**
  42294. * Fires each time the attached mesh is dragged with the pointer
  42295. * * delta between last drag position and current drag position in world space
  42296. * * dragDistance along the drag axis
  42297. * * dragPlaneNormal normal of the current drag plane used during the drag
  42298. * * dragPlanePoint in world space where the drag intersects the drag plane
  42299. */
  42300. onDragObservable: Observable<{
  42301. delta: Vector3;
  42302. dragPlanePoint: Vector3;
  42303. dragPlaneNormal: Vector3;
  42304. dragDistance: number;
  42305. pointerId: number;
  42306. }>;
  42307. /**
  42308. * Fires each time a drag begins (eg. mouse down on mesh)
  42309. */
  42310. onDragStartObservable: Observable<{
  42311. dragPlanePoint: Vector3;
  42312. pointerId: number;
  42313. }>;
  42314. /**
  42315. * Fires each time a drag ends (eg. mouse release after drag)
  42316. */
  42317. onDragEndObservable: Observable<{
  42318. dragPlanePoint: Vector3;
  42319. pointerId: number;
  42320. }>;
  42321. /**
  42322. * If the attached mesh should be moved when dragged
  42323. */
  42324. moveAttached: boolean;
  42325. /**
  42326. * If the drag behavior will react to drag events (Default: true)
  42327. */
  42328. enabled: boolean;
  42329. /**
  42330. * If pointer events should start and release the drag (Default: true)
  42331. */
  42332. startAndReleaseDragOnPointerEvents: boolean;
  42333. /**
  42334. * If camera controls should be detached during the drag
  42335. */
  42336. detachCameraControls: boolean;
  42337. /**
  42338. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42339. */
  42340. useObjectOrientationForDragging: boolean;
  42341. private _options;
  42342. /**
  42343. * Gets the options used by the behavior
  42344. */
  42345. get options(): {
  42346. dragAxis?: Vector3;
  42347. dragPlaneNormal?: Vector3;
  42348. };
  42349. /**
  42350. * Sets the options used by the behavior
  42351. */
  42352. set options(options: {
  42353. dragAxis?: Vector3;
  42354. dragPlaneNormal?: Vector3;
  42355. });
  42356. /**
  42357. * Creates a pointer drag behavior that can be attached to a mesh
  42358. * @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)
  42359. */
  42360. constructor(options?: {
  42361. dragAxis?: Vector3;
  42362. dragPlaneNormal?: Vector3;
  42363. });
  42364. /**
  42365. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42366. */
  42367. validateDrag: (targetPosition: Vector3) => boolean;
  42368. /**
  42369. * The name of the behavior
  42370. */
  42371. get name(): string;
  42372. /**
  42373. * Initializes the behavior
  42374. */
  42375. init(): void;
  42376. private _tmpVector;
  42377. private _alternatePickedPoint;
  42378. private _worldDragAxis;
  42379. private _targetPosition;
  42380. private _attachedElement;
  42381. /**
  42382. * Attaches the drag behavior the passed in mesh
  42383. * @param ownerNode The mesh that will be dragged around once attached
  42384. * @param predicate Predicate to use for pick filtering
  42385. */
  42386. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42387. /**
  42388. * Force relase the drag action by code.
  42389. */
  42390. releaseDrag(): void;
  42391. private _startDragRay;
  42392. private _lastPointerRay;
  42393. /**
  42394. * Simulates the start of a pointer drag event on the behavior
  42395. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42396. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42397. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42398. */
  42399. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42400. private _startDrag;
  42401. private _dragDelta;
  42402. private _moveDrag;
  42403. private _pickWithRayOnDragPlane;
  42404. private _pointA;
  42405. private _pointB;
  42406. private _pointC;
  42407. private _lineA;
  42408. private _lineB;
  42409. private _localAxis;
  42410. private _lookAt;
  42411. private _updateDragPlanePosition;
  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 scaled
  42421. */
  42422. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42423. private _dragBehaviorA;
  42424. private _dragBehaviorB;
  42425. private _startDistance;
  42426. private _initialScale;
  42427. private _targetScale;
  42428. private _ownerNode;
  42429. private _sceneRenderObserver;
  42430. /**
  42431. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42432. */
  42433. constructor();
  42434. /**
  42435. * The name of the behavior
  42436. */
  42437. get name(): string;
  42438. /**
  42439. * Initializes the behavior
  42440. */
  42441. init(): void;
  42442. private _getCurrentDistance;
  42443. /**
  42444. * Attaches the scale behavior the passed in mesh
  42445. * @param ownerNode The mesh that will be scaled around once attached
  42446. */
  42447. attach(ownerNode: Mesh): void;
  42448. /**
  42449. * Detaches the behavior from the mesh
  42450. */
  42451. detach(): void;
  42452. }
  42453. }
  42454. declare module BABYLON {
  42455. /**
  42456. * 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
  42457. */
  42458. export class SixDofDragBehavior implements Behavior<Mesh> {
  42459. private static _virtualScene;
  42460. private _ownerNode;
  42461. private _sceneRenderObserver;
  42462. private _scene;
  42463. private _targetPosition;
  42464. private _virtualOriginMesh;
  42465. private _virtualDragMesh;
  42466. private _pointerObserver;
  42467. private _moving;
  42468. private _startingOrientation;
  42469. private _attachedElement;
  42470. /**
  42471. * 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)
  42472. */
  42473. private zDragFactor;
  42474. /**
  42475. * If the object should rotate to face the drag origin
  42476. */
  42477. rotateDraggedObject: boolean;
  42478. /**
  42479. * If the behavior is currently in a dragging state
  42480. */
  42481. dragging: boolean;
  42482. /**
  42483. * 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)
  42484. */
  42485. dragDeltaRatio: number;
  42486. /**
  42487. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42488. */
  42489. currentDraggingPointerID: number;
  42490. /**
  42491. * If camera controls should be detached during the drag
  42492. */
  42493. detachCameraControls: boolean;
  42494. /**
  42495. * Fires each time a drag starts
  42496. */
  42497. onDragStartObservable: Observable<{}>;
  42498. /**
  42499. * Fires each time a drag ends (eg. mouse release after drag)
  42500. */
  42501. onDragEndObservable: Observable<{}>;
  42502. /**
  42503. * 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
  42504. */
  42505. constructor();
  42506. /**
  42507. * The name of the behavior
  42508. */
  42509. get name(): string;
  42510. /**
  42511. * Initializes the behavior
  42512. */
  42513. init(): void;
  42514. /**
  42515. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42516. */
  42517. private get _pointerCamera();
  42518. /**
  42519. * Attaches the scale behavior the passed in mesh
  42520. * @param ownerNode The mesh that will be scaled around once attached
  42521. */
  42522. attach(ownerNode: Mesh): void;
  42523. /**
  42524. * Detaches the behavior from the mesh
  42525. */
  42526. detach(): void;
  42527. }
  42528. }
  42529. declare module BABYLON {
  42530. /**
  42531. * Class used to apply inverse kinematics to bones
  42532. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42533. */
  42534. export class BoneIKController {
  42535. private static _tmpVecs;
  42536. private static _tmpQuat;
  42537. private static _tmpMats;
  42538. /**
  42539. * Gets or sets the target mesh
  42540. */
  42541. targetMesh: AbstractMesh;
  42542. /** Gets or sets the mesh used as pole */
  42543. poleTargetMesh: AbstractMesh;
  42544. /**
  42545. * Gets or sets the bone used as pole
  42546. */
  42547. poleTargetBone: Nullable<Bone>;
  42548. /**
  42549. * Gets or sets the target position
  42550. */
  42551. targetPosition: Vector3;
  42552. /**
  42553. * Gets or sets the pole target position
  42554. */
  42555. poleTargetPosition: Vector3;
  42556. /**
  42557. * Gets or sets the pole target local offset
  42558. */
  42559. poleTargetLocalOffset: Vector3;
  42560. /**
  42561. * Gets or sets the pole angle
  42562. */
  42563. poleAngle: number;
  42564. /**
  42565. * Gets or sets the mesh associated with the controller
  42566. */
  42567. mesh: AbstractMesh;
  42568. /**
  42569. * 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)
  42570. */
  42571. slerpAmount: number;
  42572. private _bone1Quat;
  42573. private _bone1Mat;
  42574. private _bone2Ang;
  42575. private _bone1;
  42576. private _bone2;
  42577. private _bone1Length;
  42578. private _bone2Length;
  42579. private _maxAngle;
  42580. private _maxReach;
  42581. private _rightHandedSystem;
  42582. private _bendAxis;
  42583. private _slerping;
  42584. private _adjustRoll;
  42585. /**
  42586. * Gets or sets maximum allowed angle
  42587. */
  42588. get maxAngle(): number;
  42589. set maxAngle(value: number);
  42590. /**
  42591. * Creates a new BoneIKController
  42592. * @param mesh defines the mesh to control
  42593. * @param bone defines the bone to control
  42594. * @param options defines options to set up the controller
  42595. */
  42596. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42597. targetMesh?: AbstractMesh;
  42598. poleTargetMesh?: AbstractMesh;
  42599. poleTargetBone?: Bone;
  42600. poleTargetLocalOffset?: Vector3;
  42601. poleAngle?: number;
  42602. bendAxis?: Vector3;
  42603. maxAngle?: number;
  42604. slerpAmount?: number;
  42605. });
  42606. private _setMaxAngle;
  42607. /**
  42608. * Force the controller to update the bones
  42609. */
  42610. update(): void;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /**
  42615. * Class used to make a bone look toward a point in space
  42616. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42617. */
  42618. export class BoneLookController {
  42619. private static _tmpVecs;
  42620. private static _tmpQuat;
  42621. private static _tmpMats;
  42622. /**
  42623. * The target Vector3 that the bone will look at
  42624. */
  42625. target: Vector3;
  42626. /**
  42627. * The mesh that the bone is attached to
  42628. */
  42629. mesh: AbstractMesh;
  42630. /**
  42631. * The bone that will be looking to the target
  42632. */
  42633. bone: Bone;
  42634. /**
  42635. * The up axis of the coordinate system that is used when the bone is rotated
  42636. */
  42637. upAxis: Vector3;
  42638. /**
  42639. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42640. */
  42641. upAxisSpace: Space;
  42642. /**
  42643. * Used to make an adjustment to the yaw of the bone
  42644. */
  42645. adjustYaw: number;
  42646. /**
  42647. * Used to make an adjustment to the pitch of the bone
  42648. */
  42649. adjustPitch: number;
  42650. /**
  42651. * Used to make an adjustment to the roll of the bone
  42652. */
  42653. adjustRoll: number;
  42654. /**
  42655. * 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)
  42656. */
  42657. slerpAmount: number;
  42658. private _minYaw;
  42659. private _maxYaw;
  42660. private _minPitch;
  42661. private _maxPitch;
  42662. private _minYawSin;
  42663. private _minYawCos;
  42664. private _maxYawSin;
  42665. private _maxYawCos;
  42666. private _midYawConstraint;
  42667. private _minPitchTan;
  42668. private _maxPitchTan;
  42669. private _boneQuat;
  42670. private _slerping;
  42671. private _transformYawPitch;
  42672. private _transformYawPitchInv;
  42673. private _firstFrameSkipped;
  42674. private _yawRange;
  42675. private _fowardAxis;
  42676. /**
  42677. * Gets or sets the minimum yaw angle that the bone can look to
  42678. */
  42679. get minYaw(): number;
  42680. set minYaw(value: number);
  42681. /**
  42682. * Gets or sets the maximum yaw angle that the bone can look to
  42683. */
  42684. get maxYaw(): number;
  42685. set maxYaw(value: number);
  42686. /**
  42687. * Gets or sets the minimum pitch angle that the bone can look to
  42688. */
  42689. get minPitch(): number;
  42690. set minPitch(value: number);
  42691. /**
  42692. * Gets or sets the maximum pitch angle that the bone can look to
  42693. */
  42694. get maxPitch(): number;
  42695. set maxPitch(value: number);
  42696. /**
  42697. * Create a BoneLookController
  42698. * @param mesh the mesh that the bone belongs to
  42699. * @param bone the bone that will be looking to the target
  42700. * @param target the target Vector3 to look at
  42701. * @param options optional settings:
  42702. * * maxYaw: the maximum angle the bone will yaw to
  42703. * * minYaw: the minimum angle the bone will yaw to
  42704. * * maxPitch: the maximum angle the bone will pitch to
  42705. * * minPitch: the minimum angle the bone will yaw to
  42706. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42707. * * upAxis: the up axis of the coordinate system
  42708. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42709. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42710. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42711. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42712. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42713. * * adjustRoll: used to make an adjustment to the roll of the bone
  42714. **/
  42715. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42716. maxYaw?: number;
  42717. minYaw?: number;
  42718. maxPitch?: number;
  42719. minPitch?: number;
  42720. slerpAmount?: number;
  42721. upAxis?: Vector3;
  42722. upAxisSpace?: Space;
  42723. yawAxis?: Vector3;
  42724. pitchAxis?: Vector3;
  42725. adjustYaw?: number;
  42726. adjustPitch?: number;
  42727. adjustRoll?: number;
  42728. });
  42729. /**
  42730. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42731. */
  42732. update(): void;
  42733. private _getAngleDiff;
  42734. private _getAngleBetween;
  42735. private _isAngleBetween;
  42736. }
  42737. }
  42738. declare module BABYLON {
  42739. /**
  42740. * Manage the gamepad inputs to control an arc rotate camera.
  42741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42742. */
  42743. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42744. /**
  42745. * Defines the camera the input is attached to.
  42746. */
  42747. camera: ArcRotateCamera;
  42748. /**
  42749. * Defines the gamepad the input is gathering event from.
  42750. */
  42751. gamepad: Nullable<Gamepad>;
  42752. /**
  42753. * Defines the gamepad rotation sensiblity.
  42754. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42755. */
  42756. gamepadRotationSensibility: number;
  42757. /**
  42758. * Defines the gamepad move sensiblity.
  42759. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42760. */
  42761. gamepadMoveSensibility: number;
  42762. private _yAxisScale;
  42763. /**
  42764. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42765. */
  42766. get invertYAxis(): boolean;
  42767. set invertYAxis(value: boolean);
  42768. private _onGamepadConnectedObserver;
  42769. private _onGamepadDisconnectedObserver;
  42770. /**
  42771. * Attach the input controls to a specific dom element to get the input from.
  42772. * @param element Defines the element the controls should be listened from
  42773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42774. */
  42775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42776. /**
  42777. * Detach the current controls from the specified dom element.
  42778. * @param element Defines the element to stop listening the inputs from
  42779. */
  42780. detachControl(element: Nullable<HTMLElement>): void;
  42781. /**
  42782. * Update the current camera state depending on the inputs that have been used this frame.
  42783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42784. */
  42785. checkInputs(): void;
  42786. /**
  42787. * Gets the class name of the current intput.
  42788. * @returns the class name
  42789. */
  42790. getClassName(): string;
  42791. /**
  42792. * Get the friendly name associated with the input class.
  42793. * @returns the input friendly name
  42794. */
  42795. getSimpleName(): string;
  42796. }
  42797. }
  42798. declare module BABYLON {
  42799. interface ArcRotateCameraInputsManager {
  42800. /**
  42801. * Add orientation input support to the input manager.
  42802. * @returns the current input manager
  42803. */
  42804. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42805. }
  42806. /**
  42807. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42809. */
  42810. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42811. /**
  42812. * Defines the camera the input is attached to.
  42813. */
  42814. camera: ArcRotateCamera;
  42815. /**
  42816. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42817. */
  42818. alphaCorrection: number;
  42819. /**
  42820. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42821. */
  42822. gammaCorrection: number;
  42823. private _alpha;
  42824. private _gamma;
  42825. private _dirty;
  42826. private _deviceOrientationHandler;
  42827. /**
  42828. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42829. */
  42830. constructor();
  42831. /**
  42832. * Attach the input controls to a specific dom element to get the input from.
  42833. * @param element Defines the element the controls should be listened from
  42834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42835. */
  42836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42837. /** @hidden */
  42838. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42839. /**
  42840. * Update the current camera state depending on the inputs that have been used this frame.
  42841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42842. */
  42843. checkInputs(): void;
  42844. /**
  42845. * Detach the current controls from the specified dom element.
  42846. * @param element Defines the element to stop listening the inputs from
  42847. */
  42848. detachControl(element: Nullable<HTMLElement>): void;
  42849. /**
  42850. * Gets the class name of the current intput.
  42851. * @returns the class name
  42852. */
  42853. getClassName(): string;
  42854. /**
  42855. * Get the friendly name associated with the input class.
  42856. * @returns the input friendly name
  42857. */
  42858. getSimpleName(): string;
  42859. }
  42860. }
  42861. declare module BABYLON {
  42862. /**
  42863. * Listen to mouse events to control the camera.
  42864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42865. */
  42866. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42867. /**
  42868. * Defines the camera the input is attached to.
  42869. */
  42870. camera: FlyCamera;
  42871. /**
  42872. * Defines if touch is enabled. (Default is true.)
  42873. */
  42874. touchEnabled: boolean;
  42875. /**
  42876. * Defines the buttons associated with the input to handle camera rotation.
  42877. */
  42878. buttons: number[];
  42879. /**
  42880. * Assign buttons for Yaw control.
  42881. */
  42882. buttonsYaw: number[];
  42883. /**
  42884. * Assign buttons for Pitch control.
  42885. */
  42886. buttonsPitch: number[];
  42887. /**
  42888. * Assign buttons for Roll control.
  42889. */
  42890. buttonsRoll: number[];
  42891. /**
  42892. * Detect if any button is being pressed while mouse is moved.
  42893. * -1 = Mouse locked.
  42894. * 0 = Left button.
  42895. * 1 = Middle Button.
  42896. * 2 = Right Button.
  42897. */
  42898. activeButton: number;
  42899. /**
  42900. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42901. * Higher values reduce its sensitivity.
  42902. */
  42903. angularSensibility: number;
  42904. private _mousemoveCallback;
  42905. private _observer;
  42906. private _rollObserver;
  42907. private previousPosition;
  42908. private noPreventDefault;
  42909. private element;
  42910. /**
  42911. * Listen to mouse events to control the camera.
  42912. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42914. */
  42915. constructor(touchEnabled?: boolean);
  42916. /**
  42917. * Attach the mouse control to the HTML DOM element.
  42918. * @param element Defines the element that listens to the input events.
  42919. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42920. */
  42921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42922. /**
  42923. * Detach the current controls from the specified dom element.
  42924. * @param element Defines the element to stop listening the inputs from
  42925. */
  42926. detachControl(element: Nullable<HTMLElement>): void;
  42927. /**
  42928. * Gets the class name of the current input.
  42929. * @returns the class name.
  42930. */
  42931. getClassName(): string;
  42932. /**
  42933. * Get the friendly name associated with the input class.
  42934. * @returns the input's friendly name.
  42935. */
  42936. getSimpleName(): string;
  42937. private _pointerInput;
  42938. private _onMouseMove;
  42939. /**
  42940. * Rotate camera by mouse offset.
  42941. */
  42942. private rotateCamera;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /**
  42947. * Default Inputs manager for the FlyCamera.
  42948. * It groups all the default supported inputs for ease of use.
  42949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42950. */
  42951. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42952. /**
  42953. * Instantiates a new FlyCameraInputsManager.
  42954. * @param camera Defines the camera the inputs belong to.
  42955. */
  42956. constructor(camera: FlyCamera);
  42957. /**
  42958. * Add keyboard input support to the input manager.
  42959. * @returns the new FlyCameraKeyboardMoveInput().
  42960. */
  42961. addKeyboard(): FlyCameraInputsManager;
  42962. /**
  42963. * Add mouse input support to the input manager.
  42964. * @param touchEnabled Enable touch screen support.
  42965. * @returns the new FlyCameraMouseInput().
  42966. */
  42967. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42968. }
  42969. }
  42970. declare module BABYLON {
  42971. /**
  42972. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42973. * such as in a 3D Space Shooter or a Flight Simulator.
  42974. */
  42975. export class FlyCamera extends TargetCamera {
  42976. /**
  42977. * Define the collision ellipsoid of the camera.
  42978. * This is helpful for simulating a camera body, like a player's body.
  42979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42980. */
  42981. ellipsoid: Vector3;
  42982. /**
  42983. * Define an offset for the position of the ellipsoid around the camera.
  42984. * This can be helpful if the camera is attached away from the player's body center,
  42985. * such as at its head.
  42986. */
  42987. ellipsoidOffset: Vector3;
  42988. /**
  42989. * Enable or disable collisions of the camera with the rest of the scene objects.
  42990. */
  42991. checkCollisions: boolean;
  42992. /**
  42993. * Enable or disable gravity on the camera.
  42994. */
  42995. applyGravity: boolean;
  42996. /**
  42997. * Define the current direction the camera is moving to.
  42998. */
  42999. cameraDirection: Vector3;
  43000. /**
  43001. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43002. * This overrides and empties cameraRotation.
  43003. */
  43004. rotationQuaternion: Quaternion;
  43005. /**
  43006. * Track Roll to maintain the wanted Rolling when looking around.
  43007. */
  43008. _trackRoll: number;
  43009. /**
  43010. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43011. */
  43012. rollCorrect: number;
  43013. /**
  43014. * Mimic a banked turn, Rolling the camera when Yawing.
  43015. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43016. */
  43017. bankedTurn: boolean;
  43018. /**
  43019. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43020. */
  43021. bankedTurnLimit: number;
  43022. /**
  43023. * Value of 0 disables the banked Roll.
  43024. * Value of 1 is equal to the Yaw angle in radians.
  43025. */
  43026. bankedTurnMultiplier: number;
  43027. /**
  43028. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43029. */
  43030. inputs: FlyCameraInputsManager;
  43031. /**
  43032. * Gets the input sensibility for mouse input.
  43033. * Higher values reduce sensitivity.
  43034. */
  43035. get angularSensibility(): number;
  43036. /**
  43037. * Sets the input sensibility for a mouse input.
  43038. * Higher values reduce sensitivity.
  43039. */
  43040. set angularSensibility(value: number);
  43041. /**
  43042. * Get the keys for camera movement forward.
  43043. */
  43044. get keysForward(): number[];
  43045. /**
  43046. * Set the keys for camera movement forward.
  43047. */
  43048. set keysForward(value: number[]);
  43049. /**
  43050. * Get the keys for camera movement backward.
  43051. */
  43052. get keysBackward(): number[];
  43053. set keysBackward(value: number[]);
  43054. /**
  43055. * Get the keys for camera movement up.
  43056. */
  43057. get keysUp(): number[];
  43058. /**
  43059. * Set the keys for camera movement up.
  43060. */
  43061. set keysUp(value: number[]);
  43062. /**
  43063. * Get the keys for camera movement down.
  43064. */
  43065. get keysDown(): number[];
  43066. /**
  43067. * Set the keys for camera movement down.
  43068. */
  43069. set keysDown(value: number[]);
  43070. /**
  43071. * Get the keys for camera movement left.
  43072. */
  43073. get keysLeft(): number[];
  43074. /**
  43075. * Set the keys for camera movement left.
  43076. */
  43077. set keysLeft(value: number[]);
  43078. /**
  43079. * Set the keys for camera movement right.
  43080. */
  43081. get keysRight(): number[];
  43082. /**
  43083. * Set the keys for camera movement right.
  43084. */
  43085. set keysRight(value: number[]);
  43086. /**
  43087. * Event raised when the camera collides with a mesh in the scene.
  43088. */
  43089. onCollide: (collidedMesh: AbstractMesh) => void;
  43090. private _collider;
  43091. private _needMoveForGravity;
  43092. private _oldPosition;
  43093. private _diffPosition;
  43094. private _newPosition;
  43095. /** @hidden */
  43096. _localDirection: Vector3;
  43097. /** @hidden */
  43098. _transformedDirection: Vector3;
  43099. /**
  43100. * Instantiates a FlyCamera.
  43101. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43102. * such as in a 3D Space Shooter or a Flight Simulator.
  43103. * @param name Define the name of the camera in the scene.
  43104. * @param position Define the starting position of the camera in the scene.
  43105. * @param scene Define the scene the camera belongs to.
  43106. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43107. */
  43108. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43109. /**
  43110. * Attach a control to the HTML DOM element.
  43111. * @param element Defines the element that listens to the input events.
  43112. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43113. */
  43114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43115. /**
  43116. * Detach a control from the HTML DOM element.
  43117. * The camera will stop reacting to that input.
  43118. * @param element Defines the element that listens to the input events.
  43119. */
  43120. detachControl(element: HTMLElement): void;
  43121. private _collisionMask;
  43122. /**
  43123. * Get the mask that the camera ignores in collision events.
  43124. */
  43125. get collisionMask(): number;
  43126. /**
  43127. * Set the mask that the camera ignores in collision events.
  43128. */
  43129. set collisionMask(mask: number);
  43130. /** @hidden */
  43131. _collideWithWorld(displacement: Vector3): void;
  43132. /** @hidden */
  43133. private _onCollisionPositionChange;
  43134. /** @hidden */
  43135. _checkInputs(): void;
  43136. /** @hidden */
  43137. _decideIfNeedsToMove(): boolean;
  43138. /** @hidden */
  43139. _updatePosition(): void;
  43140. /**
  43141. * Restore the Roll to its target value at the rate specified.
  43142. * @param rate - Higher means slower restoring.
  43143. * @hidden
  43144. */
  43145. restoreRoll(rate: number): void;
  43146. /**
  43147. * Destroy the camera and release the current resources held by it.
  43148. */
  43149. dispose(): void;
  43150. /**
  43151. * Get the current object class name.
  43152. * @returns the class name.
  43153. */
  43154. getClassName(): string;
  43155. }
  43156. }
  43157. declare module BABYLON {
  43158. /**
  43159. * Listen to keyboard events to control the camera.
  43160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43161. */
  43162. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43163. /**
  43164. * Defines the camera the input is attached to.
  43165. */
  43166. camera: FlyCamera;
  43167. /**
  43168. * The list of keyboard keys used to control the forward move of the camera.
  43169. */
  43170. keysForward: number[];
  43171. /**
  43172. * The list of keyboard keys used to control the backward move of the camera.
  43173. */
  43174. keysBackward: number[];
  43175. /**
  43176. * The list of keyboard keys used to control the forward move of the camera.
  43177. */
  43178. keysUp: number[];
  43179. /**
  43180. * The list of keyboard keys used to control the backward move of the camera.
  43181. */
  43182. keysDown: number[];
  43183. /**
  43184. * The list of keyboard keys used to control the right strafe move of the camera.
  43185. */
  43186. keysRight: number[];
  43187. /**
  43188. * The list of keyboard keys used to control the left strafe move of the camera.
  43189. */
  43190. keysLeft: number[];
  43191. private _keys;
  43192. private _onCanvasBlurObserver;
  43193. private _onKeyboardObserver;
  43194. private _engine;
  43195. private _scene;
  43196. /**
  43197. * Attach the input controls to a specific dom element to get the input from.
  43198. * @param element Defines the element the controls should be listened from
  43199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43200. */
  43201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43202. /**
  43203. * Detach the current controls from the specified dom element.
  43204. * @param element Defines the element to stop listening the inputs from
  43205. */
  43206. detachControl(element: Nullable<HTMLElement>): void;
  43207. /**
  43208. * Gets the class name of the current intput.
  43209. * @returns the class name
  43210. */
  43211. getClassName(): string;
  43212. /** @hidden */
  43213. _onLostFocus(e: FocusEvent): void;
  43214. /**
  43215. * Get the friendly name associated with the input class.
  43216. * @returns the input friendly name
  43217. */
  43218. getSimpleName(): string;
  43219. /**
  43220. * Update the current camera state depending on the inputs that have been used this frame.
  43221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43222. */
  43223. checkInputs(): void;
  43224. }
  43225. }
  43226. declare module BABYLON {
  43227. /**
  43228. * Manage the mouse wheel inputs to control a follow camera.
  43229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43230. */
  43231. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43232. /**
  43233. * Defines the camera the input is attached to.
  43234. */
  43235. camera: FollowCamera;
  43236. /**
  43237. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43238. */
  43239. axisControlRadius: boolean;
  43240. /**
  43241. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43242. */
  43243. axisControlHeight: boolean;
  43244. /**
  43245. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43246. */
  43247. axisControlRotation: boolean;
  43248. /**
  43249. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43250. * relation to mouseWheel events.
  43251. */
  43252. wheelPrecision: number;
  43253. /**
  43254. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43255. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43256. */
  43257. wheelDeltaPercentage: number;
  43258. private _wheel;
  43259. private _observer;
  43260. /**
  43261. * Attach the input controls to a specific dom element to get the input from.
  43262. * @param element Defines the element the controls should be listened from
  43263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43264. */
  43265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43266. /**
  43267. * Detach the current controls from the specified dom element.
  43268. * @param element Defines the element to stop listening the inputs from
  43269. */
  43270. detachControl(element: Nullable<HTMLElement>): void;
  43271. /**
  43272. * Gets the class name of the current intput.
  43273. * @returns the class name
  43274. */
  43275. getClassName(): string;
  43276. /**
  43277. * Get the friendly name associated with the input class.
  43278. * @returns the input friendly name
  43279. */
  43280. getSimpleName(): string;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * Manage the pointers inputs to control an follow camera.
  43286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43287. */
  43288. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43289. /**
  43290. * Defines the camera the input is attached to.
  43291. */
  43292. camera: FollowCamera;
  43293. /**
  43294. * Gets the class name of the current input.
  43295. * @returns the class name
  43296. */
  43297. getClassName(): string;
  43298. /**
  43299. * Defines the pointer angular sensibility along the X axis or how fast is
  43300. * the camera rotating.
  43301. * A negative number will reverse the axis direction.
  43302. */
  43303. angularSensibilityX: number;
  43304. /**
  43305. * Defines the pointer angular sensibility along the Y axis or how fast is
  43306. * the camera rotating.
  43307. * A negative number will reverse the axis direction.
  43308. */
  43309. angularSensibilityY: number;
  43310. /**
  43311. * Defines the pointer pinch precision or how fast is the camera zooming.
  43312. * A negative number will reverse the axis direction.
  43313. */
  43314. pinchPrecision: number;
  43315. /**
  43316. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43317. * from 0.
  43318. * It defines the percentage of current camera.radius to use as delta when
  43319. * pinch zoom is used.
  43320. */
  43321. pinchDeltaPercentage: number;
  43322. /**
  43323. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43324. */
  43325. axisXControlRadius: boolean;
  43326. /**
  43327. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43328. */
  43329. axisXControlHeight: boolean;
  43330. /**
  43331. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43332. */
  43333. axisXControlRotation: boolean;
  43334. /**
  43335. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43336. */
  43337. axisYControlRadius: boolean;
  43338. /**
  43339. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43340. */
  43341. axisYControlHeight: boolean;
  43342. /**
  43343. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43344. */
  43345. axisYControlRotation: boolean;
  43346. /**
  43347. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43348. */
  43349. axisPinchControlRadius: boolean;
  43350. /**
  43351. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43352. */
  43353. axisPinchControlHeight: boolean;
  43354. /**
  43355. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43356. */
  43357. axisPinchControlRotation: boolean;
  43358. /**
  43359. * Log error messages if basic misconfiguration has occurred.
  43360. */
  43361. warningEnable: boolean;
  43362. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43363. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43364. private _warningCounter;
  43365. private _warning;
  43366. }
  43367. }
  43368. declare module BABYLON {
  43369. /**
  43370. * Default Inputs manager for the FollowCamera.
  43371. * It groups all the default supported inputs for ease of use.
  43372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43373. */
  43374. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43375. /**
  43376. * Instantiates a new FollowCameraInputsManager.
  43377. * @param camera Defines the camera the inputs belong to
  43378. */
  43379. constructor(camera: FollowCamera);
  43380. /**
  43381. * Add keyboard input support to the input manager.
  43382. * @returns the current input manager
  43383. */
  43384. addKeyboard(): FollowCameraInputsManager;
  43385. /**
  43386. * Add mouse wheel input support to the input manager.
  43387. * @returns the current input manager
  43388. */
  43389. addMouseWheel(): FollowCameraInputsManager;
  43390. /**
  43391. * Add pointers input support to the input manager.
  43392. * @returns the current input manager
  43393. */
  43394. addPointers(): FollowCameraInputsManager;
  43395. /**
  43396. * Add orientation input support to the input manager.
  43397. * @returns the current input manager
  43398. */
  43399. addVRDeviceOrientation(): FollowCameraInputsManager;
  43400. }
  43401. }
  43402. declare module BABYLON {
  43403. /**
  43404. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43405. * an arc rotate version arcFollowCamera are available.
  43406. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43407. */
  43408. export class FollowCamera extends TargetCamera {
  43409. /**
  43410. * Distance the follow camera should follow an object at
  43411. */
  43412. radius: number;
  43413. /**
  43414. * Minimum allowed distance of the camera to the axis of rotation
  43415. * (The camera can not get closer).
  43416. * This can help limiting how the Camera is able to move in the scene.
  43417. */
  43418. lowerRadiusLimit: Nullable<number>;
  43419. /**
  43420. * Maximum allowed distance of the camera to the axis of rotation
  43421. * (The camera can not get further).
  43422. * This can help limiting how the Camera is able to move in the scene.
  43423. */
  43424. upperRadiusLimit: Nullable<number>;
  43425. /**
  43426. * Define a rotation offset between the camera and the object it follows
  43427. */
  43428. rotationOffset: number;
  43429. /**
  43430. * Minimum allowed angle to camera position relative to target object.
  43431. * This can help limiting how the Camera is able to move in the scene.
  43432. */
  43433. lowerRotationOffsetLimit: Nullable<number>;
  43434. /**
  43435. * Maximum allowed angle to camera position relative to target object.
  43436. * This can help limiting how the Camera is able to move in the scene.
  43437. */
  43438. upperRotationOffsetLimit: Nullable<number>;
  43439. /**
  43440. * Define a height offset between the camera and the object it follows.
  43441. * It can help following an object from the top (like a car chaing a plane)
  43442. */
  43443. heightOffset: number;
  43444. /**
  43445. * Minimum allowed height of camera position relative to target object.
  43446. * This can help limiting how the Camera is able to move in the scene.
  43447. */
  43448. lowerHeightOffsetLimit: Nullable<number>;
  43449. /**
  43450. * Maximum allowed height of camera position relative to target object.
  43451. * This can help limiting how the Camera is able to move in the scene.
  43452. */
  43453. upperHeightOffsetLimit: Nullable<number>;
  43454. /**
  43455. * Define how fast the camera can accelerate to follow it s target.
  43456. */
  43457. cameraAcceleration: number;
  43458. /**
  43459. * Define the speed limit of the camera following an object.
  43460. */
  43461. maxCameraSpeed: number;
  43462. /**
  43463. * Define the target of the camera.
  43464. */
  43465. lockedTarget: Nullable<AbstractMesh>;
  43466. /**
  43467. * Defines the input associated with the camera.
  43468. */
  43469. inputs: FollowCameraInputsManager;
  43470. /**
  43471. * Instantiates the follow camera.
  43472. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43473. * @param name Define the name of the camera in the scene
  43474. * @param position Define the position of the camera
  43475. * @param scene Define the scene the camera belong to
  43476. * @param lockedTarget Define the target of the camera
  43477. */
  43478. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43479. private _follow;
  43480. /**
  43481. * Attached controls to the current camera.
  43482. * @param element Defines the element the controls should be listened from
  43483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43484. */
  43485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43486. /**
  43487. * Detach the current controls from the camera.
  43488. * The camera will stop reacting to inputs.
  43489. * @param element Defines the element to stop listening the inputs from
  43490. */
  43491. detachControl(element: HTMLElement): void;
  43492. /** @hidden */
  43493. _checkInputs(): void;
  43494. private _checkLimits;
  43495. /**
  43496. * Gets the camera class name.
  43497. * @returns the class name
  43498. */
  43499. getClassName(): string;
  43500. }
  43501. /**
  43502. * Arc Rotate version of the follow camera.
  43503. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43504. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43505. */
  43506. export class ArcFollowCamera extends TargetCamera {
  43507. /** The longitudinal angle of the camera */
  43508. alpha: number;
  43509. /** The latitudinal angle of the camera */
  43510. beta: number;
  43511. /** The radius of the camera from its target */
  43512. radius: number;
  43513. /** Define the camera target (the messh it should follow) */
  43514. target: Nullable<AbstractMesh>;
  43515. private _cartesianCoordinates;
  43516. /**
  43517. * Instantiates a new ArcFollowCamera
  43518. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43519. * @param name Define the name of the camera
  43520. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43521. * @param beta Define the rotation angle of the camera around the elevation axis
  43522. * @param radius Define the radius of the camera from its target point
  43523. * @param target Define the target of the camera
  43524. * @param scene Define the scene the camera belongs to
  43525. */
  43526. constructor(name: string,
  43527. /** The longitudinal angle of the camera */
  43528. alpha: number,
  43529. /** The latitudinal angle of the camera */
  43530. beta: number,
  43531. /** The radius of the camera from its target */
  43532. radius: number,
  43533. /** Define the camera target (the messh it should follow) */
  43534. target: Nullable<AbstractMesh>, scene: Scene);
  43535. private _follow;
  43536. /** @hidden */
  43537. _checkInputs(): void;
  43538. /**
  43539. * Returns the class name of the object.
  43540. * It is mostly used internally for serialization purposes.
  43541. */
  43542. getClassName(): string;
  43543. }
  43544. }
  43545. declare module BABYLON {
  43546. /**
  43547. * Manage the keyboard inputs to control the movement of a follow camera.
  43548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43549. */
  43550. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43551. /**
  43552. * Defines the camera the input is attached to.
  43553. */
  43554. camera: FollowCamera;
  43555. /**
  43556. * Defines the list of key codes associated with the up action (increase heightOffset)
  43557. */
  43558. keysHeightOffsetIncr: number[];
  43559. /**
  43560. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43561. */
  43562. keysHeightOffsetDecr: number[];
  43563. /**
  43564. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43565. */
  43566. keysHeightOffsetModifierAlt: boolean;
  43567. /**
  43568. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43569. */
  43570. keysHeightOffsetModifierCtrl: boolean;
  43571. /**
  43572. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43573. */
  43574. keysHeightOffsetModifierShift: boolean;
  43575. /**
  43576. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43577. */
  43578. keysRotationOffsetIncr: number[];
  43579. /**
  43580. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43581. */
  43582. keysRotationOffsetDecr: number[];
  43583. /**
  43584. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43585. */
  43586. keysRotationOffsetModifierAlt: boolean;
  43587. /**
  43588. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43589. */
  43590. keysRotationOffsetModifierCtrl: boolean;
  43591. /**
  43592. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43593. */
  43594. keysRotationOffsetModifierShift: boolean;
  43595. /**
  43596. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43597. */
  43598. keysRadiusIncr: number[];
  43599. /**
  43600. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43601. */
  43602. keysRadiusDecr: number[];
  43603. /**
  43604. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43605. */
  43606. keysRadiusModifierAlt: boolean;
  43607. /**
  43608. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43609. */
  43610. keysRadiusModifierCtrl: boolean;
  43611. /**
  43612. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43613. */
  43614. keysRadiusModifierShift: boolean;
  43615. /**
  43616. * Defines the rate of change of heightOffset.
  43617. */
  43618. heightSensibility: number;
  43619. /**
  43620. * Defines the rate of change of rotationOffset.
  43621. */
  43622. rotationSensibility: number;
  43623. /**
  43624. * Defines the rate of change of radius.
  43625. */
  43626. radiusSensibility: number;
  43627. private _keys;
  43628. private _ctrlPressed;
  43629. private _altPressed;
  43630. private _shiftPressed;
  43631. private _onCanvasBlurObserver;
  43632. private _onKeyboardObserver;
  43633. private _engine;
  43634. private _scene;
  43635. /**
  43636. * Attach the input controls to a specific dom element to get the input from.
  43637. * @param element Defines the element the controls should be listened from
  43638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43639. */
  43640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43641. /**
  43642. * Detach the current controls from the specified dom element.
  43643. * @param element Defines the element to stop listening the inputs from
  43644. */
  43645. detachControl(element: Nullable<HTMLElement>): void;
  43646. /**
  43647. * Update the current camera state depending on the inputs that have been used this frame.
  43648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43649. */
  43650. checkInputs(): void;
  43651. /**
  43652. * Gets the class name of the current input.
  43653. * @returns the class name
  43654. */
  43655. getClassName(): string;
  43656. /**
  43657. * Get the friendly name associated with the input class.
  43658. * @returns the input friendly name
  43659. */
  43660. getSimpleName(): string;
  43661. /**
  43662. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43663. * allow modification of the heightOffset value.
  43664. */
  43665. private _modifierHeightOffset;
  43666. /**
  43667. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43668. * allow modification of the rotationOffset value.
  43669. */
  43670. private _modifierRotationOffset;
  43671. /**
  43672. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43673. * allow modification of the radius value.
  43674. */
  43675. private _modifierRadius;
  43676. }
  43677. }
  43678. declare module BABYLON {
  43679. interface FreeCameraInputsManager {
  43680. /**
  43681. * @hidden
  43682. */
  43683. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43684. /**
  43685. * Add orientation input support to the input manager.
  43686. * @returns the current input manager
  43687. */
  43688. addDeviceOrientation(): FreeCameraInputsManager;
  43689. }
  43690. /**
  43691. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43692. * Screen rotation is taken into account.
  43693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43694. */
  43695. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43696. private _camera;
  43697. private _screenOrientationAngle;
  43698. private _constantTranform;
  43699. private _screenQuaternion;
  43700. private _alpha;
  43701. private _beta;
  43702. private _gamma;
  43703. /**
  43704. * Can be used to detect if a device orientation sensor is available on a device
  43705. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43706. * @returns a promise that will resolve on orientation change
  43707. */
  43708. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43709. /**
  43710. * @hidden
  43711. */
  43712. _onDeviceOrientationChangedObservable: Observable<void>;
  43713. /**
  43714. * Instantiates a new input
  43715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43716. */
  43717. constructor();
  43718. /**
  43719. * Define the camera controlled by the input.
  43720. */
  43721. get camera(): FreeCamera;
  43722. set camera(camera: FreeCamera);
  43723. /**
  43724. * Attach the input controls to a specific dom element to get the input from.
  43725. * @param element Defines the element the controls should be listened from
  43726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43727. */
  43728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43729. private _orientationChanged;
  43730. private _deviceOrientation;
  43731. /**
  43732. * Detach the current controls from the specified dom element.
  43733. * @param element Defines the element to stop listening the inputs from
  43734. */
  43735. detachControl(element: Nullable<HTMLElement>): void;
  43736. /**
  43737. * Update the current camera state depending on the inputs that have been used this frame.
  43738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43739. */
  43740. checkInputs(): void;
  43741. /**
  43742. * Gets the class name of the current intput.
  43743. * @returns the class name
  43744. */
  43745. getClassName(): string;
  43746. /**
  43747. * Get the friendly name associated with the input class.
  43748. * @returns the input friendly name
  43749. */
  43750. getSimpleName(): string;
  43751. }
  43752. }
  43753. declare module BABYLON {
  43754. /**
  43755. * Manage the gamepad inputs to control a free camera.
  43756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43757. */
  43758. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43759. /**
  43760. * Define the camera the input is attached to.
  43761. */
  43762. camera: FreeCamera;
  43763. /**
  43764. * Define the Gamepad controlling the input
  43765. */
  43766. gamepad: Nullable<Gamepad>;
  43767. /**
  43768. * Defines the gamepad rotation sensiblity.
  43769. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43770. */
  43771. gamepadAngularSensibility: number;
  43772. /**
  43773. * Defines the gamepad move sensiblity.
  43774. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43775. */
  43776. gamepadMoveSensibility: number;
  43777. private _yAxisScale;
  43778. /**
  43779. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43780. */
  43781. get invertYAxis(): boolean;
  43782. set invertYAxis(value: boolean);
  43783. private _onGamepadConnectedObserver;
  43784. private _onGamepadDisconnectedObserver;
  43785. private _cameraTransform;
  43786. private _deltaTransform;
  43787. private _vector3;
  43788. private _vector2;
  43789. /**
  43790. * Attach the input controls to a specific dom element to get the input from.
  43791. * @param element Defines the element the controls should be listened from
  43792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43793. */
  43794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43795. /**
  43796. * Detach the current controls from the specified dom element.
  43797. * @param element Defines the element to stop listening the inputs from
  43798. */
  43799. detachControl(element: Nullable<HTMLElement>): void;
  43800. /**
  43801. * Update the current camera state depending on the inputs that have been used this frame.
  43802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43803. */
  43804. checkInputs(): void;
  43805. /**
  43806. * Gets the class name of the current intput.
  43807. * @returns the class name
  43808. */
  43809. getClassName(): string;
  43810. /**
  43811. * Get the friendly name associated with the input class.
  43812. * @returns the input friendly name
  43813. */
  43814. getSimpleName(): string;
  43815. }
  43816. }
  43817. declare module BABYLON {
  43818. /**
  43819. * Defines the potential axis of a Joystick
  43820. */
  43821. export enum JoystickAxis {
  43822. /** X axis */
  43823. X = 0,
  43824. /** Y axis */
  43825. Y = 1,
  43826. /** Z axis */
  43827. Z = 2
  43828. }
  43829. /**
  43830. * Class used to define virtual joystick (used in touch mode)
  43831. */
  43832. export class VirtualJoystick {
  43833. /**
  43834. * Gets or sets a boolean indicating that left and right values must be inverted
  43835. */
  43836. reverseLeftRight: boolean;
  43837. /**
  43838. * Gets or sets a boolean indicating that up and down values must be inverted
  43839. */
  43840. reverseUpDown: boolean;
  43841. /**
  43842. * Gets the offset value for the position (ie. the change of the position value)
  43843. */
  43844. deltaPosition: Vector3;
  43845. /**
  43846. * Gets a boolean indicating if the virtual joystick was pressed
  43847. */
  43848. pressed: boolean;
  43849. /**
  43850. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43851. */
  43852. static Canvas: Nullable<HTMLCanvasElement>;
  43853. private static _globalJoystickIndex;
  43854. private static vjCanvasContext;
  43855. private static vjCanvasWidth;
  43856. private static vjCanvasHeight;
  43857. private static halfWidth;
  43858. private _action;
  43859. private _axisTargetedByLeftAndRight;
  43860. private _axisTargetedByUpAndDown;
  43861. private _joystickSensibility;
  43862. private _inversedSensibility;
  43863. private _joystickPointerID;
  43864. private _joystickColor;
  43865. private _joystickPointerPos;
  43866. private _joystickPreviousPointerPos;
  43867. private _joystickPointerStartPos;
  43868. private _deltaJoystickVector;
  43869. private _leftJoystick;
  43870. private _touches;
  43871. private _onPointerDownHandlerRef;
  43872. private _onPointerMoveHandlerRef;
  43873. private _onPointerUpHandlerRef;
  43874. private _onResize;
  43875. /**
  43876. * Creates a new virtual joystick
  43877. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43878. */
  43879. constructor(leftJoystick?: boolean);
  43880. /**
  43881. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43882. * @param newJoystickSensibility defines the new sensibility
  43883. */
  43884. setJoystickSensibility(newJoystickSensibility: number): void;
  43885. private _onPointerDown;
  43886. private _onPointerMove;
  43887. private _onPointerUp;
  43888. /**
  43889. * Change the color of the virtual joystick
  43890. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43891. */
  43892. setJoystickColor(newColor: string): void;
  43893. /**
  43894. * Defines a callback to call when the joystick is touched
  43895. * @param action defines the callback
  43896. */
  43897. setActionOnTouch(action: () => any): void;
  43898. /**
  43899. * Defines which axis you'd like to control for left & right
  43900. * @param axis defines the axis to use
  43901. */
  43902. setAxisForLeftRight(axis: JoystickAxis): void;
  43903. /**
  43904. * Defines which axis you'd like to control for up & down
  43905. * @param axis defines the axis to use
  43906. */
  43907. setAxisForUpDown(axis: JoystickAxis): void;
  43908. private _drawVirtualJoystick;
  43909. /**
  43910. * Release internal HTML canvas
  43911. */
  43912. releaseCanvas(): void;
  43913. }
  43914. }
  43915. declare module BABYLON {
  43916. interface FreeCameraInputsManager {
  43917. /**
  43918. * Add virtual joystick input support to the input manager.
  43919. * @returns the current input manager
  43920. */
  43921. addVirtualJoystick(): FreeCameraInputsManager;
  43922. }
  43923. /**
  43924. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43926. */
  43927. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43928. /**
  43929. * Defines the camera the input is attached to.
  43930. */
  43931. camera: FreeCamera;
  43932. private _leftjoystick;
  43933. private _rightjoystick;
  43934. /**
  43935. * Gets the left stick of the virtual joystick.
  43936. * @returns The virtual Joystick
  43937. */
  43938. getLeftJoystick(): VirtualJoystick;
  43939. /**
  43940. * Gets the right stick of the virtual joystick.
  43941. * @returns The virtual Joystick
  43942. */
  43943. getRightJoystick(): VirtualJoystick;
  43944. /**
  43945. * Update the current camera state depending on the inputs that have been used this frame.
  43946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43947. */
  43948. checkInputs(): void;
  43949. /**
  43950. * Attach the input controls to a specific dom element to get the input from.
  43951. * @param element Defines the element the controls should be listened from
  43952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43953. */
  43954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43955. /**
  43956. * Detach the current controls from the specified dom element.
  43957. * @param element Defines the element to stop listening the inputs from
  43958. */
  43959. detachControl(element: Nullable<HTMLElement>): void;
  43960. /**
  43961. * Gets the class name of the current intput.
  43962. * @returns the class name
  43963. */
  43964. getClassName(): string;
  43965. /**
  43966. * Get the friendly name associated with the input class.
  43967. * @returns the input friendly name
  43968. */
  43969. getSimpleName(): string;
  43970. }
  43971. }
  43972. declare module BABYLON {
  43973. /**
  43974. * This represents a FPS type of camera controlled by touch.
  43975. * This is like a universal camera minus the Gamepad controls.
  43976. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43977. */
  43978. export class TouchCamera extends FreeCamera {
  43979. /**
  43980. * Defines the touch sensibility for rotation.
  43981. * The higher the faster.
  43982. */
  43983. get touchAngularSensibility(): number;
  43984. set touchAngularSensibility(value: number);
  43985. /**
  43986. * Defines the touch sensibility for move.
  43987. * The higher the faster.
  43988. */
  43989. get touchMoveSensibility(): number;
  43990. set touchMoveSensibility(value: number);
  43991. /**
  43992. * Instantiates a new touch camera.
  43993. * This represents a FPS type of camera controlled by touch.
  43994. * This is like a universal camera minus the Gamepad controls.
  43995. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43996. * @param name Define the name of the camera in the scene
  43997. * @param position Define the start position of the camera in the scene
  43998. * @param scene Define the scene the camera belongs to
  43999. */
  44000. constructor(name: string, position: Vector3, scene: Scene);
  44001. /**
  44002. * Gets the current object class name.
  44003. * @return the class name
  44004. */
  44005. getClassName(): string;
  44006. /** @hidden */
  44007. _setupInputs(): void;
  44008. }
  44009. }
  44010. declare module BABYLON {
  44011. /**
  44012. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44013. * being tilted forward or back and left or right.
  44014. */
  44015. export class DeviceOrientationCamera extends FreeCamera {
  44016. private _initialQuaternion;
  44017. private _quaternionCache;
  44018. private _tmpDragQuaternion;
  44019. private _disablePointerInputWhenUsingDeviceOrientation;
  44020. /**
  44021. * Creates a new device orientation camera
  44022. * @param name The name of the camera
  44023. * @param position The start position camera
  44024. * @param scene The scene the camera belongs to
  44025. */
  44026. constructor(name: string, position: Vector3, scene: Scene);
  44027. /**
  44028. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44029. */
  44030. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44031. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44032. private _dragFactor;
  44033. /**
  44034. * Enabled turning on the y axis when the orientation sensor is active
  44035. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44036. */
  44037. enableHorizontalDragging(dragFactor?: number): void;
  44038. /**
  44039. * Gets the current instance class name ("DeviceOrientationCamera").
  44040. * This helps avoiding instanceof at run time.
  44041. * @returns the class name
  44042. */
  44043. getClassName(): string;
  44044. /**
  44045. * @hidden
  44046. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44047. */
  44048. _checkInputs(): void;
  44049. /**
  44050. * Reset the camera to its default orientation on the specified axis only.
  44051. * @param axis The axis to reset
  44052. */
  44053. resetToCurrentRotation(axis?: Axis): void;
  44054. }
  44055. }
  44056. declare module BABYLON {
  44057. /**
  44058. * Defines supported buttons for XBox360 compatible gamepads
  44059. */
  44060. export enum Xbox360Button {
  44061. /** A */
  44062. A = 0,
  44063. /** B */
  44064. B = 1,
  44065. /** X */
  44066. X = 2,
  44067. /** Y */
  44068. Y = 3,
  44069. /** Left button */
  44070. LB = 4,
  44071. /** Right button */
  44072. RB = 5,
  44073. /** Back */
  44074. Back = 8,
  44075. /** Start */
  44076. Start = 9,
  44077. /** Left stick */
  44078. LeftStick = 10,
  44079. /** Right stick */
  44080. RightStick = 11
  44081. }
  44082. /** Defines values for XBox360 DPad */
  44083. export enum Xbox360Dpad {
  44084. /** Up */
  44085. Up = 12,
  44086. /** Down */
  44087. Down = 13,
  44088. /** Left */
  44089. Left = 14,
  44090. /** Right */
  44091. Right = 15
  44092. }
  44093. /**
  44094. * Defines a XBox360 gamepad
  44095. */
  44096. export class Xbox360Pad extends Gamepad {
  44097. private _leftTrigger;
  44098. private _rightTrigger;
  44099. private _onlefttriggerchanged;
  44100. private _onrighttriggerchanged;
  44101. private _onbuttondown;
  44102. private _onbuttonup;
  44103. private _ondpaddown;
  44104. private _ondpadup;
  44105. /** Observable raised when a button is pressed */
  44106. onButtonDownObservable: Observable<Xbox360Button>;
  44107. /** Observable raised when a button is released */
  44108. onButtonUpObservable: Observable<Xbox360Button>;
  44109. /** Observable raised when a pad is pressed */
  44110. onPadDownObservable: Observable<Xbox360Dpad>;
  44111. /** Observable raised when a pad is released */
  44112. onPadUpObservable: Observable<Xbox360Dpad>;
  44113. private _buttonA;
  44114. private _buttonB;
  44115. private _buttonX;
  44116. private _buttonY;
  44117. private _buttonBack;
  44118. private _buttonStart;
  44119. private _buttonLB;
  44120. private _buttonRB;
  44121. private _buttonLeftStick;
  44122. private _buttonRightStick;
  44123. private _dPadUp;
  44124. private _dPadDown;
  44125. private _dPadLeft;
  44126. private _dPadRight;
  44127. private _isXboxOnePad;
  44128. /**
  44129. * Creates a new XBox360 gamepad object
  44130. * @param id defines the id of this gamepad
  44131. * @param index defines its index
  44132. * @param gamepad defines the internal HTML gamepad object
  44133. * @param xboxOne defines if it is a XBox One gamepad
  44134. */
  44135. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44136. /**
  44137. * Defines the callback to call when left trigger is pressed
  44138. * @param callback defines the callback to use
  44139. */
  44140. onlefttriggerchanged(callback: (value: number) => void): void;
  44141. /**
  44142. * Defines the callback to call when right trigger is pressed
  44143. * @param callback defines the callback to use
  44144. */
  44145. onrighttriggerchanged(callback: (value: number) => void): void;
  44146. /**
  44147. * Gets the left trigger value
  44148. */
  44149. get leftTrigger(): number;
  44150. /**
  44151. * Sets the left trigger value
  44152. */
  44153. set leftTrigger(newValue: number);
  44154. /**
  44155. * Gets the right trigger value
  44156. */
  44157. get rightTrigger(): number;
  44158. /**
  44159. * Sets the right trigger value
  44160. */
  44161. set rightTrigger(newValue: number);
  44162. /**
  44163. * Defines the callback to call when a button is pressed
  44164. * @param callback defines the callback to use
  44165. */
  44166. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44167. /**
  44168. * Defines the callback to call when a button is released
  44169. * @param callback defines the callback to use
  44170. */
  44171. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44172. /**
  44173. * Defines the callback to call when a pad is pressed
  44174. * @param callback defines the callback to use
  44175. */
  44176. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44177. /**
  44178. * Defines the callback to call when a pad is released
  44179. * @param callback defines the callback to use
  44180. */
  44181. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44182. private _setButtonValue;
  44183. private _setDPadValue;
  44184. /**
  44185. * Gets the value of the `A` button
  44186. */
  44187. get buttonA(): number;
  44188. /**
  44189. * Sets the value of the `A` button
  44190. */
  44191. set buttonA(value: number);
  44192. /**
  44193. * Gets the value of the `B` button
  44194. */
  44195. get buttonB(): number;
  44196. /**
  44197. * Sets the value of the `B` button
  44198. */
  44199. set buttonB(value: number);
  44200. /**
  44201. * Gets the value of the `X` button
  44202. */
  44203. get buttonX(): number;
  44204. /**
  44205. * Sets the value of the `X` button
  44206. */
  44207. set buttonX(value: number);
  44208. /**
  44209. * Gets the value of the `Y` button
  44210. */
  44211. get buttonY(): number;
  44212. /**
  44213. * Sets the value of the `Y` button
  44214. */
  44215. set buttonY(value: number);
  44216. /**
  44217. * Gets the value of the `Start` button
  44218. */
  44219. get buttonStart(): number;
  44220. /**
  44221. * Sets the value of the `Start` button
  44222. */
  44223. set buttonStart(value: number);
  44224. /**
  44225. * Gets the value of the `Back` button
  44226. */
  44227. get buttonBack(): number;
  44228. /**
  44229. * Sets the value of the `Back` button
  44230. */
  44231. set buttonBack(value: number);
  44232. /**
  44233. * Gets the value of the `Left` button
  44234. */
  44235. get buttonLB(): number;
  44236. /**
  44237. * Sets the value of the `Left` button
  44238. */
  44239. set buttonLB(value: number);
  44240. /**
  44241. * Gets the value of the `Right` button
  44242. */
  44243. get buttonRB(): number;
  44244. /**
  44245. * Sets the value of the `Right` button
  44246. */
  44247. set buttonRB(value: number);
  44248. /**
  44249. * Gets the value of the Left joystick
  44250. */
  44251. get buttonLeftStick(): number;
  44252. /**
  44253. * Sets the value of the Left joystick
  44254. */
  44255. set buttonLeftStick(value: number);
  44256. /**
  44257. * Gets the value of the Right joystick
  44258. */
  44259. get buttonRightStick(): number;
  44260. /**
  44261. * Sets the value of the Right joystick
  44262. */
  44263. set buttonRightStick(value: number);
  44264. /**
  44265. * Gets the value of D-pad up
  44266. */
  44267. get dPadUp(): number;
  44268. /**
  44269. * Sets the value of D-pad up
  44270. */
  44271. set dPadUp(value: number);
  44272. /**
  44273. * Gets the value of D-pad down
  44274. */
  44275. get dPadDown(): number;
  44276. /**
  44277. * Sets the value of D-pad down
  44278. */
  44279. set dPadDown(value: number);
  44280. /**
  44281. * Gets the value of D-pad left
  44282. */
  44283. get dPadLeft(): number;
  44284. /**
  44285. * Sets the value of D-pad left
  44286. */
  44287. set dPadLeft(value: number);
  44288. /**
  44289. * Gets the value of D-pad right
  44290. */
  44291. get dPadRight(): number;
  44292. /**
  44293. * Sets the value of D-pad right
  44294. */
  44295. set dPadRight(value: number);
  44296. /**
  44297. * Force the gamepad to synchronize with device values
  44298. */
  44299. update(): void;
  44300. /**
  44301. * Disposes the gamepad
  44302. */
  44303. dispose(): void;
  44304. }
  44305. }
  44306. declare module BABYLON {
  44307. /**
  44308. * Defines supported buttons for DualShock compatible gamepads
  44309. */
  44310. export enum DualShockButton {
  44311. /** Cross */
  44312. Cross = 0,
  44313. /** Circle */
  44314. Circle = 1,
  44315. /** Square */
  44316. Square = 2,
  44317. /** Triangle */
  44318. Triangle = 3,
  44319. /** L1 */
  44320. L1 = 4,
  44321. /** R1 */
  44322. R1 = 5,
  44323. /** Share */
  44324. Share = 8,
  44325. /** Options */
  44326. Options = 9,
  44327. /** Left stick */
  44328. LeftStick = 10,
  44329. /** Right stick */
  44330. RightStick = 11
  44331. }
  44332. /** Defines values for DualShock DPad */
  44333. export enum DualShockDpad {
  44334. /** Up */
  44335. Up = 12,
  44336. /** Down */
  44337. Down = 13,
  44338. /** Left */
  44339. Left = 14,
  44340. /** Right */
  44341. Right = 15
  44342. }
  44343. /**
  44344. * Defines a DualShock gamepad
  44345. */
  44346. export class DualShockPad extends Gamepad {
  44347. private _leftTrigger;
  44348. private _rightTrigger;
  44349. private _onlefttriggerchanged;
  44350. private _onrighttriggerchanged;
  44351. private _onbuttondown;
  44352. private _onbuttonup;
  44353. private _ondpaddown;
  44354. private _ondpadup;
  44355. /** Observable raised when a button is pressed */
  44356. onButtonDownObservable: Observable<DualShockButton>;
  44357. /** Observable raised when a button is released */
  44358. onButtonUpObservable: Observable<DualShockButton>;
  44359. /** Observable raised when a pad is pressed */
  44360. onPadDownObservable: Observable<DualShockDpad>;
  44361. /** Observable raised when a pad is released */
  44362. onPadUpObservable: Observable<DualShockDpad>;
  44363. private _buttonCross;
  44364. private _buttonCircle;
  44365. private _buttonSquare;
  44366. private _buttonTriangle;
  44367. private _buttonShare;
  44368. private _buttonOptions;
  44369. private _buttonL1;
  44370. private _buttonR1;
  44371. private _buttonLeftStick;
  44372. private _buttonRightStick;
  44373. private _dPadUp;
  44374. private _dPadDown;
  44375. private _dPadLeft;
  44376. private _dPadRight;
  44377. /**
  44378. * Creates a new DualShock gamepad object
  44379. * @param id defines the id of this gamepad
  44380. * @param index defines its index
  44381. * @param gamepad defines the internal HTML gamepad object
  44382. */
  44383. constructor(id: string, index: number, gamepad: any);
  44384. /**
  44385. * Defines the callback to call when left trigger is pressed
  44386. * @param callback defines the callback to use
  44387. */
  44388. onlefttriggerchanged(callback: (value: number) => void): void;
  44389. /**
  44390. * Defines the callback to call when right trigger is pressed
  44391. * @param callback defines the callback to use
  44392. */
  44393. onrighttriggerchanged(callback: (value: number) => void): void;
  44394. /**
  44395. * Gets the left trigger value
  44396. */
  44397. get leftTrigger(): number;
  44398. /**
  44399. * Sets the left trigger value
  44400. */
  44401. set leftTrigger(newValue: number);
  44402. /**
  44403. * Gets the right trigger value
  44404. */
  44405. get rightTrigger(): number;
  44406. /**
  44407. * Sets the right trigger value
  44408. */
  44409. set rightTrigger(newValue: number);
  44410. /**
  44411. * Defines the callback to call when a button is pressed
  44412. * @param callback defines the callback to use
  44413. */
  44414. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44415. /**
  44416. * Defines the callback to call when a button is released
  44417. * @param callback defines the callback to use
  44418. */
  44419. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44420. /**
  44421. * Defines the callback to call when a pad is pressed
  44422. * @param callback defines the callback to use
  44423. */
  44424. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44425. /**
  44426. * Defines the callback to call when a pad is released
  44427. * @param callback defines the callback to use
  44428. */
  44429. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44430. private _setButtonValue;
  44431. private _setDPadValue;
  44432. /**
  44433. * Gets the value of the `Cross` button
  44434. */
  44435. get buttonCross(): number;
  44436. /**
  44437. * Sets the value of the `Cross` button
  44438. */
  44439. set buttonCross(value: number);
  44440. /**
  44441. * Gets the value of the `Circle` button
  44442. */
  44443. get buttonCircle(): number;
  44444. /**
  44445. * Sets the value of the `Circle` button
  44446. */
  44447. set buttonCircle(value: number);
  44448. /**
  44449. * Gets the value of the `Square` button
  44450. */
  44451. get buttonSquare(): number;
  44452. /**
  44453. * Sets the value of the `Square` button
  44454. */
  44455. set buttonSquare(value: number);
  44456. /**
  44457. * Gets the value of the `Triangle` button
  44458. */
  44459. get buttonTriangle(): number;
  44460. /**
  44461. * Sets the value of the `Triangle` button
  44462. */
  44463. set buttonTriangle(value: number);
  44464. /**
  44465. * Gets the value of the `Options` button
  44466. */
  44467. get buttonOptions(): number;
  44468. /**
  44469. * Sets the value of the `Options` button
  44470. */
  44471. set buttonOptions(value: number);
  44472. /**
  44473. * Gets the value of the `Share` button
  44474. */
  44475. get buttonShare(): number;
  44476. /**
  44477. * Sets the value of the `Share` button
  44478. */
  44479. set buttonShare(value: number);
  44480. /**
  44481. * Gets the value of the `L1` button
  44482. */
  44483. get buttonL1(): number;
  44484. /**
  44485. * Sets the value of the `L1` button
  44486. */
  44487. set buttonL1(value: number);
  44488. /**
  44489. * Gets the value of the `R1` button
  44490. */
  44491. get buttonR1(): number;
  44492. /**
  44493. * Sets the value of the `R1` button
  44494. */
  44495. set buttonR1(value: number);
  44496. /**
  44497. * Gets the value of the Left joystick
  44498. */
  44499. get buttonLeftStick(): number;
  44500. /**
  44501. * Sets the value of the Left joystick
  44502. */
  44503. set buttonLeftStick(value: number);
  44504. /**
  44505. * Gets the value of the Right joystick
  44506. */
  44507. get buttonRightStick(): number;
  44508. /**
  44509. * Sets the value of the Right joystick
  44510. */
  44511. set buttonRightStick(value: number);
  44512. /**
  44513. * Gets the value of D-pad up
  44514. */
  44515. get dPadUp(): number;
  44516. /**
  44517. * Sets the value of D-pad up
  44518. */
  44519. set dPadUp(value: number);
  44520. /**
  44521. * Gets the value of D-pad down
  44522. */
  44523. get dPadDown(): number;
  44524. /**
  44525. * Sets the value of D-pad down
  44526. */
  44527. set dPadDown(value: number);
  44528. /**
  44529. * Gets the value of D-pad left
  44530. */
  44531. get dPadLeft(): number;
  44532. /**
  44533. * Sets the value of D-pad left
  44534. */
  44535. set dPadLeft(value: number);
  44536. /**
  44537. * Gets the value of D-pad right
  44538. */
  44539. get dPadRight(): number;
  44540. /**
  44541. * Sets the value of D-pad right
  44542. */
  44543. set dPadRight(value: number);
  44544. /**
  44545. * Force the gamepad to synchronize with device values
  44546. */
  44547. update(): void;
  44548. /**
  44549. * Disposes the gamepad
  44550. */
  44551. dispose(): void;
  44552. }
  44553. }
  44554. declare module BABYLON {
  44555. /**
  44556. * Manager for handling gamepads
  44557. */
  44558. export class GamepadManager {
  44559. private _scene?;
  44560. private _babylonGamepads;
  44561. private _oneGamepadConnected;
  44562. /** @hidden */
  44563. _isMonitoring: boolean;
  44564. private _gamepadEventSupported;
  44565. private _gamepadSupport?;
  44566. /**
  44567. * observable to be triggered when the gamepad controller has been connected
  44568. */
  44569. onGamepadConnectedObservable: Observable<Gamepad>;
  44570. /**
  44571. * observable to be triggered when the gamepad controller has been disconnected
  44572. */
  44573. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44574. private _onGamepadConnectedEvent;
  44575. private _onGamepadDisconnectedEvent;
  44576. /**
  44577. * Initializes the gamepad manager
  44578. * @param _scene BabylonJS scene
  44579. */
  44580. constructor(_scene?: Scene | undefined);
  44581. /**
  44582. * The gamepads in the game pad manager
  44583. */
  44584. get gamepads(): Gamepad[];
  44585. /**
  44586. * Get the gamepad controllers based on type
  44587. * @param type The type of gamepad controller
  44588. * @returns Nullable gamepad
  44589. */
  44590. getGamepadByType(type?: number): Nullable<Gamepad>;
  44591. /**
  44592. * Disposes the gamepad manager
  44593. */
  44594. dispose(): void;
  44595. private _addNewGamepad;
  44596. private _startMonitoringGamepads;
  44597. private _stopMonitoringGamepads;
  44598. /** @hidden */
  44599. _checkGamepadsStatus(): void;
  44600. private _updateGamepadObjects;
  44601. }
  44602. }
  44603. declare module BABYLON {
  44604. interface Scene {
  44605. /** @hidden */
  44606. _gamepadManager: Nullable<GamepadManager>;
  44607. /**
  44608. * Gets the gamepad manager associated with the scene
  44609. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44610. */
  44611. gamepadManager: GamepadManager;
  44612. }
  44613. /**
  44614. * Interface representing a free camera inputs manager
  44615. */
  44616. interface FreeCameraInputsManager {
  44617. /**
  44618. * Adds gamepad input support to the FreeCameraInputsManager.
  44619. * @returns the FreeCameraInputsManager
  44620. */
  44621. addGamepad(): FreeCameraInputsManager;
  44622. }
  44623. /**
  44624. * Interface representing an arc rotate camera inputs manager
  44625. */
  44626. interface ArcRotateCameraInputsManager {
  44627. /**
  44628. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44629. * @returns the camera inputs manager
  44630. */
  44631. addGamepad(): ArcRotateCameraInputsManager;
  44632. }
  44633. /**
  44634. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44635. */
  44636. export class GamepadSystemSceneComponent implements ISceneComponent {
  44637. /**
  44638. * The component name helpfull to identify the component in the list of scene components.
  44639. */
  44640. readonly name: string;
  44641. /**
  44642. * The scene the component belongs to.
  44643. */
  44644. scene: Scene;
  44645. /**
  44646. * Creates a new instance of the component for the given scene
  44647. * @param scene Defines the scene to register the component in
  44648. */
  44649. constructor(scene: Scene);
  44650. /**
  44651. * Registers the component in a given scene
  44652. */
  44653. register(): void;
  44654. /**
  44655. * Rebuilds the elements related to this component in case of
  44656. * context lost for instance.
  44657. */
  44658. rebuild(): void;
  44659. /**
  44660. * Disposes the component and the associated ressources
  44661. */
  44662. dispose(): void;
  44663. private _beforeCameraUpdate;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /**
  44668. * 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,
  44669. * which still works and will still be found in many Playgrounds.
  44670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44671. */
  44672. export class UniversalCamera extends TouchCamera {
  44673. /**
  44674. * Defines the gamepad rotation sensiblity.
  44675. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44676. */
  44677. get gamepadAngularSensibility(): number;
  44678. set gamepadAngularSensibility(value: number);
  44679. /**
  44680. * Defines the gamepad move sensiblity.
  44681. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44682. */
  44683. get gamepadMoveSensibility(): number;
  44684. set gamepadMoveSensibility(value: number);
  44685. /**
  44686. * 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,
  44687. * which still works and will still be found in many Playgrounds.
  44688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44689. * @param name Define the name of the camera in the scene
  44690. * @param position Define the start position of the camera in the scene
  44691. * @param scene Define the scene the camera belongs to
  44692. */
  44693. constructor(name: string, position: Vector3, scene: Scene);
  44694. /**
  44695. * Gets the current object class name.
  44696. * @return the class name
  44697. */
  44698. getClassName(): string;
  44699. }
  44700. }
  44701. declare module BABYLON {
  44702. /**
  44703. * This represents a FPS type of camera. This is only here for back compat purpose.
  44704. * Please use the UniversalCamera instead as both are identical.
  44705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44706. */
  44707. export class GamepadCamera extends UniversalCamera {
  44708. /**
  44709. * Instantiates a new Gamepad Camera
  44710. * This represents a FPS type of camera. This is only here for back compat purpose.
  44711. * Please use the UniversalCamera instead as both are identical.
  44712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44713. * @param name Define the name of the camera in the scene
  44714. * @param position Define the start position of the camera in the scene
  44715. * @param scene Define the scene the camera belongs to
  44716. */
  44717. constructor(name: string, position: Vector3, scene: Scene);
  44718. /**
  44719. * Gets the current object class name.
  44720. * @return the class name
  44721. */
  44722. getClassName(): string;
  44723. }
  44724. }
  44725. declare module BABYLON {
  44726. /** @hidden */
  44727. export var passPixelShader: {
  44728. name: string;
  44729. shader: string;
  44730. };
  44731. }
  44732. declare module BABYLON {
  44733. /** @hidden */
  44734. export var passCubePixelShader: {
  44735. name: string;
  44736. shader: string;
  44737. };
  44738. }
  44739. declare module BABYLON {
  44740. /**
  44741. * PassPostProcess which produces an output the same as it's input
  44742. */
  44743. export class PassPostProcess extends PostProcess {
  44744. /**
  44745. * Creates the PassPostProcess
  44746. * @param name The name of the effect.
  44747. * @param options The required width/height ratio to downsize to before computing the render pass.
  44748. * @param camera The camera to apply the render pass to.
  44749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44750. * @param engine The engine which the post process will be applied. (default: current engine)
  44751. * @param reusable If the post process can be reused on the same frame. (default: false)
  44752. * @param textureType The type of texture to be used when performing the post processing.
  44753. * @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)
  44754. */
  44755. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44756. }
  44757. /**
  44758. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44759. */
  44760. export class PassCubePostProcess extends PostProcess {
  44761. private _face;
  44762. /**
  44763. * Gets or sets the cube face to display.
  44764. * * 0 is +X
  44765. * * 1 is -X
  44766. * * 2 is +Y
  44767. * * 3 is -Y
  44768. * * 4 is +Z
  44769. * * 5 is -Z
  44770. */
  44771. get face(): number;
  44772. set face(value: number);
  44773. /**
  44774. * Creates the PassCubePostProcess
  44775. * @param name The name of the effect.
  44776. * @param options The required width/height ratio to downsize to before computing the render pass.
  44777. * @param camera The camera to apply the render pass to.
  44778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44779. * @param engine The engine which the post process will be applied. (default: current engine)
  44780. * @param reusable If the post process can be reused on the same frame. (default: false)
  44781. * @param textureType The type of texture to be used when performing the post processing.
  44782. * @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)
  44783. */
  44784. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44785. }
  44786. }
  44787. declare module BABYLON {
  44788. /** @hidden */
  44789. export var anaglyphPixelShader: {
  44790. name: string;
  44791. shader: string;
  44792. };
  44793. }
  44794. declare module BABYLON {
  44795. /**
  44796. * Postprocess used to generate anaglyphic rendering
  44797. */
  44798. export class AnaglyphPostProcess extends PostProcess {
  44799. private _passedProcess;
  44800. /**
  44801. * Creates a new AnaglyphPostProcess
  44802. * @param name defines postprocess name
  44803. * @param options defines creation options or target ratio scale
  44804. * @param rigCameras defines cameras using this postprocess
  44805. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44806. * @param engine defines hosting engine
  44807. * @param reusable defines if the postprocess will be reused multiple times per frame
  44808. */
  44809. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44815. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44816. */
  44817. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44818. /**
  44819. * Creates a new AnaglyphArcRotateCamera
  44820. * @param name defines camera name
  44821. * @param alpha defines alpha angle (in radians)
  44822. * @param beta defines beta angle (in radians)
  44823. * @param radius defines radius
  44824. * @param target defines camera target
  44825. * @param interaxialDistance defines distance between each color axis
  44826. * @param scene defines the hosting scene
  44827. */
  44828. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44829. /**
  44830. * Gets camera class name
  44831. * @returns AnaglyphArcRotateCamera
  44832. */
  44833. getClassName(): string;
  44834. }
  44835. }
  44836. declare module BABYLON {
  44837. /**
  44838. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44839. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44840. */
  44841. export class AnaglyphFreeCamera extends FreeCamera {
  44842. /**
  44843. * Creates a new AnaglyphFreeCamera
  44844. * @param name defines camera name
  44845. * @param position defines initial position
  44846. * @param interaxialDistance defines distance between each color axis
  44847. * @param scene defines the hosting scene
  44848. */
  44849. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44850. /**
  44851. * Gets camera class name
  44852. * @returns AnaglyphFreeCamera
  44853. */
  44854. getClassName(): string;
  44855. }
  44856. }
  44857. declare module BABYLON {
  44858. /**
  44859. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44860. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44861. */
  44862. export class AnaglyphGamepadCamera extends GamepadCamera {
  44863. /**
  44864. * Creates a new AnaglyphGamepadCamera
  44865. * @param name defines camera name
  44866. * @param position defines initial position
  44867. * @param interaxialDistance defines distance between each color axis
  44868. * @param scene defines the hosting scene
  44869. */
  44870. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44871. /**
  44872. * Gets camera class name
  44873. * @returns AnaglyphGamepadCamera
  44874. */
  44875. getClassName(): string;
  44876. }
  44877. }
  44878. declare module BABYLON {
  44879. /**
  44880. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44881. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44882. */
  44883. export class AnaglyphUniversalCamera extends UniversalCamera {
  44884. /**
  44885. * Creates a new AnaglyphUniversalCamera
  44886. * @param name defines camera name
  44887. * @param position defines initial position
  44888. * @param interaxialDistance defines distance between each color axis
  44889. * @param scene defines the hosting scene
  44890. */
  44891. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44892. /**
  44893. * Gets camera class name
  44894. * @returns AnaglyphUniversalCamera
  44895. */
  44896. getClassName(): string;
  44897. }
  44898. }
  44899. declare module BABYLON {
  44900. /**
  44901. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44902. * @see http://doc.babylonjs.com/features/cameras
  44903. */
  44904. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44905. /**
  44906. * Creates a new StereoscopicArcRotateCamera
  44907. * @param name defines camera name
  44908. * @param alpha defines alpha angle (in radians)
  44909. * @param beta defines beta angle (in radians)
  44910. * @param radius defines radius
  44911. * @param target defines camera target
  44912. * @param interaxialDistance defines distance between each color axis
  44913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44914. * @param scene defines the hosting scene
  44915. */
  44916. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44917. /**
  44918. * Gets camera class name
  44919. * @returns StereoscopicArcRotateCamera
  44920. */
  44921. getClassName(): string;
  44922. }
  44923. }
  44924. declare module BABYLON {
  44925. /**
  44926. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44927. * @see http://doc.babylonjs.com/features/cameras
  44928. */
  44929. export class StereoscopicFreeCamera extends FreeCamera {
  44930. /**
  44931. * Creates a new StereoscopicFreeCamera
  44932. * @param name defines camera name
  44933. * @param position defines initial position
  44934. * @param interaxialDistance defines distance between each color axis
  44935. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44936. * @param scene defines the hosting scene
  44937. */
  44938. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44939. /**
  44940. * Gets camera class name
  44941. * @returns StereoscopicFreeCamera
  44942. */
  44943. getClassName(): string;
  44944. }
  44945. }
  44946. declare module BABYLON {
  44947. /**
  44948. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44949. * @see http://doc.babylonjs.com/features/cameras
  44950. */
  44951. export class StereoscopicGamepadCamera extends GamepadCamera {
  44952. /**
  44953. * Creates a new StereoscopicGamepadCamera
  44954. * @param name defines camera name
  44955. * @param position defines initial position
  44956. * @param interaxialDistance defines distance between each color axis
  44957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44958. * @param scene defines the hosting scene
  44959. */
  44960. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44961. /**
  44962. * Gets camera class name
  44963. * @returns StereoscopicGamepadCamera
  44964. */
  44965. getClassName(): string;
  44966. }
  44967. }
  44968. declare module BABYLON {
  44969. /**
  44970. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44971. * @see http://doc.babylonjs.com/features/cameras
  44972. */
  44973. export class StereoscopicUniversalCamera extends UniversalCamera {
  44974. /**
  44975. * Creates a new StereoscopicUniversalCamera
  44976. * @param name defines camera name
  44977. * @param position defines initial position
  44978. * @param interaxialDistance defines distance between each color axis
  44979. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44980. * @param scene defines the hosting scene
  44981. */
  44982. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44983. /**
  44984. * Gets camera class name
  44985. * @returns StereoscopicUniversalCamera
  44986. */
  44987. getClassName(): string;
  44988. }
  44989. }
  44990. declare module BABYLON {
  44991. /**
  44992. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44993. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44994. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44995. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44996. */
  44997. export class VirtualJoysticksCamera extends FreeCamera {
  44998. /**
  44999. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45000. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45001. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45002. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45003. * @param name Define the name of the camera in the scene
  45004. * @param position Define the start position of the camera in the scene
  45005. * @param scene Define the scene the camera belongs to
  45006. */
  45007. constructor(name: string, position: Vector3, scene: Scene);
  45008. /**
  45009. * Gets the current object class name.
  45010. * @return the class name
  45011. */
  45012. getClassName(): string;
  45013. }
  45014. }
  45015. declare module BABYLON {
  45016. /**
  45017. * This represents all the required metrics to create a VR camera.
  45018. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45019. */
  45020. export class VRCameraMetrics {
  45021. /**
  45022. * Define the horizontal resolution off the screen.
  45023. */
  45024. hResolution: number;
  45025. /**
  45026. * Define the vertical resolution off the screen.
  45027. */
  45028. vResolution: number;
  45029. /**
  45030. * Define the horizontal screen size.
  45031. */
  45032. hScreenSize: number;
  45033. /**
  45034. * Define the vertical screen size.
  45035. */
  45036. vScreenSize: number;
  45037. /**
  45038. * Define the vertical screen center position.
  45039. */
  45040. vScreenCenter: number;
  45041. /**
  45042. * Define the distance of the eyes to the screen.
  45043. */
  45044. eyeToScreenDistance: number;
  45045. /**
  45046. * Define the distance between both lenses
  45047. */
  45048. lensSeparationDistance: number;
  45049. /**
  45050. * Define the distance between both viewer's eyes.
  45051. */
  45052. interpupillaryDistance: number;
  45053. /**
  45054. * Define the distortion factor of the VR postprocess.
  45055. * Please, touch with care.
  45056. */
  45057. distortionK: number[];
  45058. /**
  45059. * Define the chromatic aberration correction factors for the VR post process.
  45060. */
  45061. chromaAbCorrection: number[];
  45062. /**
  45063. * Define the scale factor of the post process.
  45064. * The smaller the better but the slower.
  45065. */
  45066. postProcessScaleFactor: number;
  45067. /**
  45068. * Define an offset for the lens center.
  45069. */
  45070. lensCenterOffset: number;
  45071. /**
  45072. * Define if the current vr camera should compensate the distortion of the lense or not.
  45073. */
  45074. compensateDistortion: boolean;
  45075. /**
  45076. * Defines if multiview should be enabled when rendering (Default: false)
  45077. */
  45078. multiviewEnabled: boolean;
  45079. /**
  45080. * Gets the rendering aspect ratio based on the provided resolutions.
  45081. */
  45082. get aspectRatio(): number;
  45083. /**
  45084. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45085. */
  45086. get aspectRatioFov(): number;
  45087. /**
  45088. * @hidden
  45089. */
  45090. get leftHMatrix(): Matrix;
  45091. /**
  45092. * @hidden
  45093. */
  45094. get rightHMatrix(): Matrix;
  45095. /**
  45096. * @hidden
  45097. */
  45098. get leftPreViewMatrix(): Matrix;
  45099. /**
  45100. * @hidden
  45101. */
  45102. get rightPreViewMatrix(): Matrix;
  45103. /**
  45104. * Get the default VRMetrics based on the most generic setup.
  45105. * @returns the default vr metrics
  45106. */
  45107. static GetDefault(): VRCameraMetrics;
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. /** @hidden */
  45112. export var vrDistortionCorrectionPixelShader: {
  45113. name: string;
  45114. shader: string;
  45115. };
  45116. }
  45117. declare module BABYLON {
  45118. /**
  45119. * VRDistortionCorrectionPostProcess used for mobile VR
  45120. */
  45121. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45122. private _isRightEye;
  45123. private _distortionFactors;
  45124. private _postProcessScaleFactor;
  45125. private _lensCenterOffset;
  45126. private _scaleIn;
  45127. private _scaleFactor;
  45128. private _lensCenter;
  45129. /**
  45130. * Initializes the VRDistortionCorrectionPostProcess
  45131. * @param name The name of the effect.
  45132. * @param camera The camera to apply the render pass to.
  45133. * @param isRightEye If this is for the right eye distortion
  45134. * @param vrMetrics All the required metrics for the VR camera
  45135. */
  45136. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45137. }
  45138. }
  45139. declare module BABYLON {
  45140. /**
  45141. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45142. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45143. */
  45144. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45145. /**
  45146. * Creates a new VRDeviceOrientationArcRotateCamera
  45147. * @param name defines camera name
  45148. * @param alpha defines the camera rotation along the logitudinal axis
  45149. * @param beta defines the camera rotation along the latitudinal axis
  45150. * @param radius defines the camera distance from its target
  45151. * @param target defines the camera target
  45152. * @param scene defines the scene the camera belongs to
  45153. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45154. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45155. */
  45156. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45157. /**
  45158. * Gets camera class name
  45159. * @returns VRDeviceOrientationArcRotateCamera
  45160. */
  45161. getClassName(): string;
  45162. }
  45163. }
  45164. declare module BABYLON {
  45165. /**
  45166. * Camera used to simulate VR rendering (based on FreeCamera)
  45167. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45168. */
  45169. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45170. /**
  45171. * Creates a new VRDeviceOrientationFreeCamera
  45172. * @param name defines camera name
  45173. * @param position defines the start position of the camera
  45174. * @param scene defines the scene the camera belongs to
  45175. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45176. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45177. */
  45178. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45179. /**
  45180. * Gets camera class name
  45181. * @returns VRDeviceOrientationFreeCamera
  45182. */
  45183. getClassName(): string;
  45184. }
  45185. }
  45186. declare module BABYLON {
  45187. /**
  45188. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45189. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45190. */
  45191. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45192. /**
  45193. * Creates a new VRDeviceOrientationGamepadCamera
  45194. * @param name defines camera name
  45195. * @param position defines the start position of the camera
  45196. * @param scene defines the scene the camera belongs to
  45197. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45198. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45199. */
  45200. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45201. /**
  45202. * Gets camera class name
  45203. * @returns VRDeviceOrientationGamepadCamera
  45204. */
  45205. getClassName(): string;
  45206. }
  45207. }
  45208. declare module BABYLON {
  45209. /** @hidden */
  45210. export var imageProcessingPixelShader: {
  45211. name: string;
  45212. shader: string;
  45213. };
  45214. }
  45215. declare module BABYLON {
  45216. /**
  45217. * ImageProcessingPostProcess
  45218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45219. */
  45220. export class ImageProcessingPostProcess extends PostProcess {
  45221. /**
  45222. * Default configuration related to image processing available in the PBR Material.
  45223. */
  45224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45225. /**
  45226. * Gets the image processing configuration used either in this material.
  45227. */
  45228. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45229. /**
  45230. * Sets the Default image processing configuration used either in the this material.
  45231. *
  45232. * If sets to null, the scene one is in use.
  45233. */
  45234. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45235. /**
  45236. * Keep track of the image processing observer to allow dispose and replace.
  45237. */
  45238. private _imageProcessingObserver;
  45239. /**
  45240. * Attaches a new image processing configuration to the PBR Material.
  45241. * @param configuration
  45242. */
  45243. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45244. /**
  45245. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45246. */
  45247. get colorCurves(): Nullable<ColorCurves>;
  45248. /**
  45249. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45250. */
  45251. set colorCurves(value: Nullable<ColorCurves>);
  45252. /**
  45253. * Gets wether the color curves effect is enabled.
  45254. */
  45255. get colorCurvesEnabled(): boolean;
  45256. /**
  45257. * Sets wether the color curves effect is enabled.
  45258. */
  45259. set colorCurvesEnabled(value: boolean);
  45260. /**
  45261. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45262. */
  45263. get colorGradingTexture(): Nullable<BaseTexture>;
  45264. /**
  45265. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45266. */
  45267. set colorGradingTexture(value: Nullable<BaseTexture>);
  45268. /**
  45269. * Gets wether the color grading effect is enabled.
  45270. */
  45271. get colorGradingEnabled(): boolean;
  45272. /**
  45273. * Gets wether the color grading effect is enabled.
  45274. */
  45275. set colorGradingEnabled(value: boolean);
  45276. /**
  45277. * Gets exposure used in the effect.
  45278. */
  45279. get exposure(): number;
  45280. /**
  45281. * Sets exposure used in the effect.
  45282. */
  45283. set exposure(value: number);
  45284. /**
  45285. * Gets wether tonemapping is enabled or not.
  45286. */
  45287. get toneMappingEnabled(): boolean;
  45288. /**
  45289. * Sets wether tonemapping is enabled or not
  45290. */
  45291. set toneMappingEnabled(value: boolean);
  45292. /**
  45293. * Gets the type of tone mapping effect.
  45294. */
  45295. get toneMappingType(): number;
  45296. /**
  45297. * Sets the type of tone mapping effect.
  45298. */
  45299. set toneMappingType(value: number);
  45300. /**
  45301. * Gets contrast used in the effect.
  45302. */
  45303. get contrast(): number;
  45304. /**
  45305. * Sets contrast used in the effect.
  45306. */
  45307. set contrast(value: number);
  45308. /**
  45309. * Gets Vignette stretch size.
  45310. */
  45311. get vignetteStretch(): number;
  45312. /**
  45313. * Sets Vignette stretch size.
  45314. */
  45315. set vignetteStretch(value: number);
  45316. /**
  45317. * Gets Vignette centre X Offset.
  45318. */
  45319. get vignetteCentreX(): number;
  45320. /**
  45321. * Sets Vignette centre X Offset.
  45322. */
  45323. set vignetteCentreX(value: number);
  45324. /**
  45325. * Gets Vignette centre Y Offset.
  45326. */
  45327. get vignetteCentreY(): number;
  45328. /**
  45329. * Sets Vignette centre Y Offset.
  45330. */
  45331. set vignetteCentreY(value: number);
  45332. /**
  45333. * Gets Vignette weight or intensity of the vignette effect.
  45334. */
  45335. get vignetteWeight(): number;
  45336. /**
  45337. * Sets Vignette weight or intensity of the vignette effect.
  45338. */
  45339. set vignetteWeight(value: number);
  45340. /**
  45341. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45342. * if vignetteEnabled is set to true.
  45343. */
  45344. get vignetteColor(): Color4;
  45345. /**
  45346. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45347. * if vignetteEnabled is set to true.
  45348. */
  45349. set vignetteColor(value: Color4);
  45350. /**
  45351. * Gets Camera field of view used by the Vignette effect.
  45352. */
  45353. get vignetteCameraFov(): number;
  45354. /**
  45355. * Sets Camera field of view used by the Vignette effect.
  45356. */
  45357. set vignetteCameraFov(value: number);
  45358. /**
  45359. * Gets the vignette blend mode allowing different kind of effect.
  45360. */
  45361. get vignetteBlendMode(): number;
  45362. /**
  45363. * Sets the vignette blend mode allowing different kind of effect.
  45364. */
  45365. set vignetteBlendMode(value: number);
  45366. /**
  45367. * Gets wether the vignette effect is enabled.
  45368. */
  45369. get vignetteEnabled(): boolean;
  45370. /**
  45371. * Sets wether the vignette effect is enabled.
  45372. */
  45373. set vignetteEnabled(value: boolean);
  45374. private _fromLinearSpace;
  45375. /**
  45376. * Gets wether the input of the processing is in Gamma or Linear Space.
  45377. */
  45378. get fromLinearSpace(): boolean;
  45379. /**
  45380. * Sets wether the input of the processing is in Gamma or Linear Space.
  45381. */
  45382. set fromLinearSpace(value: boolean);
  45383. /**
  45384. * Defines cache preventing GC.
  45385. */
  45386. private _defines;
  45387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45388. /**
  45389. * "ImageProcessingPostProcess"
  45390. * @returns "ImageProcessingPostProcess"
  45391. */
  45392. getClassName(): string;
  45393. protected _updateParameters(): void;
  45394. dispose(camera?: Camera): void;
  45395. }
  45396. }
  45397. declare module BABYLON {
  45398. /**
  45399. * Class containing static functions to help procedurally build meshes
  45400. */
  45401. export class GroundBuilder {
  45402. /**
  45403. * Creates a ground mesh
  45404. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45405. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45407. * @param name defines the name of the mesh
  45408. * @param options defines the options used to create the mesh
  45409. * @param scene defines the hosting scene
  45410. * @returns the ground mesh
  45411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45412. */
  45413. static CreateGround(name: string, options: {
  45414. width?: number;
  45415. height?: number;
  45416. subdivisions?: number;
  45417. subdivisionsX?: number;
  45418. subdivisionsY?: number;
  45419. updatable?: boolean;
  45420. }, scene: any): Mesh;
  45421. /**
  45422. * Creates a tiled ground mesh
  45423. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45424. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45425. * * 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
  45426. * * 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
  45427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45428. * @param name defines the name of the mesh
  45429. * @param options defines the options used to create the mesh
  45430. * @param scene defines the hosting scene
  45431. * @returns the tiled ground mesh
  45432. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45433. */
  45434. static CreateTiledGround(name: string, options: {
  45435. xmin: number;
  45436. zmin: number;
  45437. xmax: number;
  45438. zmax: number;
  45439. subdivisions?: {
  45440. w: number;
  45441. h: number;
  45442. };
  45443. precision?: {
  45444. w: number;
  45445. h: number;
  45446. };
  45447. updatable?: boolean;
  45448. }, scene?: Nullable<Scene>): Mesh;
  45449. /**
  45450. * Creates a ground mesh from a height map
  45451. * * The parameter `url` sets the URL of the height map image resource.
  45452. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45453. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45454. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45455. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45456. * * 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.
  45457. * * 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).
  45458. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45460. * @param name defines the name of the mesh
  45461. * @param url defines the url to the height map
  45462. * @param options defines the options used to create the mesh
  45463. * @param scene defines the hosting scene
  45464. * @returns the ground mesh
  45465. * @see https://doc.babylonjs.com/babylon101/height_map
  45466. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45467. */
  45468. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45469. width?: number;
  45470. height?: number;
  45471. subdivisions?: number;
  45472. minHeight?: number;
  45473. maxHeight?: number;
  45474. colorFilter?: Color3;
  45475. alphaFilter?: number;
  45476. updatable?: boolean;
  45477. onReady?: (mesh: GroundMesh) => void;
  45478. }, scene?: Nullable<Scene>): GroundMesh;
  45479. }
  45480. }
  45481. declare module BABYLON {
  45482. /**
  45483. * Class containing static functions to help procedurally build meshes
  45484. */
  45485. export class TorusBuilder {
  45486. /**
  45487. * Creates a torus mesh
  45488. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45489. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45490. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45492. * * 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
  45493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45494. * @param name defines the name of the mesh
  45495. * @param options defines the options used to create the mesh
  45496. * @param scene defines the hosting scene
  45497. * @returns the torus mesh
  45498. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45499. */
  45500. static CreateTorus(name: string, options: {
  45501. diameter?: number;
  45502. thickness?: number;
  45503. tessellation?: number;
  45504. updatable?: boolean;
  45505. sideOrientation?: number;
  45506. frontUVs?: Vector4;
  45507. backUVs?: Vector4;
  45508. }, scene: any): Mesh;
  45509. }
  45510. }
  45511. declare module BABYLON {
  45512. /**
  45513. * Class containing static functions to help procedurally build meshes
  45514. */
  45515. export class CylinderBuilder {
  45516. /**
  45517. * Creates a cylinder or a cone mesh
  45518. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45519. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45520. * * 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.
  45521. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45522. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45523. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45524. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45525. * * 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).
  45526. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45527. * * 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).
  45528. * * 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
  45529. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45530. * * 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
  45531. * * 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.
  45532. * * If `enclose` is false, a ring surface is one element.
  45533. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45534. * * 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
  45535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45536. * * 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
  45537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45538. * @param name defines the name of the mesh
  45539. * @param options defines the options used to create the mesh
  45540. * @param scene defines the hosting scene
  45541. * @returns the cylinder mesh
  45542. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45543. */
  45544. static CreateCylinder(name: string, options: {
  45545. height?: number;
  45546. diameterTop?: number;
  45547. diameterBottom?: number;
  45548. diameter?: number;
  45549. tessellation?: number;
  45550. subdivisions?: number;
  45551. arc?: number;
  45552. faceColors?: Color4[];
  45553. faceUV?: Vector4[];
  45554. updatable?: boolean;
  45555. hasRings?: boolean;
  45556. enclose?: boolean;
  45557. cap?: number;
  45558. sideOrientation?: number;
  45559. frontUVs?: Vector4;
  45560. backUVs?: Vector4;
  45561. }, scene: any): Mesh;
  45562. }
  45563. }
  45564. declare module BABYLON {
  45565. /**
  45566. * States of the webXR experience
  45567. */
  45568. export enum WebXRState {
  45569. /**
  45570. * Transitioning to being in XR mode
  45571. */
  45572. ENTERING_XR = 0,
  45573. /**
  45574. * Transitioning to non XR mode
  45575. */
  45576. EXITING_XR = 1,
  45577. /**
  45578. * In XR mode and presenting
  45579. */
  45580. IN_XR = 2,
  45581. /**
  45582. * Not entered XR mode
  45583. */
  45584. NOT_IN_XR = 3
  45585. }
  45586. /**
  45587. * Abstraction of the XR render target
  45588. */
  45589. export interface WebXRRenderTarget extends IDisposable {
  45590. /**
  45591. * xrpresent context of the canvas which can be used to display/mirror xr content
  45592. */
  45593. canvasContext: WebGLRenderingContext;
  45594. /**
  45595. * xr layer for the canvas
  45596. */
  45597. xrLayer: Nullable<XRWebGLLayer>;
  45598. /**
  45599. * Initializes the xr layer for the session
  45600. * @param xrSession xr session
  45601. * @returns a promise that will resolve once the XR Layer has been created
  45602. */
  45603. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45604. }
  45605. }
  45606. declare module BABYLON {
  45607. /**
  45608. * COnfiguration object for WebXR output canvas
  45609. */
  45610. export class WebXRManagedOutputCanvasOptions {
  45611. /**
  45612. * An optional canvas in case you wish to create it yourself and provide it here.
  45613. * If not provided, a new canvas will be created
  45614. */
  45615. canvasElement?: HTMLCanvasElement;
  45616. /**
  45617. * Options for this XR Layer output
  45618. */
  45619. canvasOptions?: XRWebGLLayerOptions;
  45620. /**
  45621. * CSS styling for a newly created canvas (if not provided)
  45622. */
  45623. newCanvasCssStyle?: string;
  45624. /**
  45625. * Get the default values of the configuration object
  45626. * @returns default values of this configuration object
  45627. */
  45628. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45629. }
  45630. /**
  45631. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45632. */
  45633. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45634. private _options;
  45635. private _canvas;
  45636. private _engine;
  45637. /**
  45638. * Rendering context of the canvas which can be used to display/mirror xr content
  45639. */
  45640. canvasContext: WebGLRenderingContext;
  45641. /**
  45642. * xr layer for the canvas
  45643. */
  45644. xrLayer: Nullable<XRWebGLLayer>;
  45645. /**
  45646. * Initializes the canvas to be added/removed upon entering/exiting xr
  45647. * @param _xrSessionManager The XR Session manager
  45648. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45649. */
  45650. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45651. /**
  45652. * Disposes of the object
  45653. */
  45654. dispose(): void;
  45655. /**
  45656. * Initializes the xr layer for the session
  45657. * @param xrSession xr session
  45658. * @returns a promise that will resolve once the XR Layer has been created
  45659. */
  45660. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45661. private _addCanvas;
  45662. private _removeCanvas;
  45663. private _setManagedOutputCanvas;
  45664. }
  45665. }
  45666. declare module BABYLON {
  45667. /**
  45668. * Manages an XRSession to work with Babylon's engine
  45669. * @see https://doc.babylonjs.com/how_to/webxr
  45670. */
  45671. export class WebXRSessionManager implements IDisposable {
  45672. /** The scene which the session should be created for */
  45673. scene: Scene;
  45674. private _referenceSpace;
  45675. private _rttProvider;
  45676. private _sessionEnded;
  45677. private _xrNavigator;
  45678. private baseLayer;
  45679. /**
  45680. * The base reference space from which the session started. good if you want to reset your
  45681. * reference space
  45682. */
  45683. baseReferenceSpace: XRReferenceSpace;
  45684. /**
  45685. * Current XR frame
  45686. */
  45687. currentFrame: Nullable<XRFrame>;
  45688. /** WebXR timestamp updated every frame */
  45689. currentTimestamp: number;
  45690. /**
  45691. * Used just in case of a failure to initialize an immersive session.
  45692. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45693. */
  45694. defaultHeightCompensation: number;
  45695. /**
  45696. * Fires every time a new xrFrame arrives which can be used to update the camera
  45697. */
  45698. onXRFrameObservable: Observable<XRFrame>;
  45699. /**
  45700. * Fires when the reference space changed
  45701. */
  45702. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45703. /**
  45704. * Fires when the xr session is ended either by the device or manually done
  45705. */
  45706. onXRSessionEnded: Observable<any>;
  45707. /**
  45708. * Fires when the xr session is ended either by the device or manually done
  45709. */
  45710. onXRSessionInit: Observable<XRSession>;
  45711. /**
  45712. * Underlying xr session
  45713. */
  45714. session: XRSession;
  45715. /**
  45716. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45717. * or get the offset the player is currently at.
  45718. */
  45719. viewerReferenceSpace: XRReferenceSpace;
  45720. /**
  45721. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45722. * @param scene The scene which the session should be created for
  45723. */
  45724. constructor(
  45725. /** The scene which the session should be created for */
  45726. scene: Scene);
  45727. /**
  45728. * The current reference space used in this session. This reference space can constantly change!
  45729. * It is mainly used to offset the camera's position.
  45730. */
  45731. get referenceSpace(): XRReferenceSpace;
  45732. /**
  45733. * Set a new reference space and triggers the observable
  45734. */
  45735. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45736. /**
  45737. * Disposes of the session manager
  45738. */
  45739. dispose(): void;
  45740. /**
  45741. * Stops the xrSession and restores the render loop
  45742. * @returns Promise which resolves after it exits XR
  45743. */
  45744. exitXRAsync(): Promise<void>;
  45745. /**
  45746. * Gets the correct render target texture to be rendered this frame for this eye
  45747. * @param eye the eye for which to get the render target
  45748. * @returns the render target for the specified eye
  45749. */
  45750. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45751. /**
  45752. * Creates a WebXRRenderTarget object for the XR session
  45753. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45754. * @param options optional options to provide when creating a new render target
  45755. * @returns a WebXR render target to which the session can render
  45756. */
  45757. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45758. /**
  45759. * Initializes the manager
  45760. * After initialization enterXR can be called to start an XR session
  45761. * @returns Promise which resolves after it is initialized
  45762. */
  45763. initializeAsync(): Promise<void>;
  45764. /**
  45765. * Initializes an xr session
  45766. * @param xrSessionMode mode to initialize
  45767. * @param xrSessionInit defines optional and required values to pass to the session builder
  45768. * @returns a promise which will resolve once the session has been initialized
  45769. */
  45770. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45771. /**
  45772. * Checks if a session would be supported for the creation options specified
  45773. * @param sessionMode session mode to check if supported eg. immersive-vr
  45774. * @returns A Promise that resolves to true if supported and false if not
  45775. */
  45776. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45777. /**
  45778. * Resets the reference space to the one started the session
  45779. */
  45780. resetReferenceSpace(): void;
  45781. /**
  45782. * Starts rendering to the xr layer
  45783. */
  45784. runXRRenderLoop(): void;
  45785. /**
  45786. * Sets the reference space on the xr session
  45787. * @param referenceSpaceType space to set
  45788. * @returns a promise that will resolve once the reference space has been set
  45789. */
  45790. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45791. /**
  45792. * Updates the render state of the session
  45793. * @param state state to set
  45794. * @returns a promise that resolves once the render state has been updated
  45795. */
  45796. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45797. /**
  45798. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45799. * @param sessionMode defines the session to test
  45800. * @returns a promise with boolean as final value
  45801. */
  45802. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45803. private _createRenderTargetTexture;
  45804. }
  45805. }
  45806. declare module BABYLON {
  45807. /**
  45808. * WebXR Camera which holds the views for the xrSession
  45809. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45810. */
  45811. export class WebXRCamera extends FreeCamera {
  45812. private _xrSessionManager;
  45813. private _firstFrame;
  45814. private _referenceQuaternion;
  45815. private _referencedPosition;
  45816. private _xrInvPositionCache;
  45817. private _xrInvQuaternionCache;
  45818. /**
  45819. * Should position compensation execute on first frame.
  45820. * This is used when copying the position from a native (non XR) camera
  45821. */
  45822. compensateOnFirstFrame: boolean;
  45823. /**
  45824. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45825. * @param name the name of the camera
  45826. * @param scene the scene to add the camera to
  45827. * @param _xrSessionManager a constructed xr session manager
  45828. */
  45829. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45830. /**
  45831. * Return the user's height, unrelated to the current ground.
  45832. * This will be the y position of this camera, when ground level is 0.
  45833. */
  45834. get realWorldHeight(): number;
  45835. /** @hidden */
  45836. _updateForDualEyeDebugging(): void;
  45837. /**
  45838. * Sets this camera's transformation based on a non-vr camera
  45839. * @param otherCamera the non-vr camera to copy the transformation from
  45840. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45841. */
  45842. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45843. /**
  45844. * Gets the current instance class name ("WebXRCamera").
  45845. * @returns the class name
  45846. */
  45847. getClassName(): string;
  45848. /**
  45849. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45850. */
  45851. _getViewMatrix(): Matrix;
  45852. private _updateFromXRSession;
  45853. private _updateNumberOfRigCameras;
  45854. private _updateReferenceSpace;
  45855. private _updateReferenceSpaceOffset;
  45856. }
  45857. }
  45858. declare module BABYLON {
  45859. /**
  45860. * Defining the interface required for a (webxr) feature
  45861. */
  45862. export interface IWebXRFeature extends IDisposable {
  45863. /**
  45864. * Is this feature attached
  45865. */
  45866. attached: boolean;
  45867. /**
  45868. * Should auto-attach be disabled?
  45869. */
  45870. disableAutoAttach: boolean;
  45871. /**
  45872. * Attach the feature to the session
  45873. * Will usually be called by the features manager
  45874. *
  45875. * @param force should attachment be forced (even when already attached)
  45876. * @returns true if successful.
  45877. */
  45878. attach(force?: boolean): boolean;
  45879. /**
  45880. * Detach the feature from the session
  45881. * Will usually be called by the features manager
  45882. *
  45883. * @returns true if successful.
  45884. */
  45885. detach(): boolean;
  45886. }
  45887. /**
  45888. * A list of the currently available features without referencing them
  45889. */
  45890. export class WebXRFeatureName {
  45891. /**
  45892. * The name of the anchor system feature
  45893. */
  45894. static ANCHOR_SYSTEM: string;
  45895. /**
  45896. * The name of the background remover feature
  45897. */
  45898. static BACKGROUND_REMOVER: string;
  45899. /**
  45900. * The name of the hit test feature
  45901. */
  45902. static HIT_TEST: string;
  45903. /**
  45904. * physics impostors for xr controllers feature
  45905. */
  45906. static PHYSICS_CONTROLLERS: string;
  45907. /**
  45908. * The name of the plane detection feature
  45909. */
  45910. static PLANE_DETECTION: string;
  45911. /**
  45912. * The name of the pointer selection feature
  45913. */
  45914. static POINTER_SELECTION: string;
  45915. /**
  45916. * The name of the teleportation feature
  45917. */
  45918. static TELEPORTATION: string;
  45919. }
  45920. /**
  45921. * Defining the constructor of a feature. Used to register the modules.
  45922. */
  45923. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45924. /**
  45925. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45926. * It is mainly used in AR sessions.
  45927. *
  45928. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45929. */
  45930. export class WebXRFeaturesManager implements IDisposable {
  45931. private _xrSessionManager;
  45932. private static readonly _AvailableFeatures;
  45933. private _features;
  45934. /**
  45935. * constructs a new features manages.
  45936. *
  45937. * @param _xrSessionManager an instance of WebXRSessionManager
  45938. */
  45939. constructor(_xrSessionManager: WebXRSessionManager);
  45940. /**
  45941. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45942. * Mainly used internally.
  45943. *
  45944. * @param featureName the name of the feature to register
  45945. * @param constructorFunction the function used to construct the module
  45946. * @param version the (babylon) version of the module
  45947. * @param stable is that a stable version of this module
  45948. */
  45949. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45950. /**
  45951. * Returns a constructor of a specific feature.
  45952. *
  45953. * @param featureName the name of the feature to construct
  45954. * @param version the version of the feature to load
  45955. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45956. * @param options optional options provided to the module.
  45957. * @returns a function that, when called, will return a new instance of this feature
  45958. */
  45959. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45960. /**
  45961. * Can be used to return the list of features currently registered
  45962. *
  45963. * @returns an Array of available features
  45964. */
  45965. static GetAvailableFeatures(): string[];
  45966. /**
  45967. * Gets the versions available for a specific feature
  45968. * @param featureName the name of the feature
  45969. * @returns an array with the available versions
  45970. */
  45971. static GetAvailableVersions(featureName: string): string[];
  45972. /**
  45973. * Return the latest unstable version of this feature
  45974. * @param featureName the name of the feature to search
  45975. * @returns the version number. if not found will return -1
  45976. */
  45977. static GetLatestVersionOfFeature(featureName: string): number;
  45978. /**
  45979. * Return the latest stable version of this feature
  45980. * @param featureName the name of the feature to search
  45981. * @returns the version number. if not found will return -1
  45982. */
  45983. static GetStableVersionOfFeature(featureName: string): number;
  45984. /**
  45985. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45986. * Can be used during a session to start a feature
  45987. * @param featureName the name of feature to attach
  45988. */
  45989. attachFeature(featureName: string): void;
  45990. /**
  45991. * Can be used inside a session or when the session ends to detach a specific feature
  45992. * @param featureName the name of the feature to detach
  45993. */
  45994. detachFeature(featureName: string): void;
  45995. /**
  45996. * Used to disable an already-enabled feature
  45997. * The feature will be disposed and will be recreated once enabled.
  45998. * @param featureName the feature to disable
  45999. * @returns true if disable was successful
  46000. */
  46001. disableFeature(featureName: string | {
  46002. Name: string;
  46003. }): boolean;
  46004. /**
  46005. * dispose this features manager
  46006. */
  46007. dispose(): void;
  46008. /**
  46009. * 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.
  46010. * 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.
  46011. *
  46012. * @param featureName the name of the feature to load or the class of the feature
  46013. * @param version optional version to load. if not provided the latest version will be enabled
  46014. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46015. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46016. * @returns a new constructed feature or throws an error if feature not found.
  46017. */
  46018. enableFeature(featureName: string | {
  46019. Name: string;
  46020. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46021. /**
  46022. * get the implementation of an enabled feature.
  46023. * @param featureName the name of the feature to load
  46024. * @returns the feature class, if found
  46025. */
  46026. getEnabledFeature(featureName: string): IWebXRFeature;
  46027. /**
  46028. * Get the list of enabled features
  46029. * @returns an array of enabled features
  46030. */
  46031. getEnabledFeatures(): string[];
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /**
  46036. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46037. * @see https://doc.babylonjs.com/how_to/webxr
  46038. */
  46039. export class WebXRExperienceHelper implements IDisposable {
  46040. private scene;
  46041. private _nonVRCamera;
  46042. private _originalSceneAutoClear;
  46043. private _supported;
  46044. /**
  46045. * Camera used to render xr content
  46046. */
  46047. camera: WebXRCamera;
  46048. /** A features manager for this xr session */
  46049. featuresManager: WebXRFeaturesManager;
  46050. /**
  46051. * Observers registered here will be triggered after the camera's initial transformation is set
  46052. * This can be used to set a different ground level or an extra rotation.
  46053. *
  46054. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46055. * to the position set after this observable is done executing.
  46056. */
  46057. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46058. /**
  46059. * Fires when the state of the experience helper has changed
  46060. */
  46061. onStateChangedObservable: Observable<WebXRState>;
  46062. /** Session manager used to keep track of xr session */
  46063. sessionManager: WebXRSessionManager;
  46064. /**
  46065. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46066. */
  46067. state: WebXRState;
  46068. /**
  46069. * Creates a WebXRExperienceHelper
  46070. * @param scene The scene the helper should be created in
  46071. */
  46072. private constructor();
  46073. /**
  46074. * Creates the experience helper
  46075. * @param scene the scene to attach the experience helper to
  46076. * @returns a promise for the experience helper
  46077. */
  46078. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46079. /**
  46080. * Disposes of the experience helper
  46081. */
  46082. dispose(): void;
  46083. /**
  46084. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46085. * @param sessionMode options for the XR session
  46086. * @param referenceSpaceType frame of reference of the XR session
  46087. * @param renderTarget the output canvas that will be used to enter XR mode
  46088. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46089. * @returns promise that resolves after xr mode has entered
  46090. */
  46091. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46092. /**
  46093. * Exits XR mode and returns the scene to its original state
  46094. * @returns promise that resolves after xr mode has exited
  46095. */
  46096. exitXRAsync(): Promise<void>;
  46097. private _nonXRToXRCamera;
  46098. private _setState;
  46099. }
  46100. }
  46101. declare module BABYLON {
  46102. /**
  46103. * X-Y values for axes in WebXR
  46104. */
  46105. export interface IWebXRMotionControllerAxesValue {
  46106. /**
  46107. * The value of the x axis
  46108. */
  46109. x: number;
  46110. /**
  46111. * The value of the y-axis
  46112. */
  46113. y: number;
  46114. }
  46115. /**
  46116. * changed / previous values for the values of this component
  46117. */
  46118. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46119. /**
  46120. * current (this frame) value
  46121. */
  46122. current: T;
  46123. /**
  46124. * previous (last change) value
  46125. */
  46126. previous: T;
  46127. }
  46128. /**
  46129. * Represents changes in the component between current frame and last values recorded
  46130. */
  46131. export interface IWebXRMotionControllerComponentChanges {
  46132. /**
  46133. * will be populated with previous and current values if axes changed
  46134. */
  46135. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46136. /**
  46137. * will be populated with previous and current values if pressed changed
  46138. */
  46139. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46140. /**
  46141. * will be populated with previous and current values if touched changed
  46142. */
  46143. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46144. /**
  46145. * will be populated with previous and current values if value changed
  46146. */
  46147. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46148. }
  46149. /**
  46150. * This class represents a single component (for example button or thumbstick) of a motion controller
  46151. */
  46152. export class WebXRControllerComponent implements IDisposable {
  46153. /**
  46154. * the id of this component
  46155. */
  46156. id: string;
  46157. /**
  46158. * the type of the component
  46159. */
  46160. type: MotionControllerComponentType;
  46161. private _buttonIndex;
  46162. private _axesIndices;
  46163. private _axes;
  46164. private _changes;
  46165. private _currentValue;
  46166. private _hasChanges;
  46167. private _pressed;
  46168. private _touched;
  46169. /**
  46170. * button component type
  46171. */
  46172. static BUTTON_TYPE: MotionControllerComponentType;
  46173. /**
  46174. * squeeze component type
  46175. */
  46176. static SQUEEZE_TYPE: MotionControllerComponentType;
  46177. /**
  46178. * Thumbstick component type
  46179. */
  46180. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46181. /**
  46182. * Touchpad component type
  46183. */
  46184. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46185. /**
  46186. * trigger component type
  46187. */
  46188. static TRIGGER_TYPE: MotionControllerComponentType;
  46189. /**
  46190. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46191. * the axes data changes
  46192. */
  46193. onAxisValueChangedObservable: Observable<{
  46194. x: number;
  46195. y: number;
  46196. }>;
  46197. /**
  46198. * Observers registered here will be triggered when the state of a button changes
  46199. * State change is either pressed / touched / value
  46200. */
  46201. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46202. /**
  46203. * Creates a new component for a motion controller.
  46204. * It is created by the motion controller itself
  46205. *
  46206. * @param id the id of this component
  46207. * @param type the type of the component
  46208. * @param _buttonIndex index in the buttons array of the gamepad
  46209. * @param _axesIndices indices of the values in the axes array of the gamepad
  46210. */
  46211. constructor(
  46212. /**
  46213. * the id of this component
  46214. */
  46215. id: string,
  46216. /**
  46217. * the type of the component
  46218. */
  46219. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46220. /**
  46221. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46222. */
  46223. get axes(): IWebXRMotionControllerAxesValue;
  46224. /**
  46225. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46226. */
  46227. get changes(): IWebXRMotionControllerComponentChanges;
  46228. /**
  46229. * Return whether or not the component changed the last frame
  46230. */
  46231. get hasChanges(): boolean;
  46232. /**
  46233. * is the button currently pressed
  46234. */
  46235. get pressed(): boolean;
  46236. /**
  46237. * is the button currently touched
  46238. */
  46239. get touched(): boolean;
  46240. /**
  46241. * Get the current value of this component
  46242. */
  46243. get value(): number;
  46244. /**
  46245. * Dispose this component
  46246. */
  46247. dispose(): void;
  46248. /**
  46249. * Are there axes correlating to this component
  46250. * @return true is axes data is available
  46251. */
  46252. isAxes(): boolean;
  46253. /**
  46254. * Is this component a button (hence - pressable)
  46255. * @returns true if can be pressed
  46256. */
  46257. isButton(): boolean;
  46258. /**
  46259. * update this component using the gamepad object it is in. Called on every frame
  46260. * @param nativeController the native gamepad controller object
  46261. */
  46262. update(nativeController: IMinimalMotionControllerObject): void;
  46263. }
  46264. }
  46265. declare module BABYLON {
  46266. /**
  46267. * Class used to represent data loading progression
  46268. */
  46269. export class SceneLoaderProgressEvent {
  46270. /** defines if data length to load can be evaluated */
  46271. readonly lengthComputable: boolean;
  46272. /** defines the loaded data length */
  46273. readonly loaded: number;
  46274. /** defines the data length to load */
  46275. readonly total: number;
  46276. /**
  46277. * Create a new progress event
  46278. * @param lengthComputable defines if data length to load can be evaluated
  46279. * @param loaded defines the loaded data length
  46280. * @param total defines the data length to load
  46281. */
  46282. constructor(
  46283. /** defines if data length to load can be evaluated */
  46284. lengthComputable: boolean,
  46285. /** defines the loaded data length */
  46286. loaded: number,
  46287. /** defines the data length to load */
  46288. total: number);
  46289. /**
  46290. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46291. * @param event defines the source event
  46292. * @returns a new SceneLoaderProgressEvent
  46293. */
  46294. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46295. }
  46296. /**
  46297. * Interface used by SceneLoader plugins to define supported file extensions
  46298. */
  46299. export interface ISceneLoaderPluginExtensions {
  46300. /**
  46301. * Defines the list of supported extensions
  46302. */
  46303. [extension: string]: {
  46304. isBinary: boolean;
  46305. };
  46306. }
  46307. /**
  46308. * Interface used by SceneLoader plugin factory
  46309. */
  46310. export interface ISceneLoaderPluginFactory {
  46311. /**
  46312. * Defines the name of the factory
  46313. */
  46314. name: string;
  46315. /**
  46316. * Function called to create a new plugin
  46317. * @return the new plugin
  46318. */
  46319. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46320. /**
  46321. * The callback that returns true if the data can be directly loaded.
  46322. * @param data string containing the file data
  46323. * @returns if the data can be loaded directly
  46324. */
  46325. canDirectLoad?(data: string): boolean;
  46326. }
  46327. /**
  46328. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46329. */
  46330. export interface ISceneLoaderPluginBase {
  46331. /**
  46332. * The friendly name of this plugin.
  46333. */
  46334. name: string;
  46335. /**
  46336. * The file extensions supported by this plugin.
  46337. */
  46338. extensions: string | ISceneLoaderPluginExtensions;
  46339. /**
  46340. * The callback called when loading from a url.
  46341. * @param scene scene loading this url
  46342. * @param url url to load
  46343. * @param onSuccess callback called when the file successfully loads
  46344. * @param onProgress callback called while file is loading (if the server supports this mode)
  46345. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46346. * @param onError callback called when the file fails to load
  46347. * @returns a file request object
  46348. */
  46349. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46350. /**
  46351. * The callback called when loading from a file object.
  46352. * @param scene scene loading this file
  46353. * @param file defines the file to load
  46354. * @param onSuccess defines the callback to call when data is loaded
  46355. * @param onProgress defines the callback to call during loading process
  46356. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46357. * @param onError defines the callback to call when an error occurs
  46358. * @returns a file request object
  46359. */
  46360. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46361. /**
  46362. * The callback that returns true if the data can be directly loaded.
  46363. * @param data string containing the file data
  46364. * @returns if the data can be loaded directly
  46365. */
  46366. canDirectLoad?(data: string): boolean;
  46367. /**
  46368. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46369. * @param scene scene loading this data
  46370. * @param data string containing the data
  46371. * @returns data to pass to the plugin
  46372. */
  46373. directLoad?(scene: Scene, data: string): any;
  46374. /**
  46375. * The callback that allows custom handling of the root url based on the response url.
  46376. * @param rootUrl the original root url
  46377. * @param responseURL the response url if available
  46378. * @returns the new root url
  46379. */
  46380. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46381. }
  46382. /**
  46383. * Interface used to define a SceneLoader plugin
  46384. */
  46385. export interface ISceneLoaderPlugin 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 meshes The meshes array to import into
  46393. * @param particleSystems The particle systems array to import into
  46394. * @param skeletons The skeletons array to import into
  46395. * @param onError The callback when import fails
  46396. * @returns True if successful or false otherwise
  46397. */
  46398. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46399. /**
  46400. * Load into a scene.
  46401. * @param scene The scene to load into
  46402. * @param data The data to import
  46403. * @param rootUrl The root url for scene and resources
  46404. * @param onError The callback when import fails
  46405. * @returns True if successful or false otherwise
  46406. */
  46407. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46408. /**
  46409. * Load into an asset container.
  46410. * @param scene The scene to load into
  46411. * @param data The data to import
  46412. * @param rootUrl The root url for scene and resources
  46413. * @param onError The callback when import fails
  46414. * @returns The loaded asset container
  46415. */
  46416. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46417. }
  46418. /**
  46419. * Interface used to define an async SceneLoader plugin
  46420. */
  46421. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46422. /**
  46423. * Import meshes into a scene.
  46424. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46425. * @param scene The scene to import into
  46426. * @param data The data to import
  46427. * @param rootUrl The root url for scene and resources
  46428. * @param onProgress The callback when the load progresses
  46429. * @param fileName Defines the name of the file to load
  46430. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46431. */
  46432. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46433. meshes: AbstractMesh[];
  46434. particleSystems: IParticleSystem[];
  46435. skeletons: Skeleton[];
  46436. animationGroups: AnimationGroup[];
  46437. }>;
  46438. /**
  46439. * Load into a scene.
  46440. * @param scene The scene to load into
  46441. * @param data The data to import
  46442. * @param rootUrl The root url for scene and resources
  46443. * @param onProgress The callback when the load progresses
  46444. * @param fileName Defines the name of the file to load
  46445. * @returns Nothing
  46446. */
  46447. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46448. /**
  46449. * Load into an asset container.
  46450. * @param scene The scene to load into
  46451. * @param data The data to import
  46452. * @param rootUrl The root url for scene and resources
  46453. * @param onProgress The callback when the load progresses
  46454. * @param fileName Defines the name of the file to load
  46455. * @returns The loaded asset container
  46456. */
  46457. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46458. }
  46459. /**
  46460. * Mode that determines how to handle old animation groups before loading new ones.
  46461. */
  46462. export enum SceneLoaderAnimationGroupLoadingMode {
  46463. /**
  46464. * Reset all old animations to initial state then dispose them.
  46465. */
  46466. Clean = 0,
  46467. /**
  46468. * Stop all old animations.
  46469. */
  46470. Stop = 1,
  46471. /**
  46472. * Restart old animations from first frame.
  46473. */
  46474. Sync = 2,
  46475. /**
  46476. * Old animations remains untouched.
  46477. */
  46478. NoSync = 3
  46479. }
  46480. /**
  46481. * Class used to load scene from various file formats using registered plugins
  46482. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46483. */
  46484. export class SceneLoader {
  46485. /**
  46486. * No logging while loading
  46487. */
  46488. static readonly NO_LOGGING: number;
  46489. /**
  46490. * Minimal logging while loading
  46491. */
  46492. static readonly MINIMAL_LOGGING: number;
  46493. /**
  46494. * Summary logging while loading
  46495. */
  46496. static readonly SUMMARY_LOGGING: number;
  46497. /**
  46498. * Detailled logging while loading
  46499. */
  46500. static readonly DETAILED_LOGGING: number;
  46501. /**
  46502. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46503. */
  46504. static get ForceFullSceneLoadingForIncremental(): boolean;
  46505. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46506. /**
  46507. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46508. */
  46509. static get ShowLoadingScreen(): boolean;
  46510. static set ShowLoadingScreen(value: boolean);
  46511. /**
  46512. * Defines the current logging level (while loading the scene)
  46513. * @ignorenaming
  46514. */
  46515. static get loggingLevel(): number;
  46516. static set loggingLevel(value: number);
  46517. /**
  46518. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46519. */
  46520. static get CleanBoneMatrixWeights(): boolean;
  46521. static set CleanBoneMatrixWeights(value: boolean);
  46522. /**
  46523. * Event raised when a plugin is used to load a scene
  46524. */
  46525. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46526. private static _registeredPlugins;
  46527. private static _getDefaultPlugin;
  46528. private static _getPluginForExtension;
  46529. private static _getPluginForDirectLoad;
  46530. private static _getPluginForFilename;
  46531. private static _getDirectLoad;
  46532. private static _loadData;
  46533. private static _getFileInfo;
  46534. /**
  46535. * Gets a plugin that can load the given extension
  46536. * @param extension defines the extension to load
  46537. * @returns a plugin or null if none works
  46538. */
  46539. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46540. /**
  46541. * Gets a boolean indicating that the given extension can be loaded
  46542. * @param extension defines the extension to load
  46543. * @returns true if the extension is supported
  46544. */
  46545. static IsPluginForExtensionAvailable(extension: string): boolean;
  46546. /**
  46547. * Adds a new plugin to the list of registered plugins
  46548. * @param plugin defines the plugin to add
  46549. */
  46550. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46551. /**
  46552. * Import meshes into a scene
  46553. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46554. * @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)
  46555. * @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)
  46556. * @param scene the instance of BABYLON.Scene to append to
  46557. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46558. * @param onProgress a callback with a progress event for each file being loaded
  46559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46560. * @param pluginExtension the extension used to determine the plugin
  46561. * @returns The loaded plugin
  46562. */
  46563. 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>;
  46564. /**
  46565. * Import meshes into a scene
  46566. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46567. * @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)
  46568. * @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)
  46569. * @param scene the instance of BABYLON.Scene to append to
  46570. * @param onProgress a callback with a progress event for each file being loaded
  46571. * @param pluginExtension the extension used to determine the plugin
  46572. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46573. */
  46574. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46575. meshes: AbstractMesh[];
  46576. particleSystems: IParticleSystem[];
  46577. skeletons: Skeleton[];
  46578. animationGroups: AnimationGroup[];
  46579. }>;
  46580. /**
  46581. * Load a scene
  46582. * @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)
  46583. * @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)
  46584. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46585. * @param onSuccess a callback with the scene when import succeeds
  46586. * @param onProgress a callback with a progress event for each file being loaded
  46587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46588. * @param pluginExtension the extension used to determine the plugin
  46589. * @returns The loaded plugin
  46590. */
  46591. 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>;
  46592. /**
  46593. * Load a scene
  46594. * @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)
  46595. * @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)
  46596. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46597. * @param onProgress a callback with a progress event for each file being loaded
  46598. * @param pluginExtension the extension used to determine the plugin
  46599. * @returns The loaded scene
  46600. */
  46601. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46602. /**
  46603. * Append a scene
  46604. * @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)
  46605. * @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)
  46606. * @param scene is the instance of BABYLON.Scene to append to
  46607. * @param onSuccess a callback with the scene when import succeeds
  46608. * @param onProgress a callback with a progress event for each file being loaded
  46609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46610. * @param pluginExtension the extension used to determine the plugin
  46611. * @returns The loaded plugin
  46612. */
  46613. 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>;
  46614. /**
  46615. * Append a scene
  46616. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  46617. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  46618. * @param scene is the instance of BABYLON.Scene to append to
  46619. * @param onProgress a callback with a progress event for each file being loaded
  46620. * @param pluginExtension the extension used to determine the plugin
  46621. * @returns The given scene
  46622. */
  46623. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46624. /**
  46625. * Load a scene into an asset container
  46626. * @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)
  46627. * @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)
  46628. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46629. * @param onSuccess a callback with the scene when import succeeds
  46630. * @param onProgress a callback with a progress event for each file being loaded
  46631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46632. * @param pluginExtension the extension used to determine the plugin
  46633. * @returns The loaded plugin
  46634. */
  46635. 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>;
  46636. /**
  46637. * Load a scene into an asset container
  46638. * @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)
  46639. * @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)
  46640. * @param scene is the instance of Scene to append to
  46641. * @param onProgress a callback with a progress event for each file being loaded
  46642. * @param pluginExtension the extension used to determine the plugin
  46643. * @returns The loaded asset container
  46644. */
  46645. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46646. /**
  46647. * Import animations from a file into a scene
  46648. * @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)
  46649. * @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)
  46650. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46651. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46652. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46653. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46654. * @param onSuccess a callback with the scene when import succeeds
  46655. * @param onProgress a callback with a progress event for each file being loaded
  46656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46657. */
  46658. 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;
  46659. /**
  46660. * Import animations from a file into a scene
  46661. * @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)
  46662. * @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)
  46663. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46664. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46665. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46666. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46667. * @param onSuccess a callback with the scene when import succeeds
  46668. * @param onProgress a callback with a progress event for each file being loaded
  46669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46670. * @returns the updated scene with imported animations
  46671. */
  46672. 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>;
  46673. }
  46674. }
  46675. declare module BABYLON {
  46676. /**
  46677. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46678. */
  46679. export type MotionControllerHandedness = "none" | "left" | "right";
  46680. /**
  46681. * The type of components available in motion controllers.
  46682. * This is not the name of the component.
  46683. */
  46684. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46685. /**
  46686. * The state of a controller component
  46687. */
  46688. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46689. /**
  46690. * The schema of motion controller layout.
  46691. * No object will be initialized using this interface
  46692. * This is used just to define the profile.
  46693. */
  46694. export interface IMotionControllerLayout {
  46695. /**
  46696. * Path to load the assets. Usually relative to the base path
  46697. */
  46698. assetPath: string;
  46699. /**
  46700. * Available components (unsorted)
  46701. */
  46702. components: {
  46703. /**
  46704. * A map of component Ids
  46705. */
  46706. [componentId: string]: {
  46707. /**
  46708. * The type of input the component outputs
  46709. */
  46710. type: MotionControllerComponentType;
  46711. /**
  46712. * The indices of this component in the gamepad object
  46713. */
  46714. gamepadIndices: {
  46715. /**
  46716. * Index of button
  46717. */
  46718. button?: number;
  46719. /**
  46720. * If available, index of x-axis
  46721. */
  46722. xAxis?: number;
  46723. /**
  46724. * If available, index of y-axis
  46725. */
  46726. yAxis?: number;
  46727. };
  46728. /**
  46729. * The mesh's root node name
  46730. */
  46731. rootNodeName: string;
  46732. /**
  46733. * Animation definitions for this model
  46734. */
  46735. visualResponses: {
  46736. [stateKey: string]: {
  46737. /**
  46738. * What property will be animated
  46739. */
  46740. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46741. /**
  46742. * What states influence this visual response
  46743. */
  46744. states: MotionControllerComponentStateType[];
  46745. /**
  46746. * Type of animation - movement or visibility
  46747. */
  46748. valueNodeProperty: "transform" | "visibility";
  46749. /**
  46750. * Base node name to move. Its position will be calculated according to the min and max nodes
  46751. */
  46752. valueNodeName?: string;
  46753. /**
  46754. * Minimum movement node
  46755. */
  46756. minNodeName?: string;
  46757. /**
  46758. * Max movement node
  46759. */
  46760. maxNodeName?: string;
  46761. };
  46762. };
  46763. /**
  46764. * If touch enabled, what is the name of node to display user feedback
  46765. */
  46766. touchPointNodeName?: string;
  46767. };
  46768. };
  46769. /**
  46770. * Is it xr standard mapping or not
  46771. */
  46772. gamepadMapping: "" | "xr-standard";
  46773. /**
  46774. * Base root node of this entire model
  46775. */
  46776. rootNodeName: string;
  46777. /**
  46778. * Defines the main button component id
  46779. */
  46780. selectComponentId: string;
  46781. }
  46782. /**
  46783. * A definition for the layout map in the input profile
  46784. */
  46785. export interface IMotionControllerLayoutMap {
  46786. /**
  46787. * Layouts with handedness type as a key
  46788. */
  46789. [handedness: string]: IMotionControllerLayout;
  46790. }
  46791. /**
  46792. * The XR Input profile schema
  46793. * Profiles can be found here:
  46794. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46795. */
  46796. export interface IMotionControllerProfile {
  46797. /**
  46798. * fallback profiles for this profileId
  46799. */
  46800. fallbackProfileIds: string[];
  46801. /**
  46802. * The layout map, with handedness as key
  46803. */
  46804. layouts: IMotionControllerLayoutMap;
  46805. /**
  46806. * The id of this profile
  46807. * correlates to the profile(s) in the xrInput.profiles array
  46808. */
  46809. profileId: string;
  46810. }
  46811. /**
  46812. * A helper-interface for the 3 meshes needed for controller button animation
  46813. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46814. */
  46815. export interface IMotionControllerButtonMeshMap {
  46816. /**
  46817. * the mesh that defines the pressed value mesh position.
  46818. * This is used to find the max-position of this button
  46819. */
  46820. pressedMesh: AbstractMesh;
  46821. /**
  46822. * the mesh that defines the unpressed value mesh position.
  46823. * This is used to find the min (or initial) position of this button
  46824. */
  46825. unpressedMesh: AbstractMesh;
  46826. /**
  46827. * The mesh that will be changed when value changes
  46828. */
  46829. valueMesh: AbstractMesh;
  46830. }
  46831. /**
  46832. * A helper-interface for the 3 meshes needed for controller axis animation.
  46833. * This will be expanded when touchpad animations are fully supported
  46834. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46835. */
  46836. export interface IMotionControllerMeshMap {
  46837. /**
  46838. * the mesh that defines the maximum value mesh position.
  46839. */
  46840. maxMesh?: AbstractMesh;
  46841. /**
  46842. * the mesh that defines the minimum value mesh position.
  46843. */
  46844. minMesh?: AbstractMesh;
  46845. /**
  46846. * The mesh that will be changed when axis value changes
  46847. */
  46848. valueMesh: AbstractMesh;
  46849. }
  46850. /**
  46851. * The elements needed for change-detection of the gamepad objects in motion controllers
  46852. */
  46853. export interface IMinimalMotionControllerObject {
  46854. /**
  46855. * Available axes of this controller
  46856. */
  46857. axes: number[];
  46858. /**
  46859. * An array of available buttons
  46860. */
  46861. buttons: Array<{
  46862. /**
  46863. * Value of the button/trigger
  46864. */
  46865. value: number;
  46866. /**
  46867. * If the button/trigger is currently touched
  46868. */
  46869. touched: boolean;
  46870. /**
  46871. * If the button/trigger is currently pressed
  46872. */
  46873. pressed: boolean;
  46874. }>;
  46875. /**
  46876. * EXPERIMENTAL haptic support.
  46877. */
  46878. hapticActuators?: Array<{
  46879. pulse: (value: number, duration: number) => Promise<boolean>;
  46880. }>;
  46881. }
  46882. /**
  46883. * An Abstract Motion controller
  46884. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46885. * Each component has an observable to check for changes in value and state
  46886. */
  46887. export abstract class WebXRAbstractMotionController implements IDisposable {
  46888. protected scene: Scene;
  46889. protected layout: IMotionControllerLayout;
  46890. /**
  46891. * The gamepad object correlating to this controller
  46892. */
  46893. gamepadObject: IMinimalMotionControllerObject;
  46894. /**
  46895. * handedness (left/right/none) of this controller
  46896. */
  46897. handedness: MotionControllerHandedness;
  46898. private _initComponent;
  46899. private _modelReady;
  46900. /**
  46901. * A map of components (WebXRControllerComponent) in this motion controller
  46902. * Components have a ComponentType and can also have both button and axis definitions
  46903. */
  46904. readonly components: {
  46905. [id: string]: WebXRControllerComponent;
  46906. };
  46907. /**
  46908. * Disable the model's animation. Can be set at any time.
  46909. */
  46910. disableAnimation: boolean;
  46911. /**
  46912. * Observers registered here will be triggered when the model of this controller is done loading
  46913. */
  46914. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46915. /**
  46916. * The profile id of this motion controller
  46917. */
  46918. abstract profileId: string;
  46919. /**
  46920. * The root mesh of the model. It is null if the model was not yet initialized
  46921. */
  46922. rootMesh: Nullable<AbstractMesh>;
  46923. /**
  46924. * constructs a new abstract motion controller
  46925. * @param scene the scene to which the model of the controller will be added
  46926. * @param layout The profile layout to load
  46927. * @param gamepadObject The gamepad object correlating to this controller
  46928. * @param handedness handedness (left/right/none) of this controller
  46929. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46930. */
  46931. constructor(scene: Scene, layout: IMotionControllerLayout,
  46932. /**
  46933. * The gamepad object correlating to this controller
  46934. */
  46935. gamepadObject: IMinimalMotionControllerObject,
  46936. /**
  46937. * handedness (left/right/none) of this controller
  46938. */
  46939. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46940. /**
  46941. * Dispose this controller, the model mesh and all its components
  46942. */
  46943. dispose(): void;
  46944. /**
  46945. * Returns all components of specific type
  46946. * @param type the type to search for
  46947. * @return an array of components with this type
  46948. */
  46949. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46950. /**
  46951. * get a component based an its component id as defined in layout.components
  46952. * @param id the id of the component
  46953. * @returns the component correlates to the id or undefined if not found
  46954. */
  46955. getComponent(id: string): WebXRControllerComponent;
  46956. /**
  46957. * Get the list of components available in this motion controller
  46958. * @returns an array of strings correlating to available components
  46959. */
  46960. getComponentIds(): string[];
  46961. /**
  46962. * Get the first component of specific type
  46963. * @param type type of component to find
  46964. * @return a controller component or null if not found
  46965. */
  46966. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46967. /**
  46968. * Get the main (Select) component of this controller as defined in the layout
  46969. * @returns the main component of this controller
  46970. */
  46971. getMainComponent(): WebXRControllerComponent;
  46972. /**
  46973. * Loads the model correlating to this controller
  46974. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46975. * @returns A promise fulfilled with the result of the model loading
  46976. */
  46977. loadModel(): Promise<boolean>;
  46978. /**
  46979. * Update this model using the current XRFrame
  46980. * @param xrFrame the current xr frame to use and update the model
  46981. */
  46982. updateFromXRFrame(xrFrame: XRFrame): void;
  46983. /**
  46984. * Backwards compatibility due to a deeply-integrated typo
  46985. */
  46986. get handness(): XREye;
  46987. /**
  46988. * Pulse (vibrate) this controller
  46989. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46990. * Consecutive calls to this function will cancel the last pulse call
  46991. *
  46992. * @param value the strength of the pulse in 0.0...1.0 range
  46993. * @param duration Duration of the pulse in milliseconds
  46994. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46995. * @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
  46996. */
  46997. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46998. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46999. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47000. /**
  47001. * Moves the axis on the controller mesh based on its current state
  47002. * @param axis the index of the axis
  47003. * @param axisValue the value of the axis which determines the meshes new position
  47004. * @hidden
  47005. */
  47006. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47007. /**
  47008. * Update the model itself with the current frame data
  47009. * @param xrFrame the frame to use for updating the model mesh
  47010. */
  47011. protected updateModel(xrFrame: XRFrame): void;
  47012. /**
  47013. * Get the filename and path for this controller's model
  47014. * @returns a map of filename and path
  47015. */
  47016. protected abstract _getFilenameAndPath(): {
  47017. filename: string;
  47018. path: string;
  47019. };
  47020. /**
  47021. * This function is called before the mesh is loaded. It checks for loading constraints.
  47022. * For example, this function can check if the GLB loader is available
  47023. * If this function returns false, the generic controller will be loaded instead
  47024. * @returns Is the client ready to load the mesh
  47025. */
  47026. protected abstract _getModelLoadingConstraints(): boolean;
  47027. /**
  47028. * This function will be called after the model was successfully loaded and can be used
  47029. * for mesh transformations before it is available for the user
  47030. * @param meshes the loaded meshes
  47031. */
  47032. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47033. /**
  47034. * Set the root mesh for this controller. Important for the WebXR controller class
  47035. * @param meshes the loaded meshes
  47036. */
  47037. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47038. /**
  47039. * A function executed each frame that updates the mesh (if needed)
  47040. * @param xrFrame the current xrFrame
  47041. */
  47042. protected abstract _updateModel(xrFrame: XRFrame): void;
  47043. private _getGenericFilenameAndPath;
  47044. private _getGenericParentMesh;
  47045. }
  47046. }
  47047. declare module BABYLON {
  47048. /**
  47049. * A generic trigger-only motion controller for WebXR
  47050. */
  47051. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47052. /**
  47053. * Static version of the profile id of this controller
  47054. */
  47055. static ProfileId: string;
  47056. profileId: string;
  47057. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47058. protected _getFilenameAndPath(): {
  47059. filename: string;
  47060. path: string;
  47061. };
  47062. protected _getModelLoadingConstraints(): boolean;
  47063. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47064. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47065. protected _updateModel(): void;
  47066. }
  47067. }
  47068. declare module BABYLON {
  47069. /**
  47070. * Class containing static functions to help procedurally build meshes
  47071. */
  47072. export class SphereBuilder {
  47073. /**
  47074. * Creates a sphere mesh
  47075. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47076. * * 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`)
  47077. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47078. * * 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
  47079. * * 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)
  47080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47081. * * 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
  47082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47083. * @param name defines the name of the mesh
  47084. * @param options defines the options used to create the mesh
  47085. * @param scene defines the hosting scene
  47086. * @returns the sphere mesh
  47087. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47088. */
  47089. static CreateSphere(name: string, options: {
  47090. segments?: number;
  47091. diameter?: number;
  47092. diameterX?: number;
  47093. diameterY?: number;
  47094. diameterZ?: number;
  47095. arc?: number;
  47096. slice?: number;
  47097. sideOrientation?: number;
  47098. frontUVs?: Vector4;
  47099. backUVs?: Vector4;
  47100. updatable?: boolean;
  47101. }, scene?: Nullable<Scene>): Mesh;
  47102. }
  47103. }
  47104. declare module BABYLON {
  47105. /**
  47106. * A profiled motion controller has its profile loaded from an online repository.
  47107. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47108. */
  47109. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47110. private _repositoryUrl;
  47111. private _buttonMeshMapping;
  47112. private _touchDots;
  47113. /**
  47114. * The profile ID of this controller. Will be populated when the controller initializes.
  47115. */
  47116. profileId: string;
  47117. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47118. dispose(): void;
  47119. protected _getFilenameAndPath(): {
  47120. filename: string;
  47121. path: string;
  47122. };
  47123. protected _getModelLoadingConstraints(): boolean;
  47124. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47125. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47126. protected _updateModel(_xrFrame: XRFrame): void;
  47127. }
  47128. }
  47129. declare module BABYLON {
  47130. /**
  47131. * A construction function type to create a new controller based on an xrInput object
  47132. */
  47133. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47134. /**
  47135. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47136. *
  47137. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47138. * it should be replaced with auto-loaded controllers.
  47139. *
  47140. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47141. */
  47142. export class WebXRMotionControllerManager {
  47143. private static _AvailableControllers;
  47144. private static _Fallbacks;
  47145. private static _ProfileLoadingPromises;
  47146. private static _ProfilesList;
  47147. /**
  47148. * The base URL of the online controller repository. Can be changed at any time.
  47149. */
  47150. static BaseRepositoryUrl: string;
  47151. /**
  47152. * Which repository gets priority - local or online
  47153. */
  47154. static PrioritizeOnlineRepository: boolean;
  47155. /**
  47156. * Use the online repository, or use only locally-defined controllers
  47157. */
  47158. static UseOnlineRepository: boolean;
  47159. /**
  47160. * Clear the cache used for profile loading and reload when requested again
  47161. */
  47162. static ClearProfilesCache(): void;
  47163. /**
  47164. * Register the default fallbacks.
  47165. * This function is called automatically when this file is imported.
  47166. */
  47167. static DefaultFallbacks(): void;
  47168. /**
  47169. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47170. * @param profileId the profile to which a fallback needs to be found
  47171. * @return an array with corresponding fallback profiles
  47172. */
  47173. static FindFallbackWithProfileId(profileId: string): string[];
  47174. /**
  47175. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47176. * The order of search:
  47177. *
  47178. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47179. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47180. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47181. * 4) return the generic trigger controller if none were found
  47182. *
  47183. * @param xrInput the xrInput to which a new controller is initialized
  47184. * @param scene the scene to which the model will be added
  47185. * @param forceProfile force a certain profile for this controller
  47186. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47187. */
  47188. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47189. /**
  47190. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47191. *
  47192. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47193. *
  47194. * @param type the profile type to register
  47195. * @param constructFunction the function to be called when loading this profile
  47196. */
  47197. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47198. /**
  47199. * Register a fallback to a specific profile.
  47200. * @param profileId the profileId that will receive the fallbacks
  47201. * @param fallbacks A list of fallback profiles
  47202. */
  47203. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47204. /**
  47205. * Will update the list of profiles available in the repository
  47206. * @return a promise that resolves to a map of profiles available online
  47207. */
  47208. static UpdateProfilesList(): Promise<{
  47209. [profile: string]: string;
  47210. }>;
  47211. private static _LoadProfileFromRepository;
  47212. private static _LoadProfilesFromAvailableControllers;
  47213. }
  47214. }
  47215. declare module BABYLON {
  47216. /**
  47217. * Configuration options for the WebXR controller creation
  47218. */
  47219. export interface IWebXRControllerOptions {
  47220. /**
  47221. * Should the controller mesh be animated when a user interacts with it
  47222. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47223. */
  47224. disableMotionControllerAnimation?: boolean;
  47225. /**
  47226. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47227. */
  47228. doNotLoadControllerMesh?: boolean;
  47229. /**
  47230. * Force a specific controller type for this controller.
  47231. * This can be used when creating your own profile or when testing different controllers
  47232. */
  47233. forceControllerProfile?: string;
  47234. /**
  47235. * Defines a rendering group ID for meshes that will be loaded.
  47236. * This is for the default controllers only.
  47237. */
  47238. renderingGroupId?: number;
  47239. }
  47240. /**
  47241. * Represents an XR controller
  47242. */
  47243. export class WebXRInputSource {
  47244. private _scene;
  47245. /** The underlying input source for the controller */
  47246. inputSource: XRInputSource;
  47247. private _options;
  47248. private _tmpVector;
  47249. private _uniqueId;
  47250. /**
  47251. * 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
  47252. */
  47253. grip?: AbstractMesh;
  47254. /**
  47255. * If available, this is the gamepad object related to this controller.
  47256. * Using this object it is possible to get click events and trackpad changes of the
  47257. * webxr controller that is currently being used.
  47258. */
  47259. motionController?: WebXRAbstractMotionController;
  47260. /**
  47261. * Event that fires when the controller is removed/disposed.
  47262. * The object provided as event data is this controller, after associated assets were disposed.
  47263. * uniqueId is still available.
  47264. */
  47265. onDisposeObservable: Observable<WebXRInputSource>;
  47266. /**
  47267. * Will be triggered when the mesh associated with the motion controller is done loading.
  47268. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47269. * A shortened version of controller -> motion controller -> on mesh loaded.
  47270. */
  47271. onMeshLoadedObservable: Observable<AbstractMesh>;
  47272. /**
  47273. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47274. */
  47275. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47276. /**
  47277. * Pointer which can be used to select objects or attach a visible laser to
  47278. */
  47279. pointer: AbstractMesh;
  47280. /**
  47281. * Creates the controller
  47282. * @see https://doc.babylonjs.com/how_to/webxr
  47283. * @param _scene the scene which the controller should be associated to
  47284. * @param inputSource the underlying input source for the controller
  47285. * @param _options options for this controller creation
  47286. */
  47287. constructor(_scene: Scene,
  47288. /** The underlying input source for the controller */
  47289. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47290. /**
  47291. * Get this controllers unique id
  47292. */
  47293. get uniqueId(): string;
  47294. /**
  47295. * Disposes of the object
  47296. */
  47297. dispose(): void;
  47298. /**
  47299. * Gets a world space ray coming from the pointer or grip
  47300. * @param result the resulting ray
  47301. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47302. */
  47303. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47304. /**
  47305. * Updates the controller pose based on the given XRFrame
  47306. * @param xrFrame xr frame to update the pose with
  47307. * @param referenceSpace reference space to use
  47308. */
  47309. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47310. }
  47311. }
  47312. declare module BABYLON {
  47313. /**
  47314. * The schema for initialization options of the XR Input class
  47315. */
  47316. export interface IWebXRInputOptions {
  47317. /**
  47318. * If set to true no model will be automatically loaded
  47319. */
  47320. doNotLoadControllerMeshes?: boolean;
  47321. /**
  47322. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47323. * If not found, the xr input profile data will be used.
  47324. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47325. */
  47326. forceInputProfile?: string;
  47327. /**
  47328. * Do not send a request to the controller repository to load the profile.
  47329. *
  47330. * Instead, use the controllers available in babylon itself.
  47331. */
  47332. disableOnlineControllerRepository?: boolean;
  47333. /**
  47334. * A custom URL for the controllers repository
  47335. */
  47336. customControllersRepositoryURL?: string;
  47337. /**
  47338. * Should the controller model's components not move according to the user input
  47339. */
  47340. disableControllerAnimation?: boolean;
  47341. /**
  47342. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47343. */
  47344. controllerOptions?: IWebXRControllerOptions;
  47345. }
  47346. /**
  47347. * XR input used to track XR inputs such as controllers/rays
  47348. */
  47349. export class WebXRInput implements IDisposable {
  47350. /**
  47351. * the xr session manager for this session
  47352. */
  47353. xrSessionManager: WebXRSessionManager;
  47354. /**
  47355. * the WebXR camera for this session. Mainly used for teleportation
  47356. */
  47357. xrCamera: WebXRCamera;
  47358. private readonly options;
  47359. /**
  47360. * XR controllers being tracked
  47361. */
  47362. controllers: Array<WebXRInputSource>;
  47363. private _frameObserver;
  47364. private _sessionEndedObserver;
  47365. private _sessionInitObserver;
  47366. /**
  47367. * Event when a controller has been connected/added
  47368. */
  47369. onControllerAddedObservable: Observable<WebXRInputSource>;
  47370. /**
  47371. * Event when a controller has been removed/disconnected
  47372. */
  47373. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47374. /**
  47375. * Initializes the WebXRInput
  47376. * @param xrSessionManager the xr session manager for this session
  47377. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47378. * @param options = initialization options for this xr input
  47379. */
  47380. constructor(
  47381. /**
  47382. * the xr session manager for this session
  47383. */
  47384. xrSessionManager: WebXRSessionManager,
  47385. /**
  47386. * the WebXR camera for this session. Mainly used for teleportation
  47387. */
  47388. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47389. private _onInputSourcesChange;
  47390. private _addAndRemoveControllers;
  47391. /**
  47392. * Disposes of the object
  47393. */
  47394. dispose(): void;
  47395. }
  47396. }
  47397. declare module BABYLON {
  47398. /**
  47399. * This is the base class for all WebXR features.
  47400. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47401. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47402. */
  47403. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47404. protected _xrSessionManager: WebXRSessionManager;
  47405. private _attached;
  47406. private _removeOnDetach;
  47407. /**
  47408. * Should auto-attach be disabled?
  47409. */
  47410. disableAutoAttach: boolean;
  47411. /**
  47412. * Construct a new (abstract) WebXR feature
  47413. * @param _xrSessionManager the xr session manager for this feature
  47414. */
  47415. constructor(_xrSessionManager: WebXRSessionManager);
  47416. /**
  47417. * Is this feature attached
  47418. */
  47419. get attached(): boolean;
  47420. /**
  47421. * attach this feature
  47422. *
  47423. * @param force should attachment be forced (even when already attached)
  47424. * @returns true if successful, false is failed or already attached
  47425. */
  47426. attach(force?: boolean): boolean;
  47427. /**
  47428. * detach this feature.
  47429. *
  47430. * @returns true if successful, false if failed or already detached
  47431. */
  47432. detach(): boolean;
  47433. /**
  47434. * Dispose this feature and all of the resources attached
  47435. */
  47436. dispose(): void;
  47437. /**
  47438. * This is used to register callbacks that will automatically be removed when detach is called.
  47439. * @param observable the observable to which the observer will be attached
  47440. * @param callback the callback to register
  47441. */
  47442. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47443. /**
  47444. * Code in this function will be executed on each xrFrame received from the browser.
  47445. * This function will not execute after the feature is detached.
  47446. * @param _xrFrame the current frame
  47447. */
  47448. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47449. }
  47450. }
  47451. declare module BABYLON {
  47452. /**
  47453. * Renders a layer on top of an existing scene
  47454. */
  47455. export class UtilityLayerRenderer implements IDisposable {
  47456. /** the original scene that will be rendered on top of */
  47457. originalScene: Scene;
  47458. private _pointerCaptures;
  47459. private _lastPointerEvents;
  47460. private static _DefaultUtilityLayer;
  47461. private static _DefaultKeepDepthUtilityLayer;
  47462. private _sharedGizmoLight;
  47463. private _renderCamera;
  47464. /**
  47465. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47466. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47467. * @returns the camera that is used when rendering the utility layer
  47468. */
  47469. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47470. /**
  47471. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47472. * @param cam the camera that should be used when rendering the utility layer
  47473. */
  47474. setRenderCamera(cam: Nullable<Camera>): void;
  47475. /**
  47476. * @hidden
  47477. * Light which used by gizmos to get light shading
  47478. */
  47479. _getSharedGizmoLight(): HemisphericLight;
  47480. /**
  47481. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47482. */
  47483. pickUtilitySceneFirst: boolean;
  47484. /**
  47485. * 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)
  47486. */
  47487. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47488. /**
  47489. * 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)
  47490. */
  47491. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47492. /**
  47493. * The scene that is rendered on top of the original scene
  47494. */
  47495. utilityLayerScene: Scene;
  47496. /**
  47497. * If the utility layer should automatically be rendered on top of existing scene
  47498. */
  47499. shouldRender: boolean;
  47500. /**
  47501. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47502. */
  47503. onlyCheckPointerDownEvents: boolean;
  47504. /**
  47505. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47506. */
  47507. processAllEvents: boolean;
  47508. /**
  47509. * Observable raised when the pointer move from the utility layer scene to the main scene
  47510. */
  47511. onPointerOutObservable: Observable<number>;
  47512. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47513. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47514. private _afterRenderObserver;
  47515. private _sceneDisposeObserver;
  47516. private _originalPointerObserver;
  47517. /**
  47518. * Instantiates a UtilityLayerRenderer
  47519. * @param originalScene the original scene that will be rendered on top of
  47520. * @param handleEvents boolean indicating if the utility layer should handle events
  47521. */
  47522. constructor(
  47523. /** the original scene that will be rendered on top of */
  47524. originalScene: Scene, handleEvents?: boolean);
  47525. private _notifyObservers;
  47526. /**
  47527. * Renders the utility layers scene on top of the original scene
  47528. */
  47529. render(): void;
  47530. /**
  47531. * Disposes of the renderer
  47532. */
  47533. dispose(): void;
  47534. private _updateCamera;
  47535. }
  47536. }
  47537. declare module BABYLON {
  47538. /**
  47539. * Options interface for the pointer selection module
  47540. */
  47541. export interface IWebXRControllerPointerSelectionOptions {
  47542. /**
  47543. * if provided, this scene will be used to render meshes.
  47544. */
  47545. customUtilityLayerScene?: Scene;
  47546. /**
  47547. * 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)
  47548. * If not disabled, the last picked point will be used to execute a pointer up event
  47549. * If disabled, pointer up event will be triggered right after the pointer down event.
  47550. * Used in screen and gaze target ray mode only
  47551. */
  47552. disablePointerUpOnTouchOut: boolean;
  47553. /**
  47554. * For gaze mode (time to select instead of press)
  47555. */
  47556. forceGazeMode: boolean;
  47557. /**
  47558. * 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
  47559. * to start a new countdown to the pointer down event.
  47560. * Defaults to 1.
  47561. */
  47562. gazeModePointerMovedFactor?: number;
  47563. /**
  47564. * Different button type to use instead of the main component
  47565. */
  47566. overrideButtonId?: string;
  47567. /**
  47568. * use this rendering group id for the meshes (optional)
  47569. */
  47570. renderingGroupId?: number;
  47571. /**
  47572. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47573. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47574. * 3000 means 3 seconds between pointing at something and selecting it
  47575. */
  47576. timeToSelect?: number;
  47577. /**
  47578. * Should meshes created here be added to a utility layer or the main scene
  47579. */
  47580. useUtilityLayer?: boolean;
  47581. /**
  47582. * the xr input to use with this pointer selection
  47583. */
  47584. xrInput: WebXRInput;
  47585. }
  47586. /**
  47587. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47588. */
  47589. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47590. private readonly _options;
  47591. private static _idCounter;
  47592. private _attachController;
  47593. private _controllers;
  47594. private _scene;
  47595. private _tmpVectorForPickCompare;
  47596. /**
  47597. * The module's name
  47598. */
  47599. static readonly Name: string;
  47600. /**
  47601. * The (Babylon) version of this module.
  47602. * This is an integer representing the implementation version.
  47603. * This number does not correspond to the WebXR specs version
  47604. */
  47605. static readonly Version: number;
  47606. /**
  47607. * Disable lighting on the laser pointer (so it will always be visible)
  47608. */
  47609. disablePointerLighting: boolean;
  47610. /**
  47611. * Disable lighting on the selection mesh (so it will always be visible)
  47612. */
  47613. disableSelectionMeshLighting: boolean;
  47614. /**
  47615. * Should the laser pointer be displayed
  47616. */
  47617. displayLaserPointer: boolean;
  47618. /**
  47619. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47620. */
  47621. displaySelectionMesh: boolean;
  47622. /**
  47623. * This color will be set to the laser pointer when selection is triggered
  47624. */
  47625. laserPointerPickedColor: Color3;
  47626. /**
  47627. * Default color of the laser pointer
  47628. */
  47629. lasterPointerDefaultColor: Color3;
  47630. /**
  47631. * default color of the selection ring
  47632. */
  47633. selectionMeshDefaultColor: Color3;
  47634. /**
  47635. * This color will be applied to the selection ring when selection is triggered
  47636. */
  47637. selectionMeshPickedColor: Color3;
  47638. /**
  47639. * Optional filter to be used for ray selection. This predicate shares behavior with
  47640. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47641. */
  47642. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47643. /**
  47644. * constructs a new background remover module
  47645. * @param _xrSessionManager the session manager for this module
  47646. * @param _options read-only options to be used in this module
  47647. */
  47648. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47649. /**
  47650. * attach this feature
  47651. * Will usually be called by the features manager
  47652. *
  47653. * @returns true if successful.
  47654. */
  47655. attach(): boolean;
  47656. /**
  47657. * detach this feature.
  47658. * Will usually be called by the features manager
  47659. *
  47660. * @returns true if successful.
  47661. */
  47662. detach(): boolean;
  47663. /**
  47664. * Will get the mesh under a specific pointer.
  47665. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47666. * @param controllerId the controllerId to check
  47667. * @returns The mesh under pointer or null if no mesh is under the pointer
  47668. */
  47669. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47670. /**
  47671. * Get the xr controller that correlates to the pointer id in the pointer event
  47672. *
  47673. * @param id the pointer id to search for
  47674. * @returns the controller that correlates to this id or null if not found
  47675. */
  47676. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47677. protected _onXRFrame(_xrFrame: XRFrame): void;
  47678. private _attachGazeMode;
  47679. private _attachScreenRayMode;
  47680. private _attachTrackedPointerRayMode;
  47681. private _convertNormalToDirectionOfRay;
  47682. private _detachController;
  47683. private _generateNewMeshPair;
  47684. private _pickingMoved;
  47685. private _updatePointerDistance;
  47686. }
  47687. }
  47688. declare module BABYLON {
  47689. /**
  47690. * Button which can be used to enter a different mode of XR
  47691. */
  47692. export class WebXREnterExitUIButton {
  47693. /** button element */
  47694. element: HTMLElement;
  47695. /** XR initialization options for the button */
  47696. sessionMode: XRSessionMode;
  47697. /** Reference space type */
  47698. referenceSpaceType: XRReferenceSpaceType;
  47699. /**
  47700. * Creates a WebXREnterExitUIButton
  47701. * @param element button element
  47702. * @param sessionMode XR initialization session mode
  47703. * @param referenceSpaceType the type of reference space to be used
  47704. */
  47705. constructor(
  47706. /** button element */
  47707. element: HTMLElement,
  47708. /** XR initialization options for the button */
  47709. sessionMode: XRSessionMode,
  47710. /** Reference space type */
  47711. referenceSpaceType: XRReferenceSpaceType);
  47712. /**
  47713. * Extendable function which can be used to update the button's visuals when the state changes
  47714. * @param activeButton the current active button in the UI
  47715. */
  47716. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47717. }
  47718. /**
  47719. * Options to create the webXR UI
  47720. */
  47721. export class WebXREnterExitUIOptions {
  47722. /**
  47723. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47724. */
  47725. customButtons?: Array<WebXREnterExitUIButton>;
  47726. /**
  47727. * A reference space type to use when creating the default button.
  47728. * Default is local-floor
  47729. */
  47730. referenceSpaceType?: XRReferenceSpaceType;
  47731. /**
  47732. * Context to enter xr with
  47733. */
  47734. renderTarget?: Nullable<WebXRRenderTarget>;
  47735. /**
  47736. * A session mode to use when creating the default button.
  47737. * Default is immersive-vr
  47738. */
  47739. sessionMode?: XRSessionMode;
  47740. /**
  47741. * A list of optional features to init the session with
  47742. */
  47743. optionalFeatures?: string[];
  47744. }
  47745. /**
  47746. * UI to allow the user to enter/exit XR mode
  47747. */
  47748. export class WebXREnterExitUI implements IDisposable {
  47749. private scene;
  47750. /** version of the options passed to this UI */
  47751. options: WebXREnterExitUIOptions;
  47752. private _activeButton;
  47753. private _buttons;
  47754. private _overlay;
  47755. /**
  47756. * Fired every time the active button is changed.
  47757. *
  47758. * When xr is entered via a button that launches xr that button will be the callback parameter
  47759. *
  47760. * When exiting xr the callback parameter will be null)
  47761. */
  47762. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47763. /**
  47764. *
  47765. * @param scene babylon scene object to use
  47766. * @param options (read-only) version of the options passed to this UI
  47767. */
  47768. private constructor();
  47769. /**
  47770. * Creates UI to allow the user to enter/exit XR mode
  47771. * @param scene the scene to add the ui to
  47772. * @param helper the xr experience helper to enter/exit xr with
  47773. * @param options options to configure the UI
  47774. * @returns the created ui
  47775. */
  47776. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47777. /**
  47778. * Disposes of the XR UI component
  47779. */
  47780. dispose(): void;
  47781. private _updateButtons;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /**
  47786. * Class containing static functions to help procedurally build meshes
  47787. */
  47788. export class LinesBuilder {
  47789. /**
  47790. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47791. * * 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
  47792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47793. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47794. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47795. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47796. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47797. * * 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
  47798. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47801. * @param name defines the name of the new line system
  47802. * @param options defines the options used to create the line system
  47803. * @param scene defines the hosting scene
  47804. * @returns a new line system mesh
  47805. */
  47806. static CreateLineSystem(name: string, options: {
  47807. lines: Vector3[][];
  47808. updatable?: boolean;
  47809. instance?: Nullable<LinesMesh>;
  47810. colors?: Nullable<Color4[][]>;
  47811. useVertexAlpha?: boolean;
  47812. }, scene: Nullable<Scene>): LinesMesh;
  47813. /**
  47814. * Creates a line mesh
  47815. * 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
  47816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47817. * * The parameter `points` is an array successive Vector3
  47818. * * 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
  47819. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47821. * * When updating an instance, remember that only point positions can change, not the number of points
  47822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47824. * @param name defines the name of the new line system
  47825. * @param options defines the options used to create the line system
  47826. * @param scene defines the hosting scene
  47827. * @returns a new line mesh
  47828. */
  47829. static CreateLines(name: string, options: {
  47830. points: Vector3[];
  47831. updatable?: boolean;
  47832. instance?: Nullable<LinesMesh>;
  47833. colors?: Color4[];
  47834. useVertexAlpha?: boolean;
  47835. }, scene?: Nullable<Scene>): LinesMesh;
  47836. /**
  47837. * Creates a dashed line mesh
  47838. * * 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
  47839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47840. * * The parameter `points` is an array successive Vector3
  47841. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47842. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47843. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47844. * * 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
  47845. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47846. * * When updating an instance, remember that only point positions can change, not the number of points
  47847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47848. * @param name defines the name of the mesh
  47849. * @param options defines the options used to create the mesh
  47850. * @param scene defines the hosting scene
  47851. * @returns the dashed line mesh
  47852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47853. */
  47854. static CreateDashedLines(name: string, options: {
  47855. points: Vector3[];
  47856. dashSize?: number;
  47857. gapSize?: number;
  47858. dashNb?: number;
  47859. updatable?: boolean;
  47860. instance?: LinesMesh;
  47861. useVertexAlpha?: boolean;
  47862. }, scene?: Nullable<Scene>): LinesMesh;
  47863. }
  47864. }
  47865. declare module BABYLON {
  47866. /**
  47867. * The options container for the teleportation module
  47868. */
  47869. export interface IWebXRTeleportationOptions {
  47870. /**
  47871. * if provided, this scene will be used to render meshes.
  47872. */
  47873. customUtilityLayerScene?: Scene;
  47874. /**
  47875. * Values to configure the default target mesh
  47876. */
  47877. defaultTargetMeshOptions?: {
  47878. /**
  47879. * Fill color of the teleportation area
  47880. */
  47881. teleportationFillColor?: string;
  47882. /**
  47883. * Border color for the teleportation area
  47884. */
  47885. teleportationBorderColor?: string;
  47886. /**
  47887. * Disable the mesh's animation sequence
  47888. */
  47889. disableAnimation?: boolean;
  47890. /**
  47891. * Disable lighting on the material or the ring and arrow
  47892. */
  47893. disableLighting?: boolean;
  47894. /**
  47895. * Override the default material of the torus and arrow
  47896. */
  47897. torusArrowMaterial?: Material;
  47898. };
  47899. /**
  47900. * A list of meshes to use as floor meshes.
  47901. * Meshes can be added and removed after initializing the feature using the
  47902. * addFloorMesh and removeFloorMesh functions
  47903. * If empty, rotation will still work
  47904. */
  47905. floorMeshes?: AbstractMesh[];
  47906. /**
  47907. * use this rendering group id for the meshes (optional)
  47908. */
  47909. renderingGroupId?: number;
  47910. /**
  47911. * Should teleportation move only to snap points
  47912. */
  47913. snapPointsOnly?: boolean;
  47914. /**
  47915. * An array of points to which the teleportation will snap to.
  47916. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47917. */
  47918. snapPositions?: Vector3[];
  47919. /**
  47920. * How close should the teleportation ray be in order to snap to position.
  47921. * Default to 0.8 units (meters)
  47922. */
  47923. snapToPositionRadius?: number;
  47924. /**
  47925. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47926. * If you want to support rotation, make sure your mesh has a direction indicator.
  47927. *
  47928. * When left untouched, the default mesh will be initialized.
  47929. */
  47930. teleportationTargetMesh?: AbstractMesh;
  47931. /**
  47932. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47933. */
  47934. timeToTeleport?: number;
  47935. /**
  47936. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47937. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47938. */
  47939. useMainComponentOnly?: boolean;
  47940. /**
  47941. * Should meshes created here be added to a utility layer or the main scene
  47942. */
  47943. useUtilityLayer?: boolean;
  47944. /**
  47945. * Babylon XR Input class for controller
  47946. */
  47947. xrInput: WebXRInput;
  47948. }
  47949. /**
  47950. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47951. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47952. * the input of the attached controllers.
  47953. */
  47954. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47955. private _options;
  47956. private _controllers;
  47957. private _currentTeleportationControllerId;
  47958. private _floorMeshes;
  47959. private _quadraticBezierCurve;
  47960. private _selectionFeature;
  47961. private _snapToPositions;
  47962. private _snappedToPoint;
  47963. private _teleportationRingMaterial?;
  47964. private _tmpRay;
  47965. private _tmpVector;
  47966. /**
  47967. * The module's name
  47968. */
  47969. static readonly Name: string;
  47970. /**
  47971. * The (Babylon) version of this module.
  47972. * This is an integer representing the implementation version.
  47973. * This number does not correspond to the webxr specs version
  47974. */
  47975. static readonly Version: number;
  47976. /**
  47977. * Is movement backwards enabled
  47978. */
  47979. backwardsMovementEnabled: boolean;
  47980. /**
  47981. * Distance to travel when moving backwards
  47982. */
  47983. backwardsTeleportationDistance: number;
  47984. /**
  47985. * The distance from the user to the inspection point in the direction of the controller
  47986. * A higher number will allow the user to move further
  47987. * defaults to 5 (meters, in xr units)
  47988. */
  47989. parabolicCheckRadius: number;
  47990. /**
  47991. * Should the module support parabolic ray on top of direct ray
  47992. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47993. * Very helpful when moving between floors / different heights
  47994. */
  47995. parabolicRayEnabled: boolean;
  47996. /**
  47997. * How much rotation should be applied when rotating right and left
  47998. */
  47999. rotationAngle: number;
  48000. /**
  48001. * Is rotation enabled when moving forward?
  48002. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48003. */
  48004. rotationEnabled: boolean;
  48005. /**
  48006. * constructs a new anchor system
  48007. * @param _xrSessionManager an instance of WebXRSessionManager
  48008. * @param _options configuration object for this feature
  48009. */
  48010. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48011. /**
  48012. * Get the snapPointsOnly flag
  48013. */
  48014. get snapPointsOnly(): boolean;
  48015. /**
  48016. * Sets the snapPointsOnly flag
  48017. * @param snapToPoints should teleportation be exclusively to snap points
  48018. */
  48019. set snapPointsOnly(snapToPoints: boolean);
  48020. /**
  48021. * Add a new mesh to the floor meshes array
  48022. * @param mesh the mesh to use as floor mesh
  48023. */
  48024. addFloorMesh(mesh: AbstractMesh): void;
  48025. /**
  48026. * Add a new snap-to point to fix teleportation to this position
  48027. * @param newSnapPoint The new Snap-To point
  48028. */
  48029. addSnapPoint(newSnapPoint: Vector3): void;
  48030. attach(): boolean;
  48031. detach(): boolean;
  48032. dispose(): void;
  48033. /**
  48034. * Remove a mesh from the floor meshes array
  48035. * @param mesh the mesh to remove
  48036. */
  48037. removeFloorMesh(mesh: AbstractMesh): void;
  48038. /**
  48039. * Remove a mesh from the floor meshes array using its name
  48040. * @param name the mesh name to remove
  48041. */
  48042. removeFloorMeshByName(name: string): void;
  48043. /**
  48044. * 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
  48045. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48046. * @returns was the point found and removed or not
  48047. */
  48048. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48049. /**
  48050. * This function sets a selection feature that will be disabled when
  48051. * the forward ray is shown and will be reattached when hidden.
  48052. * This is used to remove the selection rays when moving.
  48053. * @param selectionFeature the feature to disable when forward movement is enabled
  48054. */
  48055. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48056. protected _onXRFrame(_xrFrame: XRFrame): void;
  48057. private _attachController;
  48058. private _createDefaultTargetMesh;
  48059. private _detachController;
  48060. private _findClosestSnapPointWithRadius;
  48061. private _setTargetMeshPosition;
  48062. private _setTargetMeshVisibility;
  48063. private _showParabolicPath;
  48064. private _teleportForward;
  48065. }
  48066. }
  48067. declare module BABYLON {
  48068. /**
  48069. * Options for the default xr helper
  48070. */
  48071. export class WebXRDefaultExperienceOptions {
  48072. /**
  48073. * Enable or disable default UI to enter XR
  48074. */
  48075. disableDefaultUI?: boolean;
  48076. /**
  48077. * Should teleportation not initialize. defaults to false.
  48078. */
  48079. disableTeleportation?: boolean;
  48080. /**
  48081. * Floor meshes that will be used for teleport
  48082. */
  48083. floorMeshes?: Array<AbstractMesh>;
  48084. /**
  48085. * If set to true, the first frame will not be used to reset position
  48086. * The first frame is mainly used when copying transformation from the old camera
  48087. * Mainly used in AR
  48088. */
  48089. ignoreNativeCameraTransformation?: boolean;
  48090. /**
  48091. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48092. */
  48093. inputOptions?: IWebXRInputOptions;
  48094. /**
  48095. * optional configuration for the output canvas
  48096. */
  48097. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48098. /**
  48099. * optional UI options. This can be used among other to change session mode and reference space type
  48100. */
  48101. uiOptions?: WebXREnterExitUIOptions;
  48102. /**
  48103. * When loading teleportation and pointer select, use stable versions instead of latest.
  48104. */
  48105. useStablePlugins?: boolean;
  48106. /**
  48107. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48108. */
  48109. renderingGroupId?: number;
  48110. /**
  48111. * A list of optional features to init the session with
  48112. * If set to true, all features we support will be added
  48113. */
  48114. optionalFeatures?: boolean | string[];
  48115. }
  48116. /**
  48117. * Default experience which provides a similar setup to the previous webVRExperience
  48118. */
  48119. export class WebXRDefaultExperience {
  48120. /**
  48121. * Base experience
  48122. */
  48123. baseExperience: WebXRExperienceHelper;
  48124. /**
  48125. * Enables ui for entering/exiting xr
  48126. */
  48127. enterExitUI: WebXREnterExitUI;
  48128. /**
  48129. * Input experience extension
  48130. */
  48131. input: WebXRInput;
  48132. /**
  48133. * Enables laser pointer and selection
  48134. */
  48135. pointerSelection: WebXRControllerPointerSelection;
  48136. /**
  48137. * Default target xr should render to
  48138. */
  48139. renderTarget: WebXRRenderTarget;
  48140. /**
  48141. * Enables teleportation
  48142. */
  48143. teleportation: WebXRMotionControllerTeleportation;
  48144. private constructor();
  48145. /**
  48146. * Creates the default xr experience
  48147. * @param scene scene
  48148. * @param options options for basic configuration
  48149. * @returns resulting WebXRDefaultExperience
  48150. */
  48151. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48152. /**
  48153. * DIsposes of the experience helper
  48154. */
  48155. dispose(): void;
  48156. }
  48157. }
  48158. declare module BABYLON {
  48159. /**
  48160. * Options to modify the vr teleportation behavior.
  48161. */
  48162. export interface VRTeleportationOptions {
  48163. /**
  48164. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48165. */
  48166. floorMeshName?: string;
  48167. /**
  48168. * A list of meshes to be used as the teleportation floor. (default: empty)
  48169. */
  48170. floorMeshes?: Mesh[];
  48171. /**
  48172. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48173. */
  48174. teleportationMode?: number;
  48175. /**
  48176. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48177. */
  48178. teleportationTime?: number;
  48179. /**
  48180. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48181. */
  48182. teleportationSpeed?: number;
  48183. /**
  48184. * The easing function used in the animation or null for Linear. (default CircleEase)
  48185. */
  48186. easingFunction?: EasingFunction;
  48187. }
  48188. /**
  48189. * Options to modify the vr experience helper's behavior.
  48190. */
  48191. export interface VRExperienceHelperOptions extends WebVROptions {
  48192. /**
  48193. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48194. */
  48195. createDeviceOrientationCamera?: boolean;
  48196. /**
  48197. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48198. */
  48199. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48200. /**
  48201. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48202. */
  48203. laserToggle?: boolean;
  48204. /**
  48205. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48206. */
  48207. floorMeshes?: Mesh[];
  48208. /**
  48209. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48210. */
  48211. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48212. /**
  48213. * Defines if WebXR should be used instead of WebVR (if available)
  48214. */
  48215. useXR?: boolean;
  48216. }
  48217. /**
  48218. * Event containing information after VR has been entered
  48219. */
  48220. export class OnAfterEnteringVRObservableEvent {
  48221. /**
  48222. * If entering vr was successful
  48223. */
  48224. success: boolean;
  48225. }
  48226. /**
  48227. * Helps to quickly add VR support to an existing scene.
  48228. * See http://doc.babylonjs.com/how_to/webvr_helper
  48229. */
  48230. export class VRExperienceHelper {
  48231. /** Options to modify the vr experience helper's behavior. */
  48232. webVROptions: VRExperienceHelperOptions;
  48233. private _scene;
  48234. private _position;
  48235. private _btnVR;
  48236. private _btnVRDisplayed;
  48237. private _webVRsupported;
  48238. private _webVRready;
  48239. private _webVRrequesting;
  48240. private _webVRpresenting;
  48241. private _hasEnteredVR;
  48242. private _fullscreenVRpresenting;
  48243. private _inputElement;
  48244. private _webVRCamera;
  48245. private _vrDeviceOrientationCamera;
  48246. private _deviceOrientationCamera;
  48247. private _existingCamera;
  48248. private _onKeyDown;
  48249. private _onVrDisplayPresentChange;
  48250. private _onVRDisplayChanged;
  48251. private _onVRRequestPresentStart;
  48252. private _onVRRequestPresentComplete;
  48253. /**
  48254. * 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)
  48255. */
  48256. enableGazeEvenWhenNoPointerLock: boolean;
  48257. /**
  48258. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48259. */
  48260. exitVROnDoubleTap: boolean;
  48261. /**
  48262. * Observable raised right before entering VR.
  48263. */
  48264. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48265. /**
  48266. * Observable raised when entering VR has completed.
  48267. */
  48268. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48269. /**
  48270. * Observable raised when exiting VR.
  48271. */
  48272. onExitingVRObservable: Observable<VRExperienceHelper>;
  48273. /**
  48274. * Observable raised when controller mesh is loaded.
  48275. */
  48276. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48277. /** Return this.onEnteringVRObservable
  48278. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48279. */
  48280. get onEnteringVR(): Observable<VRExperienceHelper>;
  48281. /** Return this.onExitingVRObservable
  48282. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48283. */
  48284. get onExitingVR(): Observable<VRExperienceHelper>;
  48285. /** Return this.onControllerMeshLoadedObservable
  48286. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48287. */
  48288. get onControllerMeshLoaded(): Observable<WebVRController>;
  48289. private _rayLength;
  48290. private _useCustomVRButton;
  48291. private _teleportationRequested;
  48292. private _teleportActive;
  48293. private _floorMeshName;
  48294. private _floorMeshesCollection;
  48295. private _teleportationMode;
  48296. private _teleportationTime;
  48297. private _teleportationSpeed;
  48298. private _teleportationEasing;
  48299. private _rotationAllowed;
  48300. private _teleportBackwardsVector;
  48301. private _teleportationTarget;
  48302. private _isDefaultTeleportationTarget;
  48303. private _postProcessMove;
  48304. private _teleportationFillColor;
  48305. private _teleportationBorderColor;
  48306. private _rotationAngle;
  48307. private _haloCenter;
  48308. private _cameraGazer;
  48309. private _padSensibilityUp;
  48310. private _padSensibilityDown;
  48311. private _leftController;
  48312. private _rightController;
  48313. private _gazeColor;
  48314. private _laserColor;
  48315. private _pickedLaserColor;
  48316. private _pickedGazeColor;
  48317. /**
  48318. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48319. */
  48320. onNewMeshSelected: Observable<AbstractMesh>;
  48321. /**
  48322. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48323. * This observable will provide the mesh and the controller used to select the mesh
  48324. */
  48325. onMeshSelectedWithController: Observable<{
  48326. mesh: AbstractMesh;
  48327. controller: WebVRController;
  48328. }>;
  48329. /**
  48330. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48331. */
  48332. onNewMeshPicked: Observable<PickingInfo>;
  48333. private _circleEase;
  48334. /**
  48335. * Observable raised before camera teleportation
  48336. */
  48337. onBeforeCameraTeleport: Observable<Vector3>;
  48338. /**
  48339. * Observable raised after camera teleportation
  48340. */
  48341. onAfterCameraTeleport: Observable<Vector3>;
  48342. /**
  48343. * Observable raised when current selected mesh gets unselected
  48344. */
  48345. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48346. private _raySelectionPredicate;
  48347. /**
  48348. * To be optionaly changed by user to define custom ray selection
  48349. */
  48350. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48351. /**
  48352. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48353. */
  48354. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48355. /**
  48356. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48357. */
  48358. teleportationEnabled: boolean;
  48359. private _defaultHeight;
  48360. private _teleportationInitialized;
  48361. private _interactionsEnabled;
  48362. private _interactionsRequested;
  48363. private _displayGaze;
  48364. private _displayLaserPointer;
  48365. /**
  48366. * The mesh used to display where the user is going to teleport.
  48367. */
  48368. get teleportationTarget(): Mesh;
  48369. /**
  48370. * Sets the mesh to be used to display where the user is going to teleport.
  48371. */
  48372. set teleportationTarget(value: Mesh);
  48373. /**
  48374. * 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
  48375. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48376. * See http://doc.babylonjs.com/resources/baking_transformations
  48377. */
  48378. get gazeTrackerMesh(): Mesh;
  48379. set gazeTrackerMesh(value: Mesh);
  48380. /**
  48381. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48382. */
  48383. updateGazeTrackerScale: boolean;
  48384. /**
  48385. * If the gaze trackers color should be updated when selecting meshes
  48386. */
  48387. updateGazeTrackerColor: boolean;
  48388. /**
  48389. * If the controller laser color should be updated when selecting meshes
  48390. */
  48391. updateControllerLaserColor: boolean;
  48392. /**
  48393. * The gaze tracking mesh corresponding to the left controller
  48394. */
  48395. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48396. /**
  48397. * The gaze tracking mesh corresponding to the right controller
  48398. */
  48399. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48400. /**
  48401. * If the ray of the gaze should be displayed.
  48402. */
  48403. get displayGaze(): boolean;
  48404. /**
  48405. * Sets if the ray of the gaze should be displayed.
  48406. */
  48407. set displayGaze(value: boolean);
  48408. /**
  48409. * If the ray of the LaserPointer should be displayed.
  48410. */
  48411. get displayLaserPointer(): boolean;
  48412. /**
  48413. * Sets if the ray of the LaserPointer should be displayed.
  48414. */
  48415. set displayLaserPointer(value: boolean);
  48416. /**
  48417. * The deviceOrientationCamera used as the camera when not in VR.
  48418. */
  48419. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48420. /**
  48421. * Based on the current WebVR support, returns the current VR camera used.
  48422. */
  48423. get currentVRCamera(): Nullable<Camera>;
  48424. /**
  48425. * The webVRCamera which is used when in VR.
  48426. */
  48427. get webVRCamera(): WebVRFreeCamera;
  48428. /**
  48429. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48430. */
  48431. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48432. /**
  48433. * The html button that is used to trigger entering into VR.
  48434. */
  48435. get vrButton(): Nullable<HTMLButtonElement>;
  48436. private get _teleportationRequestInitiated();
  48437. /**
  48438. * Defines whether or not Pointer lock should be requested when switching to
  48439. * full screen.
  48440. */
  48441. requestPointerLockOnFullScreen: boolean;
  48442. /**
  48443. * If asking to force XR, this will be populated with the default xr experience
  48444. */
  48445. xr: WebXRDefaultExperience;
  48446. /**
  48447. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48448. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48449. */
  48450. xrTestDone: boolean;
  48451. /**
  48452. * Instantiates a VRExperienceHelper.
  48453. * Helps to quickly add VR support to an existing scene.
  48454. * @param scene The scene the VRExperienceHelper belongs to.
  48455. * @param webVROptions Options to modify the vr experience helper's behavior.
  48456. */
  48457. constructor(scene: Scene,
  48458. /** Options to modify the vr experience helper's behavior. */
  48459. webVROptions?: VRExperienceHelperOptions);
  48460. private completeVRInit;
  48461. private _onDefaultMeshLoaded;
  48462. private _onResize;
  48463. private _onFullscreenChange;
  48464. /**
  48465. * Gets a value indicating if we are currently in VR mode.
  48466. */
  48467. get isInVRMode(): boolean;
  48468. private onVrDisplayPresentChange;
  48469. private onVRDisplayChanged;
  48470. private moveButtonToBottomRight;
  48471. private displayVRButton;
  48472. private updateButtonVisibility;
  48473. private _cachedAngularSensibility;
  48474. /**
  48475. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48476. * Otherwise, will use the fullscreen API.
  48477. */
  48478. enterVR(): void;
  48479. /**
  48480. * Attempt to exit VR, or fullscreen.
  48481. */
  48482. exitVR(): void;
  48483. /**
  48484. * The position of the vr experience helper.
  48485. */
  48486. get position(): Vector3;
  48487. /**
  48488. * Sets the position of the vr experience helper.
  48489. */
  48490. set position(value: Vector3);
  48491. /**
  48492. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48493. */
  48494. enableInteractions(): void;
  48495. private get _noControllerIsActive();
  48496. private beforeRender;
  48497. private _isTeleportationFloor;
  48498. /**
  48499. * Adds a floor mesh to be used for teleportation.
  48500. * @param floorMesh the mesh to be used for teleportation.
  48501. */
  48502. addFloorMesh(floorMesh: Mesh): void;
  48503. /**
  48504. * Removes a floor mesh from being used for teleportation.
  48505. * @param floorMesh the mesh to be removed.
  48506. */
  48507. removeFloorMesh(floorMesh: Mesh): void;
  48508. /**
  48509. * Enables interactions and teleportation using the VR controllers and gaze.
  48510. * @param vrTeleportationOptions options to modify teleportation behavior.
  48511. */
  48512. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48513. private _onNewGamepadConnected;
  48514. private _tryEnableInteractionOnController;
  48515. private _onNewGamepadDisconnected;
  48516. private _enableInteractionOnController;
  48517. private _checkTeleportWithRay;
  48518. private _checkRotate;
  48519. private _checkTeleportBackwards;
  48520. private _enableTeleportationOnController;
  48521. private _createTeleportationCircles;
  48522. private _displayTeleportationTarget;
  48523. private _hideTeleportationTarget;
  48524. private _rotateCamera;
  48525. private _moveTeleportationSelectorTo;
  48526. private _workingVector;
  48527. private _workingQuaternion;
  48528. private _workingMatrix;
  48529. /**
  48530. * Time Constant Teleportation Mode
  48531. */
  48532. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48533. /**
  48534. * Speed Constant Teleportation Mode
  48535. */
  48536. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48537. /**
  48538. * Teleports the users feet to the desired location
  48539. * @param location The location where the user's feet should be placed
  48540. */
  48541. teleportCamera(location: Vector3): void;
  48542. private _convertNormalToDirectionOfRay;
  48543. private _castRayAndSelectObject;
  48544. private _notifySelectedMeshUnselected;
  48545. /**
  48546. * Permanently set new colors for the laser pointer
  48547. * @param color the new laser color
  48548. * @param pickedColor the new laser color when picked mesh detected
  48549. */
  48550. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48551. /**
  48552. * Set lighting enabled / disabled on the laser pointer of both controllers
  48553. * @param enabled should the lighting be enabled on the laser pointer
  48554. */
  48555. setLaserLightingState(enabled?: boolean): void;
  48556. /**
  48557. * Permanently set new colors for the gaze pointer
  48558. * @param color the new gaze color
  48559. * @param pickedColor the new gaze color when picked mesh detected
  48560. */
  48561. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48562. /**
  48563. * Sets the color of the laser ray from the vr controllers.
  48564. * @param color new color for the ray.
  48565. */
  48566. changeLaserColor(color: Color3): void;
  48567. /**
  48568. * Sets the color of the ray from the vr headsets gaze.
  48569. * @param color new color for the ray.
  48570. */
  48571. changeGazeColor(color: Color3): void;
  48572. /**
  48573. * Exits VR and disposes of the vr experience helper
  48574. */
  48575. dispose(): void;
  48576. /**
  48577. * Gets the name of the VRExperienceHelper class
  48578. * @returns "VRExperienceHelper"
  48579. */
  48580. getClassName(): string;
  48581. }
  48582. }
  48583. declare module BABYLON {
  48584. /**
  48585. * Contains an array of blocks representing the octree
  48586. */
  48587. export interface IOctreeContainer<T> {
  48588. /**
  48589. * Blocks within the octree
  48590. */
  48591. blocks: Array<OctreeBlock<T>>;
  48592. }
  48593. /**
  48594. * Class used to store a cell in an octree
  48595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48596. */
  48597. export class OctreeBlock<T> {
  48598. /**
  48599. * Gets the content of the current block
  48600. */
  48601. entries: T[];
  48602. /**
  48603. * Gets the list of block children
  48604. */
  48605. blocks: Array<OctreeBlock<T>>;
  48606. private _depth;
  48607. private _maxDepth;
  48608. private _capacity;
  48609. private _minPoint;
  48610. private _maxPoint;
  48611. private _boundingVectors;
  48612. private _creationFunc;
  48613. /**
  48614. * Creates a new block
  48615. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48616. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48617. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48618. * @param depth defines the current depth of this block in the octree
  48619. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48620. * @param creationFunc defines a callback to call when an element is added to the block
  48621. */
  48622. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48623. /**
  48624. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48625. */
  48626. get capacity(): number;
  48627. /**
  48628. * Gets the minimum vector (in world space) of the block's bounding box
  48629. */
  48630. get minPoint(): Vector3;
  48631. /**
  48632. * Gets the maximum vector (in world space) of the block's bounding box
  48633. */
  48634. get maxPoint(): Vector3;
  48635. /**
  48636. * Add a new element to this block
  48637. * @param entry defines the element to add
  48638. */
  48639. addEntry(entry: T): void;
  48640. /**
  48641. * Remove an element from this block
  48642. * @param entry defines the element to remove
  48643. */
  48644. removeEntry(entry: T): void;
  48645. /**
  48646. * Add an array of elements to this block
  48647. * @param entries defines the array of elements to add
  48648. */
  48649. addEntries(entries: T[]): void;
  48650. /**
  48651. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48652. * @param frustumPlanes defines the frustum planes to test
  48653. * @param selection defines the array to store current content if selection is positive
  48654. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48655. */
  48656. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48657. /**
  48658. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48659. * @param sphereCenter defines the bounding sphere center
  48660. * @param sphereRadius defines the bounding sphere radius
  48661. * @param selection defines the array to store current content if selection is positive
  48662. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48663. */
  48664. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48665. /**
  48666. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48667. * @param ray defines the ray to test with
  48668. * @param selection defines the array to store current content if selection is positive
  48669. */
  48670. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48671. /**
  48672. * Subdivide the content into child blocks (this block will then be empty)
  48673. */
  48674. createInnerBlocks(): void;
  48675. /**
  48676. * @hidden
  48677. */
  48678. 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;
  48679. }
  48680. }
  48681. declare module BABYLON {
  48682. /**
  48683. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48684. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48685. */
  48686. export class Octree<T> {
  48687. /** 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.) */
  48688. maxDepth: number;
  48689. /**
  48690. * Blocks within the octree containing objects
  48691. */
  48692. blocks: Array<OctreeBlock<T>>;
  48693. /**
  48694. * Content stored in the octree
  48695. */
  48696. dynamicContent: T[];
  48697. private _maxBlockCapacity;
  48698. private _selectionContent;
  48699. private _creationFunc;
  48700. /**
  48701. * Creates a octree
  48702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48703. * @param creationFunc function to be used to instatiate the octree
  48704. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48705. * @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.)
  48706. */
  48707. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48708. /** 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.) */
  48709. maxDepth?: number);
  48710. /**
  48711. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48712. * @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);
  48713. * @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);
  48714. * @param entries meshes to be added to the octree blocks
  48715. */
  48716. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48717. /**
  48718. * Adds a mesh to the octree
  48719. * @param entry Mesh to add to the octree
  48720. */
  48721. addMesh(entry: T): void;
  48722. /**
  48723. * Remove an element from the octree
  48724. * @param entry defines the element to remove
  48725. */
  48726. removeMesh(entry: T): void;
  48727. /**
  48728. * Selects an array of meshes within the frustum
  48729. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48730. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48731. * @returns array of meshes within the frustum
  48732. */
  48733. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48734. /**
  48735. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48736. * @param sphereCenter defines the bounding sphere center
  48737. * @param sphereRadius defines the bounding sphere radius
  48738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48739. * @returns an array of objects that intersect the sphere
  48740. */
  48741. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48742. /**
  48743. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48744. * @param ray defines the ray to test with
  48745. * @returns array of intersected objects
  48746. */
  48747. intersectsRay(ray: Ray): SmartArray<T>;
  48748. /**
  48749. * Adds a mesh into the octree block if it intersects the block
  48750. */
  48751. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48752. /**
  48753. * Adds a submesh into the octree block if it intersects the block
  48754. */
  48755. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. interface Scene {
  48760. /**
  48761. * @hidden
  48762. * Backing Filed
  48763. */
  48764. _selectionOctree: Octree<AbstractMesh>;
  48765. /**
  48766. * Gets the octree used to boost mesh selection (picking)
  48767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48768. */
  48769. selectionOctree: Octree<AbstractMesh>;
  48770. /**
  48771. * Creates or updates the octree used to boost selection (picking)
  48772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48773. * @param maxCapacity defines the maximum capacity per leaf
  48774. * @param maxDepth defines the maximum depth of the octree
  48775. * @returns an octree of AbstractMesh
  48776. */
  48777. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48778. }
  48779. interface AbstractMesh {
  48780. /**
  48781. * @hidden
  48782. * Backing Field
  48783. */
  48784. _submeshesOctree: Octree<SubMesh>;
  48785. /**
  48786. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48787. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48788. * @param maxCapacity defines the maximum size of each block (64 by default)
  48789. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48790. * @returns the new octree
  48791. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48793. */
  48794. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48795. }
  48796. /**
  48797. * Defines the octree scene component responsible to manage any octrees
  48798. * in a given scene.
  48799. */
  48800. export class OctreeSceneComponent {
  48801. /**
  48802. * The component name help to identify the component in the list of scene components.
  48803. */
  48804. readonly name: string;
  48805. /**
  48806. * The scene the component belongs to.
  48807. */
  48808. scene: Scene;
  48809. /**
  48810. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48811. */
  48812. readonly checksIsEnabled: boolean;
  48813. /**
  48814. * Creates a new instance of the component for the given scene
  48815. * @param scene Defines the scene to register the component in
  48816. */
  48817. constructor(scene: Scene);
  48818. /**
  48819. * Registers the component in a given scene
  48820. */
  48821. register(): void;
  48822. /**
  48823. * Return the list of active meshes
  48824. * @returns the list of active meshes
  48825. */
  48826. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48827. /**
  48828. * Return the list of active sub meshes
  48829. * @param mesh The mesh to get the candidates sub meshes from
  48830. * @returns the list of active sub meshes
  48831. */
  48832. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48833. private _tempRay;
  48834. /**
  48835. * Return the list of sub meshes intersecting with a given local ray
  48836. * @param mesh defines the mesh to find the submesh for
  48837. * @param localRay defines the ray in local space
  48838. * @returns the list of intersecting sub meshes
  48839. */
  48840. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48841. /**
  48842. * Return the list of sub meshes colliding with a collider
  48843. * @param mesh defines the mesh to find the submesh for
  48844. * @param collider defines the collider to evaluate the collision against
  48845. * @returns the list of colliding sub meshes
  48846. */
  48847. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48848. /**
  48849. * Rebuilds the elements related to this component in case of
  48850. * context lost for instance.
  48851. */
  48852. rebuild(): void;
  48853. /**
  48854. * Disposes the component and the associated ressources.
  48855. */
  48856. dispose(): void;
  48857. }
  48858. }
  48859. declare module BABYLON {
  48860. /**
  48861. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48862. */
  48863. export class Gizmo implements IDisposable {
  48864. /** The utility layer the gizmo will be added to */
  48865. gizmoLayer: UtilityLayerRenderer;
  48866. /**
  48867. * The root mesh of the gizmo
  48868. */
  48869. _rootMesh: Mesh;
  48870. private _attachedMesh;
  48871. /**
  48872. * Ratio for the scale of the gizmo (Default: 1)
  48873. */
  48874. scaleRatio: number;
  48875. /**
  48876. * If a custom mesh has been set (Default: false)
  48877. */
  48878. protected _customMeshSet: boolean;
  48879. /**
  48880. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48881. * * When set, interactions will be enabled
  48882. */
  48883. get attachedMesh(): Nullable<AbstractMesh>;
  48884. set attachedMesh(value: Nullable<AbstractMesh>);
  48885. /**
  48886. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48887. * @param mesh The mesh to replace the default mesh of the gizmo
  48888. */
  48889. setCustomMesh(mesh: Mesh): void;
  48890. /**
  48891. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48892. */
  48893. updateGizmoRotationToMatchAttachedMesh: boolean;
  48894. /**
  48895. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48896. */
  48897. updateGizmoPositionToMatchAttachedMesh: boolean;
  48898. /**
  48899. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48900. */
  48901. updateScale: boolean;
  48902. protected _interactionsEnabled: boolean;
  48903. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48904. private _beforeRenderObserver;
  48905. private _tempVector;
  48906. /**
  48907. * Creates a gizmo
  48908. * @param gizmoLayer The utility layer the gizmo will be added to
  48909. */
  48910. constructor(
  48911. /** The utility layer the gizmo will be added to */
  48912. gizmoLayer?: UtilityLayerRenderer);
  48913. /**
  48914. * Updates the gizmo to match the attached mesh's position/rotation
  48915. */
  48916. protected _update(): void;
  48917. /**
  48918. * Disposes of the gizmo
  48919. */
  48920. dispose(): void;
  48921. }
  48922. }
  48923. declare module BABYLON {
  48924. /**
  48925. * Single plane drag gizmo
  48926. */
  48927. export class PlaneDragGizmo extends Gizmo {
  48928. /**
  48929. * Drag behavior responsible for the gizmos dragging interactions
  48930. */
  48931. dragBehavior: PointerDragBehavior;
  48932. private _pointerObserver;
  48933. /**
  48934. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48935. */
  48936. snapDistance: number;
  48937. /**
  48938. * Event that fires each time the gizmo snaps to a new location.
  48939. * * snapDistance is the the change in distance
  48940. */
  48941. onSnapObservable: Observable<{
  48942. snapDistance: number;
  48943. }>;
  48944. private _plane;
  48945. private _coloredMaterial;
  48946. private _hoverMaterial;
  48947. private _isEnabled;
  48948. private _parent;
  48949. /** @hidden */
  48950. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48951. /** @hidden */
  48952. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48953. /**
  48954. * Creates a PlaneDragGizmo
  48955. * @param gizmoLayer The utility layer the gizmo will be added to
  48956. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48957. * @param color The color of the gizmo
  48958. */
  48959. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48960. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48961. /**
  48962. * If the gizmo is enabled
  48963. */
  48964. set isEnabled(value: boolean);
  48965. get isEnabled(): boolean;
  48966. /**
  48967. * Disposes of the gizmo
  48968. */
  48969. dispose(): void;
  48970. }
  48971. }
  48972. declare module BABYLON {
  48973. /**
  48974. * Gizmo that enables dragging a mesh along 3 axis
  48975. */
  48976. export class PositionGizmo extends Gizmo {
  48977. /**
  48978. * Internal gizmo used for interactions on the x axis
  48979. */
  48980. xGizmo: AxisDragGizmo;
  48981. /**
  48982. * Internal gizmo used for interactions on the y axis
  48983. */
  48984. yGizmo: AxisDragGizmo;
  48985. /**
  48986. * Internal gizmo used for interactions on the z axis
  48987. */
  48988. zGizmo: AxisDragGizmo;
  48989. /**
  48990. * Internal gizmo used for interactions on the yz plane
  48991. */
  48992. xPlaneGizmo: PlaneDragGizmo;
  48993. /**
  48994. * Internal gizmo used for interactions on the xz plane
  48995. */
  48996. yPlaneGizmo: PlaneDragGizmo;
  48997. /**
  48998. * Internal gizmo used for interactions on the xy plane
  48999. */
  49000. zPlaneGizmo: PlaneDragGizmo;
  49001. /**
  49002. * private variables
  49003. */
  49004. private _meshAttached;
  49005. private _updateGizmoRotationToMatchAttachedMesh;
  49006. private _snapDistance;
  49007. private _scaleRatio;
  49008. /** Fires an event when any of it's sub gizmos are dragged */
  49009. onDragStartObservable: Observable<unknown>;
  49010. /** Fires an event when any of it's sub gizmos are released from dragging */
  49011. onDragEndObservable: Observable<unknown>;
  49012. /**
  49013. * If set to true, planar drag is enabled
  49014. */
  49015. private _planarGizmoEnabled;
  49016. get attachedMesh(): Nullable<AbstractMesh>;
  49017. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49018. /**
  49019. * Creates a PositionGizmo
  49020. * @param gizmoLayer The utility layer the gizmo will be added to
  49021. */
  49022. constructor(gizmoLayer?: UtilityLayerRenderer);
  49023. /**
  49024. * If the planar drag gizmo is enabled
  49025. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49026. */
  49027. set planarGizmoEnabled(value: boolean);
  49028. get planarGizmoEnabled(): boolean;
  49029. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49030. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49031. /**
  49032. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49033. */
  49034. set snapDistance(value: number);
  49035. get snapDistance(): number;
  49036. /**
  49037. * Ratio for the scale of the gizmo (Default: 1)
  49038. */
  49039. set scaleRatio(value: number);
  49040. get scaleRatio(): number;
  49041. /**
  49042. * Disposes of the gizmo
  49043. */
  49044. dispose(): void;
  49045. /**
  49046. * CustomMeshes are not supported by this gizmo
  49047. * @param mesh The mesh to replace the default mesh of the gizmo
  49048. */
  49049. setCustomMesh(mesh: Mesh): void;
  49050. }
  49051. }
  49052. declare module BABYLON {
  49053. /**
  49054. * Single axis drag gizmo
  49055. */
  49056. export class AxisDragGizmo extends Gizmo {
  49057. /**
  49058. * Drag behavior responsible for the gizmos dragging interactions
  49059. */
  49060. dragBehavior: PointerDragBehavior;
  49061. private _pointerObserver;
  49062. /**
  49063. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49064. */
  49065. snapDistance: number;
  49066. /**
  49067. * Event that fires each time the gizmo snaps to a new location.
  49068. * * snapDistance is the the change in distance
  49069. */
  49070. onSnapObservable: Observable<{
  49071. snapDistance: number;
  49072. }>;
  49073. private _isEnabled;
  49074. private _parent;
  49075. private _arrow;
  49076. private _coloredMaterial;
  49077. private _hoverMaterial;
  49078. /** @hidden */
  49079. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49080. /** @hidden */
  49081. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49082. /**
  49083. * Creates an AxisDragGizmo
  49084. * @param gizmoLayer The utility layer the gizmo will be added to
  49085. * @param dragAxis The axis which the gizmo will be able to drag on
  49086. * @param color The color of the gizmo
  49087. */
  49088. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49090. /**
  49091. * If the gizmo is enabled
  49092. */
  49093. set isEnabled(value: boolean);
  49094. get isEnabled(): boolean;
  49095. /**
  49096. * Disposes of the gizmo
  49097. */
  49098. dispose(): void;
  49099. }
  49100. }
  49101. declare module BABYLON.Debug {
  49102. /**
  49103. * The Axes viewer will show 3 axes in a specific point in space
  49104. */
  49105. export class AxesViewer {
  49106. private _xAxis;
  49107. private _yAxis;
  49108. private _zAxis;
  49109. private _scaleLinesFactor;
  49110. private _instanced;
  49111. /**
  49112. * Gets the hosting scene
  49113. */
  49114. scene: Scene;
  49115. /**
  49116. * Gets or sets a number used to scale line length
  49117. */
  49118. scaleLines: number;
  49119. /** Gets the node hierarchy used to render x-axis */
  49120. get xAxis(): TransformNode;
  49121. /** Gets the node hierarchy used to render y-axis */
  49122. get yAxis(): TransformNode;
  49123. /** Gets the node hierarchy used to render z-axis */
  49124. get zAxis(): TransformNode;
  49125. /**
  49126. * Creates a new AxesViewer
  49127. * @param scene defines the hosting scene
  49128. * @param scaleLines defines a number used to scale line length (1 by default)
  49129. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49130. * @param xAxis defines the node hierarchy used to render the x-axis
  49131. * @param yAxis defines the node hierarchy used to render the y-axis
  49132. * @param zAxis defines the node hierarchy used to render the z-axis
  49133. */
  49134. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49135. /**
  49136. * Force the viewer to update
  49137. * @param position defines the position of the viewer
  49138. * @param xaxis defines the x axis of the viewer
  49139. * @param yaxis defines the y axis of the viewer
  49140. * @param zaxis defines the z axis of the viewer
  49141. */
  49142. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49143. /**
  49144. * Creates an instance of this axes viewer.
  49145. * @returns a new axes viewer with instanced meshes
  49146. */
  49147. createInstance(): AxesViewer;
  49148. /** Releases resources */
  49149. dispose(): void;
  49150. private static _SetRenderingGroupId;
  49151. }
  49152. }
  49153. declare module BABYLON.Debug {
  49154. /**
  49155. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49156. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49157. */
  49158. export class BoneAxesViewer extends AxesViewer {
  49159. /**
  49160. * Gets or sets the target mesh where to display the axes viewer
  49161. */
  49162. mesh: Nullable<Mesh>;
  49163. /**
  49164. * Gets or sets the target bone where to display the axes viewer
  49165. */
  49166. bone: Nullable<Bone>;
  49167. /** Gets current position */
  49168. pos: Vector3;
  49169. /** Gets direction of X axis */
  49170. xaxis: Vector3;
  49171. /** Gets direction of Y axis */
  49172. yaxis: Vector3;
  49173. /** Gets direction of Z axis */
  49174. zaxis: Vector3;
  49175. /**
  49176. * Creates a new BoneAxesViewer
  49177. * @param scene defines the hosting scene
  49178. * @param bone defines the target bone
  49179. * @param mesh defines the target mesh
  49180. * @param scaleLines defines a scaling factor for line length (1 by default)
  49181. */
  49182. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49183. /**
  49184. * Force the viewer to update
  49185. */
  49186. update(): void;
  49187. /** Releases resources */
  49188. dispose(): void;
  49189. }
  49190. }
  49191. declare module BABYLON {
  49192. /**
  49193. * Interface used to define scene explorer extensibility option
  49194. */
  49195. export interface IExplorerExtensibilityOption {
  49196. /**
  49197. * Define the option label
  49198. */
  49199. label: string;
  49200. /**
  49201. * Defines the action to execute on click
  49202. */
  49203. action: (entity: any) => void;
  49204. }
  49205. /**
  49206. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49207. */
  49208. export interface IExplorerExtensibilityGroup {
  49209. /**
  49210. * Defines a predicate to test if a given type mut be extended
  49211. */
  49212. predicate: (entity: any) => boolean;
  49213. /**
  49214. * Gets the list of options added to a type
  49215. */
  49216. entries: IExplorerExtensibilityOption[];
  49217. }
  49218. /**
  49219. * Interface used to define the options to use to create the Inspector
  49220. */
  49221. export interface IInspectorOptions {
  49222. /**
  49223. * Display in overlay mode (default: false)
  49224. */
  49225. overlay?: boolean;
  49226. /**
  49227. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49228. */
  49229. globalRoot?: HTMLElement;
  49230. /**
  49231. * Display the Scene explorer
  49232. */
  49233. showExplorer?: boolean;
  49234. /**
  49235. * Display the property inspector
  49236. */
  49237. showInspector?: boolean;
  49238. /**
  49239. * Display in embed mode (both panes on the right)
  49240. */
  49241. embedMode?: boolean;
  49242. /**
  49243. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49244. */
  49245. handleResize?: boolean;
  49246. /**
  49247. * Allow the panes to popup (default: true)
  49248. */
  49249. enablePopup?: boolean;
  49250. /**
  49251. * Allow the panes to be closed by users (default: true)
  49252. */
  49253. enableClose?: boolean;
  49254. /**
  49255. * Optional list of extensibility entries
  49256. */
  49257. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49258. /**
  49259. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49260. */
  49261. inspectorURL?: string;
  49262. /**
  49263. * Optional initial tab (default to DebugLayerTab.Properties)
  49264. */
  49265. initialTab?: DebugLayerTab;
  49266. }
  49267. interface Scene {
  49268. /**
  49269. * @hidden
  49270. * Backing field
  49271. */
  49272. _debugLayer: DebugLayer;
  49273. /**
  49274. * Gets the debug layer (aka Inspector) associated with the scene
  49275. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49276. */
  49277. debugLayer: DebugLayer;
  49278. }
  49279. /**
  49280. * Enum of inspector action tab
  49281. */
  49282. export enum DebugLayerTab {
  49283. /**
  49284. * Properties tag (default)
  49285. */
  49286. Properties = 0,
  49287. /**
  49288. * Debug tab
  49289. */
  49290. Debug = 1,
  49291. /**
  49292. * Statistics tab
  49293. */
  49294. Statistics = 2,
  49295. /**
  49296. * Tools tab
  49297. */
  49298. Tools = 3,
  49299. /**
  49300. * Settings tab
  49301. */
  49302. Settings = 4
  49303. }
  49304. /**
  49305. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49306. * what is happening in your scene
  49307. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49308. */
  49309. export class DebugLayer {
  49310. /**
  49311. * Define the url to get the inspector script from.
  49312. * By default it uses the babylonjs CDN.
  49313. * @ignoreNaming
  49314. */
  49315. static InspectorURL: string;
  49316. private _scene;
  49317. private BJSINSPECTOR;
  49318. private _onPropertyChangedObservable?;
  49319. /**
  49320. * Observable triggered when a property is changed through the inspector.
  49321. */
  49322. get onPropertyChangedObservable(): any;
  49323. /**
  49324. * Instantiates a new debug layer.
  49325. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49326. * what is happening in your scene
  49327. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49328. * @param scene Defines the scene to inspect
  49329. */
  49330. constructor(scene: Scene);
  49331. /** Creates the inspector window. */
  49332. private _createInspector;
  49333. /**
  49334. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49335. * @param entity defines the entity to select
  49336. * @param lineContainerTitle defines the specific block to highlight
  49337. */
  49338. select(entity: any, lineContainerTitle?: string): void;
  49339. /** Get the inspector from bundle or global */
  49340. private _getGlobalInspector;
  49341. /**
  49342. * Get if the inspector is visible or not.
  49343. * @returns true if visible otherwise, false
  49344. */
  49345. isVisible(): boolean;
  49346. /**
  49347. * Hide the inspector and close its window.
  49348. */
  49349. hide(): void;
  49350. /**
  49351. * Update the scene in the inspector
  49352. */
  49353. setAsActiveScene(): void;
  49354. /**
  49355. * Launch the debugLayer.
  49356. * @param config Define the configuration of the inspector
  49357. * @return a promise fulfilled when the debug layer is visible
  49358. */
  49359. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49360. }
  49361. }
  49362. declare module BABYLON {
  49363. /**
  49364. * Class containing static functions to help procedurally build meshes
  49365. */
  49366. export class BoxBuilder {
  49367. /**
  49368. * Creates a box mesh
  49369. * * The parameter `size` sets the size (float) of each box side (default 1)
  49370. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49371. * * 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)
  49372. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49374. * * 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
  49375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49376. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49377. * @param name defines the name of the mesh
  49378. * @param options defines the options used to create the mesh
  49379. * @param scene defines the hosting scene
  49380. * @returns the box mesh
  49381. */
  49382. static CreateBox(name: string, options: {
  49383. size?: number;
  49384. width?: number;
  49385. height?: number;
  49386. depth?: number;
  49387. faceUV?: Vector4[];
  49388. faceColors?: Color4[];
  49389. sideOrientation?: number;
  49390. frontUVs?: Vector4;
  49391. backUVs?: Vector4;
  49392. wrap?: boolean;
  49393. topBaseAt?: number;
  49394. bottomBaseAt?: number;
  49395. updatable?: boolean;
  49396. }, scene?: Nullable<Scene>): Mesh;
  49397. }
  49398. }
  49399. declare module BABYLON.Debug {
  49400. /**
  49401. * Used to show the physics impostor around the specific mesh
  49402. */
  49403. export class PhysicsViewer {
  49404. /** @hidden */
  49405. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49406. /** @hidden */
  49407. protected _meshes: Array<Nullable<AbstractMesh>>;
  49408. /** @hidden */
  49409. protected _scene: Nullable<Scene>;
  49410. /** @hidden */
  49411. protected _numMeshes: number;
  49412. /** @hidden */
  49413. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49414. private _renderFunction;
  49415. private _utilityLayer;
  49416. private _debugBoxMesh;
  49417. private _debugSphereMesh;
  49418. private _debugCylinderMesh;
  49419. private _debugMaterial;
  49420. private _debugMeshMeshes;
  49421. /**
  49422. * Creates a new PhysicsViewer
  49423. * @param scene defines the hosting scene
  49424. */
  49425. constructor(scene: Scene);
  49426. /** @hidden */
  49427. protected _updateDebugMeshes(): void;
  49428. /**
  49429. * Renders a specified physic impostor
  49430. * @param impostor defines the impostor to render
  49431. * @param targetMesh defines the mesh represented by the impostor
  49432. * @returns the new debug mesh used to render the impostor
  49433. */
  49434. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49435. /**
  49436. * Hides a specified physic impostor
  49437. * @param impostor defines the impostor to hide
  49438. */
  49439. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49440. private _getDebugMaterial;
  49441. private _getDebugBoxMesh;
  49442. private _getDebugSphereMesh;
  49443. private _getDebugCylinderMesh;
  49444. private _getDebugMeshMesh;
  49445. private _getDebugMesh;
  49446. /** Releases all resources */
  49447. dispose(): void;
  49448. }
  49449. }
  49450. declare module BABYLON {
  49451. /**
  49452. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49453. * in order to better appreciate the issue one might have.
  49454. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49455. */
  49456. export class RayHelper {
  49457. /**
  49458. * Defines the ray we are currently tryin to visualize.
  49459. */
  49460. ray: Nullable<Ray>;
  49461. private _renderPoints;
  49462. private _renderLine;
  49463. private _renderFunction;
  49464. private _scene;
  49465. private _updateToMeshFunction;
  49466. private _attachedToMesh;
  49467. private _meshSpaceDirection;
  49468. private _meshSpaceOrigin;
  49469. /**
  49470. * Helper function to create a colored helper in a scene in one line.
  49471. * @param ray Defines the ray we are currently tryin to visualize
  49472. * @param scene Defines the scene the ray is used in
  49473. * @param color Defines the color we want to see the ray in
  49474. * @returns The newly created ray helper.
  49475. */
  49476. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49477. /**
  49478. * Instantiate a new ray helper.
  49479. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49480. * in order to better appreciate the issue one might have.
  49481. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49482. * @param ray Defines the ray we are currently tryin to visualize
  49483. */
  49484. constructor(ray: Ray);
  49485. /**
  49486. * Shows the ray we are willing to debug.
  49487. * @param scene Defines the scene the ray needs to be rendered in
  49488. * @param color Defines the color the ray needs to be rendered in
  49489. */
  49490. show(scene: Scene, color?: Color3): void;
  49491. /**
  49492. * Hides the ray we are debugging.
  49493. */
  49494. hide(): void;
  49495. private _render;
  49496. /**
  49497. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49498. * @param mesh Defines the mesh we want the helper attached to
  49499. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49500. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49501. * @param length Defines the length of the ray
  49502. */
  49503. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49504. /**
  49505. * Detach the ray helper from the mesh it has previously been attached to.
  49506. */
  49507. detachFromMesh(): void;
  49508. private _updateToMesh;
  49509. /**
  49510. * Dispose the helper and release its associated resources.
  49511. */
  49512. dispose(): void;
  49513. }
  49514. }
  49515. declare module BABYLON.Debug {
  49516. /**
  49517. * Class used to render a debug view of a given skeleton
  49518. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49519. */
  49520. export class SkeletonViewer {
  49521. /** defines the skeleton to render */
  49522. skeleton: Skeleton;
  49523. /** defines the mesh attached to the skeleton */
  49524. mesh: AbstractMesh;
  49525. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49526. autoUpdateBonesMatrices: boolean;
  49527. /** defines the rendering group id to use with the viewer */
  49528. renderingGroupId: number;
  49529. /** Gets or sets the color used to render the skeleton */
  49530. color: Color3;
  49531. private _scene;
  49532. private _debugLines;
  49533. private _debugMesh;
  49534. private _isEnabled;
  49535. private _renderFunction;
  49536. private _utilityLayer;
  49537. /**
  49538. * Returns the mesh used to render the bones
  49539. */
  49540. get debugMesh(): Nullable<LinesMesh>;
  49541. /**
  49542. * Creates a new SkeletonViewer
  49543. * @param skeleton defines the skeleton to render
  49544. * @param mesh defines the mesh attached to the skeleton
  49545. * @param scene defines the hosting scene
  49546. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49547. * @param renderingGroupId defines the rendering group id to use with the viewer
  49548. */
  49549. constructor(
  49550. /** defines the skeleton to render */
  49551. skeleton: Skeleton,
  49552. /** defines the mesh attached to the skeleton */
  49553. mesh: AbstractMesh, scene: Scene,
  49554. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49555. autoUpdateBonesMatrices?: boolean,
  49556. /** defines the rendering group id to use with the viewer */
  49557. renderingGroupId?: number);
  49558. /** Gets or sets a boolean indicating if the viewer is enabled */
  49559. set isEnabled(value: boolean);
  49560. get isEnabled(): boolean;
  49561. private _getBonePosition;
  49562. private _getLinesForBonesWithLength;
  49563. private _getLinesForBonesNoLength;
  49564. /** Update the viewer to sync with current skeleton state */
  49565. update(): void;
  49566. /** Release associated resources */
  49567. dispose(): void;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Enum for Device Types
  49573. */
  49574. export enum DeviceType {
  49575. /** Generic */
  49576. Generic = 0,
  49577. /** Keyboard */
  49578. Keyboard = 1,
  49579. /** Mouse */
  49580. Mouse = 2,
  49581. /** Touch Pointers */
  49582. Touch = 3,
  49583. /** PS4 Dual Shock */
  49584. DualShock = 4,
  49585. /** Xbox */
  49586. Xbox = 5,
  49587. /** Switch Controller */
  49588. Switch = 6
  49589. }
  49590. /**
  49591. * Enum for All Pointers (Touch/Mouse)
  49592. */
  49593. export enum PointerInput {
  49594. /** Horizontal Axis */
  49595. Horizontal = 0,
  49596. /** Vertical Axis */
  49597. Vertical = 1,
  49598. /** Left Click or Touch */
  49599. LeftClick = 2,
  49600. /** Middle Click */
  49601. MiddleClick = 3,
  49602. /** Right Click */
  49603. RightClick = 4,
  49604. /** Browser Back */
  49605. BrowserBack = 5,
  49606. /** Browser Forward */
  49607. BrowserForward = 6
  49608. }
  49609. /**
  49610. * Enum for Dual Shock Gamepad
  49611. */
  49612. export enum DualShockInput {
  49613. /** Cross */
  49614. Cross = 0,
  49615. /** Circle */
  49616. Circle = 1,
  49617. /** Square */
  49618. Square = 2,
  49619. /** Triangle */
  49620. Triangle = 3,
  49621. /** L1 */
  49622. L1 = 4,
  49623. /** R1 */
  49624. R1 = 5,
  49625. /** L2 */
  49626. L2 = 6,
  49627. /** R2 */
  49628. R2 = 7,
  49629. /** Share */
  49630. Share = 8,
  49631. /** Options */
  49632. Options = 9,
  49633. /** L3 */
  49634. L3 = 10,
  49635. /** R3 */
  49636. R3 = 11,
  49637. /** DPadUp */
  49638. DPadUp = 12,
  49639. /** DPadDown */
  49640. DPadDown = 13,
  49641. /** DPadLeft */
  49642. DPadLeft = 14,
  49643. /** DRight */
  49644. DPadRight = 15,
  49645. /** Home */
  49646. Home = 16,
  49647. /** TouchPad */
  49648. TouchPad = 17,
  49649. /** LStickXAxis */
  49650. LStickXAxis = 18,
  49651. /** LStickYAxis */
  49652. LStickYAxis = 19,
  49653. /** RStickXAxis */
  49654. RStickXAxis = 20,
  49655. /** RStickYAxis */
  49656. RStickYAxis = 21
  49657. }
  49658. /**
  49659. * Enum for Xbox Gamepad
  49660. */
  49661. export enum XboxInput {
  49662. /** A */
  49663. A = 0,
  49664. /** B */
  49665. B = 1,
  49666. /** X */
  49667. X = 2,
  49668. /** Y */
  49669. Y = 3,
  49670. /** LB */
  49671. LB = 4,
  49672. /** RB */
  49673. RB = 5,
  49674. /** LT */
  49675. LT = 6,
  49676. /** RT */
  49677. RT = 7,
  49678. /** Back */
  49679. Back = 8,
  49680. /** Start */
  49681. Start = 9,
  49682. /** LS */
  49683. LS = 10,
  49684. /** RS */
  49685. RS = 11,
  49686. /** DPadUp */
  49687. DPadUp = 12,
  49688. /** DPadDown */
  49689. DPadDown = 13,
  49690. /** DPadLeft */
  49691. DPadLeft = 14,
  49692. /** DRight */
  49693. DPadRight = 15,
  49694. /** Home */
  49695. Home = 16,
  49696. /** LStickXAxis */
  49697. LStickXAxis = 17,
  49698. /** LStickYAxis */
  49699. LStickYAxis = 18,
  49700. /** RStickXAxis */
  49701. RStickXAxis = 19,
  49702. /** RStickYAxis */
  49703. RStickYAxis = 20
  49704. }
  49705. /**
  49706. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49707. */
  49708. export enum SwitchInput {
  49709. /** B */
  49710. B = 0,
  49711. /** A */
  49712. A = 1,
  49713. /** Y */
  49714. Y = 2,
  49715. /** X */
  49716. X = 3,
  49717. /** L */
  49718. L = 4,
  49719. /** R */
  49720. R = 5,
  49721. /** ZL */
  49722. ZL = 6,
  49723. /** ZR */
  49724. ZR = 7,
  49725. /** Minus */
  49726. Minus = 8,
  49727. /** Plus */
  49728. Plus = 9,
  49729. /** LS */
  49730. LS = 10,
  49731. /** RS */
  49732. RS = 11,
  49733. /** DPadUp */
  49734. DPadUp = 12,
  49735. /** DPadDown */
  49736. DPadDown = 13,
  49737. /** DPadLeft */
  49738. DPadLeft = 14,
  49739. /** DRight */
  49740. DPadRight = 15,
  49741. /** Home */
  49742. Home = 16,
  49743. /** Capture */
  49744. Capture = 17,
  49745. /** LStickXAxis */
  49746. LStickXAxis = 18,
  49747. /** LStickYAxis */
  49748. LStickYAxis = 19,
  49749. /** RStickXAxis */
  49750. RStickXAxis = 20,
  49751. /** RStickYAxis */
  49752. RStickYAxis = 21
  49753. }
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * This class will take all inputs from Keyboard, Pointer, and
  49758. * any Gamepads and provide a polling system that all devices
  49759. * will use. This class assumes that there will only be one
  49760. * pointer device and one keyboard.
  49761. */
  49762. export class DeviceInputSystem implements IDisposable {
  49763. /**
  49764. * Callback to be triggered when a device is connected
  49765. */
  49766. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49767. /**
  49768. * Callback to be triggered when a device is disconnected
  49769. */
  49770. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49771. /**
  49772. * Callback to be triggered when event driven input is updated
  49773. */
  49774. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49775. private _inputs;
  49776. private _gamepads;
  49777. private _keyboardActive;
  49778. private _pointerActive;
  49779. private _elementToAttachTo;
  49780. private _keyboardDownEvent;
  49781. private _keyboardUpEvent;
  49782. private _pointerMoveEvent;
  49783. private _pointerDownEvent;
  49784. private _pointerUpEvent;
  49785. private _gamepadConnectedEvent;
  49786. private _gamepadDisconnectedEvent;
  49787. private static _MAX_KEYCODES;
  49788. private static _MAX_POINTER_INPUTS;
  49789. /**
  49790. * Default Constructor
  49791. * @param engine - engine to pull input element from
  49792. */
  49793. constructor(engine: Engine);
  49794. /**
  49795. * Checks for current device input value, given an id and input index
  49796. * @param deviceName Id of connected device
  49797. * @param inputIndex Index of device input
  49798. * @returns Current value of input
  49799. */
  49800. /**
  49801. * Checks for current device input value, given an id and input index
  49802. * @param deviceType Enum specifiying device type
  49803. * @param deviceSlot "Slot" or index that device is referenced in
  49804. * @param inputIndex Id of input to be checked
  49805. * @returns Current value of input
  49806. */
  49807. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49808. /**
  49809. * Dispose of all the eventlisteners
  49810. */
  49811. dispose(): void;
  49812. /**
  49813. * Add device and inputs to device array
  49814. * @param deviceType Enum specifiying device type
  49815. * @param deviceSlot "Slot" or index that device is referenced in
  49816. * @param numberOfInputs Number of input entries to create for given device
  49817. */
  49818. private _registerDevice;
  49819. /**
  49820. * Given a specific device name, remove that device from the device map
  49821. * @param deviceType Enum specifiying device type
  49822. * @param deviceSlot "Slot" or index that device is referenced in
  49823. */
  49824. private _unregisterDevice;
  49825. /**
  49826. * Handle all actions that come from keyboard interaction
  49827. */
  49828. private _handleKeyActions;
  49829. /**
  49830. * Handle all actions that come from pointer interaction
  49831. */
  49832. private _handlePointerActions;
  49833. /**
  49834. * Handle all actions that come from gamepad interaction
  49835. */
  49836. private _handleGamepadActions;
  49837. /**
  49838. * Update all non-event based devices with each frame
  49839. * @param deviceType Enum specifiying device type
  49840. * @param deviceSlot "Slot" or index that device is referenced in
  49841. * @param inputIndex Id of input to be checked
  49842. */
  49843. private _updateDevice;
  49844. /**
  49845. * Gets DeviceType from the device name
  49846. * @param deviceName Name of Device from DeviceInputSystem
  49847. * @returns DeviceType enum value
  49848. */
  49849. private _getGamepadDeviceType;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * Type to handle enforcement of inputs
  49855. */
  49856. 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;
  49857. }
  49858. declare module BABYLON {
  49859. /**
  49860. * Class that handles all input for a specific device
  49861. */
  49862. export class DeviceSource<T extends DeviceType> {
  49863. /** Type of device */
  49864. readonly deviceType: DeviceType;
  49865. /** "Slot" or index that device is referenced in */
  49866. readonly deviceSlot: number;
  49867. /**
  49868. * Observable to handle device input changes per device
  49869. */
  49870. readonly onInputChangedObservable: Observable<{
  49871. inputIndex: DeviceInput<T>;
  49872. previousState: Nullable<number>;
  49873. currentState: Nullable<number>;
  49874. }>;
  49875. private readonly _deviceInputSystem;
  49876. /**
  49877. * Default Constructor
  49878. * @param deviceInputSystem Reference to DeviceInputSystem
  49879. * @param deviceType Type of device
  49880. * @param deviceSlot "Slot" or index that device is referenced in
  49881. */
  49882. constructor(deviceInputSystem: DeviceInputSystem,
  49883. /** Type of device */
  49884. deviceType: DeviceType,
  49885. /** "Slot" or index that device is referenced in */
  49886. deviceSlot?: number);
  49887. /**
  49888. * Get input for specific input
  49889. * @param inputIndex index of specific input on device
  49890. * @returns Input value from DeviceInputSystem
  49891. */
  49892. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49893. }
  49894. /**
  49895. * Class to keep track of devices
  49896. */
  49897. export class DeviceSourceManager implements IDisposable {
  49898. /**
  49899. * Observable to be triggered when before a device is connected
  49900. */
  49901. readonly onBeforeDeviceConnectedObservable: Observable<{
  49902. deviceType: DeviceType;
  49903. deviceSlot: number;
  49904. }>;
  49905. /**
  49906. * Observable to be triggered when before a device is disconnected
  49907. */
  49908. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49909. deviceType: DeviceType;
  49910. deviceSlot: number;
  49911. }>;
  49912. /**
  49913. * Observable to be triggered when after a device is connected
  49914. */
  49915. readonly onAfterDeviceConnectedObservable: Observable<{
  49916. deviceType: DeviceType;
  49917. deviceSlot: number;
  49918. }>;
  49919. /**
  49920. * Observable to be triggered when after a device is disconnected
  49921. */
  49922. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49923. deviceType: DeviceType;
  49924. deviceSlot: number;
  49925. }>;
  49926. private readonly _devices;
  49927. private readonly _firstDevice;
  49928. private readonly _deviceInputSystem;
  49929. /**
  49930. * Default Constructor
  49931. * @param engine engine to pull input element from
  49932. */
  49933. constructor(engine: Engine);
  49934. /**
  49935. * Gets a DeviceSource, given a type and slot
  49936. * @param deviceType Enum specifying device type
  49937. * @param deviceSlot "Slot" or index that device is referenced in
  49938. * @returns DeviceSource object
  49939. */
  49940. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49941. /**
  49942. * Gets an array of DeviceSource objects for a given device type
  49943. * @param deviceType Enum specifying device type
  49944. * @returns Array of DeviceSource objects
  49945. */
  49946. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49947. /**
  49948. * Dispose of DeviceInputSystem and other parts
  49949. */
  49950. dispose(): void;
  49951. /**
  49952. * Function to add device name to device list
  49953. * @param deviceType Enum specifying device type
  49954. * @param deviceSlot "Slot" or index that device is referenced in
  49955. */
  49956. private _addDevice;
  49957. /**
  49958. * Function to remove device name to device list
  49959. * @param deviceType Enum specifying device type
  49960. * @param deviceSlot "Slot" or index that device is referenced in
  49961. */
  49962. private _removeDevice;
  49963. /**
  49964. * Updates array storing first connected device of each type
  49965. * @param type Type of Device
  49966. */
  49967. private _updateFirstDevices;
  49968. }
  49969. }
  49970. declare module BABYLON {
  49971. /**
  49972. * Options to create the null engine
  49973. */
  49974. export class NullEngineOptions {
  49975. /**
  49976. * Render width (Default: 512)
  49977. */
  49978. renderWidth: number;
  49979. /**
  49980. * Render height (Default: 256)
  49981. */
  49982. renderHeight: number;
  49983. /**
  49984. * Texture size (Default: 512)
  49985. */
  49986. textureSize: number;
  49987. /**
  49988. * If delta time between frames should be constant
  49989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49990. */
  49991. deterministicLockstep: boolean;
  49992. /**
  49993. * Maximum about of steps between frames (Default: 4)
  49994. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49995. */
  49996. lockstepMaxSteps: number;
  49997. }
  49998. /**
  49999. * The null engine class provides support for headless version of babylon.js.
  50000. * This can be used in server side scenario or for testing purposes
  50001. */
  50002. export class NullEngine extends Engine {
  50003. private _options;
  50004. /**
  50005. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50007. * @returns true if engine is in deterministic lock step mode
  50008. */
  50009. isDeterministicLockStep(): boolean;
  50010. /**
  50011. * Gets the max steps when engine is running in deterministic lock step
  50012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50013. * @returns the max steps
  50014. */
  50015. getLockstepMaxSteps(): number;
  50016. /**
  50017. * Gets the current hardware scaling level.
  50018. * By default the hardware scaling level is computed from the window device ratio.
  50019. * 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.
  50020. * @returns a number indicating the current hardware scaling level
  50021. */
  50022. getHardwareScalingLevel(): number;
  50023. constructor(options?: NullEngineOptions);
  50024. /**
  50025. * Creates a vertex buffer
  50026. * @param vertices the data for the vertex buffer
  50027. * @returns the new WebGL static buffer
  50028. */
  50029. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50030. /**
  50031. * Creates a new index buffer
  50032. * @param indices defines the content of the index buffer
  50033. * @param updatable defines if the index buffer must be updatable
  50034. * @returns a new webGL buffer
  50035. */
  50036. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50037. /**
  50038. * Clear the current render buffer or the current render target (if any is set up)
  50039. * @param color defines the color to use
  50040. * @param backBuffer defines if the back buffer must be cleared
  50041. * @param depth defines if the depth buffer must be cleared
  50042. * @param stencil defines if the stencil buffer must be cleared
  50043. */
  50044. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50045. /**
  50046. * Gets the current render width
  50047. * @param useScreen defines if screen size must be used (or the current render target if any)
  50048. * @returns a number defining the current render width
  50049. */
  50050. getRenderWidth(useScreen?: boolean): number;
  50051. /**
  50052. * Gets the current render height
  50053. * @param useScreen defines if screen size must be used (or the current render target if any)
  50054. * @returns a number defining the current render height
  50055. */
  50056. getRenderHeight(useScreen?: boolean): number;
  50057. /**
  50058. * Set the WebGL's viewport
  50059. * @param viewport defines the viewport element to be used
  50060. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50061. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50062. */
  50063. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50064. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50065. /**
  50066. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50067. * @param pipelineContext defines the pipeline context to use
  50068. * @param uniformsNames defines the list of uniform names
  50069. * @returns an array of webGL uniform locations
  50070. */
  50071. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50072. /**
  50073. * Gets the lsit of active attributes for a given webGL program
  50074. * @param pipelineContext defines the pipeline context to use
  50075. * @param attributesNames defines the list of attribute names to get
  50076. * @returns an array of indices indicating the offset of each attribute
  50077. */
  50078. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50079. /**
  50080. * Binds an effect to the webGL context
  50081. * @param effect defines the effect to bind
  50082. */
  50083. bindSamplers(effect: Effect): void;
  50084. /**
  50085. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50086. * @param effect defines the effect to activate
  50087. */
  50088. enableEffect(effect: Effect): void;
  50089. /**
  50090. * Set various states to the webGL context
  50091. * @param culling defines backface culling state
  50092. * @param zOffset defines the value to apply to zOffset (0 by default)
  50093. * @param force defines if states must be applied even if cache is up to date
  50094. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50095. */
  50096. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50097. /**
  50098. * Set the value of an uniform to an array of int32
  50099. * @param uniform defines the webGL uniform location where to store the value
  50100. * @param array defines the array of int32 to store
  50101. */
  50102. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50103. /**
  50104. * Set the value of an uniform to an array of int32 (stored as vec2)
  50105. * @param uniform defines the webGL uniform location where to store the value
  50106. * @param array defines the array of int32 to store
  50107. */
  50108. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50109. /**
  50110. * Set the value of an uniform to an array of int32 (stored as vec3)
  50111. * @param uniform defines the webGL uniform location where to store the value
  50112. * @param array defines the array of int32 to store
  50113. */
  50114. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50115. /**
  50116. * Set the value of an uniform to an array of int32 (stored as vec4)
  50117. * @param uniform defines the webGL uniform location where to store the value
  50118. * @param array defines the array of int32 to store
  50119. */
  50120. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50121. /**
  50122. * Set the value of an uniform to an array of float32
  50123. * @param uniform defines the webGL uniform location where to store the value
  50124. * @param array defines the array of float32 to store
  50125. */
  50126. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50127. /**
  50128. * Set the value of an uniform to an array of float32 (stored as vec2)
  50129. * @param uniform defines the webGL uniform location where to store the value
  50130. * @param array defines the array of float32 to store
  50131. */
  50132. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50133. /**
  50134. * Set the value of an uniform to an array of float32 (stored as vec3)
  50135. * @param uniform defines the webGL uniform location where to store the value
  50136. * @param array defines the array of float32 to store
  50137. */
  50138. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50139. /**
  50140. * Set the value of an uniform to an array of float32 (stored as vec4)
  50141. * @param uniform defines the webGL uniform location where to store the value
  50142. * @param array defines the array of float32 to store
  50143. */
  50144. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50145. /**
  50146. * Set the value of an uniform to an array of number
  50147. * @param uniform defines the webGL uniform location where to store the value
  50148. * @param array defines the array of number to store
  50149. */
  50150. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50151. /**
  50152. * Set the value of an uniform to an array of number (stored as vec2)
  50153. * @param uniform defines the webGL uniform location where to store the value
  50154. * @param array defines the array of number to store
  50155. */
  50156. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50157. /**
  50158. * Set the value of an uniform to an array of number (stored as vec3)
  50159. * @param uniform defines the webGL uniform location where to store the value
  50160. * @param array defines the array of number to store
  50161. */
  50162. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50163. /**
  50164. * Set the value of an uniform to an array of number (stored as vec4)
  50165. * @param uniform defines the webGL uniform location where to store the value
  50166. * @param array defines the array of number to store
  50167. */
  50168. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50169. /**
  50170. * Set the value of an uniform to an array of float32 (stored as matrices)
  50171. * @param uniform defines the webGL uniform location where to store the value
  50172. * @param matrices defines the array of float32 to store
  50173. */
  50174. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50175. /**
  50176. * Set the value of an uniform to a matrix (3x3)
  50177. * @param uniform defines the webGL uniform location where to store the value
  50178. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50179. */
  50180. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50181. /**
  50182. * Set the value of an uniform to a matrix (2x2)
  50183. * @param uniform defines the webGL uniform location where to store the value
  50184. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50185. */
  50186. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50187. /**
  50188. * Set the value of an uniform to a number (float)
  50189. * @param uniform defines the webGL uniform location where to store the value
  50190. * @param value defines the float number to store
  50191. */
  50192. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50193. /**
  50194. * Set the value of an uniform to a vec2
  50195. * @param uniform defines the webGL uniform location where to store the value
  50196. * @param x defines the 1st component of the value
  50197. * @param y defines the 2nd component of the value
  50198. */
  50199. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50200. /**
  50201. * Set the value of an uniform to a vec3
  50202. * @param uniform defines the webGL uniform location where to store the value
  50203. * @param x defines the 1st component of the value
  50204. * @param y defines the 2nd component of the value
  50205. * @param z defines the 3rd component of the value
  50206. */
  50207. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50208. /**
  50209. * Set the value of an uniform to a boolean
  50210. * @param uniform defines the webGL uniform location where to store the value
  50211. * @param bool defines the boolean to store
  50212. */
  50213. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50214. /**
  50215. * Set the value of an uniform to a vec4
  50216. * @param uniform defines the webGL uniform location where to store the value
  50217. * @param x defines the 1st component of the value
  50218. * @param y defines the 2nd component of the value
  50219. * @param z defines the 3rd component of the value
  50220. * @param w defines the 4th component of the value
  50221. */
  50222. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50223. /**
  50224. * Sets the current alpha mode
  50225. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50226. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50227. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50228. */
  50229. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50230. /**
  50231. * Bind webGl buffers directly to the webGL context
  50232. * @param vertexBuffers defines the vertex buffer to bind
  50233. * @param indexBuffer defines the index buffer to bind
  50234. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50235. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50236. * @param effect defines the effect associated with the vertex buffer
  50237. */
  50238. bindBuffers(vertexBuffers: {
  50239. [key: string]: VertexBuffer;
  50240. }, indexBuffer: DataBuffer, effect: Effect): void;
  50241. /**
  50242. * Force the entire cache to be cleared
  50243. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50244. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50245. */
  50246. wipeCaches(bruteForce?: boolean): void;
  50247. /**
  50248. * Send a draw order
  50249. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50250. * @param indexStart defines the starting index
  50251. * @param indexCount defines the number of index to draw
  50252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50253. */
  50254. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50255. /**
  50256. * Draw a list of indexed primitives
  50257. * @param fillMode defines the primitive to use
  50258. * @param indexStart defines the starting index
  50259. * @param indexCount defines the number of index to draw
  50260. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50261. */
  50262. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50263. /**
  50264. * Draw a list of unindexed primitives
  50265. * @param fillMode defines the primitive to use
  50266. * @param verticesStart defines the index of first vertex to draw
  50267. * @param verticesCount defines the count of vertices to draw
  50268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50269. */
  50270. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50271. /** @hidden */
  50272. _createTexture(): WebGLTexture;
  50273. /** @hidden */
  50274. _releaseTexture(texture: InternalTexture): void;
  50275. /**
  50276. * Usually called from Texture.ts.
  50277. * Passed information to create a WebGLTexture
  50278. * @param urlArg defines a value which contains one of the following:
  50279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50283. * @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)
  50284. * @param scene needed for loading to the correct scene
  50285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50286. * @param onLoad optional callback to be called upon successful completion
  50287. * @param onError optional callback to be called upon failure
  50288. * @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
  50289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50291. * @param forcedExtension defines the extension to use to pick the right loader
  50292. * @param mimeType defines an optional mime type
  50293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50294. */
  50295. 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;
  50296. /**
  50297. * Creates a new render target texture
  50298. * @param size defines the size of the texture
  50299. * @param options defines the options used to create the texture
  50300. * @returns a new render target texture stored in an InternalTexture
  50301. */
  50302. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50303. /**
  50304. * Update the sampling mode of a given texture
  50305. * @param samplingMode defines the required sampling mode
  50306. * @param texture defines the texture to update
  50307. */
  50308. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50309. /**
  50310. * Binds the frame buffer to the specified texture.
  50311. * @param texture The texture to render to or null for the default canvas
  50312. * @param faceIndex The face of the texture to render to in case of cube texture
  50313. * @param requiredWidth The width of the target to render to
  50314. * @param requiredHeight The height of the target to render to
  50315. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50316. * @param lodLevel defines le lod level to bind to the frame buffer
  50317. */
  50318. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50319. /**
  50320. * Unbind the current render target texture from the webGL context
  50321. * @param texture defines the render target texture to unbind
  50322. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50323. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50324. */
  50325. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50326. /**
  50327. * Creates a dynamic vertex buffer
  50328. * @param vertices the data for the dynamic vertex buffer
  50329. * @returns the new WebGL dynamic buffer
  50330. */
  50331. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50332. /**
  50333. * Update the content of a dynamic texture
  50334. * @param texture defines the texture to update
  50335. * @param canvas defines the canvas containing the source
  50336. * @param invertY defines if data must be stored with Y axis inverted
  50337. * @param premulAlpha defines if alpha is stored as premultiplied
  50338. * @param format defines the format of the data
  50339. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50340. */
  50341. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50342. /**
  50343. * Gets a boolean indicating if all created effects are ready
  50344. * @returns true if all effects are ready
  50345. */
  50346. areAllEffectsReady(): boolean;
  50347. /**
  50348. * @hidden
  50349. * Get the current error code of the webGL context
  50350. * @returns the error code
  50351. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50352. */
  50353. getError(): number;
  50354. /** @hidden */
  50355. _getUnpackAlignement(): number;
  50356. /** @hidden */
  50357. _unpackFlipY(value: boolean): void;
  50358. /**
  50359. * Update a dynamic index buffer
  50360. * @param indexBuffer defines the target index buffer
  50361. * @param indices defines the data to update
  50362. * @param offset defines the offset in the target index buffer where update should start
  50363. */
  50364. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50365. /**
  50366. * Updates a dynamic vertex buffer.
  50367. * @param vertexBuffer the vertex buffer to update
  50368. * @param vertices the data used to update the vertex buffer
  50369. * @param byteOffset the byte offset of the data (optional)
  50370. * @param byteLength the byte length of the data (optional)
  50371. */
  50372. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50373. /** @hidden */
  50374. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50375. /** @hidden */
  50376. _bindTexture(channel: number, texture: InternalTexture): void;
  50377. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50378. /**
  50379. * 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
  50380. */
  50381. releaseEffects(): void;
  50382. displayLoadingUI(): void;
  50383. hideLoadingUI(): void;
  50384. /** @hidden */
  50385. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50386. /** @hidden */
  50387. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50388. /** @hidden */
  50389. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50390. /** @hidden */
  50391. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50392. }
  50393. }
  50394. declare module BABYLON {
  50395. /**
  50396. * @hidden
  50397. **/
  50398. export class _TimeToken {
  50399. _startTimeQuery: Nullable<WebGLQuery>;
  50400. _endTimeQuery: Nullable<WebGLQuery>;
  50401. _timeElapsedQuery: Nullable<WebGLQuery>;
  50402. _timeElapsedQueryEnded: boolean;
  50403. }
  50404. }
  50405. declare module BABYLON {
  50406. /** @hidden */
  50407. export class _OcclusionDataStorage {
  50408. /** @hidden */
  50409. occlusionInternalRetryCounter: number;
  50410. /** @hidden */
  50411. isOcclusionQueryInProgress: boolean;
  50412. /** @hidden */
  50413. isOccluded: boolean;
  50414. /** @hidden */
  50415. occlusionRetryCount: number;
  50416. /** @hidden */
  50417. occlusionType: number;
  50418. /** @hidden */
  50419. occlusionQueryAlgorithmType: number;
  50420. }
  50421. interface Engine {
  50422. /**
  50423. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50424. * @return the new query
  50425. */
  50426. createQuery(): WebGLQuery;
  50427. /**
  50428. * Delete and release a webGL query
  50429. * @param query defines the query to delete
  50430. * @return the current engine
  50431. */
  50432. deleteQuery(query: WebGLQuery): Engine;
  50433. /**
  50434. * Check if a given query has resolved and got its value
  50435. * @param query defines the query to check
  50436. * @returns true if the query got its value
  50437. */
  50438. isQueryResultAvailable(query: WebGLQuery): boolean;
  50439. /**
  50440. * Gets the value of a given query
  50441. * @param query defines the query to check
  50442. * @returns the value of the query
  50443. */
  50444. getQueryResult(query: WebGLQuery): number;
  50445. /**
  50446. * Initiates an occlusion query
  50447. * @param algorithmType defines the algorithm to use
  50448. * @param query defines the query to use
  50449. * @returns the current engine
  50450. * @see http://doc.babylonjs.com/features/occlusionquery
  50451. */
  50452. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50453. /**
  50454. * Ends an occlusion query
  50455. * @see http://doc.babylonjs.com/features/occlusionquery
  50456. * @param algorithmType defines the algorithm to use
  50457. * @returns the current engine
  50458. */
  50459. endOcclusionQuery(algorithmType: number): Engine;
  50460. /**
  50461. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50462. * Please note that only one query can be issued at a time
  50463. * @returns a time token used to track the time span
  50464. */
  50465. startTimeQuery(): Nullable<_TimeToken>;
  50466. /**
  50467. * Ends a time query
  50468. * @param token defines the token used to measure the time span
  50469. * @returns the time spent (in ns)
  50470. */
  50471. endTimeQuery(token: _TimeToken): int;
  50472. /** @hidden */
  50473. _currentNonTimestampToken: Nullable<_TimeToken>;
  50474. /** @hidden */
  50475. _createTimeQuery(): WebGLQuery;
  50476. /** @hidden */
  50477. _deleteTimeQuery(query: WebGLQuery): void;
  50478. /** @hidden */
  50479. _getGlAlgorithmType(algorithmType: number): number;
  50480. /** @hidden */
  50481. _getTimeQueryResult(query: WebGLQuery): any;
  50482. /** @hidden */
  50483. _getTimeQueryAvailability(query: WebGLQuery): any;
  50484. }
  50485. interface AbstractMesh {
  50486. /**
  50487. * Backing filed
  50488. * @hidden
  50489. */
  50490. __occlusionDataStorage: _OcclusionDataStorage;
  50491. /**
  50492. * Access property
  50493. * @hidden
  50494. */
  50495. _occlusionDataStorage: _OcclusionDataStorage;
  50496. /**
  50497. * 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.
  50498. * The default value is -1 which means don't break the query and wait till the result
  50499. * @see http://doc.babylonjs.com/features/occlusionquery
  50500. */
  50501. occlusionRetryCount: number;
  50502. /**
  50503. * 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:
  50504. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50505. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50506. * * 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.
  50507. * @see http://doc.babylonjs.com/features/occlusionquery
  50508. */
  50509. occlusionType: number;
  50510. /**
  50511. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50512. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50513. * * 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.
  50514. * @see http://doc.babylonjs.com/features/occlusionquery
  50515. */
  50516. occlusionQueryAlgorithmType: number;
  50517. /**
  50518. * 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
  50519. * @see http://doc.babylonjs.com/features/occlusionquery
  50520. */
  50521. isOccluded: boolean;
  50522. /**
  50523. * Flag to check the progress status of the query
  50524. * @see http://doc.babylonjs.com/features/occlusionquery
  50525. */
  50526. isOcclusionQueryInProgress: boolean;
  50527. }
  50528. }
  50529. declare module BABYLON {
  50530. /** @hidden */
  50531. export var _forceTransformFeedbackToBundle: boolean;
  50532. interface Engine {
  50533. /**
  50534. * Creates a webGL transform feedback object
  50535. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50536. * @returns the webGL transform feedback object
  50537. */
  50538. createTransformFeedback(): WebGLTransformFeedback;
  50539. /**
  50540. * Delete a webGL transform feedback object
  50541. * @param value defines the webGL transform feedback object to delete
  50542. */
  50543. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50544. /**
  50545. * Bind a webGL transform feedback object to the webgl context
  50546. * @param value defines the webGL transform feedback object to bind
  50547. */
  50548. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50549. /**
  50550. * Begins a transform feedback operation
  50551. * @param usePoints defines if points or triangles must be used
  50552. */
  50553. beginTransformFeedback(usePoints: boolean): void;
  50554. /**
  50555. * Ends a transform feedback operation
  50556. */
  50557. endTransformFeedback(): void;
  50558. /**
  50559. * Specify the varyings to use with transform feedback
  50560. * @param program defines the associated webGL program
  50561. * @param value defines the list of strings representing the varying names
  50562. */
  50563. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50564. /**
  50565. * Bind a webGL buffer for a transform feedback operation
  50566. * @param value defines the webGL buffer to bind
  50567. */
  50568. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * Creation options of the multi render target texture.
  50574. */
  50575. export interface IMultiRenderTargetOptions {
  50576. /**
  50577. * Define if the texture needs to create mip maps after render.
  50578. */
  50579. generateMipMaps?: boolean;
  50580. /**
  50581. * Define the types of all the draw buffers we want to create
  50582. */
  50583. types?: number[];
  50584. /**
  50585. * Define the sampling modes of all the draw buffers we want to create
  50586. */
  50587. samplingModes?: number[];
  50588. /**
  50589. * Define if a depth buffer is required
  50590. */
  50591. generateDepthBuffer?: boolean;
  50592. /**
  50593. * Define if a stencil buffer is required
  50594. */
  50595. generateStencilBuffer?: boolean;
  50596. /**
  50597. * Define if a depth texture is required instead of a depth buffer
  50598. */
  50599. generateDepthTexture?: boolean;
  50600. /**
  50601. * Define the number of desired draw buffers
  50602. */
  50603. textureCount?: number;
  50604. /**
  50605. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50606. */
  50607. doNotChangeAspectRatio?: boolean;
  50608. /**
  50609. * Define the default type of the buffers we are creating
  50610. */
  50611. defaultType?: number;
  50612. }
  50613. /**
  50614. * A multi render target, like a render target provides the ability to render to a texture.
  50615. * Unlike the render target, it can render to several draw buffers in one draw.
  50616. * This is specially interesting in deferred rendering or for any effects requiring more than
  50617. * just one color from a single pass.
  50618. */
  50619. export class MultiRenderTarget extends RenderTargetTexture {
  50620. private _internalTextures;
  50621. private _textures;
  50622. private _multiRenderTargetOptions;
  50623. /**
  50624. * Get if draw buffers are currently supported by the used hardware and browser.
  50625. */
  50626. get isSupported(): boolean;
  50627. /**
  50628. * Get the list of textures generated by the multi render target.
  50629. */
  50630. get textures(): Texture[];
  50631. /**
  50632. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50633. */
  50634. get depthTexture(): Texture;
  50635. /**
  50636. * Set the wrapping mode on U of all the textures we are rendering to.
  50637. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50638. */
  50639. set wrapU(wrap: number);
  50640. /**
  50641. * Set the wrapping mode on V of all the textures we are rendering to.
  50642. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50643. */
  50644. set wrapV(wrap: number);
  50645. /**
  50646. * Instantiate a new multi render target texture.
  50647. * A multi render target, like a render target provides the ability to render to a texture.
  50648. * Unlike the render target, it can render to several draw buffers in one draw.
  50649. * This is specially interesting in deferred rendering or for any effects requiring more than
  50650. * just one color from a single pass.
  50651. * @param name Define the name of the texture
  50652. * @param size Define the size of the buffers to render to
  50653. * @param count Define the number of target we are rendering into
  50654. * @param scene Define the scene the texture belongs to
  50655. * @param options Define the options used to create the multi render target
  50656. */
  50657. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50658. /** @hidden */
  50659. _rebuild(): void;
  50660. private _createInternalTextures;
  50661. private _createTextures;
  50662. /**
  50663. * Define the number of samples used if MSAA is enabled.
  50664. */
  50665. get samples(): number;
  50666. set samples(value: number);
  50667. /**
  50668. * Resize all the textures in the multi render target.
  50669. * Be carrefull as it will recreate all the data in the new texture.
  50670. * @param size Define the new size
  50671. */
  50672. resize(size: any): void;
  50673. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50674. /**
  50675. * Dispose the render targets and their associated resources
  50676. */
  50677. dispose(): void;
  50678. /**
  50679. * Release all the underlying texture used as draw buffers.
  50680. */
  50681. releaseInternalTextures(): void;
  50682. }
  50683. }
  50684. declare module BABYLON {
  50685. interface ThinEngine {
  50686. /**
  50687. * Unbind a list of render target textures from the webGL context
  50688. * This is used only when drawBuffer extension or webGL2 are active
  50689. * @param textures defines the render target textures to unbind
  50690. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50691. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50692. */
  50693. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50694. /**
  50695. * Create a multi render target texture
  50696. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50697. * @param size defines the size of the texture
  50698. * @param options defines the creation options
  50699. * @returns the cube texture as an InternalTexture
  50700. */
  50701. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50702. /**
  50703. * Update the sample count for a given multiple render target texture
  50704. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50705. * @param textures defines the textures to update
  50706. * @param samples defines the sample count to set
  50707. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50708. */
  50709. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50710. }
  50711. }
  50712. declare module BABYLON {
  50713. /**
  50714. * Class used to define an additional view for the engine
  50715. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50716. */
  50717. export class EngineView {
  50718. /** Defines the canvas where to render the view */
  50719. target: HTMLCanvasElement;
  50720. /** Defines an optional camera used to render the view (will use active camera else) */
  50721. camera?: Camera;
  50722. }
  50723. interface Engine {
  50724. /**
  50725. * Gets or sets the HTML element to use for attaching events
  50726. */
  50727. inputElement: Nullable<HTMLElement>;
  50728. /**
  50729. * Gets the current engine view
  50730. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50731. */
  50732. activeView: Nullable<EngineView>;
  50733. /** Gets or sets the list of views */
  50734. views: EngineView[];
  50735. /**
  50736. * Register a new child canvas
  50737. * @param canvas defines the canvas to register
  50738. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50739. * @returns the associated view
  50740. */
  50741. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50742. /**
  50743. * Remove a registered child canvas
  50744. * @param canvas defines the canvas to remove
  50745. * @returns the current engine
  50746. */
  50747. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50748. }
  50749. }
  50750. declare module BABYLON {
  50751. interface Engine {
  50752. /** @hidden */
  50753. _excludedCompressedTextures: string[];
  50754. /** @hidden */
  50755. _textureFormatInUse: string;
  50756. /**
  50757. * Gets the list of texture formats supported
  50758. */
  50759. readonly texturesSupported: Array<string>;
  50760. /**
  50761. * Gets the texture format in use
  50762. */
  50763. readonly textureFormatInUse: Nullable<string>;
  50764. /**
  50765. * Set the compressed texture extensions or file names to skip.
  50766. *
  50767. * @param skippedFiles defines the list of those texture files you want to skip
  50768. * Example: [".dds", ".env", "myfile.png"]
  50769. */
  50770. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50771. /**
  50772. * Set the compressed texture format to use, based on the formats you have, and the formats
  50773. * supported by the hardware / browser.
  50774. *
  50775. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50776. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50777. * to API arguments needed to compressed textures. This puts the burden on the container
  50778. * generator to house the arcane code for determining these for current & future formats.
  50779. *
  50780. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50781. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50782. *
  50783. * Note: The result of this call is not taken into account when a texture is base64.
  50784. *
  50785. * @param formatsAvailable defines the list of those format families you have created
  50786. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50787. *
  50788. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50789. * @returns The extension selected.
  50790. */
  50791. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50792. }
  50793. }
  50794. declare module BABYLON {
  50795. /**
  50796. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50797. */
  50798. export interface CubeMapInfo {
  50799. /**
  50800. * The pixel array for the front face.
  50801. * This is stored in format, left to right, up to down format.
  50802. */
  50803. front: Nullable<ArrayBufferView>;
  50804. /**
  50805. * The pixel array for the back face.
  50806. * This is stored in format, left to right, up to down format.
  50807. */
  50808. back: Nullable<ArrayBufferView>;
  50809. /**
  50810. * The pixel array for the left face.
  50811. * This is stored in format, left to right, up to down format.
  50812. */
  50813. left: Nullable<ArrayBufferView>;
  50814. /**
  50815. * The pixel array for the right face.
  50816. * This is stored in format, left to right, up to down format.
  50817. */
  50818. right: Nullable<ArrayBufferView>;
  50819. /**
  50820. * The pixel array for the up face.
  50821. * This is stored in format, left to right, up to down format.
  50822. */
  50823. up: Nullable<ArrayBufferView>;
  50824. /**
  50825. * The pixel array for the down face.
  50826. * This is stored in format, left to right, up to down format.
  50827. */
  50828. down: Nullable<ArrayBufferView>;
  50829. /**
  50830. * The size of the cubemap stored.
  50831. *
  50832. * Each faces will be size * size pixels.
  50833. */
  50834. size: number;
  50835. /**
  50836. * The format of the texture.
  50837. *
  50838. * RGBA, RGB.
  50839. */
  50840. format: number;
  50841. /**
  50842. * The type of the texture data.
  50843. *
  50844. * UNSIGNED_INT, FLOAT.
  50845. */
  50846. type: number;
  50847. /**
  50848. * Specifies whether the texture is in gamma space.
  50849. */
  50850. gammaSpace: boolean;
  50851. }
  50852. /**
  50853. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50854. */
  50855. export class PanoramaToCubeMapTools {
  50856. private static FACE_LEFT;
  50857. private static FACE_RIGHT;
  50858. private static FACE_FRONT;
  50859. private static FACE_BACK;
  50860. private static FACE_DOWN;
  50861. private static FACE_UP;
  50862. /**
  50863. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50864. *
  50865. * @param float32Array The source data.
  50866. * @param inputWidth The width of the input panorama.
  50867. * @param inputHeight The height of the input panorama.
  50868. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50869. * @return The cubemap data
  50870. */
  50871. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50872. private static CreateCubemapTexture;
  50873. private static CalcProjectionSpherical;
  50874. }
  50875. }
  50876. declare module BABYLON {
  50877. /**
  50878. * Helper class dealing with the extraction of spherical polynomial dataArray
  50879. * from a cube map.
  50880. */
  50881. export class CubeMapToSphericalPolynomialTools {
  50882. private static FileFaces;
  50883. /**
  50884. * Converts a texture to the according Spherical Polynomial data.
  50885. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50886. *
  50887. * @param texture The texture to extract the information from.
  50888. * @return The Spherical Polynomial data.
  50889. */
  50890. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50891. /**
  50892. * Converts a cubemap to the according Spherical Polynomial data.
  50893. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50894. *
  50895. * @param cubeInfo The Cube map to extract the information from.
  50896. * @return The Spherical Polynomial data.
  50897. */
  50898. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50899. }
  50900. }
  50901. declare module BABYLON {
  50902. interface BaseTexture {
  50903. /**
  50904. * Get the polynomial representation of the texture data.
  50905. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50906. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50907. */
  50908. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50909. }
  50910. }
  50911. declare module BABYLON {
  50912. /** @hidden */
  50913. export var rgbdEncodePixelShader: {
  50914. name: string;
  50915. shader: string;
  50916. };
  50917. }
  50918. declare module BABYLON {
  50919. /** @hidden */
  50920. export var rgbdDecodePixelShader: {
  50921. name: string;
  50922. shader: string;
  50923. };
  50924. }
  50925. declare module BABYLON {
  50926. /**
  50927. * Raw texture data and descriptor sufficient for WebGL texture upload
  50928. */
  50929. export interface EnvironmentTextureInfo {
  50930. /**
  50931. * Version of the environment map
  50932. */
  50933. version: number;
  50934. /**
  50935. * Width of image
  50936. */
  50937. width: number;
  50938. /**
  50939. * Irradiance information stored in the file.
  50940. */
  50941. irradiance: any;
  50942. /**
  50943. * Specular information stored in the file.
  50944. */
  50945. specular: any;
  50946. }
  50947. /**
  50948. * Defines One Image in the file. It requires only the position in the file
  50949. * as well as the length.
  50950. */
  50951. interface BufferImageData {
  50952. /**
  50953. * Length of the image data.
  50954. */
  50955. length: number;
  50956. /**
  50957. * Position of the data from the null terminator delimiting the end of the JSON.
  50958. */
  50959. position: number;
  50960. }
  50961. /**
  50962. * Defines the specular data enclosed in the file.
  50963. * This corresponds to the version 1 of the data.
  50964. */
  50965. export interface EnvironmentTextureSpecularInfoV1 {
  50966. /**
  50967. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50968. */
  50969. specularDataPosition?: number;
  50970. /**
  50971. * This contains all the images data needed to reconstruct the cubemap.
  50972. */
  50973. mipmaps: Array<BufferImageData>;
  50974. /**
  50975. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50976. */
  50977. lodGenerationScale: number;
  50978. }
  50979. /**
  50980. * Sets of helpers addressing the serialization and deserialization of environment texture
  50981. * stored in a BabylonJS env file.
  50982. * Those files are usually stored as .env files.
  50983. */
  50984. export class EnvironmentTextureTools {
  50985. /**
  50986. * Magic number identifying the env file.
  50987. */
  50988. private static _MagicBytes;
  50989. /**
  50990. * Gets the environment info from an env file.
  50991. * @param data The array buffer containing the .env bytes.
  50992. * @returns the environment file info (the json header) if successfully parsed.
  50993. */
  50994. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50995. /**
  50996. * Creates an environment texture from a loaded cube texture.
  50997. * @param texture defines the cube texture to convert in env file
  50998. * @return a promise containing the environment data if succesfull.
  50999. */
  51000. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51001. /**
  51002. * Creates a JSON representation of the spherical data.
  51003. * @param texture defines the texture containing the polynomials
  51004. * @return the JSON representation of the spherical info
  51005. */
  51006. private static _CreateEnvTextureIrradiance;
  51007. /**
  51008. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51009. * @param data the image data
  51010. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51011. * @return the views described by info providing access to the underlying buffer
  51012. */
  51013. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51014. /**
  51015. * Uploads the texture info contained in the env file to the GPU.
  51016. * @param texture defines the internal texture to upload to
  51017. * @param data defines the data to load
  51018. * @param info defines the texture info retrieved through the GetEnvInfo method
  51019. * @returns a promise
  51020. */
  51021. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51022. private static _OnImageReadyAsync;
  51023. /**
  51024. * Uploads the levels of image data to the GPU.
  51025. * @param texture defines the internal texture to upload to
  51026. * @param imageData defines the array buffer views of image data [mipmap][face]
  51027. * @returns a promise
  51028. */
  51029. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51030. /**
  51031. * Uploads spherical polynomials information to the texture.
  51032. * @param texture defines the texture we are trying to upload the information to
  51033. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51034. */
  51035. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51036. /** @hidden */
  51037. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51038. }
  51039. }
  51040. declare module BABYLON {
  51041. /** @hidden */
  51042. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51043. private _genericAttributeLocation;
  51044. private _varyingLocationCount;
  51045. private _varyingLocationMap;
  51046. private _replacements;
  51047. private _textureCount;
  51048. private _uniforms;
  51049. lineProcessor(line: string): string;
  51050. attributeProcessor(attribute: string): string;
  51051. varyingProcessor(varying: string, isFragment: boolean): string;
  51052. uniformProcessor(uniform: string): string;
  51053. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51054. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51055. }
  51056. }
  51057. declare module BABYLON {
  51058. /**
  51059. * Class used to inline functions in shader code
  51060. */
  51061. export class ShaderCodeInliner {
  51062. private static readonly _RegexpFindFunctionNameAndType;
  51063. private _sourceCode;
  51064. private _functionDescr;
  51065. private _numMaxIterations;
  51066. /** Gets or sets the token used to mark the functions to inline */
  51067. inlineToken: string;
  51068. /** Gets or sets the debug mode */
  51069. debug: boolean;
  51070. /** Gets the code after the inlining process */
  51071. get code(): string;
  51072. /**
  51073. * Initializes the inliner
  51074. * @param sourceCode shader code source to inline
  51075. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51076. */
  51077. constructor(sourceCode: string, numMaxIterations?: number);
  51078. /**
  51079. * Start the processing of the shader code
  51080. */
  51081. processCode(): void;
  51082. private _collectFunctions;
  51083. private _processInlining;
  51084. private _extractBetweenMarkers;
  51085. private _skipWhitespaces;
  51086. private _removeComments;
  51087. private _replaceFunctionCallsByCode;
  51088. private _findBackward;
  51089. private _escapeRegExp;
  51090. private _replaceNames;
  51091. }
  51092. }
  51093. declare module BABYLON {
  51094. /**
  51095. * Container for accessors for natively-stored mesh data buffers.
  51096. */
  51097. class NativeDataBuffer extends DataBuffer {
  51098. /**
  51099. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51100. */
  51101. nativeIndexBuffer?: any;
  51102. /**
  51103. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51104. */
  51105. nativeVertexBuffer?: any;
  51106. }
  51107. /** @hidden */
  51108. class NativeTexture extends InternalTexture {
  51109. getInternalTexture(): InternalTexture;
  51110. getViewCount(): number;
  51111. }
  51112. /** @hidden */
  51113. export class NativeEngine extends Engine {
  51114. private readonly _native;
  51115. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51116. private readonly INVALID_HANDLE;
  51117. getHardwareScalingLevel(): number;
  51118. constructor();
  51119. dispose(): void;
  51120. /**
  51121. * Can be used to override the current requestAnimationFrame requester.
  51122. * @hidden
  51123. */
  51124. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51125. /**
  51126. * Override default engine behavior.
  51127. * @param color
  51128. * @param backBuffer
  51129. * @param depth
  51130. * @param stencil
  51131. */
  51132. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51133. /**
  51134. * Gets host document
  51135. * @returns the host document object
  51136. */
  51137. getHostDocument(): Nullable<Document>;
  51138. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51139. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51140. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51141. recordVertexArrayObject(vertexBuffers: {
  51142. [key: string]: VertexBuffer;
  51143. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51144. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51145. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51146. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51147. /**
  51148. * Draw a list of indexed primitives
  51149. * @param fillMode defines the primitive to use
  51150. * @param indexStart defines the starting index
  51151. * @param indexCount defines the number of index to draw
  51152. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51153. */
  51154. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51155. /**
  51156. * Draw a list of unindexed primitives
  51157. * @param fillMode defines the primitive to use
  51158. * @param verticesStart defines the index of first vertex to draw
  51159. * @param verticesCount defines the count of vertices to draw
  51160. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51161. */
  51162. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51163. createPipelineContext(): IPipelineContext;
  51164. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51165. /** @hidden */
  51166. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51167. /** @hidden */
  51168. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51169. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51170. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51171. protected _setProgram(program: WebGLProgram): void;
  51172. _releaseEffect(effect: Effect): void;
  51173. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51174. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51175. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51176. bindSamplers(effect: Effect): void;
  51177. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51178. getRenderWidth(useScreen?: boolean): number;
  51179. getRenderHeight(useScreen?: boolean): number;
  51180. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51181. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51182. /**
  51183. * Set the z offset to apply to current rendering
  51184. * @param value defines the offset to apply
  51185. */
  51186. setZOffset(value: number): void;
  51187. /**
  51188. * Gets the current value of the zOffset
  51189. * @returns the current zOffset state
  51190. */
  51191. getZOffset(): number;
  51192. /**
  51193. * Enable or disable depth buffering
  51194. * @param enable defines the state to set
  51195. */
  51196. setDepthBuffer(enable: boolean): void;
  51197. /**
  51198. * Gets a boolean indicating if depth writing is enabled
  51199. * @returns the current depth writing state
  51200. */
  51201. getDepthWrite(): boolean;
  51202. /**
  51203. * Enable or disable depth writing
  51204. * @param enable defines the state to set
  51205. */
  51206. setDepthWrite(enable: boolean): void;
  51207. /**
  51208. * Enable or disable color writing
  51209. * @param enable defines the state to set
  51210. */
  51211. setColorWrite(enable: boolean): void;
  51212. /**
  51213. * Gets a boolean indicating if color writing is enabled
  51214. * @returns the current color writing state
  51215. */
  51216. getColorWrite(): boolean;
  51217. /**
  51218. * Sets alpha constants used by some alpha blending modes
  51219. * @param r defines the red component
  51220. * @param g defines the green component
  51221. * @param b defines the blue component
  51222. * @param a defines the alpha component
  51223. */
  51224. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51225. /**
  51226. * Sets the current alpha mode
  51227. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51228. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51230. */
  51231. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51232. /**
  51233. * Gets the current alpha mode
  51234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51235. * @returns the current alpha mode
  51236. */
  51237. getAlphaMode(): number;
  51238. setInt(uniform: WebGLUniformLocation, int: number): void;
  51239. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51240. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51241. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51242. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51243. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51244. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51245. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51246. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51247. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51248. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51249. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51250. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51251. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51252. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51253. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51254. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51255. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51256. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51257. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51258. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51259. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51260. wipeCaches(bruteForce?: boolean): void;
  51261. _createTexture(): WebGLTexture;
  51262. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51263. /**
  51264. * Usually called from Texture.ts.
  51265. * Passed information to create a WebGLTexture
  51266. * @param url defines a value which contains one of the following:
  51267. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51268. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51269. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51270. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51271. * @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)
  51272. * @param scene needed for loading to the correct scene
  51273. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51274. * @param onLoad optional callback to be called upon successful completion
  51275. * @param onError optional callback to be called upon failure
  51276. * @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
  51277. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51278. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51279. * @param forcedExtension defines the extension to use to pick the right loader
  51280. * @param mimeType defines an optional mime type
  51281. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51282. */
  51283. 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;
  51284. /**
  51285. * Creates a cube texture
  51286. * @param rootUrl defines the url where the files to load is located
  51287. * @param scene defines the current scene
  51288. * @param files defines the list of files to load (1 per face)
  51289. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51290. * @param onLoad defines an optional callback raised when the texture is loaded
  51291. * @param onError defines an optional callback raised if there is an issue to load the texture
  51292. * @param format defines the format of the data
  51293. * @param forcedExtension defines the extension to use to pick the right loader
  51294. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51295. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51296. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51297. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51298. * @returns the cube texture as an InternalTexture
  51299. */
  51300. 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;
  51301. private _getSamplingFilter;
  51302. private static _GetNativeTextureFormat;
  51303. createRenderTargetTexture(size: number | {
  51304. width: number;
  51305. height: number;
  51306. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51307. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51308. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51309. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51310. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51311. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51312. /**
  51313. * Updates a dynamic vertex buffer.
  51314. * @param vertexBuffer the vertex buffer to update
  51315. * @param data the data used to update the vertex buffer
  51316. * @param byteOffset the byte offset of the data (optional)
  51317. * @param byteLength the byte length of the data (optional)
  51318. */
  51319. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51320. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51321. private _updateAnisotropicLevel;
  51322. private _getAddressMode;
  51323. /** @hidden */
  51324. _bindTexture(channel: number, texture: InternalTexture): void;
  51325. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51326. releaseEffects(): void;
  51327. /** @hidden */
  51328. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51329. /** @hidden */
  51330. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51331. /** @hidden */
  51332. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51333. /** @hidden */
  51334. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51335. }
  51336. }
  51337. declare module BABYLON {
  51338. /**
  51339. * Gather the list of clipboard event types as constants.
  51340. */
  51341. export class ClipboardEventTypes {
  51342. /**
  51343. * The clipboard event is fired when a copy command is active (pressed).
  51344. */
  51345. static readonly COPY: number;
  51346. /**
  51347. * The clipboard event is fired when a cut command is active (pressed).
  51348. */
  51349. static readonly CUT: number;
  51350. /**
  51351. * The clipboard event is fired when a paste command is active (pressed).
  51352. */
  51353. static readonly PASTE: number;
  51354. }
  51355. /**
  51356. * This class is used to store clipboard related info for the onClipboardObservable event.
  51357. */
  51358. export class ClipboardInfo {
  51359. /**
  51360. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51361. */
  51362. type: number;
  51363. /**
  51364. * Defines the related dom event
  51365. */
  51366. event: ClipboardEvent;
  51367. /**
  51368. *Creates an instance of ClipboardInfo.
  51369. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51370. * @param event Defines the related dom event
  51371. */
  51372. constructor(
  51373. /**
  51374. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51375. */
  51376. type: number,
  51377. /**
  51378. * Defines the related dom event
  51379. */
  51380. event: ClipboardEvent);
  51381. /**
  51382. * Get the clipboard event's type from the keycode.
  51383. * @param keyCode Defines the keyCode for the current keyboard event.
  51384. * @return {number}
  51385. */
  51386. static GetTypeFromCharacter(keyCode: number): number;
  51387. }
  51388. }
  51389. declare module BABYLON {
  51390. /**
  51391. * Google Daydream controller
  51392. */
  51393. export class DaydreamController extends WebVRController {
  51394. /**
  51395. * Base Url for the controller model.
  51396. */
  51397. static MODEL_BASE_URL: string;
  51398. /**
  51399. * File name for the controller model.
  51400. */
  51401. static MODEL_FILENAME: string;
  51402. /**
  51403. * Gamepad Id prefix used to identify Daydream Controller.
  51404. */
  51405. static readonly GAMEPAD_ID_PREFIX: string;
  51406. /**
  51407. * Creates a new DaydreamController from a gamepad
  51408. * @param vrGamepad the gamepad that the controller should be created from
  51409. */
  51410. constructor(vrGamepad: any);
  51411. /**
  51412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51413. * @param scene scene in which to add meshes
  51414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51415. */
  51416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51417. /**
  51418. * Called once for each button that changed state since the last frame
  51419. * @param buttonIdx Which button index changed
  51420. * @param state New state of the button
  51421. * @param changes Which properties on the state changed since last frame
  51422. */
  51423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51424. }
  51425. }
  51426. declare module BABYLON {
  51427. /**
  51428. * Gear VR Controller
  51429. */
  51430. export class GearVRController extends WebVRController {
  51431. /**
  51432. * Base Url for the controller model.
  51433. */
  51434. static MODEL_BASE_URL: string;
  51435. /**
  51436. * File name for the controller model.
  51437. */
  51438. static MODEL_FILENAME: string;
  51439. /**
  51440. * Gamepad Id prefix used to identify this controller.
  51441. */
  51442. static readonly GAMEPAD_ID_PREFIX: string;
  51443. private readonly _buttonIndexToObservableNameMap;
  51444. /**
  51445. * Creates a new GearVRController from a gamepad
  51446. * @param vrGamepad the gamepad that the controller should be created from
  51447. */
  51448. constructor(vrGamepad: any);
  51449. /**
  51450. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51451. * @param scene scene in which to add meshes
  51452. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51453. */
  51454. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51455. /**
  51456. * Called once for each button that changed state since the last frame
  51457. * @param buttonIdx Which button index changed
  51458. * @param state New state of the button
  51459. * @param changes Which properties on the state changed since last frame
  51460. */
  51461. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51462. }
  51463. }
  51464. declare module BABYLON {
  51465. /**
  51466. * Generic Controller
  51467. */
  51468. export class GenericController extends WebVRController {
  51469. /**
  51470. * Base Url for the controller model.
  51471. */
  51472. static readonly MODEL_BASE_URL: string;
  51473. /**
  51474. * File name for the controller model.
  51475. */
  51476. static readonly MODEL_FILENAME: string;
  51477. /**
  51478. * Creates a new GenericController from a gamepad
  51479. * @param vrGamepad the gamepad that the controller should be created from
  51480. */
  51481. constructor(vrGamepad: any);
  51482. /**
  51483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51484. * @param scene scene in which to add meshes
  51485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51486. */
  51487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51488. /**
  51489. * Called once for each button that changed state since the last frame
  51490. * @param buttonIdx Which button index changed
  51491. * @param state New state of the button
  51492. * @param changes Which properties on the state changed since last frame
  51493. */
  51494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51495. }
  51496. }
  51497. declare module BABYLON {
  51498. /**
  51499. * Oculus Touch Controller
  51500. */
  51501. export class OculusTouchController extends WebVRController {
  51502. /**
  51503. * Base Url for the controller model.
  51504. */
  51505. static MODEL_BASE_URL: string;
  51506. /**
  51507. * File name for the left controller model.
  51508. */
  51509. static MODEL_LEFT_FILENAME: string;
  51510. /**
  51511. * File name for the right controller model.
  51512. */
  51513. static MODEL_RIGHT_FILENAME: string;
  51514. /**
  51515. * Base Url for the Quest controller model.
  51516. */
  51517. static QUEST_MODEL_BASE_URL: string;
  51518. /**
  51519. * @hidden
  51520. * If the controllers are running on a device that needs the updated Quest controller models
  51521. */
  51522. static _IsQuest: boolean;
  51523. /**
  51524. * Fired when the secondary trigger on this controller is modified
  51525. */
  51526. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51527. /**
  51528. * Fired when the thumb rest on this controller is modified
  51529. */
  51530. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51531. /**
  51532. * Creates a new OculusTouchController from a gamepad
  51533. * @param vrGamepad the gamepad that the controller should be created from
  51534. */
  51535. constructor(vrGamepad: any);
  51536. /**
  51537. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51538. * @param scene scene in which to add meshes
  51539. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51540. */
  51541. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51542. /**
  51543. * Fired when the A button on this controller is modified
  51544. */
  51545. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51546. /**
  51547. * Fired when the B button on this controller is modified
  51548. */
  51549. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51550. /**
  51551. * Fired when the X button on this controller is modified
  51552. */
  51553. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51554. /**
  51555. * Fired when the Y button on this controller is modified
  51556. */
  51557. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51558. /**
  51559. * Called once for each button that changed state since the last frame
  51560. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51561. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51562. * 2) secondary trigger (same)
  51563. * 3) A (right) X (left), touch, pressed = value
  51564. * 4) B / Y
  51565. * 5) thumb rest
  51566. * @param buttonIdx Which button index changed
  51567. * @param state New state of the button
  51568. * @param changes Which properties on the state changed since last frame
  51569. */
  51570. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51571. }
  51572. }
  51573. declare module BABYLON {
  51574. /**
  51575. * Vive Controller
  51576. */
  51577. export class ViveController extends WebVRController {
  51578. /**
  51579. * Base Url for the controller model.
  51580. */
  51581. static MODEL_BASE_URL: string;
  51582. /**
  51583. * File name for the controller model.
  51584. */
  51585. static MODEL_FILENAME: string;
  51586. /**
  51587. * Creates a new ViveController from a gamepad
  51588. * @param vrGamepad the gamepad that the controller should be created from
  51589. */
  51590. constructor(vrGamepad: any);
  51591. /**
  51592. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51593. * @param scene scene in which to add meshes
  51594. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51595. */
  51596. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51597. /**
  51598. * Fired when the left button on this controller is modified
  51599. */
  51600. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51601. /**
  51602. * Fired when the right button on this controller is modified
  51603. */
  51604. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51605. /**
  51606. * Fired when the menu button on this controller is modified
  51607. */
  51608. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51609. /**
  51610. * Called once for each button that changed state since the last frame
  51611. * Vive mapping:
  51612. * 0: touchpad
  51613. * 1: trigger
  51614. * 2: left AND right buttons
  51615. * 3: menu button
  51616. * @param buttonIdx Which button index changed
  51617. * @param state New state of the button
  51618. * @param changes Which properties on the state changed since last frame
  51619. */
  51620. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51621. }
  51622. }
  51623. declare module BABYLON {
  51624. /**
  51625. * Defines the WindowsMotionController object that the state of the windows motion controller
  51626. */
  51627. export class WindowsMotionController extends WebVRController {
  51628. /**
  51629. * The base url used to load the left and right controller models
  51630. */
  51631. static MODEL_BASE_URL: string;
  51632. /**
  51633. * The name of the left controller model file
  51634. */
  51635. static MODEL_LEFT_FILENAME: string;
  51636. /**
  51637. * The name of the right controller model file
  51638. */
  51639. static MODEL_RIGHT_FILENAME: string;
  51640. /**
  51641. * The controller name prefix for this controller type
  51642. */
  51643. static readonly GAMEPAD_ID_PREFIX: string;
  51644. /**
  51645. * The controller id pattern for this controller type
  51646. */
  51647. private static readonly GAMEPAD_ID_PATTERN;
  51648. private _loadedMeshInfo;
  51649. protected readonly _mapping: {
  51650. buttons: string[];
  51651. buttonMeshNames: {
  51652. trigger: string;
  51653. menu: string;
  51654. grip: string;
  51655. thumbstick: string;
  51656. trackpad: string;
  51657. };
  51658. buttonObservableNames: {
  51659. trigger: string;
  51660. menu: string;
  51661. grip: string;
  51662. thumbstick: string;
  51663. trackpad: string;
  51664. };
  51665. axisMeshNames: string[];
  51666. pointingPoseMeshName: string;
  51667. };
  51668. /**
  51669. * Fired when the trackpad on this controller is clicked
  51670. */
  51671. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51672. /**
  51673. * Fired when the trackpad on this controller is modified
  51674. */
  51675. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51676. /**
  51677. * The current x and y values of this controller's trackpad
  51678. */
  51679. trackpad: StickValues;
  51680. /**
  51681. * Creates a new WindowsMotionController from a gamepad
  51682. * @param vrGamepad the gamepad that the controller should be created from
  51683. */
  51684. constructor(vrGamepad: any);
  51685. /**
  51686. * Fired when the trigger on this controller is modified
  51687. */
  51688. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51689. /**
  51690. * Fired when the menu button on this controller is modified
  51691. */
  51692. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51693. /**
  51694. * Fired when the grip button on this controller is modified
  51695. */
  51696. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51697. /**
  51698. * Fired when the thumbstick button on this controller is modified
  51699. */
  51700. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51701. /**
  51702. * Fired when the touchpad button on this controller is modified
  51703. */
  51704. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51705. /**
  51706. * Fired when the touchpad values on this controller are modified
  51707. */
  51708. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51709. protected _updateTrackpad(): void;
  51710. /**
  51711. * Called once per frame by the engine.
  51712. */
  51713. update(): void;
  51714. /**
  51715. * Called once for each button that changed state since the last frame
  51716. * @param buttonIdx Which button index changed
  51717. * @param state New state of the button
  51718. * @param changes Which properties on the state changed since last frame
  51719. */
  51720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51721. /**
  51722. * Moves the buttons on the controller mesh based on their current state
  51723. * @param buttonName the name of the button to move
  51724. * @param buttonValue the value of the button which determines the buttons new position
  51725. */
  51726. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51727. /**
  51728. * Moves the axis on the controller mesh based on its current state
  51729. * @param axis the index of the axis
  51730. * @param axisValue the value of the axis which determines the meshes new position
  51731. * @hidden
  51732. */
  51733. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51734. /**
  51735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51736. * @param scene scene in which to add meshes
  51737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51738. */
  51739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51740. /**
  51741. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51742. * can be transformed by button presses and axes values, based on this._mapping.
  51743. *
  51744. * @param scene scene in which the meshes exist
  51745. * @param meshes list of meshes that make up the controller model to process
  51746. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51747. */
  51748. private processModel;
  51749. private createMeshInfo;
  51750. /**
  51751. * Gets the ray of the controller in the direction the controller is pointing
  51752. * @param length the length the resulting ray should be
  51753. * @returns a ray in the direction the controller is pointing
  51754. */
  51755. getForwardRay(length?: number): Ray;
  51756. /**
  51757. * Disposes of the controller
  51758. */
  51759. dispose(): void;
  51760. }
  51761. /**
  51762. * This class represents a new windows motion controller in XR.
  51763. */
  51764. export class XRWindowsMotionController extends WindowsMotionController {
  51765. /**
  51766. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51767. */
  51768. protected readonly _mapping: {
  51769. buttons: string[];
  51770. buttonMeshNames: {
  51771. trigger: string;
  51772. menu: string;
  51773. grip: string;
  51774. thumbstick: string;
  51775. trackpad: string;
  51776. };
  51777. buttonObservableNames: {
  51778. trigger: string;
  51779. menu: string;
  51780. grip: string;
  51781. thumbstick: string;
  51782. trackpad: string;
  51783. };
  51784. axisMeshNames: string[];
  51785. pointingPoseMeshName: string;
  51786. };
  51787. /**
  51788. * Construct a new XR-Based windows motion controller
  51789. *
  51790. * @param gamepadInfo the gamepad object from the browser
  51791. */
  51792. constructor(gamepadInfo: any);
  51793. /**
  51794. * holds the thumbstick values (X,Y)
  51795. */
  51796. thumbstickValues: StickValues;
  51797. /**
  51798. * Fired when the thumbstick on this controller is clicked
  51799. */
  51800. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51801. /**
  51802. * Fired when the thumbstick on this controller is modified
  51803. */
  51804. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51805. /**
  51806. * Fired when the touchpad button on this controller is modified
  51807. */
  51808. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51809. /**
  51810. * Fired when the touchpad values on this controller are modified
  51811. */
  51812. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51813. /**
  51814. * Fired when the thumbstick button on this controller is modified
  51815. * here to prevent breaking changes
  51816. */
  51817. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51818. /**
  51819. * updating the thumbstick(!) and not the trackpad.
  51820. * This is named this way due to the difference between WebVR and XR and to avoid
  51821. * changing the parent class.
  51822. */
  51823. protected _updateTrackpad(): void;
  51824. /**
  51825. * Disposes the class with joy
  51826. */
  51827. dispose(): void;
  51828. }
  51829. }
  51830. declare module BABYLON {
  51831. /**
  51832. * Class containing static functions to help procedurally build meshes
  51833. */
  51834. export class PolyhedronBuilder {
  51835. /**
  51836. * Creates a polyhedron mesh
  51837. * * 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
  51838. * * The parameter `size` (positive float, default 1) sets the polygon size
  51839. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51840. * * 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`
  51841. * * 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
  51842. * * 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)`)
  51843. * * 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
  51844. * * 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
  51845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51846. * * 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
  51847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51848. * @param name defines the name of the mesh
  51849. * @param options defines the options used to create the mesh
  51850. * @param scene defines the hosting scene
  51851. * @returns the polyhedron mesh
  51852. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51853. */
  51854. static CreatePolyhedron(name: string, options: {
  51855. type?: number;
  51856. size?: number;
  51857. sizeX?: number;
  51858. sizeY?: number;
  51859. sizeZ?: number;
  51860. custom?: any;
  51861. faceUV?: Vector4[];
  51862. faceColors?: Color4[];
  51863. flat?: boolean;
  51864. updatable?: boolean;
  51865. sideOrientation?: number;
  51866. frontUVs?: Vector4;
  51867. backUVs?: Vector4;
  51868. }, scene?: Nullable<Scene>): Mesh;
  51869. }
  51870. }
  51871. declare module BABYLON {
  51872. /**
  51873. * Gizmo that enables scaling a mesh along 3 axis
  51874. */
  51875. export class ScaleGizmo extends Gizmo {
  51876. /**
  51877. * Internal gizmo used for interactions on the x axis
  51878. */
  51879. xGizmo: AxisScaleGizmo;
  51880. /**
  51881. * Internal gizmo used for interactions on the y axis
  51882. */
  51883. yGizmo: AxisScaleGizmo;
  51884. /**
  51885. * Internal gizmo used for interactions on the z axis
  51886. */
  51887. zGizmo: AxisScaleGizmo;
  51888. /**
  51889. * Internal gizmo used to scale all axis equally
  51890. */
  51891. uniformScaleGizmo: AxisScaleGizmo;
  51892. private _meshAttached;
  51893. private _updateGizmoRotationToMatchAttachedMesh;
  51894. private _snapDistance;
  51895. private _scaleRatio;
  51896. private _uniformScalingMesh;
  51897. private _octahedron;
  51898. private _sensitivity;
  51899. /** Fires an event when any of it's sub gizmos are dragged */
  51900. onDragStartObservable: Observable<unknown>;
  51901. /** Fires an event when any of it's sub gizmos are released from dragging */
  51902. onDragEndObservable: Observable<unknown>;
  51903. get attachedMesh(): Nullable<AbstractMesh>;
  51904. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51905. /**
  51906. * Creates a ScaleGizmo
  51907. * @param gizmoLayer The utility layer the gizmo will be added to
  51908. */
  51909. constructor(gizmoLayer?: UtilityLayerRenderer);
  51910. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51911. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51912. /**
  51913. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51914. */
  51915. set snapDistance(value: number);
  51916. get snapDistance(): number;
  51917. /**
  51918. * Ratio for the scale of the gizmo (Default: 1)
  51919. */
  51920. set scaleRatio(value: number);
  51921. get scaleRatio(): number;
  51922. /**
  51923. * Sensitivity factor for dragging (Default: 1)
  51924. */
  51925. set sensitivity(value: number);
  51926. get sensitivity(): number;
  51927. /**
  51928. * Disposes of the gizmo
  51929. */
  51930. dispose(): void;
  51931. }
  51932. }
  51933. declare module BABYLON {
  51934. /**
  51935. * Single axis scale gizmo
  51936. */
  51937. export class AxisScaleGizmo extends Gizmo {
  51938. /**
  51939. * Drag behavior responsible for the gizmos dragging interactions
  51940. */
  51941. dragBehavior: PointerDragBehavior;
  51942. private _pointerObserver;
  51943. /**
  51944. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51945. */
  51946. snapDistance: number;
  51947. /**
  51948. * Event that fires each time the gizmo snaps to a new location.
  51949. * * snapDistance is the the change in distance
  51950. */
  51951. onSnapObservable: Observable<{
  51952. snapDistance: number;
  51953. }>;
  51954. /**
  51955. * If the scaling operation should be done on all axis (default: false)
  51956. */
  51957. uniformScaling: boolean;
  51958. /**
  51959. * Custom sensitivity value for the drag strength
  51960. */
  51961. sensitivity: number;
  51962. private _isEnabled;
  51963. private _parent;
  51964. private _arrow;
  51965. private _coloredMaterial;
  51966. private _hoverMaterial;
  51967. /**
  51968. * Creates an AxisScaleGizmo
  51969. * @param gizmoLayer The utility layer the gizmo will be added to
  51970. * @param dragAxis The axis which the gizmo will be able to scale on
  51971. * @param color The color of the gizmo
  51972. */
  51973. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51974. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51975. /**
  51976. * If the gizmo is enabled
  51977. */
  51978. set isEnabled(value: boolean);
  51979. get isEnabled(): boolean;
  51980. /**
  51981. * Disposes of the gizmo
  51982. */
  51983. dispose(): void;
  51984. /**
  51985. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51986. * @param mesh The mesh to replace the default mesh of the gizmo
  51987. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51988. */
  51989. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51990. }
  51991. }
  51992. declare module BABYLON {
  51993. /**
  51994. * Bounding box gizmo
  51995. */
  51996. export class BoundingBoxGizmo extends Gizmo {
  51997. private _lineBoundingBox;
  51998. private _rotateSpheresParent;
  51999. private _scaleBoxesParent;
  52000. private _boundingDimensions;
  52001. private _renderObserver;
  52002. private _pointerObserver;
  52003. private _scaleDragSpeed;
  52004. private _tmpQuaternion;
  52005. private _tmpVector;
  52006. private _tmpRotationMatrix;
  52007. /**
  52008. * 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)
  52009. */
  52010. ignoreChildren: boolean;
  52011. /**
  52012. * 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)
  52013. */
  52014. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52015. /**
  52016. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52017. */
  52018. rotationSphereSize: number;
  52019. /**
  52020. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52021. */
  52022. scaleBoxSize: number;
  52023. /**
  52024. * 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)
  52025. */
  52026. fixedDragMeshScreenSize: boolean;
  52027. /**
  52028. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52029. */
  52030. fixedDragMeshScreenSizeDistanceFactor: number;
  52031. /**
  52032. * Fired when a rotation sphere or scale box is dragged
  52033. */
  52034. onDragStartObservable: Observable<{}>;
  52035. /**
  52036. * Fired when a scale box is dragged
  52037. */
  52038. onScaleBoxDragObservable: Observable<{}>;
  52039. /**
  52040. * Fired when a scale box drag is ended
  52041. */
  52042. onScaleBoxDragEndObservable: Observable<{}>;
  52043. /**
  52044. * Fired when a rotation sphere is dragged
  52045. */
  52046. onRotationSphereDragObservable: Observable<{}>;
  52047. /**
  52048. * Fired when a rotation sphere drag is ended
  52049. */
  52050. onRotationSphereDragEndObservable: Observable<{}>;
  52051. /**
  52052. * 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)
  52053. */
  52054. scalePivot: Nullable<Vector3>;
  52055. /**
  52056. * Mesh used as a pivot to rotate the attached mesh
  52057. */
  52058. private _anchorMesh;
  52059. private _existingMeshScale;
  52060. private _dragMesh;
  52061. private pointerDragBehavior;
  52062. private coloredMaterial;
  52063. private hoverColoredMaterial;
  52064. /**
  52065. * Sets the color of the bounding box gizmo
  52066. * @param color the color to set
  52067. */
  52068. setColor(color: Color3): void;
  52069. /**
  52070. * Creates an BoundingBoxGizmo
  52071. * @param gizmoLayer The utility layer the gizmo will be added to
  52072. * @param color The color of the gizmo
  52073. */
  52074. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52076. private _selectNode;
  52077. /**
  52078. * Updates the bounding box information for the Gizmo
  52079. */
  52080. updateBoundingBox(): void;
  52081. private _updateRotationSpheres;
  52082. private _updateScaleBoxes;
  52083. /**
  52084. * Enables rotation on the specified axis and disables rotation on the others
  52085. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52086. */
  52087. setEnabledRotationAxis(axis: string): void;
  52088. /**
  52089. * Enables/disables scaling
  52090. * @param enable if scaling should be enabled
  52091. * @param homogeneousScaling defines if scaling should only be homogeneous
  52092. */
  52093. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52094. private _updateDummy;
  52095. /**
  52096. * Enables a pointer drag behavior on the bounding box of the gizmo
  52097. */
  52098. enableDragBehavior(): void;
  52099. /**
  52100. * Disposes of the gizmo
  52101. */
  52102. dispose(): void;
  52103. /**
  52104. * 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)
  52105. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52106. * @returns the bounding box mesh with the passed in mesh as a child
  52107. */
  52108. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52109. /**
  52110. * CustomMeshes are not supported by this gizmo
  52111. * @param mesh The mesh to replace the default mesh of the gizmo
  52112. */
  52113. setCustomMesh(mesh: Mesh): void;
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. /**
  52118. * Single plane rotation gizmo
  52119. */
  52120. export class PlaneRotationGizmo extends Gizmo {
  52121. /**
  52122. * Drag behavior responsible for the gizmos dragging interactions
  52123. */
  52124. dragBehavior: PointerDragBehavior;
  52125. private _pointerObserver;
  52126. /**
  52127. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52128. */
  52129. snapDistance: number;
  52130. /**
  52131. * Event that fires each time the gizmo snaps to a new location.
  52132. * * snapDistance is the the change in distance
  52133. */
  52134. onSnapObservable: Observable<{
  52135. snapDistance: number;
  52136. }>;
  52137. private _isEnabled;
  52138. private _parent;
  52139. /**
  52140. * Creates a PlaneRotationGizmo
  52141. * @param gizmoLayer The utility layer the gizmo will be added to
  52142. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52143. * @param color The color of the gizmo
  52144. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52145. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52146. */
  52147. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52148. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52149. /**
  52150. * If the gizmo is enabled
  52151. */
  52152. set isEnabled(value: boolean);
  52153. get isEnabled(): boolean;
  52154. /**
  52155. * Disposes of the gizmo
  52156. */
  52157. dispose(): void;
  52158. }
  52159. }
  52160. declare module BABYLON {
  52161. /**
  52162. * Gizmo that enables rotating a mesh along 3 axis
  52163. */
  52164. export class RotationGizmo extends Gizmo {
  52165. /**
  52166. * Internal gizmo used for interactions on the x axis
  52167. */
  52168. xGizmo: PlaneRotationGizmo;
  52169. /**
  52170. * Internal gizmo used for interactions on the y axis
  52171. */
  52172. yGizmo: PlaneRotationGizmo;
  52173. /**
  52174. * Internal gizmo used for interactions on the z axis
  52175. */
  52176. zGizmo: PlaneRotationGizmo;
  52177. /** Fires an event when any of it's sub gizmos are dragged */
  52178. onDragStartObservable: Observable<unknown>;
  52179. /** Fires an event when any of it's sub gizmos are released from dragging */
  52180. onDragEndObservable: Observable<unknown>;
  52181. private _meshAttached;
  52182. get attachedMesh(): Nullable<AbstractMesh>;
  52183. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52184. /**
  52185. * Creates a RotationGizmo
  52186. * @param gizmoLayer The utility layer the gizmo will be added to
  52187. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52188. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52189. */
  52190. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52191. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52192. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52193. /**
  52194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52195. */
  52196. set snapDistance(value: number);
  52197. get snapDistance(): number;
  52198. /**
  52199. * Ratio for the scale of the gizmo (Default: 1)
  52200. */
  52201. set scaleRatio(value: number);
  52202. get scaleRatio(): number;
  52203. /**
  52204. * Disposes of the gizmo
  52205. */
  52206. dispose(): void;
  52207. /**
  52208. * CustomMeshes are not supported by this gizmo
  52209. * @param mesh The mesh to replace the default mesh of the gizmo
  52210. */
  52211. setCustomMesh(mesh: Mesh): void;
  52212. }
  52213. }
  52214. declare module BABYLON {
  52215. /**
  52216. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52217. */
  52218. export class GizmoManager implements IDisposable {
  52219. private scene;
  52220. /**
  52221. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52222. */
  52223. gizmos: {
  52224. positionGizmo: Nullable<PositionGizmo>;
  52225. rotationGizmo: Nullable<RotationGizmo>;
  52226. scaleGizmo: Nullable<ScaleGizmo>;
  52227. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52228. };
  52229. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52230. clearGizmoOnEmptyPointerEvent: boolean;
  52231. /** Fires an event when the manager is attached to a mesh */
  52232. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52233. private _gizmosEnabled;
  52234. private _pointerObserver;
  52235. private _attachedMesh;
  52236. private _boundingBoxColor;
  52237. private _defaultUtilityLayer;
  52238. private _defaultKeepDepthUtilityLayer;
  52239. /**
  52240. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52241. */
  52242. boundingBoxDragBehavior: SixDofDragBehavior;
  52243. /**
  52244. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52245. */
  52246. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52247. /**
  52248. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52249. */
  52250. usePointerToAttachGizmos: boolean;
  52251. /**
  52252. * Utility layer that the bounding box gizmo belongs to
  52253. */
  52254. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52255. /**
  52256. * Utility layer that all gizmos besides bounding box belong to
  52257. */
  52258. get utilityLayer(): UtilityLayerRenderer;
  52259. /**
  52260. * Instatiates a gizmo manager
  52261. * @param scene the scene to overlay the gizmos on top of
  52262. */
  52263. constructor(scene: Scene);
  52264. /**
  52265. * Attaches a set of gizmos to the specified mesh
  52266. * @param mesh The mesh the gizmo's should be attached to
  52267. */
  52268. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52269. /**
  52270. * If the position gizmo is enabled
  52271. */
  52272. set positionGizmoEnabled(value: boolean);
  52273. get positionGizmoEnabled(): boolean;
  52274. /**
  52275. * If the rotation gizmo is enabled
  52276. */
  52277. set rotationGizmoEnabled(value: boolean);
  52278. get rotationGizmoEnabled(): boolean;
  52279. /**
  52280. * If the scale gizmo is enabled
  52281. */
  52282. set scaleGizmoEnabled(value: boolean);
  52283. get scaleGizmoEnabled(): boolean;
  52284. /**
  52285. * If the boundingBox gizmo is enabled
  52286. */
  52287. set boundingBoxGizmoEnabled(value: boolean);
  52288. get boundingBoxGizmoEnabled(): boolean;
  52289. /**
  52290. * Disposes of the gizmo manager
  52291. */
  52292. dispose(): void;
  52293. }
  52294. }
  52295. declare module BABYLON {
  52296. /**
  52297. * A directional light is defined by a direction (what a surprise!).
  52298. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52299. * 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.
  52300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52301. */
  52302. export class DirectionalLight extends ShadowLight {
  52303. private _shadowFrustumSize;
  52304. /**
  52305. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52306. */
  52307. get shadowFrustumSize(): number;
  52308. /**
  52309. * Specifies a fix frustum size for the shadow generation.
  52310. */
  52311. set shadowFrustumSize(value: number);
  52312. private _shadowOrthoScale;
  52313. /**
  52314. * Gets the shadow projection scale against the optimal computed one.
  52315. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52316. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52317. */
  52318. get shadowOrthoScale(): number;
  52319. /**
  52320. * Sets the shadow projection scale against the optimal computed one.
  52321. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52322. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52323. */
  52324. set shadowOrthoScale(value: number);
  52325. /**
  52326. * Automatically compute the projection matrix to best fit (including all the casters)
  52327. * on each frame.
  52328. */
  52329. autoUpdateExtends: boolean;
  52330. /**
  52331. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52332. * on each frame. autoUpdateExtends must be set to true for this to work
  52333. */
  52334. autoCalcShadowZBounds: boolean;
  52335. private _orthoLeft;
  52336. private _orthoRight;
  52337. private _orthoTop;
  52338. private _orthoBottom;
  52339. /**
  52340. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52341. * The directional light is emitted from everywhere in the given direction.
  52342. * It can cast shadows.
  52343. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52344. * @param name The friendly name of the light
  52345. * @param direction The direction of the light
  52346. * @param scene The scene the light belongs to
  52347. */
  52348. constructor(name: string, direction: Vector3, scene: Scene);
  52349. /**
  52350. * Returns the string "DirectionalLight".
  52351. * @return The class name
  52352. */
  52353. getClassName(): string;
  52354. /**
  52355. * Returns the integer 1.
  52356. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52357. */
  52358. getTypeID(): number;
  52359. /**
  52360. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52361. * Returns the DirectionalLight Shadow projection matrix.
  52362. */
  52363. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52364. /**
  52365. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52366. * Returns the DirectionalLight Shadow projection matrix.
  52367. */
  52368. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52369. /**
  52370. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52371. * Returns the DirectionalLight Shadow projection matrix.
  52372. */
  52373. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52374. protected _buildUniformLayout(): void;
  52375. /**
  52376. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52377. * @param effect The effect to update
  52378. * @param lightIndex The index of the light in the effect to update
  52379. * @returns The directional light
  52380. */
  52381. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52382. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52383. /**
  52384. * Gets the minZ used for shadow according to both the scene and the light.
  52385. *
  52386. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52387. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52388. * @param activeCamera The camera we are returning the min for
  52389. * @returns the depth min z
  52390. */
  52391. getDepthMinZ(activeCamera: Camera): number;
  52392. /**
  52393. * Gets the maxZ used for shadow according to both the scene and the light.
  52394. *
  52395. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52396. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52397. * @param activeCamera The camera we are returning the max for
  52398. * @returns the depth max z
  52399. */
  52400. getDepthMaxZ(activeCamera: Camera): number;
  52401. /**
  52402. * Prepares the list of defines specific to the light type.
  52403. * @param defines the list of defines
  52404. * @param lightIndex defines the index of the light for the effect
  52405. */
  52406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52407. }
  52408. }
  52409. declare module BABYLON {
  52410. /**
  52411. * Class containing static functions to help procedurally build meshes
  52412. */
  52413. export class HemisphereBuilder {
  52414. /**
  52415. * Creates a hemisphere mesh
  52416. * @param name defines the name of the mesh
  52417. * @param options defines the options used to create the mesh
  52418. * @param scene defines the hosting scene
  52419. * @returns the hemisphere mesh
  52420. */
  52421. static CreateHemisphere(name: string, options: {
  52422. segments?: number;
  52423. diameter?: number;
  52424. sideOrientation?: number;
  52425. }, scene: any): Mesh;
  52426. }
  52427. }
  52428. declare module BABYLON {
  52429. /**
  52430. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52431. * These values define a cone of light starting from the position, emitting toward the direction.
  52432. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52433. * and the exponent defines the speed of the decay of the light with distance (reach).
  52434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52435. */
  52436. export class SpotLight extends ShadowLight {
  52437. private _angle;
  52438. private _innerAngle;
  52439. private _cosHalfAngle;
  52440. private _lightAngleScale;
  52441. private _lightAngleOffset;
  52442. /**
  52443. * Gets the cone angle of the spot light in Radians.
  52444. */
  52445. get angle(): number;
  52446. /**
  52447. * Sets the cone angle of the spot light in Radians.
  52448. */
  52449. set angle(value: number);
  52450. /**
  52451. * Only used in gltf falloff mode, this defines the angle where
  52452. * the directional falloff will start before cutting at angle which could be seen
  52453. * as outer angle.
  52454. */
  52455. get innerAngle(): number;
  52456. /**
  52457. * Only used in gltf falloff mode, this defines the angle where
  52458. * the directional falloff will start before cutting at angle which could be seen
  52459. * as outer angle.
  52460. */
  52461. set innerAngle(value: number);
  52462. private _shadowAngleScale;
  52463. /**
  52464. * Allows scaling the angle of the light for shadow generation only.
  52465. */
  52466. get shadowAngleScale(): number;
  52467. /**
  52468. * Allows scaling the angle of the light for shadow generation only.
  52469. */
  52470. set shadowAngleScale(value: number);
  52471. /**
  52472. * The light decay speed with the distance from the emission spot.
  52473. */
  52474. exponent: number;
  52475. private _projectionTextureMatrix;
  52476. /**
  52477. * Allows reading the projecton texture
  52478. */
  52479. get projectionTextureMatrix(): Matrix;
  52480. protected _projectionTextureLightNear: number;
  52481. /**
  52482. * Gets the near clip of the Spotlight for texture projection.
  52483. */
  52484. get projectionTextureLightNear(): number;
  52485. /**
  52486. * Sets the near clip of the Spotlight for texture projection.
  52487. */
  52488. set projectionTextureLightNear(value: number);
  52489. protected _projectionTextureLightFar: number;
  52490. /**
  52491. * Gets the far clip of the Spotlight for texture projection.
  52492. */
  52493. get projectionTextureLightFar(): number;
  52494. /**
  52495. * Sets the far clip of the Spotlight for texture projection.
  52496. */
  52497. set projectionTextureLightFar(value: number);
  52498. protected _projectionTextureUpDirection: Vector3;
  52499. /**
  52500. * Gets the Up vector of the Spotlight for texture projection.
  52501. */
  52502. get projectionTextureUpDirection(): Vector3;
  52503. /**
  52504. * Sets the Up vector of the Spotlight for texture projection.
  52505. */
  52506. set projectionTextureUpDirection(value: Vector3);
  52507. private _projectionTexture;
  52508. /**
  52509. * Gets the projection texture of the light.
  52510. */
  52511. get projectionTexture(): Nullable<BaseTexture>;
  52512. /**
  52513. * Sets the projection texture of the light.
  52514. */
  52515. set projectionTexture(value: Nullable<BaseTexture>);
  52516. private _projectionTextureViewLightDirty;
  52517. private _projectionTextureProjectionLightDirty;
  52518. private _projectionTextureDirty;
  52519. private _projectionTextureViewTargetVector;
  52520. private _projectionTextureViewLightMatrix;
  52521. private _projectionTextureProjectionLightMatrix;
  52522. private _projectionTextureScalingMatrix;
  52523. /**
  52524. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52525. * It can cast shadows.
  52526. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52527. * @param name The light friendly name
  52528. * @param position The position of the spot light in the scene
  52529. * @param direction The direction of the light in the scene
  52530. * @param angle The cone angle of the light in Radians
  52531. * @param exponent The light decay speed with the distance from the emission spot
  52532. * @param scene The scene the lights belongs to
  52533. */
  52534. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52535. /**
  52536. * Returns the string "SpotLight".
  52537. * @returns the class name
  52538. */
  52539. getClassName(): string;
  52540. /**
  52541. * Returns the integer 2.
  52542. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52543. */
  52544. getTypeID(): number;
  52545. /**
  52546. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52547. */
  52548. protected _setDirection(value: Vector3): void;
  52549. /**
  52550. * Overrides the position setter to recompute the projection texture view light Matrix.
  52551. */
  52552. protected _setPosition(value: Vector3): void;
  52553. /**
  52554. * 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.
  52555. * Returns the SpotLight.
  52556. */
  52557. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52558. protected _computeProjectionTextureViewLightMatrix(): void;
  52559. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52560. /**
  52561. * Main function for light texture projection matrix computing.
  52562. */
  52563. protected _computeProjectionTextureMatrix(): void;
  52564. protected _buildUniformLayout(): void;
  52565. private _computeAngleValues;
  52566. /**
  52567. * Sets the passed Effect "effect" with the Light textures.
  52568. * @param effect The effect to update
  52569. * @param lightIndex The index of the light in the effect to update
  52570. * @returns The light
  52571. */
  52572. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52573. /**
  52574. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52575. * @param effect The effect to update
  52576. * @param lightIndex The index of the light in the effect to update
  52577. * @returns The spot light
  52578. */
  52579. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52580. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52581. /**
  52582. * Disposes the light and the associated resources.
  52583. */
  52584. dispose(): void;
  52585. /**
  52586. * Prepares the list of defines specific to the light type.
  52587. * @param defines the list of defines
  52588. * @param lightIndex defines the index of the light for the effect
  52589. */
  52590. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Gizmo that enables viewing a light
  52596. */
  52597. export class LightGizmo extends Gizmo {
  52598. private _lightMesh;
  52599. private _material;
  52600. private _cachedPosition;
  52601. private _cachedForward;
  52602. private _attachedMeshParent;
  52603. /**
  52604. * Creates a LightGizmo
  52605. * @param gizmoLayer The utility layer the gizmo will be added to
  52606. */
  52607. constructor(gizmoLayer?: UtilityLayerRenderer);
  52608. private _light;
  52609. /**
  52610. * The light that the gizmo is attached to
  52611. */
  52612. set light(light: Nullable<Light>);
  52613. get light(): Nullable<Light>;
  52614. /**
  52615. * Gets the material used to render the light gizmo
  52616. */
  52617. get material(): StandardMaterial;
  52618. /**
  52619. * @hidden
  52620. * Updates the gizmo to match the attached mesh's position/rotation
  52621. */
  52622. protected _update(): void;
  52623. private static _Scale;
  52624. /**
  52625. * Creates the lines for a light mesh
  52626. */
  52627. private static _CreateLightLines;
  52628. /**
  52629. * Disposes of the light gizmo
  52630. */
  52631. dispose(): void;
  52632. private static _CreateHemisphericLightMesh;
  52633. private static _CreatePointLightMesh;
  52634. private static _CreateSpotLightMesh;
  52635. private static _CreateDirectionalLightMesh;
  52636. }
  52637. }
  52638. declare module BABYLON {
  52639. /** @hidden */
  52640. export var backgroundFragmentDeclaration: {
  52641. name: string;
  52642. shader: string;
  52643. };
  52644. }
  52645. declare module BABYLON {
  52646. /** @hidden */
  52647. export var backgroundUboDeclaration: {
  52648. name: string;
  52649. shader: string;
  52650. };
  52651. }
  52652. declare module BABYLON {
  52653. /** @hidden */
  52654. export var backgroundPixelShader: {
  52655. name: string;
  52656. shader: string;
  52657. };
  52658. }
  52659. declare module BABYLON {
  52660. /** @hidden */
  52661. export var backgroundVertexDeclaration: {
  52662. name: string;
  52663. shader: string;
  52664. };
  52665. }
  52666. declare module BABYLON {
  52667. /** @hidden */
  52668. export var backgroundVertexShader: {
  52669. name: string;
  52670. shader: string;
  52671. };
  52672. }
  52673. declare module BABYLON {
  52674. /**
  52675. * Background material used to create an efficient environement around your scene.
  52676. */
  52677. export class BackgroundMaterial extends PushMaterial {
  52678. /**
  52679. * Standard reflectance value at parallel view angle.
  52680. */
  52681. static StandardReflectance0: number;
  52682. /**
  52683. * Standard reflectance value at grazing angle.
  52684. */
  52685. static StandardReflectance90: number;
  52686. protected _primaryColor: Color3;
  52687. /**
  52688. * Key light Color (multiply against the environement texture)
  52689. */
  52690. primaryColor: Color3;
  52691. protected __perceptualColor: Nullable<Color3>;
  52692. /**
  52693. * Experimental Internal Use Only.
  52694. *
  52695. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52696. * This acts as a helper to set the primary color to a more "human friendly" value.
  52697. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52698. * output color as close as possible from the chosen value.
  52699. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52700. * part of lighting setup.)
  52701. */
  52702. get _perceptualColor(): Nullable<Color3>;
  52703. set _perceptualColor(value: Nullable<Color3>);
  52704. protected _primaryColorShadowLevel: float;
  52705. /**
  52706. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52707. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52708. */
  52709. get primaryColorShadowLevel(): float;
  52710. set primaryColorShadowLevel(value: float);
  52711. protected _primaryColorHighlightLevel: float;
  52712. /**
  52713. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52714. * The primary color is used at the level chosen to define what the white area would look.
  52715. */
  52716. get primaryColorHighlightLevel(): float;
  52717. set primaryColorHighlightLevel(value: float);
  52718. protected _reflectionTexture: Nullable<BaseTexture>;
  52719. /**
  52720. * Reflection Texture used in the material.
  52721. * Should be author in a specific way for the best result (refer to the documentation).
  52722. */
  52723. reflectionTexture: Nullable<BaseTexture>;
  52724. protected _reflectionBlur: float;
  52725. /**
  52726. * Reflection Texture level of blur.
  52727. *
  52728. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52729. * texture twice.
  52730. */
  52731. reflectionBlur: float;
  52732. protected _diffuseTexture: Nullable<BaseTexture>;
  52733. /**
  52734. * Diffuse Texture used in the material.
  52735. * Should be author in a specific way for the best result (refer to the documentation).
  52736. */
  52737. diffuseTexture: Nullable<BaseTexture>;
  52738. protected _shadowLights: Nullable<IShadowLight[]>;
  52739. /**
  52740. * Specify the list of lights casting shadow on the material.
  52741. * All scene shadow lights will be included if null.
  52742. */
  52743. shadowLights: Nullable<IShadowLight[]>;
  52744. protected _shadowLevel: float;
  52745. /**
  52746. * Helps adjusting the shadow to a softer level if required.
  52747. * 0 means black shadows and 1 means no shadows.
  52748. */
  52749. shadowLevel: float;
  52750. protected _sceneCenter: Vector3;
  52751. /**
  52752. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52753. * It is usually zero but might be interesting to modify according to your setup.
  52754. */
  52755. sceneCenter: Vector3;
  52756. protected _opacityFresnel: boolean;
  52757. /**
  52758. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52759. * This helps ensuring a nice transition when the camera goes under the ground.
  52760. */
  52761. opacityFresnel: boolean;
  52762. protected _reflectionFresnel: boolean;
  52763. /**
  52764. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52765. * This helps adding a mirror texture on the ground.
  52766. */
  52767. reflectionFresnel: boolean;
  52768. protected _reflectionFalloffDistance: number;
  52769. /**
  52770. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52771. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52772. */
  52773. reflectionFalloffDistance: number;
  52774. protected _reflectionAmount: number;
  52775. /**
  52776. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52777. */
  52778. reflectionAmount: number;
  52779. protected _reflectionReflectance0: number;
  52780. /**
  52781. * This specifies the weight of the reflection at grazing angle.
  52782. */
  52783. reflectionReflectance0: number;
  52784. protected _reflectionReflectance90: number;
  52785. /**
  52786. * This specifies the weight of the reflection at a perpendicular point of view.
  52787. */
  52788. reflectionReflectance90: number;
  52789. /**
  52790. * Sets the reflection reflectance fresnel values according to the default standard
  52791. * empirically know to work well :-)
  52792. */
  52793. set reflectionStandardFresnelWeight(value: number);
  52794. protected _useRGBColor: boolean;
  52795. /**
  52796. * Helps to directly use the maps channels instead of their level.
  52797. */
  52798. useRGBColor: boolean;
  52799. protected _enableNoise: boolean;
  52800. /**
  52801. * This helps reducing the banding effect that could occur on the background.
  52802. */
  52803. enableNoise: boolean;
  52804. /**
  52805. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52806. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52807. * Recommended to be keep at 1.0 except for special cases.
  52808. */
  52809. get fovMultiplier(): number;
  52810. set fovMultiplier(value: number);
  52811. private _fovMultiplier;
  52812. /**
  52813. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52814. */
  52815. useEquirectangularFOV: boolean;
  52816. private _maxSimultaneousLights;
  52817. /**
  52818. * Number of Simultaneous lights allowed on the material.
  52819. */
  52820. maxSimultaneousLights: int;
  52821. /**
  52822. * Default configuration related to image processing available in the Background Material.
  52823. */
  52824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52825. /**
  52826. * Keep track of the image processing observer to allow dispose and replace.
  52827. */
  52828. private _imageProcessingObserver;
  52829. /**
  52830. * Attaches a new image processing configuration to the PBR Material.
  52831. * @param configuration (if null the scene configuration will be use)
  52832. */
  52833. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52834. /**
  52835. * Gets the image processing configuration used either in this material.
  52836. */
  52837. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52838. /**
  52839. * Sets the Default image processing configuration used either in the this material.
  52840. *
  52841. * If sets to null, the scene one is in use.
  52842. */
  52843. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52844. /**
  52845. * Gets wether the color curves effect is enabled.
  52846. */
  52847. get cameraColorCurvesEnabled(): boolean;
  52848. /**
  52849. * Sets wether the color curves effect is enabled.
  52850. */
  52851. set cameraColorCurvesEnabled(value: boolean);
  52852. /**
  52853. * Gets wether the color grading effect is enabled.
  52854. */
  52855. get cameraColorGradingEnabled(): boolean;
  52856. /**
  52857. * Gets wether the color grading effect is enabled.
  52858. */
  52859. set cameraColorGradingEnabled(value: boolean);
  52860. /**
  52861. * Gets wether tonemapping is enabled or not.
  52862. */
  52863. get cameraToneMappingEnabled(): boolean;
  52864. /**
  52865. * Sets wether tonemapping is enabled or not
  52866. */
  52867. set cameraToneMappingEnabled(value: boolean);
  52868. /**
  52869. * The camera exposure used on this material.
  52870. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52871. * This corresponds to a photographic exposure.
  52872. */
  52873. get cameraExposure(): float;
  52874. /**
  52875. * The camera exposure used on this material.
  52876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52877. * This corresponds to a photographic exposure.
  52878. */
  52879. set cameraExposure(value: float);
  52880. /**
  52881. * Gets The camera contrast used on this material.
  52882. */
  52883. get cameraContrast(): float;
  52884. /**
  52885. * Sets The camera contrast used on this material.
  52886. */
  52887. set cameraContrast(value: float);
  52888. /**
  52889. * Gets the Color Grading 2D Lookup Texture.
  52890. */
  52891. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52892. /**
  52893. * Sets the Color Grading 2D Lookup Texture.
  52894. */
  52895. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52896. /**
  52897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52899. * 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;
  52900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52901. */
  52902. get cameraColorCurves(): Nullable<ColorCurves>;
  52903. /**
  52904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52906. * 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;
  52907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52908. */
  52909. set cameraColorCurves(value: Nullable<ColorCurves>);
  52910. /**
  52911. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52912. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52913. */
  52914. switchToBGR: boolean;
  52915. private _renderTargets;
  52916. private _reflectionControls;
  52917. private _white;
  52918. private _primaryShadowColor;
  52919. private _primaryHighlightColor;
  52920. /**
  52921. * Instantiates a Background Material in the given scene
  52922. * @param name The friendly name of the material
  52923. * @param scene The scene to add the material to
  52924. */
  52925. constructor(name: string, scene: Scene);
  52926. /**
  52927. * Gets a boolean indicating that current material needs to register RTT
  52928. */
  52929. get hasRenderTargetTextures(): boolean;
  52930. /**
  52931. * The entire material has been created in order to prevent overdraw.
  52932. * @returns false
  52933. */
  52934. needAlphaTesting(): boolean;
  52935. /**
  52936. * The entire material has been created in order to prevent overdraw.
  52937. * @returns true if blending is enable
  52938. */
  52939. needAlphaBlending(): boolean;
  52940. /**
  52941. * Checks wether the material is ready to be rendered for a given mesh.
  52942. * @param mesh The mesh to render
  52943. * @param subMesh The submesh to check against
  52944. * @param useInstances Specify wether or not the material is used with instances
  52945. * @returns true if all the dependencies are ready (Textures, Effects...)
  52946. */
  52947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52948. /**
  52949. * Compute the primary color according to the chosen perceptual color.
  52950. */
  52951. private _computePrimaryColorFromPerceptualColor;
  52952. /**
  52953. * Compute the highlights and shadow colors according to their chosen levels.
  52954. */
  52955. private _computePrimaryColors;
  52956. /**
  52957. * Build the uniform buffer used in the material.
  52958. */
  52959. buildUniformLayout(): void;
  52960. /**
  52961. * Unbind the material.
  52962. */
  52963. unbind(): void;
  52964. /**
  52965. * Bind only the world matrix to the material.
  52966. * @param world The world matrix to bind.
  52967. */
  52968. bindOnlyWorldMatrix(world: Matrix): void;
  52969. /**
  52970. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52971. * @param world The world matrix to bind.
  52972. * @param subMesh The submesh to bind for.
  52973. */
  52974. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52975. /**
  52976. * Checks to see if a texture is used in the material.
  52977. * @param texture - Base texture to use.
  52978. * @returns - Boolean specifying if a texture is used in the material.
  52979. */
  52980. hasTexture(texture: BaseTexture): boolean;
  52981. /**
  52982. * Dispose the material.
  52983. * @param forceDisposeEffect Force disposal of the associated effect.
  52984. * @param forceDisposeTextures Force disposal of the associated textures.
  52985. */
  52986. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52987. /**
  52988. * Clones the material.
  52989. * @param name The cloned name.
  52990. * @returns The cloned material.
  52991. */
  52992. clone(name: string): BackgroundMaterial;
  52993. /**
  52994. * Serializes the current material to its JSON representation.
  52995. * @returns The JSON representation.
  52996. */
  52997. serialize(): any;
  52998. /**
  52999. * Gets the class name of the material
  53000. * @returns "BackgroundMaterial"
  53001. */
  53002. getClassName(): string;
  53003. /**
  53004. * Parse a JSON input to create back a background material.
  53005. * @param source The JSON data to parse
  53006. * @param scene The scene to create the parsed material in
  53007. * @param rootUrl The root url of the assets the material depends upon
  53008. * @returns the instantiated BackgroundMaterial.
  53009. */
  53010. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53011. }
  53012. }
  53013. declare module BABYLON {
  53014. /**
  53015. * Represents the different options available during the creation of
  53016. * a Environment helper.
  53017. *
  53018. * This can control the default ground, skybox and image processing setup of your scene.
  53019. */
  53020. export interface IEnvironmentHelperOptions {
  53021. /**
  53022. * Specifies whether or not to create a ground.
  53023. * True by default.
  53024. */
  53025. createGround: boolean;
  53026. /**
  53027. * Specifies the ground size.
  53028. * 15 by default.
  53029. */
  53030. groundSize: number;
  53031. /**
  53032. * The texture used on the ground for the main color.
  53033. * Comes from the BabylonJS CDN by default.
  53034. *
  53035. * Remarks: Can be either a texture or a url.
  53036. */
  53037. groundTexture: string | BaseTexture;
  53038. /**
  53039. * The color mixed in the ground texture by default.
  53040. * BabylonJS clearColor by default.
  53041. */
  53042. groundColor: Color3;
  53043. /**
  53044. * Specifies the ground opacity.
  53045. * 1 by default.
  53046. */
  53047. groundOpacity: number;
  53048. /**
  53049. * Enables the ground to receive shadows.
  53050. * True by default.
  53051. */
  53052. enableGroundShadow: boolean;
  53053. /**
  53054. * Helps preventing the shadow to be fully black on the ground.
  53055. * 0.5 by default.
  53056. */
  53057. groundShadowLevel: number;
  53058. /**
  53059. * Creates a mirror texture attach to the ground.
  53060. * false by default.
  53061. */
  53062. enableGroundMirror: boolean;
  53063. /**
  53064. * Specifies the ground mirror size ratio.
  53065. * 0.3 by default as the default kernel is 64.
  53066. */
  53067. groundMirrorSizeRatio: number;
  53068. /**
  53069. * Specifies the ground mirror blur kernel size.
  53070. * 64 by default.
  53071. */
  53072. groundMirrorBlurKernel: number;
  53073. /**
  53074. * Specifies the ground mirror visibility amount.
  53075. * 1 by default
  53076. */
  53077. groundMirrorAmount: number;
  53078. /**
  53079. * Specifies the ground mirror reflectance weight.
  53080. * This uses the standard weight of the background material to setup the fresnel effect
  53081. * of the mirror.
  53082. * 1 by default.
  53083. */
  53084. groundMirrorFresnelWeight: number;
  53085. /**
  53086. * Specifies the ground mirror Falloff distance.
  53087. * This can helps reducing the size of the reflection.
  53088. * 0 by Default.
  53089. */
  53090. groundMirrorFallOffDistance: number;
  53091. /**
  53092. * Specifies the ground mirror texture type.
  53093. * Unsigned Int by Default.
  53094. */
  53095. groundMirrorTextureType: number;
  53096. /**
  53097. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53098. * the shown objects.
  53099. */
  53100. groundYBias: number;
  53101. /**
  53102. * Specifies whether or not to create a skybox.
  53103. * True by default.
  53104. */
  53105. createSkybox: boolean;
  53106. /**
  53107. * Specifies the skybox size.
  53108. * 20 by default.
  53109. */
  53110. skyboxSize: number;
  53111. /**
  53112. * The texture used on the skybox for the main color.
  53113. * Comes from the BabylonJS CDN by default.
  53114. *
  53115. * Remarks: Can be either a texture or a url.
  53116. */
  53117. skyboxTexture: string | BaseTexture;
  53118. /**
  53119. * The color mixed in the skybox texture by default.
  53120. * BabylonJS clearColor by default.
  53121. */
  53122. skyboxColor: Color3;
  53123. /**
  53124. * The background rotation around the Y axis of the scene.
  53125. * This helps aligning the key lights of your scene with the background.
  53126. * 0 by default.
  53127. */
  53128. backgroundYRotation: number;
  53129. /**
  53130. * Compute automatically the size of the elements to best fit with the scene.
  53131. */
  53132. sizeAuto: boolean;
  53133. /**
  53134. * Default position of the rootMesh if autoSize is not true.
  53135. */
  53136. rootPosition: Vector3;
  53137. /**
  53138. * Sets up the image processing in the scene.
  53139. * true by default.
  53140. */
  53141. setupImageProcessing: boolean;
  53142. /**
  53143. * The texture used as your environment texture in the scene.
  53144. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53145. *
  53146. * Remarks: Can be either a texture or a url.
  53147. */
  53148. environmentTexture: string | BaseTexture;
  53149. /**
  53150. * The value of the exposure to apply to the scene.
  53151. * 0.6 by default if setupImageProcessing is true.
  53152. */
  53153. cameraExposure: number;
  53154. /**
  53155. * The value of the contrast to apply to the scene.
  53156. * 1.6 by default if setupImageProcessing is true.
  53157. */
  53158. cameraContrast: number;
  53159. /**
  53160. * Specifies whether or not tonemapping should be enabled in the scene.
  53161. * true by default if setupImageProcessing is true.
  53162. */
  53163. toneMappingEnabled: boolean;
  53164. }
  53165. /**
  53166. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53167. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53168. * It also helps with the default setup of your imageProcessing configuration.
  53169. */
  53170. export class EnvironmentHelper {
  53171. /**
  53172. * Default ground texture URL.
  53173. */
  53174. private static _groundTextureCDNUrl;
  53175. /**
  53176. * Default skybox texture URL.
  53177. */
  53178. private static _skyboxTextureCDNUrl;
  53179. /**
  53180. * Default environment texture URL.
  53181. */
  53182. private static _environmentTextureCDNUrl;
  53183. /**
  53184. * Creates the default options for the helper.
  53185. */
  53186. private static _getDefaultOptions;
  53187. private _rootMesh;
  53188. /**
  53189. * Gets the root mesh created by the helper.
  53190. */
  53191. get rootMesh(): Mesh;
  53192. private _skybox;
  53193. /**
  53194. * Gets the skybox created by the helper.
  53195. */
  53196. get skybox(): Nullable<Mesh>;
  53197. private _skyboxTexture;
  53198. /**
  53199. * Gets the skybox texture created by the helper.
  53200. */
  53201. get skyboxTexture(): Nullable<BaseTexture>;
  53202. private _skyboxMaterial;
  53203. /**
  53204. * Gets the skybox material created by the helper.
  53205. */
  53206. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53207. private _ground;
  53208. /**
  53209. * Gets the ground mesh created by the helper.
  53210. */
  53211. get ground(): Nullable<Mesh>;
  53212. private _groundTexture;
  53213. /**
  53214. * Gets the ground texture created by the helper.
  53215. */
  53216. get groundTexture(): Nullable<BaseTexture>;
  53217. private _groundMirror;
  53218. /**
  53219. * Gets the ground mirror created by the helper.
  53220. */
  53221. get groundMirror(): Nullable<MirrorTexture>;
  53222. /**
  53223. * Gets the ground mirror render list to helps pushing the meshes
  53224. * you wish in the ground reflection.
  53225. */
  53226. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53227. private _groundMaterial;
  53228. /**
  53229. * Gets the ground material created by the helper.
  53230. */
  53231. get groundMaterial(): Nullable<BackgroundMaterial>;
  53232. /**
  53233. * Stores the creation options.
  53234. */
  53235. private readonly _scene;
  53236. private _options;
  53237. /**
  53238. * This observable will be notified with any error during the creation of the environment,
  53239. * mainly texture creation errors.
  53240. */
  53241. onErrorObservable: Observable<{
  53242. message?: string;
  53243. exception?: any;
  53244. }>;
  53245. /**
  53246. * constructor
  53247. * @param options Defines the options we want to customize the helper
  53248. * @param scene The scene to add the material to
  53249. */
  53250. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53251. /**
  53252. * Updates the background according to the new options
  53253. * @param options
  53254. */
  53255. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53256. /**
  53257. * Sets the primary color of all the available elements.
  53258. * @param color the main color to affect to the ground and the background
  53259. */
  53260. setMainColor(color: Color3): void;
  53261. /**
  53262. * Setup the image processing according to the specified options.
  53263. */
  53264. private _setupImageProcessing;
  53265. /**
  53266. * Setup the environment texture according to the specified options.
  53267. */
  53268. private _setupEnvironmentTexture;
  53269. /**
  53270. * Setup the background according to the specified options.
  53271. */
  53272. private _setupBackground;
  53273. /**
  53274. * Get the scene sizes according to the setup.
  53275. */
  53276. private _getSceneSize;
  53277. /**
  53278. * Setup the ground according to the specified options.
  53279. */
  53280. private _setupGround;
  53281. /**
  53282. * Setup the ground material according to the specified options.
  53283. */
  53284. private _setupGroundMaterial;
  53285. /**
  53286. * Setup the ground diffuse texture according to the specified options.
  53287. */
  53288. private _setupGroundDiffuseTexture;
  53289. /**
  53290. * Setup the ground mirror texture according to the specified options.
  53291. */
  53292. private _setupGroundMirrorTexture;
  53293. /**
  53294. * Setup the ground to receive the mirror texture.
  53295. */
  53296. private _setupMirrorInGroundMaterial;
  53297. /**
  53298. * Setup the skybox according to the specified options.
  53299. */
  53300. private _setupSkybox;
  53301. /**
  53302. * Setup the skybox material according to the specified options.
  53303. */
  53304. private _setupSkyboxMaterial;
  53305. /**
  53306. * Setup the skybox reflection texture according to the specified options.
  53307. */
  53308. private _setupSkyboxReflectionTexture;
  53309. private _errorHandler;
  53310. /**
  53311. * Dispose all the elements created by the Helper.
  53312. */
  53313. dispose(): void;
  53314. }
  53315. }
  53316. declare module BABYLON {
  53317. /**
  53318. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53319. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53320. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53321. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53322. */
  53323. export class PhotoDome extends TransformNode {
  53324. /**
  53325. * Define the image as a Monoscopic panoramic 360 image.
  53326. */
  53327. static readonly MODE_MONOSCOPIC: number;
  53328. /**
  53329. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53330. */
  53331. static readonly MODE_TOPBOTTOM: number;
  53332. /**
  53333. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53334. */
  53335. static readonly MODE_SIDEBYSIDE: number;
  53336. private _useDirectMapping;
  53337. /**
  53338. * The texture being displayed on the sphere
  53339. */
  53340. protected _photoTexture: Texture;
  53341. /**
  53342. * Gets or sets the texture being displayed on the sphere
  53343. */
  53344. get photoTexture(): Texture;
  53345. set photoTexture(value: Texture);
  53346. /**
  53347. * Observable raised when an error occured while loading the 360 image
  53348. */
  53349. onLoadErrorObservable: Observable<string>;
  53350. /**
  53351. * The skybox material
  53352. */
  53353. protected _material: BackgroundMaterial;
  53354. /**
  53355. * The surface used for the skybox
  53356. */
  53357. protected _mesh: Mesh;
  53358. /**
  53359. * Gets the mesh used for the skybox.
  53360. */
  53361. get mesh(): Mesh;
  53362. /**
  53363. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53364. * Also see the options.resolution property.
  53365. */
  53366. get fovMultiplier(): number;
  53367. set fovMultiplier(value: number);
  53368. private _imageMode;
  53369. /**
  53370. * Gets or set the current video mode for the video. It can be:
  53371. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53372. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53373. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53374. */
  53375. get imageMode(): number;
  53376. set imageMode(value: number);
  53377. /**
  53378. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53379. * @param name Element's name, child elements will append suffixes for their own names.
  53380. * @param urlsOfPhoto defines the url of the photo to display
  53381. * @param options defines an object containing optional or exposed sub element properties
  53382. * @param onError defines a callback called when an error occured while loading the texture
  53383. */
  53384. constructor(name: string, urlOfPhoto: string, options: {
  53385. resolution?: number;
  53386. size?: number;
  53387. useDirectMapping?: boolean;
  53388. faceForward?: boolean;
  53389. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53390. private _onBeforeCameraRenderObserver;
  53391. private _changeImageMode;
  53392. /**
  53393. * Releases resources associated with this node.
  53394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53396. */
  53397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53398. }
  53399. }
  53400. declare module BABYLON {
  53401. /**
  53402. * Class used to host RGBD texture specific utilities
  53403. */
  53404. export class RGBDTextureTools {
  53405. /**
  53406. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53407. * @param texture the texture to expand.
  53408. */
  53409. static ExpandRGBDTexture(texture: Texture): void;
  53410. }
  53411. }
  53412. declare module BABYLON {
  53413. /**
  53414. * Class used to host texture specific utilities
  53415. */
  53416. export class BRDFTextureTools {
  53417. /**
  53418. * Prevents texture cache collision
  53419. */
  53420. private static _instanceNumber;
  53421. /**
  53422. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53423. * @param scene defines the hosting scene
  53424. * @returns the environment BRDF texture
  53425. */
  53426. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53427. private static _environmentBRDFBase64Texture;
  53428. }
  53429. }
  53430. declare module BABYLON {
  53431. /**
  53432. * @hidden
  53433. */
  53434. export interface IMaterialClearCoatDefines {
  53435. CLEARCOAT: boolean;
  53436. CLEARCOAT_DEFAULTIOR: boolean;
  53437. CLEARCOAT_TEXTURE: boolean;
  53438. CLEARCOAT_TEXTUREDIRECTUV: number;
  53439. CLEARCOAT_BUMP: boolean;
  53440. CLEARCOAT_BUMPDIRECTUV: number;
  53441. CLEARCOAT_TINT: boolean;
  53442. CLEARCOAT_TINT_TEXTURE: boolean;
  53443. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53444. /** @hidden */
  53445. _areTexturesDirty: boolean;
  53446. }
  53447. /**
  53448. * Define the code related to the clear coat parameters of the pbr material.
  53449. */
  53450. export class PBRClearCoatConfiguration {
  53451. /**
  53452. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53453. * The default fits with a polyurethane material.
  53454. */
  53455. private static readonly _DefaultIndexOfRefraction;
  53456. private _isEnabled;
  53457. /**
  53458. * Defines if the clear coat is enabled in the material.
  53459. */
  53460. isEnabled: boolean;
  53461. /**
  53462. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53463. */
  53464. intensity: number;
  53465. /**
  53466. * Defines the clear coat layer roughness.
  53467. */
  53468. roughness: number;
  53469. private _indexOfRefraction;
  53470. /**
  53471. * Defines the index of refraction of the clear coat.
  53472. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53473. * The default fits with a polyurethane material.
  53474. * Changing the default value is more performance intensive.
  53475. */
  53476. indexOfRefraction: number;
  53477. private _texture;
  53478. /**
  53479. * Stores the clear coat values in a texture.
  53480. */
  53481. texture: Nullable<BaseTexture>;
  53482. private _bumpTexture;
  53483. /**
  53484. * Define the clear coat specific bump texture.
  53485. */
  53486. bumpTexture: Nullable<BaseTexture>;
  53487. private _isTintEnabled;
  53488. /**
  53489. * Defines if the clear coat tint is enabled in the material.
  53490. */
  53491. isTintEnabled: boolean;
  53492. /**
  53493. * Defines the clear coat tint of the material.
  53494. * This is only use if tint is enabled
  53495. */
  53496. tintColor: Color3;
  53497. /**
  53498. * Defines the distance at which the tint color should be found in the
  53499. * clear coat media.
  53500. * This is only use if tint is enabled
  53501. */
  53502. tintColorAtDistance: number;
  53503. /**
  53504. * Defines the clear coat layer thickness.
  53505. * This is only use if tint is enabled
  53506. */
  53507. tintThickness: number;
  53508. private _tintTexture;
  53509. /**
  53510. * Stores the clear tint values in a texture.
  53511. * rgb is tint
  53512. * a is a thickness factor
  53513. */
  53514. tintTexture: Nullable<BaseTexture>;
  53515. /** @hidden */
  53516. private _internalMarkAllSubMeshesAsTexturesDirty;
  53517. /** @hidden */
  53518. _markAllSubMeshesAsTexturesDirty(): void;
  53519. /**
  53520. * Instantiate a new istance of clear coat configuration.
  53521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53522. */
  53523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53524. /**
  53525. * Gets wehter the submesh is ready to be used or not.
  53526. * @param defines the list of "defines" to update.
  53527. * @param scene defines the scene the material belongs to.
  53528. * @param engine defines the engine the material belongs to.
  53529. * @param disableBumpMap defines wether the material disables bump or not.
  53530. * @returns - boolean indicating that the submesh is ready or not.
  53531. */
  53532. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53533. /**
  53534. * Checks to see if a texture is used in the material.
  53535. * @param defines the list of "defines" to update.
  53536. * @param scene defines the scene to the material belongs to.
  53537. */
  53538. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53539. /**
  53540. * Binds the material data.
  53541. * @param uniformBuffer defines the Uniform buffer to fill in.
  53542. * @param scene defines the scene the material belongs to.
  53543. * @param engine defines the engine the material belongs to.
  53544. * @param disableBumpMap defines wether the material disables bump or not.
  53545. * @param isFrozen defines wether the material is frozen or not.
  53546. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53547. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53548. */
  53549. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53550. /**
  53551. * Checks to see if a texture is used in the material.
  53552. * @param texture - Base texture to use.
  53553. * @returns - Boolean specifying if a texture is used in the material.
  53554. */
  53555. hasTexture(texture: BaseTexture): boolean;
  53556. /**
  53557. * Returns an array of the actively used textures.
  53558. * @param activeTextures Array of BaseTextures
  53559. */
  53560. getActiveTextures(activeTextures: BaseTexture[]): void;
  53561. /**
  53562. * Returns the animatable textures.
  53563. * @param animatables Array of animatable textures.
  53564. */
  53565. getAnimatables(animatables: IAnimatable[]): void;
  53566. /**
  53567. * Disposes the resources of the material.
  53568. * @param forceDisposeTextures - Forces the disposal of all textures.
  53569. */
  53570. dispose(forceDisposeTextures?: boolean): void;
  53571. /**
  53572. * Get the current class name of the texture useful for serialization or dynamic coding.
  53573. * @returns "PBRClearCoatConfiguration"
  53574. */
  53575. getClassName(): string;
  53576. /**
  53577. * Add fallbacks to the effect fallbacks list.
  53578. * @param defines defines the Base texture to use.
  53579. * @param fallbacks defines the current fallback list.
  53580. * @param currentRank defines the current fallback rank.
  53581. * @returns the new fallback rank.
  53582. */
  53583. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53584. /**
  53585. * Add the required uniforms to the current list.
  53586. * @param uniforms defines the current uniform list.
  53587. */
  53588. static AddUniforms(uniforms: string[]): void;
  53589. /**
  53590. * Add the required samplers to the current list.
  53591. * @param samplers defines the current sampler list.
  53592. */
  53593. static AddSamplers(samplers: string[]): void;
  53594. /**
  53595. * Add the required uniforms to the current buffer.
  53596. * @param uniformBuffer defines the current uniform buffer.
  53597. */
  53598. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53599. /**
  53600. * Makes a duplicate of the current configuration into another one.
  53601. * @param clearCoatConfiguration define the config where to copy the info
  53602. */
  53603. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53604. /**
  53605. * Serializes this clear coat configuration.
  53606. * @returns - An object with the serialized config.
  53607. */
  53608. serialize(): any;
  53609. /**
  53610. * Parses a anisotropy Configuration from a serialized object.
  53611. * @param source - Serialized object.
  53612. * @param scene Defines the scene we are parsing for
  53613. * @param rootUrl Defines the rootUrl to load from
  53614. */
  53615. parse(source: any, scene: Scene, rootUrl: string): void;
  53616. }
  53617. }
  53618. declare module BABYLON {
  53619. /**
  53620. * @hidden
  53621. */
  53622. export interface IMaterialAnisotropicDefines {
  53623. ANISOTROPIC: boolean;
  53624. ANISOTROPIC_TEXTURE: boolean;
  53625. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53626. MAINUV1: boolean;
  53627. _areTexturesDirty: boolean;
  53628. _needUVs: boolean;
  53629. }
  53630. /**
  53631. * Define the code related to the anisotropic parameters of the pbr material.
  53632. */
  53633. export class PBRAnisotropicConfiguration {
  53634. private _isEnabled;
  53635. /**
  53636. * Defines if the anisotropy is enabled in the material.
  53637. */
  53638. isEnabled: boolean;
  53639. /**
  53640. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53641. */
  53642. intensity: number;
  53643. /**
  53644. * Defines if the effect is along the tangents, bitangents or in between.
  53645. * By default, the effect is "strectching" the highlights along the tangents.
  53646. */
  53647. direction: Vector2;
  53648. private _texture;
  53649. /**
  53650. * Stores the anisotropy values in a texture.
  53651. * rg is direction (like normal from -1 to 1)
  53652. * b is a intensity
  53653. */
  53654. texture: Nullable<BaseTexture>;
  53655. /** @hidden */
  53656. private _internalMarkAllSubMeshesAsTexturesDirty;
  53657. /** @hidden */
  53658. _markAllSubMeshesAsTexturesDirty(): void;
  53659. /**
  53660. * Instantiate a new istance of anisotropy configuration.
  53661. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53662. */
  53663. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53664. /**
  53665. * Specifies that the submesh is ready to be used.
  53666. * @param defines the list of "defines" to update.
  53667. * @param scene defines the scene the material belongs to.
  53668. * @returns - boolean indicating that the submesh is ready or not.
  53669. */
  53670. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53671. /**
  53672. * Checks to see if a texture is used in the material.
  53673. * @param defines the list of "defines" to update.
  53674. * @param mesh the mesh we are preparing the defines for.
  53675. * @param scene defines the scene the material belongs to.
  53676. */
  53677. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53678. /**
  53679. * Binds the material data.
  53680. * @param uniformBuffer defines the Uniform buffer to fill in.
  53681. * @param scene defines the scene the material belongs to.
  53682. * @param isFrozen defines wether the material is frozen or not.
  53683. */
  53684. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53685. /**
  53686. * Checks to see if a texture is used in the material.
  53687. * @param texture - Base texture to use.
  53688. * @returns - Boolean specifying if a texture is used in the material.
  53689. */
  53690. hasTexture(texture: BaseTexture): boolean;
  53691. /**
  53692. * Returns an array of the actively used textures.
  53693. * @param activeTextures Array of BaseTextures
  53694. */
  53695. getActiveTextures(activeTextures: BaseTexture[]): void;
  53696. /**
  53697. * Returns the animatable textures.
  53698. * @param animatables Array of animatable textures.
  53699. */
  53700. getAnimatables(animatables: IAnimatable[]): void;
  53701. /**
  53702. * Disposes the resources of the material.
  53703. * @param forceDisposeTextures - Forces the disposal of all textures.
  53704. */
  53705. dispose(forceDisposeTextures?: boolean): void;
  53706. /**
  53707. * Get the current class name of the texture useful for serialization or dynamic coding.
  53708. * @returns "PBRAnisotropicConfiguration"
  53709. */
  53710. getClassName(): string;
  53711. /**
  53712. * Add fallbacks to the effect fallbacks list.
  53713. * @param defines defines the Base texture to use.
  53714. * @param fallbacks defines the current fallback list.
  53715. * @param currentRank defines the current fallback rank.
  53716. * @returns the new fallback rank.
  53717. */
  53718. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53719. /**
  53720. * Add the required uniforms to the current list.
  53721. * @param uniforms defines the current uniform list.
  53722. */
  53723. static AddUniforms(uniforms: string[]): void;
  53724. /**
  53725. * Add the required uniforms to the current buffer.
  53726. * @param uniformBuffer defines the current uniform buffer.
  53727. */
  53728. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53729. /**
  53730. * Add the required samplers to the current list.
  53731. * @param samplers defines the current sampler list.
  53732. */
  53733. static AddSamplers(samplers: string[]): void;
  53734. /**
  53735. * Makes a duplicate of the current configuration into another one.
  53736. * @param anisotropicConfiguration define the config where to copy the info
  53737. */
  53738. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53739. /**
  53740. * Serializes this anisotropy configuration.
  53741. * @returns - An object with the serialized config.
  53742. */
  53743. serialize(): any;
  53744. /**
  53745. * Parses a anisotropy Configuration from a serialized object.
  53746. * @param source - Serialized object.
  53747. * @param scene Defines the scene we are parsing for
  53748. * @param rootUrl Defines the rootUrl to load from
  53749. */
  53750. parse(source: any, scene: Scene, rootUrl: string): void;
  53751. }
  53752. }
  53753. declare module BABYLON {
  53754. /**
  53755. * @hidden
  53756. */
  53757. export interface IMaterialBRDFDefines {
  53758. BRDF_V_HEIGHT_CORRELATED: boolean;
  53759. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53760. SPHERICAL_HARMONICS: boolean;
  53761. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53762. /** @hidden */
  53763. _areMiscDirty: boolean;
  53764. }
  53765. /**
  53766. * Define the code related to the BRDF parameters of the pbr material.
  53767. */
  53768. export class PBRBRDFConfiguration {
  53769. /**
  53770. * Default value used for the energy conservation.
  53771. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53772. */
  53773. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53774. /**
  53775. * Default value used for the Smith Visibility Height Correlated mode.
  53776. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53777. */
  53778. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53779. /**
  53780. * Default value used for the IBL diffuse part.
  53781. * This can help switching back to the polynomials mode globally which is a tiny bit
  53782. * less GPU intensive at the drawback of a lower quality.
  53783. */
  53784. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53785. /**
  53786. * Default value used for activating energy conservation for the specular workflow.
  53787. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53788. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53789. */
  53790. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53791. private _useEnergyConservation;
  53792. /**
  53793. * Defines if the material uses energy conservation.
  53794. */
  53795. useEnergyConservation: boolean;
  53796. private _useSmithVisibilityHeightCorrelated;
  53797. /**
  53798. * LEGACY Mode set to false
  53799. * Defines if the material uses height smith correlated visibility term.
  53800. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53801. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53802. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53803. * Not relying on height correlated will also disable energy conservation.
  53804. */
  53805. useSmithVisibilityHeightCorrelated: boolean;
  53806. private _useSphericalHarmonics;
  53807. /**
  53808. * LEGACY Mode set to false
  53809. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53810. * diffuse part of the IBL.
  53811. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53812. * to the ground truth.
  53813. */
  53814. useSphericalHarmonics: boolean;
  53815. private _useSpecularGlossinessInputEnergyConservation;
  53816. /**
  53817. * Defines if the material uses energy conservation, when the specular workflow is active.
  53818. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53819. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53820. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53821. */
  53822. useSpecularGlossinessInputEnergyConservation: boolean;
  53823. /** @hidden */
  53824. private _internalMarkAllSubMeshesAsMiscDirty;
  53825. /** @hidden */
  53826. _markAllSubMeshesAsMiscDirty(): void;
  53827. /**
  53828. * Instantiate a new istance of clear coat configuration.
  53829. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53830. */
  53831. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53832. /**
  53833. * Checks to see if a texture is used in the material.
  53834. * @param defines the list of "defines" to update.
  53835. */
  53836. prepareDefines(defines: IMaterialBRDFDefines): void;
  53837. /**
  53838. * Get the current class name of the texture useful for serialization or dynamic coding.
  53839. * @returns "PBRClearCoatConfiguration"
  53840. */
  53841. getClassName(): string;
  53842. /**
  53843. * Makes a duplicate of the current configuration into another one.
  53844. * @param brdfConfiguration define the config where to copy the info
  53845. */
  53846. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53847. /**
  53848. * Serializes this BRDF configuration.
  53849. * @returns - An object with the serialized config.
  53850. */
  53851. serialize(): any;
  53852. /**
  53853. * Parses a anisotropy Configuration from a serialized object.
  53854. * @param source - Serialized object.
  53855. * @param scene Defines the scene we are parsing for
  53856. * @param rootUrl Defines the rootUrl to load from
  53857. */
  53858. parse(source: any, scene: Scene, rootUrl: string): void;
  53859. }
  53860. }
  53861. declare module BABYLON {
  53862. /**
  53863. * @hidden
  53864. */
  53865. export interface IMaterialSheenDefines {
  53866. SHEEN: boolean;
  53867. SHEEN_TEXTURE: boolean;
  53868. SHEEN_TEXTUREDIRECTUV: number;
  53869. SHEEN_LINKWITHALBEDO: boolean;
  53870. SHEEN_ROUGHNESS: boolean;
  53871. SHEEN_ALBEDOSCALING: boolean;
  53872. /** @hidden */
  53873. _areTexturesDirty: boolean;
  53874. }
  53875. /**
  53876. * Define the code related to the Sheen parameters of the pbr material.
  53877. */
  53878. export class PBRSheenConfiguration {
  53879. private _isEnabled;
  53880. /**
  53881. * Defines if the material uses sheen.
  53882. */
  53883. isEnabled: boolean;
  53884. private _linkSheenWithAlbedo;
  53885. /**
  53886. * Defines if the sheen is linked to the sheen color.
  53887. */
  53888. linkSheenWithAlbedo: boolean;
  53889. /**
  53890. * Defines the sheen intensity.
  53891. */
  53892. intensity: number;
  53893. /**
  53894. * Defines the sheen color.
  53895. */
  53896. color: Color3;
  53897. private _texture;
  53898. /**
  53899. * Stores the sheen tint values in a texture.
  53900. * rgb is tint
  53901. * a is a intensity
  53902. */
  53903. texture: Nullable<BaseTexture>;
  53904. private _roughness;
  53905. /**
  53906. * Defines the sheen roughness.
  53907. * It is not taken into account if linkSheenWithAlbedo is true.
  53908. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53909. */
  53910. roughness: Nullable<number>;
  53911. private _albedoScaling;
  53912. /**
  53913. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53914. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53915. * making it easier to setup and tweak the effect
  53916. */
  53917. albedoScaling: boolean;
  53918. /** @hidden */
  53919. private _internalMarkAllSubMeshesAsTexturesDirty;
  53920. /** @hidden */
  53921. _markAllSubMeshesAsTexturesDirty(): void;
  53922. /**
  53923. * Instantiate a new istance of clear coat configuration.
  53924. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53925. */
  53926. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53927. /**
  53928. * Specifies that the submesh is ready to be used.
  53929. * @param defines the list of "defines" to update.
  53930. * @param scene defines the scene the material belongs to.
  53931. * @returns - boolean indicating that the submesh is ready or not.
  53932. */
  53933. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53934. /**
  53935. * Checks to see if a texture is used in the material.
  53936. * @param defines the list of "defines" to update.
  53937. * @param scene defines the scene the material belongs to.
  53938. */
  53939. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53940. /**
  53941. * Binds the material data.
  53942. * @param uniformBuffer defines the Uniform buffer to fill in.
  53943. * @param scene defines the scene the material belongs to.
  53944. * @param isFrozen defines wether the material is frozen or not.
  53945. */
  53946. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53947. /**
  53948. * Checks to see if a texture is used in the material.
  53949. * @param texture - Base texture to use.
  53950. * @returns - Boolean specifying if a texture is used in the material.
  53951. */
  53952. hasTexture(texture: BaseTexture): boolean;
  53953. /**
  53954. * Returns an array of the actively used textures.
  53955. * @param activeTextures Array of BaseTextures
  53956. */
  53957. getActiveTextures(activeTextures: BaseTexture[]): void;
  53958. /**
  53959. * Returns the animatable textures.
  53960. * @param animatables Array of animatable textures.
  53961. */
  53962. getAnimatables(animatables: IAnimatable[]): void;
  53963. /**
  53964. * Disposes the resources of the material.
  53965. * @param forceDisposeTextures - Forces the disposal of all textures.
  53966. */
  53967. dispose(forceDisposeTextures?: boolean): void;
  53968. /**
  53969. * Get the current class name of the texture useful for serialization or dynamic coding.
  53970. * @returns "PBRSheenConfiguration"
  53971. */
  53972. getClassName(): string;
  53973. /**
  53974. * Add fallbacks to the effect fallbacks list.
  53975. * @param defines defines the Base texture to use.
  53976. * @param fallbacks defines the current fallback list.
  53977. * @param currentRank defines the current fallback rank.
  53978. * @returns the new fallback rank.
  53979. */
  53980. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53981. /**
  53982. * Add the required uniforms to the current list.
  53983. * @param uniforms defines the current uniform list.
  53984. */
  53985. static AddUniforms(uniforms: string[]): void;
  53986. /**
  53987. * Add the required uniforms to the current buffer.
  53988. * @param uniformBuffer defines the current uniform buffer.
  53989. */
  53990. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53991. /**
  53992. * Add the required samplers to the current list.
  53993. * @param samplers defines the current sampler list.
  53994. */
  53995. static AddSamplers(samplers: string[]): void;
  53996. /**
  53997. * Makes a duplicate of the current configuration into another one.
  53998. * @param sheenConfiguration define the config where to copy the info
  53999. */
  54000. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54001. /**
  54002. * Serializes this BRDF configuration.
  54003. * @returns - An object with the serialized config.
  54004. */
  54005. serialize(): any;
  54006. /**
  54007. * Parses a anisotropy Configuration from a serialized object.
  54008. * @param source - Serialized object.
  54009. * @param scene Defines the scene we are parsing for
  54010. * @param rootUrl Defines the rootUrl to load from
  54011. */
  54012. parse(source: any, scene: Scene, rootUrl: string): void;
  54013. }
  54014. }
  54015. declare module BABYLON {
  54016. /**
  54017. * @hidden
  54018. */
  54019. export interface IMaterialSubSurfaceDefines {
  54020. SUBSURFACE: boolean;
  54021. SS_REFRACTION: boolean;
  54022. SS_TRANSLUCENCY: boolean;
  54023. SS_SCATERRING: boolean;
  54024. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54025. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54026. SS_REFRACTIONMAP_3D: boolean;
  54027. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54028. SS_LODINREFRACTIONALPHA: boolean;
  54029. SS_GAMMAREFRACTION: boolean;
  54030. SS_RGBDREFRACTION: boolean;
  54031. SS_LINEARSPECULARREFRACTION: boolean;
  54032. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54033. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54034. /** @hidden */
  54035. _areTexturesDirty: boolean;
  54036. }
  54037. /**
  54038. * Define the code related to the sub surface parameters of the pbr material.
  54039. */
  54040. export class PBRSubSurfaceConfiguration {
  54041. private _isRefractionEnabled;
  54042. /**
  54043. * Defines if the refraction is enabled in the material.
  54044. */
  54045. isRefractionEnabled: boolean;
  54046. private _isTranslucencyEnabled;
  54047. /**
  54048. * Defines if the translucency is enabled in the material.
  54049. */
  54050. isTranslucencyEnabled: boolean;
  54051. private _isScatteringEnabled;
  54052. /**
  54053. * Defines the refraction intensity of the material.
  54054. * The refraction when enabled replaces the Diffuse part of the material.
  54055. * The intensity helps transitionning between diffuse and refraction.
  54056. */
  54057. refractionIntensity: number;
  54058. /**
  54059. * Defines the translucency intensity of the material.
  54060. * When translucency has been enabled, this defines how much of the "translucency"
  54061. * is addded to the diffuse part of the material.
  54062. */
  54063. translucencyIntensity: number;
  54064. /**
  54065. * Defines the scattering intensity of the material.
  54066. * When scattering has been enabled, this defines how much of the "scattered light"
  54067. * is addded to the diffuse part of the material.
  54068. */
  54069. scatteringIntensity: number;
  54070. private _thicknessTexture;
  54071. /**
  54072. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54073. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54074. * 0 would mean minimumThickness
  54075. * 1 would mean maximumThickness
  54076. * The other channels might be use as a mask to vary the different effects intensity.
  54077. */
  54078. thicknessTexture: Nullable<BaseTexture>;
  54079. private _refractionTexture;
  54080. /**
  54081. * Defines the texture to use for refraction.
  54082. */
  54083. refractionTexture: Nullable<BaseTexture>;
  54084. private _indexOfRefraction;
  54085. /**
  54086. * Index of refraction of the material base layer.
  54087. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54088. *
  54089. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54090. *
  54091. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54092. */
  54093. indexOfRefraction: number;
  54094. private _invertRefractionY;
  54095. /**
  54096. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54097. */
  54098. invertRefractionY: boolean;
  54099. private _linkRefractionWithTransparency;
  54100. /**
  54101. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54102. * Materials half opaque for instance using refraction could benefit from this control.
  54103. */
  54104. linkRefractionWithTransparency: boolean;
  54105. /**
  54106. * Defines the minimum thickness stored in the thickness map.
  54107. * If no thickness map is defined, this value will be used to simulate thickness.
  54108. */
  54109. minimumThickness: number;
  54110. /**
  54111. * Defines the maximum thickness stored in the thickness map.
  54112. */
  54113. maximumThickness: number;
  54114. /**
  54115. * Defines the volume tint of the material.
  54116. * This is used for both translucency and scattering.
  54117. */
  54118. tintColor: Color3;
  54119. /**
  54120. * Defines the distance at which the tint color should be found in the media.
  54121. * This is used for refraction only.
  54122. */
  54123. tintColorAtDistance: number;
  54124. /**
  54125. * Defines how far each channel transmit through the media.
  54126. * It is defined as a color to simplify it selection.
  54127. */
  54128. diffusionDistance: Color3;
  54129. private _useMaskFromThicknessTexture;
  54130. /**
  54131. * Stores the intensity of the different subsurface effects in the thickness texture.
  54132. * * the green channel is the translucency intensity.
  54133. * * the blue channel is the scattering intensity.
  54134. * * the alpha channel is the refraction intensity.
  54135. */
  54136. useMaskFromThicknessTexture: boolean;
  54137. /** @hidden */
  54138. private _internalMarkAllSubMeshesAsTexturesDirty;
  54139. /** @hidden */
  54140. _markAllSubMeshesAsTexturesDirty(): void;
  54141. /**
  54142. * Instantiate a new istance of sub surface configuration.
  54143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54144. */
  54145. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54146. /**
  54147. * Gets wehter the submesh is ready to be used or not.
  54148. * @param defines the list of "defines" to update.
  54149. * @param scene defines the scene the material belongs to.
  54150. * @returns - boolean indicating that the submesh is ready or not.
  54151. */
  54152. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54153. /**
  54154. * Checks to see if a texture is used in the material.
  54155. * @param defines the list of "defines" to update.
  54156. * @param scene defines the scene to the material belongs to.
  54157. */
  54158. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54159. /**
  54160. * Binds the material data.
  54161. * @param uniformBuffer defines the Uniform buffer to fill in.
  54162. * @param scene defines the scene the material belongs to.
  54163. * @param engine defines the engine the material belongs to.
  54164. * @param isFrozen defines whether the material is frozen or not.
  54165. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54166. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54167. */
  54168. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54169. /**
  54170. * Unbinds the material from the mesh.
  54171. * @param activeEffect defines the effect that should be unbound from.
  54172. * @returns true if unbound, otherwise false
  54173. */
  54174. unbind(activeEffect: Effect): boolean;
  54175. /**
  54176. * Returns the texture used for refraction or null if none is used.
  54177. * @param scene defines the scene the material belongs to.
  54178. * @returns - Refraction texture if present. If no refraction texture and refraction
  54179. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54180. */
  54181. private _getRefractionTexture;
  54182. /**
  54183. * Returns true if alpha blending should be disabled.
  54184. */
  54185. get disableAlphaBlending(): boolean;
  54186. /**
  54187. * Fills the list of render target textures.
  54188. * @param renderTargets the list of render targets to update
  54189. */
  54190. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54191. /**
  54192. * Checks to see if a texture is used in the material.
  54193. * @param texture - Base texture to use.
  54194. * @returns - Boolean specifying if a texture is used in the material.
  54195. */
  54196. hasTexture(texture: BaseTexture): boolean;
  54197. /**
  54198. * Gets a boolean indicating that current material needs to register RTT
  54199. * @returns true if this uses a render target otherwise false.
  54200. */
  54201. hasRenderTargetTextures(): boolean;
  54202. /**
  54203. * Returns an array of the actively used textures.
  54204. * @param activeTextures Array of BaseTextures
  54205. */
  54206. getActiveTextures(activeTextures: BaseTexture[]): void;
  54207. /**
  54208. * Returns the animatable textures.
  54209. * @param animatables Array of animatable textures.
  54210. */
  54211. getAnimatables(animatables: IAnimatable[]): void;
  54212. /**
  54213. * Disposes the resources of the material.
  54214. * @param forceDisposeTextures - Forces the disposal of all textures.
  54215. */
  54216. dispose(forceDisposeTextures?: boolean): void;
  54217. /**
  54218. * Get the current class name of the texture useful for serialization or dynamic coding.
  54219. * @returns "PBRSubSurfaceConfiguration"
  54220. */
  54221. getClassName(): string;
  54222. /**
  54223. * Add fallbacks to the effect fallbacks list.
  54224. * @param defines defines the Base texture to use.
  54225. * @param fallbacks defines the current fallback list.
  54226. * @param currentRank defines the current fallback rank.
  54227. * @returns the new fallback rank.
  54228. */
  54229. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54230. /**
  54231. * Add the required uniforms to the current list.
  54232. * @param uniforms defines the current uniform list.
  54233. */
  54234. static AddUniforms(uniforms: string[]): void;
  54235. /**
  54236. * Add the required samplers to the current list.
  54237. * @param samplers defines the current sampler list.
  54238. */
  54239. static AddSamplers(samplers: string[]): void;
  54240. /**
  54241. * Add the required uniforms to the current buffer.
  54242. * @param uniformBuffer defines the current uniform buffer.
  54243. */
  54244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54245. /**
  54246. * Makes a duplicate of the current configuration into another one.
  54247. * @param configuration define the config where to copy the info
  54248. */
  54249. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54250. /**
  54251. * Serializes this Sub Surface configuration.
  54252. * @returns - An object with the serialized config.
  54253. */
  54254. serialize(): any;
  54255. /**
  54256. * Parses a anisotropy Configuration from a serialized object.
  54257. * @param source - Serialized object.
  54258. * @param scene Defines the scene we are parsing for
  54259. * @param rootUrl Defines the rootUrl to load from
  54260. */
  54261. parse(source: any, scene: Scene, rootUrl: string): void;
  54262. }
  54263. }
  54264. declare module BABYLON {
  54265. /** @hidden */
  54266. export var pbrFragmentDeclaration: {
  54267. name: string;
  54268. shader: string;
  54269. };
  54270. }
  54271. declare module BABYLON {
  54272. /** @hidden */
  54273. export var pbrUboDeclaration: {
  54274. name: string;
  54275. shader: string;
  54276. };
  54277. }
  54278. declare module BABYLON {
  54279. /** @hidden */
  54280. export var pbrFragmentExtraDeclaration: {
  54281. name: string;
  54282. shader: string;
  54283. };
  54284. }
  54285. declare module BABYLON {
  54286. /** @hidden */
  54287. export var pbrFragmentSamplersDeclaration: {
  54288. name: string;
  54289. shader: string;
  54290. };
  54291. }
  54292. declare module BABYLON {
  54293. /** @hidden */
  54294. export var importanceSampling: {
  54295. name: string;
  54296. shader: string;
  54297. };
  54298. }
  54299. declare module BABYLON {
  54300. /** @hidden */
  54301. export var pbrHelperFunctions: {
  54302. name: string;
  54303. shader: string;
  54304. };
  54305. }
  54306. declare module BABYLON {
  54307. /** @hidden */
  54308. export var harmonicsFunctions: {
  54309. name: string;
  54310. shader: string;
  54311. };
  54312. }
  54313. declare module BABYLON {
  54314. /** @hidden */
  54315. export var pbrDirectLightingSetupFunctions: {
  54316. name: string;
  54317. shader: string;
  54318. };
  54319. }
  54320. declare module BABYLON {
  54321. /** @hidden */
  54322. export var pbrDirectLightingFalloffFunctions: {
  54323. name: string;
  54324. shader: string;
  54325. };
  54326. }
  54327. declare module BABYLON {
  54328. /** @hidden */
  54329. export var pbrBRDFFunctions: {
  54330. name: string;
  54331. shader: string;
  54332. };
  54333. }
  54334. declare module BABYLON {
  54335. /** @hidden */
  54336. export var hdrFilteringFunctions: {
  54337. name: string;
  54338. shader: string;
  54339. };
  54340. }
  54341. declare module BABYLON {
  54342. /** @hidden */
  54343. export var pbrDirectLightingFunctions: {
  54344. name: string;
  54345. shader: string;
  54346. };
  54347. }
  54348. declare module BABYLON {
  54349. /** @hidden */
  54350. export var pbrIBLFunctions: {
  54351. name: string;
  54352. shader: string;
  54353. };
  54354. }
  54355. declare module BABYLON {
  54356. /** @hidden */
  54357. export var pbrBlockAlbedoOpacity: {
  54358. name: string;
  54359. shader: string;
  54360. };
  54361. }
  54362. declare module BABYLON {
  54363. /** @hidden */
  54364. export var pbrBlockReflectivity: {
  54365. name: string;
  54366. shader: string;
  54367. };
  54368. }
  54369. declare module BABYLON {
  54370. /** @hidden */
  54371. export var pbrBlockAmbientOcclusion: {
  54372. name: string;
  54373. shader: string;
  54374. };
  54375. }
  54376. declare module BABYLON {
  54377. /** @hidden */
  54378. export var pbrBlockAlphaFresnel: {
  54379. name: string;
  54380. shader: string;
  54381. };
  54382. }
  54383. declare module BABYLON {
  54384. /** @hidden */
  54385. export var pbrBlockAnisotropic: {
  54386. name: string;
  54387. shader: string;
  54388. };
  54389. }
  54390. declare module BABYLON {
  54391. /** @hidden */
  54392. export var pbrBlockReflection: {
  54393. name: string;
  54394. shader: string;
  54395. };
  54396. }
  54397. declare module BABYLON {
  54398. /** @hidden */
  54399. export var pbrBlockSheen: {
  54400. name: string;
  54401. shader: string;
  54402. };
  54403. }
  54404. declare module BABYLON {
  54405. /** @hidden */
  54406. export var pbrBlockClearcoat: {
  54407. name: string;
  54408. shader: string;
  54409. };
  54410. }
  54411. declare module BABYLON {
  54412. /** @hidden */
  54413. export var pbrBlockSubSurface: {
  54414. name: string;
  54415. shader: string;
  54416. };
  54417. }
  54418. declare module BABYLON {
  54419. /** @hidden */
  54420. export var pbrBlockNormalGeometric: {
  54421. name: string;
  54422. shader: string;
  54423. };
  54424. }
  54425. declare module BABYLON {
  54426. /** @hidden */
  54427. export var pbrBlockNormalFinal: {
  54428. name: string;
  54429. shader: string;
  54430. };
  54431. }
  54432. declare module BABYLON {
  54433. /** @hidden */
  54434. export var pbrBlockGeometryInfo: {
  54435. name: string;
  54436. shader: string;
  54437. };
  54438. }
  54439. declare module BABYLON {
  54440. /** @hidden */
  54441. export var pbrBlockReflectance0: {
  54442. name: string;
  54443. shader: string;
  54444. };
  54445. }
  54446. declare module BABYLON {
  54447. /** @hidden */
  54448. export var pbrBlockReflectance: {
  54449. name: string;
  54450. shader: string;
  54451. };
  54452. }
  54453. declare module BABYLON {
  54454. /** @hidden */
  54455. export var pbrBlockDirectLighting: {
  54456. name: string;
  54457. shader: string;
  54458. };
  54459. }
  54460. declare module BABYLON {
  54461. /** @hidden */
  54462. export var pbrBlockFinalLitComponents: {
  54463. name: string;
  54464. shader: string;
  54465. };
  54466. }
  54467. declare module BABYLON {
  54468. /** @hidden */
  54469. export var pbrBlockFinalUnlitComponents: {
  54470. name: string;
  54471. shader: string;
  54472. };
  54473. }
  54474. declare module BABYLON {
  54475. /** @hidden */
  54476. export var pbrBlockFinalColorComposition: {
  54477. name: string;
  54478. shader: string;
  54479. };
  54480. }
  54481. declare module BABYLON {
  54482. /** @hidden */
  54483. export var pbrBlockImageProcessing: {
  54484. name: string;
  54485. shader: string;
  54486. };
  54487. }
  54488. declare module BABYLON {
  54489. /** @hidden */
  54490. export var pbrDebug: {
  54491. name: string;
  54492. shader: string;
  54493. };
  54494. }
  54495. declare module BABYLON {
  54496. /** @hidden */
  54497. export var pbrPixelShader: {
  54498. name: string;
  54499. shader: string;
  54500. };
  54501. }
  54502. declare module BABYLON {
  54503. /** @hidden */
  54504. export var pbrVertexDeclaration: {
  54505. name: string;
  54506. shader: string;
  54507. };
  54508. }
  54509. declare module BABYLON {
  54510. /** @hidden */
  54511. export var pbrVertexShader: {
  54512. name: string;
  54513. shader: string;
  54514. };
  54515. }
  54516. declare module BABYLON {
  54517. /**
  54518. * Manages the defines for the PBR Material.
  54519. * @hidden
  54520. */
  54521. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54522. PBR: boolean;
  54523. NUM_SAMPLES: string;
  54524. REALTIME_FILTERING: boolean;
  54525. MAINUV1: boolean;
  54526. MAINUV2: boolean;
  54527. UV1: boolean;
  54528. UV2: boolean;
  54529. ALBEDO: boolean;
  54530. GAMMAALBEDO: boolean;
  54531. ALBEDODIRECTUV: number;
  54532. VERTEXCOLOR: boolean;
  54533. AMBIENT: boolean;
  54534. AMBIENTDIRECTUV: number;
  54535. AMBIENTINGRAYSCALE: boolean;
  54536. OPACITY: boolean;
  54537. VERTEXALPHA: boolean;
  54538. OPACITYDIRECTUV: number;
  54539. OPACITYRGB: boolean;
  54540. ALPHATEST: boolean;
  54541. DEPTHPREPASS: boolean;
  54542. ALPHABLEND: boolean;
  54543. ALPHAFROMALBEDO: boolean;
  54544. ALPHATESTVALUE: string;
  54545. SPECULAROVERALPHA: boolean;
  54546. RADIANCEOVERALPHA: boolean;
  54547. ALPHAFRESNEL: boolean;
  54548. LINEARALPHAFRESNEL: boolean;
  54549. PREMULTIPLYALPHA: boolean;
  54550. EMISSIVE: boolean;
  54551. EMISSIVEDIRECTUV: number;
  54552. REFLECTIVITY: boolean;
  54553. REFLECTIVITYDIRECTUV: number;
  54554. SPECULARTERM: boolean;
  54555. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54556. MICROSURFACEAUTOMATIC: boolean;
  54557. LODBASEDMICROSFURACE: boolean;
  54558. MICROSURFACEMAP: boolean;
  54559. MICROSURFACEMAPDIRECTUV: number;
  54560. METALLICWORKFLOW: boolean;
  54561. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54562. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54563. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54564. AOSTOREINMETALMAPRED: boolean;
  54565. METALLIC_REFLECTANCE: boolean;
  54566. METALLIC_REFLECTANCEDIRECTUV: number;
  54567. ENVIRONMENTBRDF: boolean;
  54568. ENVIRONMENTBRDF_RGBD: boolean;
  54569. NORMAL: boolean;
  54570. TANGENT: boolean;
  54571. BUMP: boolean;
  54572. BUMPDIRECTUV: number;
  54573. OBJECTSPACE_NORMALMAP: boolean;
  54574. PARALLAX: boolean;
  54575. PARALLAXOCCLUSION: boolean;
  54576. NORMALXYSCALE: boolean;
  54577. LIGHTMAP: boolean;
  54578. LIGHTMAPDIRECTUV: number;
  54579. USELIGHTMAPASSHADOWMAP: boolean;
  54580. GAMMALIGHTMAP: boolean;
  54581. RGBDLIGHTMAP: boolean;
  54582. REFLECTION: boolean;
  54583. REFLECTIONMAP_3D: boolean;
  54584. REFLECTIONMAP_SPHERICAL: boolean;
  54585. REFLECTIONMAP_PLANAR: boolean;
  54586. REFLECTIONMAP_CUBIC: boolean;
  54587. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54588. REFLECTIONMAP_PROJECTION: boolean;
  54589. REFLECTIONMAP_SKYBOX: boolean;
  54590. REFLECTIONMAP_EXPLICIT: boolean;
  54591. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54592. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54593. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54594. INVERTCUBICMAP: boolean;
  54595. USESPHERICALFROMREFLECTIONMAP: boolean;
  54596. USEIRRADIANCEMAP: boolean;
  54597. SPHERICAL_HARMONICS: boolean;
  54598. USESPHERICALINVERTEX: boolean;
  54599. REFLECTIONMAP_OPPOSITEZ: boolean;
  54600. LODINREFLECTIONALPHA: boolean;
  54601. GAMMAREFLECTION: boolean;
  54602. RGBDREFLECTION: boolean;
  54603. LINEARSPECULARREFLECTION: boolean;
  54604. RADIANCEOCCLUSION: boolean;
  54605. HORIZONOCCLUSION: boolean;
  54606. INSTANCES: boolean;
  54607. THIN_INSTANCES: boolean;
  54608. NUM_BONE_INFLUENCERS: number;
  54609. BonesPerMesh: number;
  54610. BONETEXTURE: boolean;
  54611. NONUNIFORMSCALING: boolean;
  54612. MORPHTARGETS: boolean;
  54613. MORPHTARGETS_NORMAL: boolean;
  54614. MORPHTARGETS_TANGENT: boolean;
  54615. MORPHTARGETS_UV: boolean;
  54616. NUM_MORPH_INFLUENCERS: number;
  54617. IMAGEPROCESSING: boolean;
  54618. VIGNETTE: boolean;
  54619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54620. VIGNETTEBLENDMODEOPAQUE: boolean;
  54621. TONEMAPPING: boolean;
  54622. TONEMAPPING_ACES: boolean;
  54623. CONTRAST: boolean;
  54624. COLORCURVES: boolean;
  54625. COLORGRADING: boolean;
  54626. COLORGRADING3D: boolean;
  54627. SAMPLER3DGREENDEPTH: boolean;
  54628. SAMPLER3DBGRMAP: boolean;
  54629. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54630. EXPOSURE: boolean;
  54631. MULTIVIEW: boolean;
  54632. USEPHYSICALLIGHTFALLOFF: boolean;
  54633. USEGLTFLIGHTFALLOFF: boolean;
  54634. TWOSIDEDLIGHTING: boolean;
  54635. SHADOWFLOAT: boolean;
  54636. CLIPPLANE: boolean;
  54637. CLIPPLANE2: boolean;
  54638. CLIPPLANE3: boolean;
  54639. CLIPPLANE4: boolean;
  54640. CLIPPLANE5: boolean;
  54641. CLIPPLANE6: boolean;
  54642. POINTSIZE: boolean;
  54643. FOG: boolean;
  54644. LOGARITHMICDEPTH: boolean;
  54645. FORCENORMALFORWARD: boolean;
  54646. SPECULARAA: boolean;
  54647. CLEARCOAT: boolean;
  54648. CLEARCOAT_DEFAULTIOR: boolean;
  54649. CLEARCOAT_TEXTURE: boolean;
  54650. CLEARCOAT_TEXTUREDIRECTUV: number;
  54651. CLEARCOAT_BUMP: boolean;
  54652. CLEARCOAT_BUMPDIRECTUV: number;
  54653. CLEARCOAT_TINT: boolean;
  54654. CLEARCOAT_TINT_TEXTURE: boolean;
  54655. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54656. ANISOTROPIC: boolean;
  54657. ANISOTROPIC_TEXTURE: boolean;
  54658. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54659. BRDF_V_HEIGHT_CORRELATED: boolean;
  54660. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54661. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54662. SHEEN: boolean;
  54663. SHEEN_TEXTURE: boolean;
  54664. SHEEN_TEXTUREDIRECTUV: number;
  54665. SHEEN_LINKWITHALBEDO: boolean;
  54666. SHEEN_ROUGHNESS: boolean;
  54667. SHEEN_ALBEDOSCALING: boolean;
  54668. SUBSURFACE: boolean;
  54669. SS_REFRACTION: boolean;
  54670. SS_TRANSLUCENCY: boolean;
  54671. SS_SCATERRING: boolean;
  54672. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54673. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54674. SS_REFRACTIONMAP_3D: boolean;
  54675. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54676. SS_LODINREFRACTIONALPHA: boolean;
  54677. SS_GAMMAREFRACTION: boolean;
  54678. SS_RGBDREFRACTION: boolean;
  54679. SS_LINEARSPECULARREFRACTION: boolean;
  54680. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54681. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54682. UNLIT: boolean;
  54683. DEBUGMODE: number;
  54684. /**
  54685. * Initializes the PBR Material defines.
  54686. */
  54687. constructor();
  54688. /**
  54689. * Resets the PBR Material defines.
  54690. */
  54691. reset(): void;
  54692. }
  54693. /**
  54694. * The Physically based material base class of BJS.
  54695. *
  54696. * This offers the main features of a standard PBR material.
  54697. * For more information, please refer to the documentation :
  54698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54699. */
  54700. export abstract class PBRBaseMaterial extends PushMaterial {
  54701. /**
  54702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54703. */
  54704. static readonly PBRMATERIAL_OPAQUE: number;
  54705. /**
  54706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54707. */
  54708. static readonly PBRMATERIAL_ALPHATEST: number;
  54709. /**
  54710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54711. */
  54712. static readonly PBRMATERIAL_ALPHABLEND: number;
  54713. /**
  54714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54715. * They are also discarded below the alpha cutoff threshold to improve performances.
  54716. */
  54717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54718. /**
  54719. * Defines the default value of how much AO map is occluding the analytical lights
  54720. * (point spot...).
  54721. */
  54722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54723. /**
  54724. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54725. */
  54726. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54727. /**
  54728. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54729. * to enhance interoperability with other engines.
  54730. */
  54731. static readonly LIGHTFALLOFF_GLTF: number;
  54732. /**
  54733. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54734. * to enhance interoperability with other materials.
  54735. */
  54736. static readonly LIGHTFALLOFF_STANDARD: number;
  54737. /**
  54738. * Intensity of the direct lights e.g. the four lights available in your scene.
  54739. * This impacts both the direct diffuse and specular highlights.
  54740. */
  54741. protected _directIntensity: number;
  54742. /**
  54743. * Intensity of the emissive part of the material.
  54744. * This helps controlling the emissive effect without modifying the emissive color.
  54745. */
  54746. protected _emissiveIntensity: number;
  54747. /**
  54748. * Intensity of the environment e.g. how much the environment will light the object
  54749. * either through harmonics for rough material or through the refelction for shiny ones.
  54750. */
  54751. protected _environmentIntensity: number;
  54752. /**
  54753. * This is a special control allowing the reduction of the specular highlights coming from the
  54754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54755. */
  54756. protected _specularIntensity: number;
  54757. /**
  54758. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54759. */
  54760. private _lightingInfos;
  54761. /**
  54762. * Debug Control allowing disabling the bump map on this material.
  54763. */
  54764. protected _disableBumpMap: boolean;
  54765. /**
  54766. * AKA Diffuse Texture in standard nomenclature.
  54767. */
  54768. protected _albedoTexture: Nullable<BaseTexture>;
  54769. /**
  54770. * AKA Occlusion Texture in other nomenclature.
  54771. */
  54772. protected _ambientTexture: Nullable<BaseTexture>;
  54773. /**
  54774. * AKA Occlusion Texture Intensity in other nomenclature.
  54775. */
  54776. protected _ambientTextureStrength: number;
  54777. /**
  54778. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54779. * 1 means it completely occludes it
  54780. * 0 mean it has no impact
  54781. */
  54782. protected _ambientTextureImpactOnAnalyticalLights: number;
  54783. /**
  54784. * Stores the alpha values in a texture.
  54785. */
  54786. protected _opacityTexture: Nullable<BaseTexture>;
  54787. /**
  54788. * Stores the reflection values in a texture.
  54789. */
  54790. protected _reflectionTexture: Nullable<BaseTexture>;
  54791. /**
  54792. * Stores the emissive values in a texture.
  54793. */
  54794. protected _emissiveTexture: Nullable<BaseTexture>;
  54795. /**
  54796. * AKA Specular texture in other nomenclature.
  54797. */
  54798. protected _reflectivityTexture: Nullable<BaseTexture>;
  54799. /**
  54800. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54801. */
  54802. protected _metallicTexture: Nullable<BaseTexture>;
  54803. /**
  54804. * Specifies the metallic scalar of the metallic/roughness workflow.
  54805. * Can also be used to scale the metalness values of the metallic texture.
  54806. */
  54807. protected _metallic: Nullable<number>;
  54808. /**
  54809. * Specifies the roughness scalar of the metallic/roughness workflow.
  54810. * Can also be used to scale the roughness values of the metallic texture.
  54811. */
  54812. protected _roughness: Nullable<number>;
  54813. /**
  54814. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54815. * By default the indexOfrefraction is used to compute F0;
  54816. *
  54817. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54818. *
  54819. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54820. * F90 = metallicReflectanceColor;
  54821. */
  54822. protected _metallicF0Factor: number;
  54823. /**
  54824. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54825. * By default the F90 is always 1;
  54826. *
  54827. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54828. *
  54829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54830. * F90 = metallicReflectanceColor;
  54831. */
  54832. protected _metallicReflectanceColor: Color3;
  54833. /**
  54834. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54835. * This is multiply against the scalar values defined in the material.
  54836. */
  54837. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54838. /**
  54839. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54840. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54841. */
  54842. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54843. /**
  54844. * Stores surface normal data used to displace a mesh in a texture.
  54845. */
  54846. protected _bumpTexture: Nullable<BaseTexture>;
  54847. /**
  54848. * Stores the pre-calculated light information of a mesh in a texture.
  54849. */
  54850. protected _lightmapTexture: Nullable<BaseTexture>;
  54851. /**
  54852. * The color of a material in ambient lighting.
  54853. */
  54854. protected _ambientColor: Color3;
  54855. /**
  54856. * AKA Diffuse Color in other nomenclature.
  54857. */
  54858. protected _albedoColor: Color3;
  54859. /**
  54860. * AKA Specular Color in other nomenclature.
  54861. */
  54862. protected _reflectivityColor: Color3;
  54863. /**
  54864. * The color applied when light is reflected from a material.
  54865. */
  54866. protected _reflectionColor: Color3;
  54867. /**
  54868. * The color applied when light is emitted from a material.
  54869. */
  54870. protected _emissiveColor: Color3;
  54871. /**
  54872. * AKA Glossiness in other nomenclature.
  54873. */
  54874. protected _microSurface: number;
  54875. /**
  54876. * Specifies that the material will use the light map as a show map.
  54877. */
  54878. protected _useLightmapAsShadowmap: boolean;
  54879. /**
  54880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54881. * makes the reflect vector face the model (under horizon).
  54882. */
  54883. protected _useHorizonOcclusion: boolean;
  54884. /**
  54885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54886. * too much the area relying on ambient texture to define their ambient occlusion.
  54887. */
  54888. protected _useRadianceOcclusion: boolean;
  54889. /**
  54890. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54891. */
  54892. protected _useAlphaFromAlbedoTexture: boolean;
  54893. /**
  54894. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54896. */
  54897. protected _useSpecularOverAlpha: boolean;
  54898. /**
  54899. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54900. */
  54901. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54902. /**
  54903. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54904. */
  54905. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54906. /**
  54907. * Specifies if the metallic texture contains the roughness information in its green channel.
  54908. */
  54909. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54910. /**
  54911. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54912. */
  54913. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54914. /**
  54915. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54916. */
  54917. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54918. /**
  54919. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54920. */
  54921. protected _useAmbientInGrayScale: boolean;
  54922. /**
  54923. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54924. * The material will try to infer what glossiness each pixel should be.
  54925. */
  54926. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54927. /**
  54928. * Defines the falloff type used in this material.
  54929. * It by default is Physical.
  54930. */
  54931. protected _lightFalloff: number;
  54932. /**
  54933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54935. */
  54936. protected _useRadianceOverAlpha: boolean;
  54937. /**
  54938. * Allows using an object space normal map (instead of tangent space).
  54939. */
  54940. protected _useObjectSpaceNormalMap: boolean;
  54941. /**
  54942. * Allows using the bump map in parallax mode.
  54943. */
  54944. protected _useParallax: boolean;
  54945. /**
  54946. * Allows using the bump map in parallax occlusion mode.
  54947. */
  54948. protected _useParallaxOcclusion: boolean;
  54949. /**
  54950. * Controls the scale bias of the parallax mode.
  54951. */
  54952. protected _parallaxScaleBias: number;
  54953. /**
  54954. * If sets to true, disables all the lights affecting the material.
  54955. */
  54956. protected _disableLighting: boolean;
  54957. /**
  54958. * Number of Simultaneous lights allowed on the material.
  54959. */
  54960. protected _maxSimultaneousLights: number;
  54961. /**
  54962. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54963. */
  54964. protected _invertNormalMapX: boolean;
  54965. /**
  54966. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54967. */
  54968. protected _invertNormalMapY: boolean;
  54969. /**
  54970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54971. */
  54972. protected _twoSidedLighting: boolean;
  54973. /**
  54974. * Defines the alpha limits in alpha test mode.
  54975. */
  54976. protected _alphaCutOff: number;
  54977. /**
  54978. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54979. */
  54980. protected _forceAlphaTest: boolean;
  54981. /**
  54982. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54983. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54984. */
  54985. protected _useAlphaFresnel: boolean;
  54986. /**
  54987. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54988. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54989. */
  54990. protected _useLinearAlphaFresnel: boolean;
  54991. /**
  54992. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54993. * from cos thetav and roughness:
  54994. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54995. */
  54996. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54997. /**
  54998. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54999. */
  55000. protected _forceIrradianceInFragment: boolean;
  55001. private _realTimeFiltering;
  55002. /**
  55003. * Enables realtime filtering on the texture.
  55004. */
  55005. get realTimeFiltering(): boolean;
  55006. set realTimeFiltering(b: boolean);
  55007. private _realTimeFilteringQuality;
  55008. /**
  55009. * Quality switch for realtime filtering
  55010. */
  55011. get realTimeFilteringQuality(): number;
  55012. set realTimeFilteringQuality(n: number);
  55013. /**
  55014. * Force normal to face away from face.
  55015. */
  55016. protected _forceNormalForward: boolean;
  55017. /**
  55018. * Enables specular anti aliasing in the PBR shader.
  55019. * It will both interacts on the Geometry for analytical and IBL lighting.
  55020. * It also prefilter the roughness map based on the bump values.
  55021. */
  55022. protected _enableSpecularAntiAliasing: boolean;
  55023. /**
  55024. * Default configuration related to image processing available in the PBR Material.
  55025. */
  55026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55027. /**
  55028. * Keep track of the image processing observer to allow dispose and replace.
  55029. */
  55030. private _imageProcessingObserver;
  55031. /**
  55032. * Attaches a new image processing configuration to the PBR Material.
  55033. * @param configuration
  55034. */
  55035. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55036. /**
  55037. * Stores the available render targets.
  55038. */
  55039. private _renderTargets;
  55040. /**
  55041. * Sets the global ambient color for the material used in lighting calculations.
  55042. */
  55043. private _globalAmbientColor;
  55044. /**
  55045. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55046. */
  55047. private _useLogarithmicDepth;
  55048. /**
  55049. * If set to true, no lighting calculations will be applied.
  55050. */
  55051. private _unlit;
  55052. private _debugMode;
  55053. /**
  55054. * @hidden
  55055. * This is reserved for the inspector.
  55056. * Defines the material debug mode.
  55057. * It helps seeing only some components of the material while troubleshooting.
  55058. */
  55059. debugMode: number;
  55060. /**
  55061. * @hidden
  55062. * This is reserved for the inspector.
  55063. * Specify from where on screen the debug mode should start.
  55064. * The value goes from -1 (full screen) to 1 (not visible)
  55065. * It helps with side by side comparison against the final render
  55066. * This defaults to -1
  55067. */
  55068. private debugLimit;
  55069. /**
  55070. * @hidden
  55071. * This is reserved for the inspector.
  55072. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55073. * You can use the factor to better multiply the final value.
  55074. */
  55075. private debugFactor;
  55076. /**
  55077. * Defines the clear coat layer parameters for the material.
  55078. */
  55079. readonly clearCoat: PBRClearCoatConfiguration;
  55080. /**
  55081. * Defines the anisotropic parameters for the material.
  55082. */
  55083. readonly anisotropy: PBRAnisotropicConfiguration;
  55084. /**
  55085. * Defines the BRDF parameters for the material.
  55086. */
  55087. readonly brdf: PBRBRDFConfiguration;
  55088. /**
  55089. * Defines the Sheen parameters for the material.
  55090. */
  55091. readonly sheen: PBRSheenConfiguration;
  55092. /**
  55093. * Defines the SubSurface parameters for the material.
  55094. */
  55095. readonly subSurface: PBRSubSurfaceConfiguration;
  55096. protected _rebuildInParallel: boolean;
  55097. /**
  55098. * Instantiates a new PBRMaterial instance.
  55099. *
  55100. * @param name The material name
  55101. * @param scene The scene the material will be use in.
  55102. */
  55103. constructor(name: string, scene: Scene);
  55104. /**
  55105. * Gets a boolean indicating that current material needs to register RTT
  55106. */
  55107. get hasRenderTargetTextures(): boolean;
  55108. /**
  55109. * Gets the name of the material class.
  55110. */
  55111. getClassName(): string;
  55112. /**
  55113. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55114. */
  55115. get useLogarithmicDepth(): boolean;
  55116. /**
  55117. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55118. */
  55119. set useLogarithmicDepth(value: boolean);
  55120. /**
  55121. * Returns true if alpha blending should be disabled.
  55122. */
  55123. protected get _disableAlphaBlending(): boolean;
  55124. /**
  55125. * Specifies whether or not this material should be rendered in alpha blend mode.
  55126. */
  55127. needAlphaBlending(): boolean;
  55128. /**
  55129. * Specifies whether or not this material should be rendered in alpha test mode.
  55130. */
  55131. needAlphaTesting(): boolean;
  55132. /**
  55133. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55134. */
  55135. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55136. /**
  55137. * Gets the texture used for the alpha test.
  55138. */
  55139. getAlphaTestTexture(): Nullable<BaseTexture>;
  55140. /**
  55141. * Specifies that the submesh is ready to be used.
  55142. * @param mesh - BJS mesh.
  55143. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55144. * @param useInstances - Specifies that instances should be used.
  55145. * @returns - boolean indicating that the submesh is ready or not.
  55146. */
  55147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55148. /**
  55149. * Specifies if the material uses metallic roughness workflow.
  55150. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55151. */
  55152. isMetallicWorkflow(): boolean;
  55153. private _prepareEffect;
  55154. private _prepareDefines;
  55155. /**
  55156. * Force shader compilation
  55157. */
  55158. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55159. /**
  55160. * Initializes the uniform buffer layout for the shader.
  55161. */
  55162. buildUniformLayout(): void;
  55163. /**
  55164. * Unbinds the material from the mesh
  55165. */
  55166. unbind(): void;
  55167. /**
  55168. * Binds the submesh data.
  55169. * @param world - The world matrix.
  55170. * @param mesh - The BJS mesh.
  55171. * @param subMesh - A submesh of the BJS mesh.
  55172. */
  55173. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55174. /**
  55175. * Returns the animatable textures.
  55176. * @returns - Array of animatable textures.
  55177. */
  55178. getAnimatables(): IAnimatable[];
  55179. /**
  55180. * Returns the texture used for reflections.
  55181. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55182. */
  55183. private _getReflectionTexture;
  55184. /**
  55185. * Returns an array of the actively used textures.
  55186. * @returns - Array of BaseTextures
  55187. */
  55188. getActiveTextures(): BaseTexture[];
  55189. /**
  55190. * Checks to see if a texture is used in the material.
  55191. * @param texture - Base texture to use.
  55192. * @returns - Boolean specifying if a texture is used in the material.
  55193. */
  55194. hasTexture(texture: BaseTexture): boolean;
  55195. /**
  55196. * Disposes the resources of the material.
  55197. * @param forceDisposeEffect - Forces the disposal of effects.
  55198. * @param forceDisposeTextures - Forces the disposal of all textures.
  55199. */
  55200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55201. }
  55202. }
  55203. declare module BABYLON {
  55204. /**
  55205. * The Physically based material of BJS.
  55206. *
  55207. * This offers the main features of a standard PBR material.
  55208. * For more information, please refer to the documentation :
  55209. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55210. */
  55211. export class PBRMaterial extends PBRBaseMaterial {
  55212. /**
  55213. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55214. */
  55215. static readonly PBRMATERIAL_OPAQUE: number;
  55216. /**
  55217. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55218. */
  55219. static readonly PBRMATERIAL_ALPHATEST: number;
  55220. /**
  55221. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55222. */
  55223. static readonly PBRMATERIAL_ALPHABLEND: number;
  55224. /**
  55225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55226. * They are also discarded below the alpha cutoff threshold to improve performances.
  55227. */
  55228. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55229. /**
  55230. * Defines the default value of how much AO map is occluding the analytical lights
  55231. * (point spot...).
  55232. */
  55233. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55234. /**
  55235. * Intensity of the direct lights e.g. the four lights available in your scene.
  55236. * This impacts both the direct diffuse and specular highlights.
  55237. */
  55238. directIntensity: number;
  55239. /**
  55240. * Intensity of the emissive part of the material.
  55241. * This helps controlling the emissive effect without modifying the emissive color.
  55242. */
  55243. emissiveIntensity: number;
  55244. /**
  55245. * Intensity of the environment e.g. how much the environment will light the object
  55246. * either through harmonics for rough material or through the refelction for shiny ones.
  55247. */
  55248. environmentIntensity: number;
  55249. /**
  55250. * This is a special control allowing the reduction of the specular highlights coming from the
  55251. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55252. */
  55253. specularIntensity: number;
  55254. /**
  55255. * Debug Control allowing disabling the bump map on this material.
  55256. */
  55257. disableBumpMap: boolean;
  55258. /**
  55259. * AKA Diffuse Texture in standard nomenclature.
  55260. */
  55261. albedoTexture: BaseTexture;
  55262. /**
  55263. * AKA Occlusion Texture in other nomenclature.
  55264. */
  55265. ambientTexture: BaseTexture;
  55266. /**
  55267. * AKA Occlusion Texture Intensity in other nomenclature.
  55268. */
  55269. ambientTextureStrength: number;
  55270. /**
  55271. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55272. * 1 means it completely occludes it
  55273. * 0 mean it has no impact
  55274. */
  55275. ambientTextureImpactOnAnalyticalLights: number;
  55276. /**
  55277. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55278. */
  55279. opacityTexture: BaseTexture;
  55280. /**
  55281. * Stores the reflection values in a texture.
  55282. */
  55283. reflectionTexture: Nullable<BaseTexture>;
  55284. /**
  55285. * Stores the emissive values in a texture.
  55286. */
  55287. emissiveTexture: BaseTexture;
  55288. /**
  55289. * AKA Specular texture in other nomenclature.
  55290. */
  55291. reflectivityTexture: BaseTexture;
  55292. /**
  55293. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55294. */
  55295. metallicTexture: BaseTexture;
  55296. /**
  55297. * Specifies the metallic scalar of the metallic/roughness workflow.
  55298. * Can also be used to scale the metalness values of the metallic texture.
  55299. */
  55300. metallic: Nullable<number>;
  55301. /**
  55302. * Specifies the roughness scalar of the metallic/roughness workflow.
  55303. * Can also be used to scale the roughness values of the metallic texture.
  55304. */
  55305. roughness: Nullable<number>;
  55306. /**
  55307. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55308. * By default the indexOfrefraction is used to compute F0;
  55309. *
  55310. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55311. *
  55312. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55313. * F90 = metallicReflectanceColor;
  55314. */
  55315. metallicF0Factor: number;
  55316. /**
  55317. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55318. * By default the F90 is always 1;
  55319. *
  55320. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55321. *
  55322. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55323. * F90 = metallicReflectanceColor;
  55324. */
  55325. metallicReflectanceColor: Color3;
  55326. /**
  55327. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55328. * This is multiply against the scalar values defined in the material.
  55329. */
  55330. metallicReflectanceTexture: Nullable<BaseTexture>;
  55331. /**
  55332. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55333. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55334. */
  55335. microSurfaceTexture: BaseTexture;
  55336. /**
  55337. * Stores surface normal data used to displace a mesh in a texture.
  55338. */
  55339. bumpTexture: BaseTexture;
  55340. /**
  55341. * Stores the pre-calculated light information of a mesh in a texture.
  55342. */
  55343. lightmapTexture: BaseTexture;
  55344. /**
  55345. * Stores the refracted light information in a texture.
  55346. */
  55347. get refractionTexture(): Nullable<BaseTexture>;
  55348. set refractionTexture(value: Nullable<BaseTexture>);
  55349. /**
  55350. * The color of a material in ambient lighting.
  55351. */
  55352. ambientColor: Color3;
  55353. /**
  55354. * AKA Diffuse Color in other nomenclature.
  55355. */
  55356. albedoColor: Color3;
  55357. /**
  55358. * AKA Specular Color in other nomenclature.
  55359. */
  55360. reflectivityColor: Color3;
  55361. /**
  55362. * The color reflected from the material.
  55363. */
  55364. reflectionColor: Color3;
  55365. /**
  55366. * The color emitted from the material.
  55367. */
  55368. emissiveColor: Color3;
  55369. /**
  55370. * AKA Glossiness in other nomenclature.
  55371. */
  55372. microSurface: number;
  55373. /**
  55374. * Index of refraction of the material base layer.
  55375. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55376. *
  55377. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55378. *
  55379. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55380. */
  55381. get indexOfRefraction(): number;
  55382. set indexOfRefraction(value: number);
  55383. /**
  55384. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55385. */
  55386. get invertRefractionY(): boolean;
  55387. set invertRefractionY(value: boolean);
  55388. /**
  55389. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55390. * Materials half opaque for instance using refraction could benefit from this control.
  55391. */
  55392. get linkRefractionWithTransparency(): boolean;
  55393. set linkRefractionWithTransparency(value: boolean);
  55394. /**
  55395. * If true, the light map contains occlusion information instead of lighting info.
  55396. */
  55397. useLightmapAsShadowmap: boolean;
  55398. /**
  55399. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55400. */
  55401. useAlphaFromAlbedoTexture: boolean;
  55402. /**
  55403. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55404. */
  55405. forceAlphaTest: boolean;
  55406. /**
  55407. * Defines the alpha limits in alpha test mode.
  55408. */
  55409. alphaCutOff: number;
  55410. /**
  55411. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55412. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55413. */
  55414. useSpecularOverAlpha: boolean;
  55415. /**
  55416. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55417. */
  55418. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55419. /**
  55420. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55421. */
  55422. useRoughnessFromMetallicTextureAlpha: boolean;
  55423. /**
  55424. * Specifies if the metallic texture contains the roughness information in its green channel.
  55425. */
  55426. useRoughnessFromMetallicTextureGreen: boolean;
  55427. /**
  55428. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55429. */
  55430. useMetallnessFromMetallicTextureBlue: boolean;
  55431. /**
  55432. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55433. */
  55434. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55435. /**
  55436. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55437. */
  55438. useAmbientInGrayScale: boolean;
  55439. /**
  55440. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55441. * The material will try to infer what glossiness each pixel should be.
  55442. */
  55443. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55444. /**
  55445. * BJS is using an harcoded light falloff based on a manually sets up range.
  55446. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55447. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55448. */
  55449. get usePhysicalLightFalloff(): boolean;
  55450. /**
  55451. * BJS is using an harcoded light falloff based on a manually sets up range.
  55452. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55453. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55454. */
  55455. set usePhysicalLightFalloff(value: boolean);
  55456. /**
  55457. * In order to support the falloff compatibility with gltf, a special mode has been added
  55458. * to reproduce the gltf light falloff.
  55459. */
  55460. get useGLTFLightFalloff(): boolean;
  55461. /**
  55462. * In order to support the falloff compatibility with gltf, a special mode has been added
  55463. * to reproduce the gltf light falloff.
  55464. */
  55465. set useGLTFLightFalloff(value: boolean);
  55466. /**
  55467. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55468. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55469. */
  55470. useRadianceOverAlpha: boolean;
  55471. /**
  55472. * Allows using an object space normal map (instead of tangent space).
  55473. */
  55474. useObjectSpaceNormalMap: boolean;
  55475. /**
  55476. * Allows using the bump map in parallax mode.
  55477. */
  55478. useParallax: boolean;
  55479. /**
  55480. * Allows using the bump map in parallax occlusion mode.
  55481. */
  55482. useParallaxOcclusion: boolean;
  55483. /**
  55484. * Controls the scale bias of the parallax mode.
  55485. */
  55486. parallaxScaleBias: number;
  55487. /**
  55488. * If sets to true, disables all the lights affecting the material.
  55489. */
  55490. disableLighting: boolean;
  55491. /**
  55492. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55493. */
  55494. forceIrradianceInFragment: boolean;
  55495. /**
  55496. * Number of Simultaneous lights allowed on the material.
  55497. */
  55498. maxSimultaneousLights: number;
  55499. /**
  55500. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55501. */
  55502. invertNormalMapX: boolean;
  55503. /**
  55504. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55505. */
  55506. invertNormalMapY: boolean;
  55507. /**
  55508. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55509. */
  55510. twoSidedLighting: boolean;
  55511. /**
  55512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55513. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55514. */
  55515. useAlphaFresnel: boolean;
  55516. /**
  55517. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55518. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55519. */
  55520. useLinearAlphaFresnel: boolean;
  55521. /**
  55522. * Let user defines the brdf lookup texture used for IBL.
  55523. * A default 8bit version is embedded but you could point at :
  55524. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55525. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55526. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55527. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55528. */
  55529. environmentBRDFTexture: Nullable<BaseTexture>;
  55530. /**
  55531. * Force normal to face away from face.
  55532. */
  55533. forceNormalForward: boolean;
  55534. /**
  55535. * Enables specular anti aliasing in the PBR shader.
  55536. * It will both interacts on the Geometry for analytical and IBL lighting.
  55537. * It also prefilter the roughness map based on the bump values.
  55538. */
  55539. enableSpecularAntiAliasing: boolean;
  55540. /**
  55541. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55542. * makes the reflect vector face the model (under horizon).
  55543. */
  55544. useHorizonOcclusion: boolean;
  55545. /**
  55546. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55547. * too much the area relying on ambient texture to define their ambient occlusion.
  55548. */
  55549. useRadianceOcclusion: boolean;
  55550. /**
  55551. * If set to true, no lighting calculations will be applied.
  55552. */
  55553. unlit: boolean;
  55554. /**
  55555. * Gets the image processing configuration used either in this material.
  55556. */
  55557. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55558. /**
  55559. * Sets the Default image processing configuration used either in the this material.
  55560. *
  55561. * If sets to null, the scene one is in use.
  55562. */
  55563. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55564. /**
  55565. * Gets wether the color curves effect is enabled.
  55566. */
  55567. get cameraColorCurvesEnabled(): boolean;
  55568. /**
  55569. * Sets wether the color curves effect is enabled.
  55570. */
  55571. set cameraColorCurvesEnabled(value: boolean);
  55572. /**
  55573. * Gets wether the color grading effect is enabled.
  55574. */
  55575. get cameraColorGradingEnabled(): boolean;
  55576. /**
  55577. * Gets wether the color grading effect is enabled.
  55578. */
  55579. set cameraColorGradingEnabled(value: boolean);
  55580. /**
  55581. * Gets wether tonemapping is enabled or not.
  55582. */
  55583. get cameraToneMappingEnabled(): boolean;
  55584. /**
  55585. * Sets wether tonemapping is enabled or not
  55586. */
  55587. set cameraToneMappingEnabled(value: boolean);
  55588. /**
  55589. * The camera exposure used on this material.
  55590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55591. * This corresponds to a photographic exposure.
  55592. */
  55593. get cameraExposure(): number;
  55594. /**
  55595. * The camera exposure used on this material.
  55596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55597. * This corresponds to a photographic exposure.
  55598. */
  55599. set cameraExposure(value: number);
  55600. /**
  55601. * Gets The camera contrast used on this material.
  55602. */
  55603. get cameraContrast(): number;
  55604. /**
  55605. * Sets The camera contrast used on this material.
  55606. */
  55607. set cameraContrast(value: number);
  55608. /**
  55609. * Gets the Color Grading 2D Lookup Texture.
  55610. */
  55611. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55612. /**
  55613. * Sets the Color Grading 2D Lookup Texture.
  55614. */
  55615. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55616. /**
  55617. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55618. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55619. * 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;
  55620. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55621. */
  55622. get cameraColorCurves(): Nullable<ColorCurves>;
  55623. /**
  55624. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55625. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55626. * 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;
  55627. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55628. */
  55629. set cameraColorCurves(value: Nullable<ColorCurves>);
  55630. /**
  55631. * Instantiates a new PBRMaterial instance.
  55632. *
  55633. * @param name The material name
  55634. * @param scene The scene the material will be use in.
  55635. */
  55636. constructor(name: string, scene: Scene);
  55637. /**
  55638. * Returns the name of this material class.
  55639. */
  55640. getClassName(): string;
  55641. /**
  55642. * Makes a duplicate of the current material.
  55643. * @param name - name to use for the new material.
  55644. */
  55645. clone(name: string): PBRMaterial;
  55646. /**
  55647. * Serializes this PBR Material.
  55648. * @returns - An object with the serialized material.
  55649. */
  55650. serialize(): any;
  55651. /**
  55652. * Parses a PBR Material from a serialized object.
  55653. * @param source - Serialized object.
  55654. * @param scene - BJS scene instance.
  55655. * @param rootUrl - url for the scene object
  55656. * @returns - PBRMaterial
  55657. */
  55658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55659. }
  55660. }
  55661. declare module BABYLON {
  55662. /**
  55663. * Direct draw surface info
  55664. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55665. */
  55666. export interface DDSInfo {
  55667. /**
  55668. * Width of the texture
  55669. */
  55670. width: number;
  55671. /**
  55672. * Width of the texture
  55673. */
  55674. height: number;
  55675. /**
  55676. * Number of Mipmaps for the texture
  55677. * @see https://en.wikipedia.org/wiki/Mipmap
  55678. */
  55679. mipmapCount: number;
  55680. /**
  55681. * If the textures format is a known fourCC format
  55682. * @see https://www.fourcc.org/
  55683. */
  55684. isFourCC: boolean;
  55685. /**
  55686. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55687. */
  55688. isRGB: boolean;
  55689. /**
  55690. * If the texture is a lumincance format
  55691. */
  55692. isLuminance: boolean;
  55693. /**
  55694. * If this is a cube texture
  55695. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55696. */
  55697. isCube: boolean;
  55698. /**
  55699. * If the texture is a compressed format eg. FOURCC_DXT1
  55700. */
  55701. isCompressed: boolean;
  55702. /**
  55703. * The dxgiFormat of the texture
  55704. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55705. */
  55706. dxgiFormat: number;
  55707. /**
  55708. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55709. */
  55710. textureType: number;
  55711. /**
  55712. * Sphericle polynomial created for the dds texture
  55713. */
  55714. sphericalPolynomial?: SphericalPolynomial;
  55715. }
  55716. /**
  55717. * Class used to provide DDS decompression tools
  55718. */
  55719. export class DDSTools {
  55720. /**
  55721. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55722. */
  55723. static StoreLODInAlphaChannel: boolean;
  55724. /**
  55725. * Gets DDS information from an array buffer
  55726. * @param data defines the array buffer view to read data from
  55727. * @returns the DDS information
  55728. */
  55729. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55730. private static _FloatView;
  55731. private static _Int32View;
  55732. private static _ToHalfFloat;
  55733. private static _FromHalfFloat;
  55734. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55735. private static _GetHalfFloatRGBAArrayBuffer;
  55736. private static _GetFloatRGBAArrayBuffer;
  55737. private static _GetFloatAsUIntRGBAArrayBuffer;
  55738. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55739. private static _GetRGBAArrayBuffer;
  55740. private static _ExtractLongWordOrder;
  55741. private static _GetRGBArrayBuffer;
  55742. private static _GetLuminanceArrayBuffer;
  55743. /**
  55744. * Uploads DDS Levels to a Babylon Texture
  55745. * @hidden
  55746. */
  55747. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55748. }
  55749. interface ThinEngine {
  55750. /**
  55751. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55752. * @param rootUrl defines the url where the file to load is located
  55753. * @param scene defines the current scene
  55754. * @param lodScale defines scale to apply to the mip map selection
  55755. * @param lodOffset defines offset to apply to the mip map selection
  55756. * @param onLoad defines an optional callback raised when the texture is loaded
  55757. * @param onError defines an optional callback raised if there is an issue to load the texture
  55758. * @param format defines the format of the data
  55759. * @param forcedExtension defines the extension to use to pick the right loader
  55760. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55761. * @returns the cube texture as an InternalTexture
  55762. */
  55763. 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;
  55764. }
  55765. }
  55766. declare module BABYLON {
  55767. /**
  55768. * Implementation of the DDS Texture Loader.
  55769. * @hidden
  55770. */
  55771. export class _DDSTextureLoader implements IInternalTextureLoader {
  55772. /**
  55773. * Defines wether the loader supports cascade loading the different faces.
  55774. */
  55775. readonly supportCascades: boolean;
  55776. /**
  55777. * This returns if the loader support the current file information.
  55778. * @param extension defines the file extension of the file being loaded
  55779. * @returns true if the loader can load the specified file
  55780. */
  55781. canLoad(extension: string): boolean;
  55782. /**
  55783. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55784. * @param data contains the texture data
  55785. * @param texture defines the BabylonJS internal texture
  55786. * @param createPolynomials will be true if polynomials have been requested
  55787. * @param onLoad defines the callback to trigger once the texture is ready
  55788. * @param onError defines the callback to trigger in case of error
  55789. */
  55790. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55791. /**
  55792. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55793. * @param data contains the texture data
  55794. * @param texture defines the BabylonJS internal texture
  55795. * @param callback defines the method to call once ready to upload
  55796. */
  55797. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55798. }
  55799. }
  55800. declare module BABYLON {
  55801. /**
  55802. * Implementation of the ENV Texture Loader.
  55803. * @hidden
  55804. */
  55805. export class _ENVTextureLoader implements IInternalTextureLoader {
  55806. /**
  55807. * Defines wether the loader supports cascade loading the different faces.
  55808. */
  55809. readonly supportCascades: boolean;
  55810. /**
  55811. * This returns if the loader support the current file information.
  55812. * @param extension defines the file extension of the file being loaded
  55813. * @returns true if the loader can load the specified file
  55814. */
  55815. canLoad(extension: string): boolean;
  55816. /**
  55817. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55818. * @param data contains the texture data
  55819. * @param texture defines the BabylonJS internal texture
  55820. * @param createPolynomials will be true if polynomials have been requested
  55821. * @param onLoad defines the callback to trigger once the texture is ready
  55822. * @param onError defines the callback to trigger in case of error
  55823. */
  55824. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55825. /**
  55826. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55827. * @param data contains the texture data
  55828. * @param texture defines the BabylonJS internal texture
  55829. * @param callback defines the method to call once ready to upload
  55830. */
  55831. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55832. }
  55833. }
  55834. declare module BABYLON {
  55835. /**
  55836. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55837. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55838. */
  55839. export class KhronosTextureContainer {
  55840. /** contents of the KTX container file */
  55841. data: ArrayBufferView;
  55842. private static HEADER_LEN;
  55843. private static COMPRESSED_2D;
  55844. private static COMPRESSED_3D;
  55845. private static TEX_2D;
  55846. private static TEX_3D;
  55847. /**
  55848. * Gets the openGL type
  55849. */
  55850. glType: number;
  55851. /**
  55852. * Gets the openGL type size
  55853. */
  55854. glTypeSize: number;
  55855. /**
  55856. * Gets the openGL format
  55857. */
  55858. glFormat: number;
  55859. /**
  55860. * Gets the openGL internal format
  55861. */
  55862. glInternalFormat: number;
  55863. /**
  55864. * Gets the base internal format
  55865. */
  55866. glBaseInternalFormat: number;
  55867. /**
  55868. * Gets image width in pixel
  55869. */
  55870. pixelWidth: number;
  55871. /**
  55872. * Gets image height in pixel
  55873. */
  55874. pixelHeight: number;
  55875. /**
  55876. * Gets image depth in pixels
  55877. */
  55878. pixelDepth: number;
  55879. /**
  55880. * Gets the number of array elements
  55881. */
  55882. numberOfArrayElements: number;
  55883. /**
  55884. * Gets the number of faces
  55885. */
  55886. numberOfFaces: number;
  55887. /**
  55888. * Gets the number of mipmap levels
  55889. */
  55890. numberOfMipmapLevels: number;
  55891. /**
  55892. * Gets the bytes of key value data
  55893. */
  55894. bytesOfKeyValueData: number;
  55895. /**
  55896. * Gets the load type
  55897. */
  55898. loadType: number;
  55899. /**
  55900. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55901. */
  55902. isInvalid: boolean;
  55903. /**
  55904. * Creates a new KhronosTextureContainer
  55905. * @param data contents of the KTX container file
  55906. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55907. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55908. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55909. */
  55910. constructor(
  55911. /** contents of the KTX container file */
  55912. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55913. /**
  55914. * Uploads KTX content to a Babylon Texture.
  55915. * It is assumed that the texture has already been created & is currently bound
  55916. * @hidden
  55917. */
  55918. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55919. private _upload2DCompressedLevels;
  55920. /**
  55921. * Checks if the given data starts with a KTX file identifier.
  55922. * @param data the data to check
  55923. * @returns true if the data is a KTX file or false otherwise
  55924. */
  55925. static IsValid(data: ArrayBufferView): boolean;
  55926. }
  55927. }
  55928. declare module BABYLON {
  55929. /**
  55930. * Class for loading KTX2 files
  55931. * !!! Experimental Extension Subject to Changes !!!
  55932. * @hidden
  55933. */
  55934. export class KhronosTextureContainer2 {
  55935. private static _ModulePromise;
  55936. private static _TranscodeFormat;
  55937. constructor(engine: ThinEngine);
  55938. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55939. private _determineTranscodeFormat;
  55940. /**
  55941. * Checks if the given data starts with a KTX2 file identifier.
  55942. * @param data the data to check
  55943. * @returns true if the data is a KTX2 file or false otherwise
  55944. */
  55945. static IsValid(data: ArrayBufferView): boolean;
  55946. }
  55947. }
  55948. declare module BABYLON {
  55949. /**
  55950. * Implementation of the KTX Texture Loader.
  55951. * @hidden
  55952. */
  55953. export class _KTXTextureLoader implements IInternalTextureLoader {
  55954. /**
  55955. * Defines wether the loader supports cascade loading the different faces.
  55956. */
  55957. readonly supportCascades: boolean;
  55958. /**
  55959. * This returns if the loader support the current file information.
  55960. * @param extension defines the file extension of the file being loaded
  55961. * @returns true if the loader can load the specified file
  55962. */
  55963. canLoad(extension: string): boolean;
  55964. /**
  55965. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55966. * @param data contains the texture data
  55967. * @param texture defines the BabylonJS internal texture
  55968. * @param createPolynomials will be true if polynomials have been requested
  55969. * @param onLoad defines the callback to trigger once the texture is ready
  55970. * @param onError defines the callback to trigger in case of error
  55971. */
  55972. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55973. /**
  55974. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55975. * @param data contains the texture data
  55976. * @param texture defines the BabylonJS internal texture
  55977. * @param callback defines the method to call once ready to upload
  55978. */
  55979. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55980. }
  55981. }
  55982. declare module BABYLON {
  55983. /** @hidden */
  55984. export var _forceSceneHelpersToBundle: boolean;
  55985. interface Scene {
  55986. /**
  55987. * Creates a default light for the scene.
  55988. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55989. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55990. */
  55991. createDefaultLight(replace?: boolean): void;
  55992. /**
  55993. * Creates a default camera for the scene.
  55994. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55995. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55996. * @param replace has default false, when true replaces the active camera in the scene
  55997. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55998. */
  55999. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56000. /**
  56001. * Creates a default camera and a default light.
  56002. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56003. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56004. * @param replace has the default false, when true replaces the active camera/light in the scene
  56005. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56006. */
  56007. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56008. /**
  56009. * Creates a new sky box
  56010. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56011. * @param environmentTexture defines the texture to use as environment texture
  56012. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56013. * @param scale defines the overall scale of the skybox
  56014. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56015. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56016. * @returns a new mesh holding the sky box
  56017. */
  56018. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56019. /**
  56020. * Creates a new environment
  56021. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56022. * @param options defines the options you can use to configure the environment
  56023. * @returns the new EnvironmentHelper
  56024. */
  56025. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56026. /**
  56027. * Creates a new VREXperienceHelper
  56028. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56029. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56030. * @returns a new VREXperienceHelper
  56031. */
  56032. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56033. /**
  56034. * Creates a new WebXRDefaultExperience
  56035. * @see http://doc.babylonjs.com/how_to/webxr
  56036. * @param options experience options
  56037. * @returns a promise for a new WebXRDefaultExperience
  56038. */
  56039. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56040. }
  56041. }
  56042. declare module BABYLON {
  56043. /**
  56044. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56045. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56046. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56047. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56048. */
  56049. export class VideoDome extends TransformNode {
  56050. /**
  56051. * Define the video source as a Monoscopic panoramic 360 video.
  56052. */
  56053. static readonly MODE_MONOSCOPIC: number;
  56054. /**
  56055. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56056. */
  56057. static readonly MODE_TOPBOTTOM: number;
  56058. /**
  56059. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56060. */
  56061. static readonly MODE_SIDEBYSIDE: number;
  56062. private _halfDome;
  56063. private _useDirectMapping;
  56064. /**
  56065. * The video texture being displayed on the sphere
  56066. */
  56067. protected _videoTexture: VideoTexture;
  56068. /**
  56069. * Gets the video texture being displayed on the sphere
  56070. */
  56071. get videoTexture(): VideoTexture;
  56072. /**
  56073. * The skybox material
  56074. */
  56075. protected _material: BackgroundMaterial;
  56076. /**
  56077. * The surface used for the skybox
  56078. */
  56079. protected _mesh: Mesh;
  56080. /**
  56081. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56082. */
  56083. private _halfDomeMask;
  56084. /**
  56085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56086. * Also see the options.resolution property.
  56087. */
  56088. get fovMultiplier(): number;
  56089. set fovMultiplier(value: number);
  56090. private _videoMode;
  56091. /**
  56092. * Gets or set the current video mode for the video. It can be:
  56093. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56094. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56095. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56096. */
  56097. get videoMode(): number;
  56098. set videoMode(value: number);
  56099. /**
  56100. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56101. *
  56102. */
  56103. get halfDome(): boolean;
  56104. /**
  56105. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56106. */
  56107. set halfDome(enabled: boolean);
  56108. /**
  56109. * Oberserver used in Stereoscopic VR Mode.
  56110. */
  56111. private _onBeforeCameraRenderObserver;
  56112. /**
  56113. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56114. * @param name Element's name, child elements will append suffixes for their own names.
  56115. * @param urlsOrVideo defines the url(s) or the video element to use
  56116. * @param options An object containing optional or exposed sub element properties
  56117. */
  56118. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56119. resolution?: number;
  56120. clickToPlay?: boolean;
  56121. autoPlay?: boolean;
  56122. loop?: boolean;
  56123. size?: number;
  56124. poster?: string;
  56125. faceForward?: boolean;
  56126. useDirectMapping?: boolean;
  56127. halfDomeMode?: boolean;
  56128. }, scene: Scene);
  56129. private _changeVideoMode;
  56130. /**
  56131. * Releases resources associated with this node.
  56132. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56133. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56134. */
  56135. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56136. }
  56137. }
  56138. declare module BABYLON {
  56139. /**
  56140. * This class can be used to get instrumentation data from a Babylon engine
  56141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56142. */
  56143. export class EngineInstrumentation implements IDisposable {
  56144. /**
  56145. * Define the instrumented engine.
  56146. */
  56147. engine: Engine;
  56148. private _captureGPUFrameTime;
  56149. private _gpuFrameTimeToken;
  56150. private _gpuFrameTime;
  56151. private _captureShaderCompilationTime;
  56152. private _shaderCompilationTime;
  56153. private _onBeginFrameObserver;
  56154. private _onEndFrameObserver;
  56155. private _onBeforeShaderCompilationObserver;
  56156. private _onAfterShaderCompilationObserver;
  56157. /**
  56158. * Gets the perf counter used for GPU frame time
  56159. */
  56160. get gpuFrameTimeCounter(): PerfCounter;
  56161. /**
  56162. * Gets the GPU frame time capture status
  56163. */
  56164. get captureGPUFrameTime(): boolean;
  56165. /**
  56166. * Enable or disable the GPU frame time capture
  56167. */
  56168. set captureGPUFrameTime(value: boolean);
  56169. /**
  56170. * Gets the perf counter used for shader compilation time
  56171. */
  56172. get shaderCompilationTimeCounter(): PerfCounter;
  56173. /**
  56174. * Gets the shader compilation time capture status
  56175. */
  56176. get captureShaderCompilationTime(): boolean;
  56177. /**
  56178. * Enable or disable the shader compilation time capture
  56179. */
  56180. set captureShaderCompilationTime(value: boolean);
  56181. /**
  56182. * Instantiates a new engine instrumentation.
  56183. * This class can be used to get instrumentation data from a Babylon engine
  56184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56185. * @param engine Defines the engine to instrument
  56186. */
  56187. constructor(
  56188. /**
  56189. * Define the instrumented engine.
  56190. */
  56191. engine: Engine);
  56192. /**
  56193. * Dispose and release associated resources.
  56194. */
  56195. dispose(): void;
  56196. }
  56197. }
  56198. declare module BABYLON {
  56199. /**
  56200. * This class can be used to get instrumentation data from a Babylon engine
  56201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56202. */
  56203. export class SceneInstrumentation implements IDisposable {
  56204. /**
  56205. * Defines the scene to instrument
  56206. */
  56207. scene: Scene;
  56208. private _captureActiveMeshesEvaluationTime;
  56209. private _activeMeshesEvaluationTime;
  56210. private _captureRenderTargetsRenderTime;
  56211. private _renderTargetsRenderTime;
  56212. private _captureFrameTime;
  56213. private _frameTime;
  56214. private _captureRenderTime;
  56215. private _renderTime;
  56216. private _captureInterFrameTime;
  56217. private _interFrameTime;
  56218. private _captureParticlesRenderTime;
  56219. private _particlesRenderTime;
  56220. private _captureSpritesRenderTime;
  56221. private _spritesRenderTime;
  56222. private _capturePhysicsTime;
  56223. private _physicsTime;
  56224. private _captureAnimationsTime;
  56225. private _animationsTime;
  56226. private _captureCameraRenderTime;
  56227. private _cameraRenderTime;
  56228. private _onBeforeActiveMeshesEvaluationObserver;
  56229. private _onAfterActiveMeshesEvaluationObserver;
  56230. private _onBeforeRenderTargetsRenderObserver;
  56231. private _onAfterRenderTargetsRenderObserver;
  56232. private _onAfterRenderObserver;
  56233. private _onBeforeDrawPhaseObserver;
  56234. private _onAfterDrawPhaseObserver;
  56235. private _onBeforeAnimationsObserver;
  56236. private _onBeforeParticlesRenderingObserver;
  56237. private _onAfterParticlesRenderingObserver;
  56238. private _onBeforeSpritesRenderingObserver;
  56239. private _onAfterSpritesRenderingObserver;
  56240. private _onBeforePhysicsObserver;
  56241. private _onAfterPhysicsObserver;
  56242. private _onAfterAnimationsObserver;
  56243. private _onBeforeCameraRenderObserver;
  56244. private _onAfterCameraRenderObserver;
  56245. /**
  56246. * Gets the perf counter used for active meshes evaluation time
  56247. */
  56248. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56249. /**
  56250. * Gets the active meshes evaluation time capture status
  56251. */
  56252. get captureActiveMeshesEvaluationTime(): boolean;
  56253. /**
  56254. * Enable or disable the active meshes evaluation time capture
  56255. */
  56256. set captureActiveMeshesEvaluationTime(value: boolean);
  56257. /**
  56258. * Gets the perf counter used for render targets render time
  56259. */
  56260. get renderTargetsRenderTimeCounter(): PerfCounter;
  56261. /**
  56262. * Gets the render targets render time capture status
  56263. */
  56264. get captureRenderTargetsRenderTime(): boolean;
  56265. /**
  56266. * Enable or disable the render targets render time capture
  56267. */
  56268. set captureRenderTargetsRenderTime(value: boolean);
  56269. /**
  56270. * Gets the perf counter used for particles render time
  56271. */
  56272. get particlesRenderTimeCounter(): PerfCounter;
  56273. /**
  56274. * Gets the particles render time capture status
  56275. */
  56276. get captureParticlesRenderTime(): boolean;
  56277. /**
  56278. * Enable or disable the particles render time capture
  56279. */
  56280. set captureParticlesRenderTime(value: boolean);
  56281. /**
  56282. * Gets the perf counter used for sprites render time
  56283. */
  56284. get spritesRenderTimeCounter(): PerfCounter;
  56285. /**
  56286. * Gets the sprites render time capture status
  56287. */
  56288. get captureSpritesRenderTime(): boolean;
  56289. /**
  56290. * Enable or disable the sprites render time capture
  56291. */
  56292. set captureSpritesRenderTime(value: boolean);
  56293. /**
  56294. * Gets the perf counter used for physics time
  56295. */
  56296. get physicsTimeCounter(): PerfCounter;
  56297. /**
  56298. * Gets the physics time capture status
  56299. */
  56300. get capturePhysicsTime(): boolean;
  56301. /**
  56302. * Enable or disable the physics time capture
  56303. */
  56304. set capturePhysicsTime(value: boolean);
  56305. /**
  56306. * Gets the perf counter used for animations time
  56307. */
  56308. get animationsTimeCounter(): PerfCounter;
  56309. /**
  56310. * Gets the animations time capture status
  56311. */
  56312. get captureAnimationsTime(): boolean;
  56313. /**
  56314. * Enable or disable the animations time capture
  56315. */
  56316. set captureAnimationsTime(value: boolean);
  56317. /**
  56318. * Gets the perf counter used for frame time capture
  56319. */
  56320. get frameTimeCounter(): PerfCounter;
  56321. /**
  56322. * Gets the frame time capture status
  56323. */
  56324. get captureFrameTime(): boolean;
  56325. /**
  56326. * Enable or disable the frame time capture
  56327. */
  56328. set captureFrameTime(value: boolean);
  56329. /**
  56330. * Gets the perf counter used for inter-frames time capture
  56331. */
  56332. get interFrameTimeCounter(): PerfCounter;
  56333. /**
  56334. * Gets the inter-frames time capture status
  56335. */
  56336. get captureInterFrameTime(): boolean;
  56337. /**
  56338. * Enable or disable the inter-frames time capture
  56339. */
  56340. set captureInterFrameTime(value: boolean);
  56341. /**
  56342. * Gets the perf counter used for render time capture
  56343. */
  56344. get renderTimeCounter(): PerfCounter;
  56345. /**
  56346. * Gets the render time capture status
  56347. */
  56348. get captureRenderTime(): boolean;
  56349. /**
  56350. * Enable or disable the render time capture
  56351. */
  56352. set captureRenderTime(value: boolean);
  56353. /**
  56354. * Gets the perf counter used for camera render time capture
  56355. */
  56356. get cameraRenderTimeCounter(): PerfCounter;
  56357. /**
  56358. * Gets the camera render time capture status
  56359. */
  56360. get captureCameraRenderTime(): boolean;
  56361. /**
  56362. * Enable or disable the camera render time capture
  56363. */
  56364. set captureCameraRenderTime(value: boolean);
  56365. /**
  56366. * Gets the perf counter used for draw calls
  56367. */
  56368. get drawCallsCounter(): PerfCounter;
  56369. /**
  56370. * Instantiates a new scene instrumentation.
  56371. * This class can be used to get instrumentation data from a Babylon engine
  56372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56373. * @param scene Defines the scene to instrument
  56374. */
  56375. constructor(
  56376. /**
  56377. * Defines the scene to instrument
  56378. */
  56379. scene: Scene);
  56380. /**
  56381. * Dispose and release associated resources.
  56382. */
  56383. dispose(): void;
  56384. }
  56385. }
  56386. declare module BABYLON {
  56387. /** @hidden */
  56388. export var glowMapGenerationPixelShader: {
  56389. name: string;
  56390. shader: string;
  56391. };
  56392. }
  56393. declare module BABYLON {
  56394. /** @hidden */
  56395. export var glowMapGenerationVertexShader: {
  56396. name: string;
  56397. shader: string;
  56398. };
  56399. }
  56400. declare module BABYLON {
  56401. /**
  56402. * Effect layer options. This helps customizing the behaviour
  56403. * of the effect layer.
  56404. */
  56405. export interface IEffectLayerOptions {
  56406. /**
  56407. * Multiplication factor apply to the canvas size to compute the render target size
  56408. * used to generated the objects (the smaller the faster).
  56409. */
  56410. mainTextureRatio: number;
  56411. /**
  56412. * Enforces a fixed size texture to ensure effect stability across devices.
  56413. */
  56414. mainTextureFixedSize?: number;
  56415. /**
  56416. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56417. */
  56418. alphaBlendingMode: number;
  56419. /**
  56420. * The camera attached to the layer.
  56421. */
  56422. camera: Nullable<Camera>;
  56423. /**
  56424. * The rendering group to draw the layer in.
  56425. */
  56426. renderingGroupId: number;
  56427. }
  56428. /**
  56429. * The effect layer Helps adding post process effect blended with the main pass.
  56430. *
  56431. * This can be for instance use to generate glow or higlight effects on the scene.
  56432. *
  56433. * The effect layer class can not be used directly and is intented to inherited from to be
  56434. * customized per effects.
  56435. */
  56436. export abstract class EffectLayer {
  56437. private _vertexBuffers;
  56438. private _indexBuffer;
  56439. private _cachedDefines;
  56440. private _effectLayerMapGenerationEffect;
  56441. private _effectLayerOptions;
  56442. private _mergeEffect;
  56443. protected _scene: Scene;
  56444. protected _engine: Engine;
  56445. protected _maxSize: number;
  56446. protected _mainTextureDesiredSize: ISize;
  56447. protected _mainTexture: RenderTargetTexture;
  56448. protected _shouldRender: boolean;
  56449. protected _postProcesses: PostProcess[];
  56450. protected _textures: BaseTexture[];
  56451. protected _emissiveTextureAndColor: {
  56452. texture: Nullable<BaseTexture>;
  56453. color: Color4;
  56454. };
  56455. /**
  56456. * The name of the layer
  56457. */
  56458. name: string;
  56459. /**
  56460. * The clear color of the texture used to generate the glow map.
  56461. */
  56462. neutralColor: Color4;
  56463. /**
  56464. * Specifies whether the highlight layer is enabled or not.
  56465. */
  56466. isEnabled: boolean;
  56467. /**
  56468. * Gets the camera attached to the layer.
  56469. */
  56470. get camera(): Nullable<Camera>;
  56471. /**
  56472. * Gets the rendering group id the layer should render in.
  56473. */
  56474. get renderingGroupId(): number;
  56475. set renderingGroupId(renderingGroupId: number);
  56476. /**
  56477. * An event triggered when the effect layer has been disposed.
  56478. */
  56479. onDisposeObservable: Observable<EffectLayer>;
  56480. /**
  56481. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56482. */
  56483. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56484. /**
  56485. * An event triggered when the generated texture is being merged in the scene.
  56486. */
  56487. onBeforeComposeObservable: Observable<EffectLayer>;
  56488. /**
  56489. * An event triggered when the mesh is rendered into the effect render target.
  56490. */
  56491. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56492. /**
  56493. * An event triggered after the mesh has been rendered into the effect render target.
  56494. */
  56495. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56496. /**
  56497. * An event triggered when the generated texture has been merged in the scene.
  56498. */
  56499. onAfterComposeObservable: Observable<EffectLayer>;
  56500. /**
  56501. * An event triggered when the efffect layer changes its size.
  56502. */
  56503. onSizeChangedObservable: Observable<EffectLayer>;
  56504. /** @hidden */
  56505. static _SceneComponentInitialization: (scene: Scene) => void;
  56506. /**
  56507. * Instantiates a new effect Layer and references it in the scene.
  56508. * @param name The name of the layer
  56509. * @param scene The scene to use the layer in
  56510. */
  56511. constructor(
  56512. /** The Friendly of the effect in the scene */
  56513. name: string, scene: Scene);
  56514. /**
  56515. * Get the effect name of the layer.
  56516. * @return The effect name
  56517. */
  56518. abstract getEffectName(): string;
  56519. /**
  56520. * Checks for the readiness of the element composing the layer.
  56521. * @param subMesh the mesh to check for
  56522. * @param useInstances specify whether or not to use instances to render the mesh
  56523. * @return true if ready otherwise, false
  56524. */
  56525. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56526. /**
  56527. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56528. * @returns true if the effect requires stencil during the main canvas render pass.
  56529. */
  56530. abstract needStencil(): boolean;
  56531. /**
  56532. * Create the merge effect. This is the shader use to blit the information back
  56533. * to the main canvas at the end of the scene rendering.
  56534. * @returns The effect containing the shader used to merge the effect on the main canvas
  56535. */
  56536. protected abstract _createMergeEffect(): Effect;
  56537. /**
  56538. * Creates the render target textures and post processes used in the effect layer.
  56539. */
  56540. protected abstract _createTextureAndPostProcesses(): void;
  56541. /**
  56542. * Implementation specific of rendering the generating effect on the main canvas.
  56543. * @param effect The effect used to render through
  56544. */
  56545. protected abstract _internalRender(effect: Effect): void;
  56546. /**
  56547. * Sets the required values for both the emissive texture and and the main color.
  56548. */
  56549. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56550. /**
  56551. * Free any resources and references associated to a mesh.
  56552. * Internal use
  56553. * @param mesh The mesh to free.
  56554. */
  56555. abstract _disposeMesh(mesh: Mesh): void;
  56556. /**
  56557. * Serializes this layer (Glow or Highlight for example)
  56558. * @returns a serialized layer object
  56559. */
  56560. abstract serialize?(): any;
  56561. /**
  56562. * Initializes the effect layer with the required options.
  56563. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56564. */
  56565. protected _init(options: Partial<IEffectLayerOptions>): void;
  56566. /**
  56567. * Generates the index buffer of the full screen quad blending to the main canvas.
  56568. */
  56569. private _generateIndexBuffer;
  56570. /**
  56571. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56572. */
  56573. private _generateVertexBuffer;
  56574. /**
  56575. * Sets the main texture desired size which is the closest power of two
  56576. * of the engine canvas size.
  56577. */
  56578. private _setMainTextureSize;
  56579. /**
  56580. * Creates the main texture for the effect layer.
  56581. */
  56582. protected _createMainTexture(): void;
  56583. /**
  56584. * Adds specific effects defines.
  56585. * @param defines The defines to add specifics to.
  56586. */
  56587. protected _addCustomEffectDefines(defines: string[]): void;
  56588. /**
  56589. * Checks for the readiness of the element composing the layer.
  56590. * @param subMesh the mesh to check for
  56591. * @param useInstances specify whether or not to use instances to render the mesh
  56592. * @param emissiveTexture the associated emissive texture used to generate the glow
  56593. * @return true if ready otherwise, false
  56594. */
  56595. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56596. /**
  56597. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56598. */
  56599. render(): void;
  56600. /**
  56601. * Determine if a given mesh will be used in the current effect.
  56602. * @param mesh mesh to test
  56603. * @returns true if the mesh will be used
  56604. */
  56605. hasMesh(mesh: AbstractMesh): boolean;
  56606. /**
  56607. * Returns true if the layer contains information to display, otherwise false.
  56608. * @returns true if the glow layer should be rendered
  56609. */
  56610. shouldRender(): boolean;
  56611. /**
  56612. * Returns true if the mesh should render, otherwise false.
  56613. * @param mesh The mesh to render
  56614. * @returns true if it should render otherwise false
  56615. */
  56616. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56617. /**
  56618. * Returns true if the mesh can be rendered, otherwise false.
  56619. * @param mesh The mesh to render
  56620. * @param material The material used on the mesh
  56621. * @returns true if it can be rendered otherwise false
  56622. */
  56623. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56624. /**
  56625. * Returns true if the mesh should render, otherwise false.
  56626. * @param mesh The mesh to render
  56627. * @returns true if it should render otherwise false
  56628. */
  56629. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56630. /**
  56631. * Renders the submesh passed in parameter to the generation map.
  56632. */
  56633. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56634. /**
  56635. * Defines whether the current material of the mesh should be use to render the effect.
  56636. * @param mesh defines the current mesh to render
  56637. */
  56638. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56639. /**
  56640. * Rebuild the required buffers.
  56641. * @hidden Internal use only.
  56642. */
  56643. _rebuild(): void;
  56644. /**
  56645. * Dispose only the render target textures and post process.
  56646. */
  56647. private _disposeTextureAndPostProcesses;
  56648. /**
  56649. * Dispose the highlight layer and free resources.
  56650. */
  56651. dispose(): void;
  56652. /**
  56653. * Gets the class name of the effect layer
  56654. * @returns the string with the class name of the effect layer
  56655. */
  56656. getClassName(): string;
  56657. /**
  56658. * Creates an effect layer from parsed effect layer data
  56659. * @param parsedEffectLayer defines effect layer data
  56660. * @param scene defines the current scene
  56661. * @param rootUrl defines the root URL containing the effect layer information
  56662. * @returns a parsed effect Layer
  56663. */
  56664. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. interface AbstractScene {
  56669. /**
  56670. * The list of effect layers (highlights/glow) added to the scene
  56671. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56672. * @see http://doc.babylonjs.com/how_to/glow_layer
  56673. */
  56674. effectLayers: Array<EffectLayer>;
  56675. /**
  56676. * Removes the given effect layer from this scene.
  56677. * @param toRemove defines the effect layer to remove
  56678. * @returns the index of the removed effect layer
  56679. */
  56680. removeEffectLayer(toRemove: EffectLayer): number;
  56681. /**
  56682. * Adds the given effect layer to this scene
  56683. * @param newEffectLayer defines the effect layer to add
  56684. */
  56685. addEffectLayer(newEffectLayer: EffectLayer): void;
  56686. }
  56687. /**
  56688. * Defines the layer scene component responsible to manage any effect layers
  56689. * in a given scene.
  56690. */
  56691. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56692. /**
  56693. * The component name helpfull to identify the component in the list of scene components.
  56694. */
  56695. readonly name: string;
  56696. /**
  56697. * The scene the component belongs to.
  56698. */
  56699. scene: Scene;
  56700. private _engine;
  56701. private _renderEffects;
  56702. private _needStencil;
  56703. private _previousStencilState;
  56704. /**
  56705. * Creates a new instance of the component for the given scene
  56706. * @param scene Defines the scene to register the component in
  56707. */
  56708. constructor(scene: Scene);
  56709. /**
  56710. * Registers the component in a given scene
  56711. */
  56712. register(): void;
  56713. /**
  56714. * Rebuilds the elements related to this component in case of
  56715. * context lost for instance.
  56716. */
  56717. rebuild(): void;
  56718. /**
  56719. * Serializes the component data to the specified json object
  56720. * @param serializationObject The object to serialize to
  56721. */
  56722. serialize(serializationObject: any): void;
  56723. /**
  56724. * Adds all the elements from the container to the scene
  56725. * @param container the container holding the elements
  56726. */
  56727. addFromContainer(container: AbstractScene): void;
  56728. /**
  56729. * Removes all the elements in the container from the scene
  56730. * @param container contains the elements to remove
  56731. * @param dispose if the removed element should be disposed (default: false)
  56732. */
  56733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56734. /**
  56735. * Disposes the component and the associated ressources.
  56736. */
  56737. dispose(): void;
  56738. private _isReadyForMesh;
  56739. private _renderMainTexture;
  56740. private _setStencil;
  56741. private _setStencilBack;
  56742. private _draw;
  56743. private _drawCamera;
  56744. private _drawRenderingGroup;
  56745. }
  56746. }
  56747. declare module BABYLON {
  56748. /** @hidden */
  56749. export var glowMapMergePixelShader: {
  56750. name: string;
  56751. shader: string;
  56752. };
  56753. }
  56754. declare module BABYLON {
  56755. /** @hidden */
  56756. export var glowMapMergeVertexShader: {
  56757. name: string;
  56758. shader: string;
  56759. };
  56760. }
  56761. declare module BABYLON {
  56762. interface AbstractScene {
  56763. /**
  56764. * Return a the first highlight layer of the scene with a given name.
  56765. * @param name The name of the highlight layer to look for.
  56766. * @return The highlight layer if found otherwise null.
  56767. */
  56768. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56769. }
  56770. /**
  56771. * Glow layer options. This helps customizing the behaviour
  56772. * of the glow layer.
  56773. */
  56774. export interface IGlowLayerOptions {
  56775. /**
  56776. * Multiplication factor apply to the canvas size to compute the render target size
  56777. * used to generated the glowing objects (the smaller the faster).
  56778. */
  56779. mainTextureRatio: number;
  56780. /**
  56781. * Enforces a fixed size texture to ensure resize independant blur.
  56782. */
  56783. mainTextureFixedSize?: number;
  56784. /**
  56785. * How big is the kernel of the blur texture.
  56786. */
  56787. blurKernelSize: number;
  56788. /**
  56789. * The camera attached to the layer.
  56790. */
  56791. camera: Nullable<Camera>;
  56792. /**
  56793. * Enable MSAA by chosing the number of samples.
  56794. */
  56795. mainTextureSamples?: number;
  56796. /**
  56797. * The rendering group to draw the layer in.
  56798. */
  56799. renderingGroupId: number;
  56800. }
  56801. /**
  56802. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56803. *
  56804. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56805. *
  56806. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56807. */
  56808. export class GlowLayer extends EffectLayer {
  56809. /**
  56810. * Effect Name of the layer.
  56811. */
  56812. static readonly EffectName: string;
  56813. /**
  56814. * The default blur kernel size used for the glow.
  56815. */
  56816. static DefaultBlurKernelSize: number;
  56817. /**
  56818. * The default texture size ratio used for the glow.
  56819. */
  56820. static DefaultTextureRatio: number;
  56821. /**
  56822. * Sets the kernel size of the blur.
  56823. */
  56824. set blurKernelSize(value: number);
  56825. /**
  56826. * Gets the kernel size of the blur.
  56827. */
  56828. get blurKernelSize(): number;
  56829. /**
  56830. * Sets the glow intensity.
  56831. */
  56832. set intensity(value: number);
  56833. /**
  56834. * Gets the glow intensity.
  56835. */
  56836. get intensity(): number;
  56837. private _options;
  56838. private _intensity;
  56839. private _horizontalBlurPostprocess1;
  56840. private _verticalBlurPostprocess1;
  56841. private _horizontalBlurPostprocess2;
  56842. private _verticalBlurPostprocess2;
  56843. private _blurTexture1;
  56844. private _blurTexture2;
  56845. private _postProcesses1;
  56846. private _postProcesses2;
  56847. private _includedOnlyMeshes;
  56848. private _excludedMeshes;
  56849. private _meshesUsingTheirOwnMaterials;
  56850. /**
  56851. * Callback used to let the user override the color selection on a per mesh basis
  56852. */
  56853. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56854. /**
  56855. * Callback used to let the user override the texture selection on a per mesh basis
  56856. */
  56857. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56858. /**
  56859. * Instantiates a new glow Layer and references it to the scene.
  56860. * @param name The name of the layer
  56861. * @param scene The scene to use the layer in
  56862. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56863. */
  56864. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56865. /**
  56866. * Get the effect name of the layer.
  56867. * @return The effect name
  56868. */
  56869. getEffectName(): string;
  56870. /**
  56871. * Create the merge effect. This is the shader use to blit the information back
  56872. * to the main canvas at the end of the scene rendering.
  56873. */
  56874. protected _createMergeEffect(): Effect;
  56875. /**
  56876. * Creates the render target textures and post processes used in the glow layer.
  56877. */
  56878. protected _createTextureAndPostProcesses(): void;
  56879. /**
  56880. * Checks for the readiness of the element composing the layer.
  56881. * @param subMesh the mesh to check for
  56882. * @param useInstances specify wether or not to use instances to render the mesh
  56883. * @param emissiveTexture the associated emissive texture used to generate the glow
  56884. * @return true if ready otherwise, false
  56885. */
  56886. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56887. /**
  56888. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56889. */
  56890. needStencil(): boolean;
  56891. /**
  56892. * Returns true if the mesh can be rendered, otherwise false.
  56893. * @param mesh The mesh to render
  56894. * @param material The material used on the mesh
  56895. * @returns true if it can be rendered otherwise false
  56896. */
  56897. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56898. /**
  56899. * Implementation specific of rendering the generating effect on the main canvas.
  56900. * @param effect The effect used to render through
  56901. */
  56902. protected _internalRender(effect: Effect): void;
  56903. /**
  56904. * Sets the required values for both the emissive texture and and the main color.
  56905. */
  56906. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56907. /**
  56908. * Returns true if the mesh should render, otherwise false.
  56909. * @param mesh The mesh to render
  56910. * @returns true if it should render otherwise false
  56911. */
  56912. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56913. /**
  56914. * Adds specific effects defines.
  56915. * @param defines The defines to add specifics to.
  56916. */
  56917. protected _addCustomEffectDefines(defines: string[]): void;
  56918. /**
  56919. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56920. * @param mesh The mesh to exclude from the glow layer
  56921. */
  56922. addExcludedMesh(mesh: Mesh): void;
  56923. /**
  56924. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56925. * @param mesh The mesh to remove
  56926. */
  56927. removeExcludedMesh(mesh: Mesh): void;
  56928. /**
  56929. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56930. * @param mesh The mesh to include in the glow layer
  56931. */
  56932. addIncludedOnlyMesh(mesh: Mesh): void;
  56933. /**
  56934. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56935. * @param mesh The mesh to remove
  56936. */
  56937. removeIncludedOnlyMesh(mesh: Mesh): void;
  56938. /**
  56939. * Determine if a given mesh will be used in the glow layer
  56940. * @param mesh The mesh to test
  56941. * @returns true if the mesh will be highlighted by the current glow layer
  56942. */
  56943. hasMesh(mesh: AbstractMesh): boolean;
  56944. /**
  56945. * Defines whether the current material of the mesh should be use to render the effect.
  56946. * @param mesh defines the current mesh to render
  56947. */
  56948. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56949. /**
  56950. * Add a mesh to be rendered through its own material and not with emissive only.
  56951. * @param mesh The mesh for which we need to use its material
  56952. */
  56953. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56954. /**
  56955. * Remove a mesh from being rendered through its own material and not with emissive only.
  56956. * @param mesh The mesh for which we need to not use its material
  56957. */
  56958. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56959. /**
  56960. * Free any resources and references associated to a mesh.
  56961. * Internal use
  56962. * @param mesh The mesh to free.
  56963. * @hidden
  56964. */
  56965. _disposeMesh(mesh: Mesh): void;
  56966. /**
  56967. * Gets the class name of the effect layer
  56968. * @returns the string with the class name of the effect layer
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Serializes this glow layer
  56973. * @returns a serialized glow layer object
  56974. */
  56975. serialize(): any;
  56976. /**
  56977. * Creates a Glow Layer from parsed glow layer data
  56978. * @param parsedGlowLayer defines glow layer data
  56979. * @param scene defines the current scene
  56980. * @param rootUrl defines the root URL containing the glow layer information
  56981. * @returns a parsed Glow Layer
  56982. */
  56983. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56984. }
  56985. }
  56986. declare module BABYLON {
  56987. /** @hidden */
  56988. export var glowBlurPostProcessPixelShader: {
  56989. name: string;
  56990. shader: string;
  56991. };
  56992. }
  56993. declare module BABYLON {
  56994. interface AbstractScene {
  56995. /**
  56996. * Return a the first highlight layer of the scene with a given name.
  56997. * @param name The name of the highlight layer to look for.
  56998. * @return The highlight layer if found otherwise null.
  56999. */
  57000. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57001. }
  57002. /**
  57003. * Highlight layer options. This helps customizing the behaviour
  57004. * of the highlight layer.
  57005. */
  57006. export interface IHighlightLayerOptions {
  57007. /**
  57008. * Multiplication factor apply to the canvas size to compute the render target size
  57009. * used to generated the glowing objects (the smaller the faster).
  57010. */
  57011. mainTextureRatio: number;
  57012. /**
  57013. * Enforces a fixed size texture to ensure resize independant blur.
  57014. */
  57015. mainTextureFixedSize?: number;
  57016. /**
  57017. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57018. * of the picture to blur (the smaller the faster).
  57019. */
  57020. blurTextureSizeRatio: number;
  57021. /**
  57022. * How big in texel of the blur texture is the vertical blur.
  57023. */
  57024. blurVerticalSize: number;
  57025. /**
  57026. * How big in texel of the blur texture is the horizontal blur.
  57027. */
  57028. blurHorizontalSize: number;
  57029. /**
  57030. * Alpha blending mode used to apply the blur. Default is combine.
  57031. */
  57032. alphaBlendingMode: number;
  57033. /**
  57034. * The camera attached to the layer.
  57035. */
  57036. camera: Nullable<Camera>;
  57037. /**
  57038. * Should we display highlight as a solid stroke?
  57039. */
  57040. isStroke?: boolean;
  57041. /**
  57042. * The rendering group to draw the layer in.
  57043. */
  57044. renderingGroupId: number;
  57045. }
  57046. /**
  57047. * The highlight layer Helps adding a glow effect around a mesh.
  57048. *
  57049. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57050. * glowy meshes to your scene.
  57051. *
  57052. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57053. */
  57054. export class HighlightLayer extends EffectLayer {
  57055. name: string;
  57056. /**
  57057. * Effect Name of the highlight layer.
  57058. */
  57059. static readonly EffectName: string;
  57060. /**
  57061. * The neutral color used during the preparation of the glow effect.
  57062. * This is black by default as the blend operation is a blend operation.
  57063. */
  57064. static NeutralColor: Color4;
  57065. /**
  57066. * Stencil value used for glowing meshes.
  57067. */
  57068. static GlowingMeshStencilReference: number;
  57069. /**
  57070. * Stencil value used for the other meshes in the scene.
  57071. */
  57072. static NormalMeshStencilReference: number;
  57073. /**
  57074. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57075. */
  57076. innerGlow: boolean;
  57077. /**
  57078. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57079. */
  57080. outerGlow: boolean;
  57081. /**
  57082. * Specifies the horizontal size of the blur.
  57083. */
  57084. set blurHorizontalSize(value: number);
  57085. /**
  57086. * Specifies the vertical size of the blur.
  57087. */
  57088. set blurVerticalSize(value: number);
  57089. /**
  57090. * Gets the horizontal size of the blur.
  57091. */
  57092. get blurHorizontalSize(): number;
  57093. /**
  57094. * Gets the vertical size of the blur.
  57095. */
  57096. get blurVerticalSize(): number;
  57097. /**
  57098. * An event triggered when the highlight layer is being blurred.
  57099. */
  57100. onBeforeBlurObservable: Observable<HighlightLayer>;
  57101. /**
  57102. * An event triggered when the highlight layer has been blurred.
  57103. */
  57104. onAfterBlurObservable: Observable<HighlightLayer>;
  57105. private _instanceGlowingMeshStencilReference;
  57106. private _options;
  57107. private _downSamplePostprocess;
  57108. private _horizontalBlurPostprocess;
  57109. private _verticalBlurPostprocess;
  57110. private _blurTexture;
  57111. private _meshes;
  57112. private _excludedMeshes;
  57113. /**
  57114. * Instantiates a new highlight Layer and references it to the scene..
  57115. * @param name The name of the layer
  57116. * @param scene The scene to use the layer in
  57117. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57118. */
  57119. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57120. /**
  57121. * Get the effect name of the layer.
  57122. * @return The effect name
  57123. */
  57124. getEffectName(): string;
  57125. /**
  57126. * Create the merge effect. This is the shader use to blit the information back
  57127. * to the main canvas at the end of the scene rendering.
  57128. */
  57129. protected _createMergeEffect(): Effect;
  57130. /**
  57131. * Creates the render target textures and post processes used in the highlight layer.
  57132. */
  57133. protected _createTextureAndPostProcesses(): void;
  57134. /**
  57135. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57136. */
  57137. needStencil(): boolean;
  57138. /**
  57139. * Checks for the readiness of the element composing the layer.
  57140. * @param subMesh the mesh to check for
  57141. * @param useInstances specify wether or not to use instances to render the mesh
  57142. * @param emissiveTexture the associated emissive texture used to generate the glow
  57143. * @return true if ready otherwise, false
  57144. */
  57145. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57146. /**
  57147. * Implementation specific of rendering the generating effect on the main canvas.
  57148. * @param effect The effect used to render through
  57149. */
  57150. protected _internalRender(effect: Effect): void;
  57151. /**
  57152. * Returns true if the layer contains information to display, otherwise false.
  57153. */
  57154. shouldRender(): boolean;
  57155. /**
  57156. * Returns true if the mesh should render, otherwise false.
  57157. * @param mesh The mesh to render
  57158. * @returns true if it should render otherwise false
  57159. */
  57160. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57161. /**
  57162. * Adds specific effects defines.
  57163. * @param defines The defines to add specifics to.
  57164. */
  57165. protected _addCustomEffectDefines(defines: string[]): void;
  57166. /**
  57167. * Sets the required values for both the emissive texture and and the main color.
  57168. */
  57169. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57170. /**
  57171. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57172. * @param mesh The mesh to exclude from the highlight layer
  57173. */
  57174. addExcludedMesh(mesh: Mesh): void;
  57175. /**
  57176. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57177. * @param mesh The mesh to highlight
  57178. */
  57179. removeExcludedMesh(mesh: Mesh): void;
  57180. /**
  57181. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57182. * @param mesh mesh to test
  57183. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57184. */
  57185. hasMesh(mesh: AbstractMesh): boolean;
  57186. /**
  57187. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57188. * @param mesh The mesh to highlight
  57189. * @param color The color of the highlight
  57190. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57191. */
  57192. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57193. /**
  57194. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57195. * @param mesh The mesh to highlight
  57196. */
  57197. removeMesh(mesh: Mesh): void;
  57198. /**
  57199. * Remove all the meshes currently referenced in the highlight layer
  57200. */
  57201. removeAllMeshes(): void;
  57202. /**
  57203. * Force the stencil to the normal expected value for none glowing parts
  57204. */
  57205. private _defaultStencilReference;
  57206. /**
  57207. * Free any resources and references associated to a mesh.
  57208. * Internal use
  57209. * @param mesh The mesh to free.
  57210. * @hidden
  57211. */
  57212. _disposeMesh(mesh: Mesh): void;
  57213. /**
  57214. * Dispose the highlight layer and free resources.
  57215. */
  57216. dispose(): void;
  57217. /**
  57218. * Gets the class name of the effect layer
  57219. * @returns the string with the class name of the effect layer
  57220. */
  57221. getClassName(): string;
  57222. /**
  57223. * Serializes this Highlight layer
  57224. * @returns a serialized Highlight layer object
  57225. */
  57226. serialize(): any;
  57227. /**
  57228. * Creates a Highlight layer from parsed Highlight layer data
  57229. * @param parsedHightlightLayer defines the Highlight layer data
  57230. * @param scene defines the current scene
  57231. * @param rootUrl defines the root URL containing the Highlight layer information
  57232. * @returns a parsed Highlight layer
  57233. */
  57234. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57235. }
  57236. }
  57237. declare module BABYLON {
  57238. interface AbstractScene {
  57239. /**
  57240. * The list of layers (background and foreground) of the scene
  57241. */
  57242. layers: Array<Layer>;
  57243. }
  57244. /**
  57245. * Defines the layer scene component responsible to manage any layers
  57246. * in a given scene.
  57247. */
  57248. export class LayerSceneComponent implements ISceneComponent {
  57249. /**
  57250. * The component name helpfull to identify the component in the list of scene components.
  57251. */
  57252. readonly name: string;
  57253. /**
  57254. * The scene the component belongs to.
  57255. */
  57256. scene: Scene;
  57257. private _engine;
  57258. /**
  57259. * Creates a new instance of the component for the given scene
  57260. * @param scene Defines the scene to register the component in
  57261. */
  57262. constructor(scene: Scene);
  57263. /**
  57264. * Registers the component in a given scene
  57265. */
  57266. register(): void;
  57267. /**
  57268. * Rebuilds the elements related to this component in case of
  57269. * context lost for instance.
  57270. */
  57271. rebuild(): void;
  57272. /**
  57273. * Disposes the component and the associated ressources.
  57274. */
  57275. dispose(): void;
  57276. private _draw;
  57277. private _drawCameraPredicate;
  57278. private _drawCameraBackground;
  57279. private _drawCameraForeground;
  57280. private _drawRenderTargetPredicate;
  57281. private _drawRenderTargetBackground;
  57282. private _drawRenderTargetForeground;
  57283. /**
  57284. * Adds all the elements from the container to the scene
  57285. * @param container the container holding the elements
  57286. */
  57287. addFromContainer(container: AbstractScene): void;
  57288. /**
  57289. * Removes all the elements in the container from the scene
  57290. * @param container contains the elements to remove
  57291. * @param dispose if the removed element should be disposed (default: false)
  57292. */
  57293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57294. }
  57295. }
  57296. declare module BABYLON {
  57297. /** @hidden */
  57298. export var layerPixelShader: {
  57299. name: string;
  57300. shader: string;
  57301. };
  57302. }
  57303. declare module BABYLON {
  57304. /** @hidden */
  57305. export var layerVertexShader: {
  57306. name: string;
  57307. shader: string;
  57308. };
  57309. }
  57310. declare module BABYLON {
  57311. /**
  57312. * This represents a full screen 2d layer.
  57313. * This can be useful to display a picture in the background of your scene for instance.
  57314. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57315. */
  57316. export class Layer {
  57317. /**
  57318. * Define the name of the layer.
  57319. */
  57320. name: string;
  57321. /**
  57322. * Define the texture the layer should display.
  57323. */
  57324. texture: Nullable<Texture>;
  57325. /**
  57326. * Is the layer in background or foreground.
  57327. */
  57328. isBackground: boolean;
  57329. /**
  57330. * Define the color of the layer (instead of texture).
  57331. */
  57332. color: Color4;
  57333. /**
  57334. * Define the scale of the layer in order to zoom in out of the texture.
  57335. */
  57336. scale: Vector2;
  57337. /**
  57338. * Define an offset for the layer in order to shift the texture.
  57339. */
  57340. offset: Vector2;
  57341. /**
  57342. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57343. */
  57344. alphaBlendingMode: number;
  57345. /**
  57346. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57347. * Alpha test will not mix with the background color in case of transparency.
  57348. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57349. */
  57350. alphaTest: boolean;
  57351. /**
  57352. * Define a mask to restrict the layer to only some of the scene cameras.
  57353. */
  57354. layerMask: number;
  57355. /**
  57356. * Define the list of render target the layer is visible into.
  57357. */
  57358. renderTargetTextures: RenderTargetTexture[];
  57359. /**
  57360. * Define if the layer is only used in renderTarget or if it also
  57361. * renders in the main frame buffer of the canvas.
  57362. */
  57363. renderOnlyInRenderTargetTextures: boolean;
  57364. private _scene;
  57365. private _vertexBuffers;
  57366. private _indexBuffer;
  57367. private _effect;
  57368. private _previousDefines;
  57369. /**
  57370. * An event triggered when the layer is disposed.
  57371. */
  57372. onDisposeObservable: Observable<Layer>;
  57373. private _onDisposeObserver;
  57374. /**
  57375. * Back compatibility with callback before the onDisposeObservable existed.
  57376. * The set callback will be triggered when the layer has been disposed.
  57377. */
  57378. set onDispose(callback: () => void);
  57379. /**
  57380. * An event triggered before rendering the scene
  57381. */
  57382. onBeforeRenderObservable: Observable<Layer>;
  57383. private _onBeforeRenderObserver;
  57384. /**
  57385. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57386. * The set callback will be triggered just before rendering the layer.
  57387. */
  57388. set onBeforeRender(callback: () => void);
  57389. /**
  57390. * An event triggered after rendering the scene
  57391. */
  57392. onAfterRenderObservable: Observable<Layer>;
  57393. private _onAfterRenderObserver;
  57394. /**
  57395. * Back compatibility with callback before the onAfterRenderObservable existed.
  57396. * The set callback will be triggered just after rendering the layer.
  57397. */
  57398. set onAfterRender(callback: () => void);
  57399. /**
  57400. * Instantiates a new layer.
  57401. * This represents a full screen 2d layer.
  57402. * This can be useful to display a picture in the background of your scene for instance.
  57403. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57404. * @param name Define the name of the layer in the scene
  57405. * @param imgUrl Define the url of the texture to display in the layer
  57406. * @param scene Define the scene the layer belongs to
  57407. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57408. * @param color Defines a color for the layer
  57409. */
  57410. constructor(
  57411. /**
  57412. * Define the name of the layer.
  57413. */
  57414. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57415. private _createIndexBuffer;
  57416. /** @hidden */
  57417. _rebuild(): void;
  57418. /**
  57419. * Renders the layer in the scene.
  57420. */
  57421. render(): void;
  57422. /**
  57423. * Disposes and releases the associated ressources.
  57424. */
  57425. dispose(): void;
  57426. }
  57427. }
  57428. declare module BABYLON {
  57429. /** @hidden */
  57430. export var lensFlarePixelShader: {
  57431. name: string;
  57432. shader: string;
  57433. };
  57434. }
  57435. declare module BABYLON {
  57436. /** @hidden */
  57437. export var lensFlareVertexShader: {
  57438. name: string;
  57439. shader: string;
  57440. };
  57441. }
  57442. declare module BABYLON {
  57443. /**
  57444. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57445. * It is usually composed of several `lensFlare`.
  57446. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57447. */
  57448. export class LensFlareSystem {
  57449. /**
  57450. * Define the name of the lens flare system
  57451. */
  57452. name: string;
  57453. /**
  57454. * List of lens flares used in this system.
  57455. */
  57456. lensFlares: LensFlare[];
  57457. /**
  57458. * Define a limit from the border the lens flare can be visible.
  57459. */
  57460. borderLimit: number;
  57461. /**
  57462. * Define a viewport border we do not want to see the lens flare in.
  57463. */
  57464. viewportBorder: number;
  57465. /**
  57466. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57467. */
  57468. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57469. /**
  57470. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57471. */
  57472. layerMask: number;
  57473. /**
  57474. * Define the id of the lens flare system in the scene.
  57475. * (equal to name by default)
  57476. */
  57477. id: string;
  57478. private _scene;
  57479. private _emitter;
  57480. private _vertexBuffers;
  57481. private _indexBuffer;
  57482. private _effect;
  57483. private _positionX;
  57484. private _positionY;
  57485. private _isEnabled;
  57486. /** @hidden */
  57487. static _SceneComponentInitialization: (scene: Scene) => void;
  57488. /**
  57489. * Instantiates a lens flare system.
  57490. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57491. * It is usually composed of several `lensFlare`.
  57492. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57493. * @param name Define the name of the lens flare system in the scene
  57494. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57495. * @param scene Define the scene the lens flare system belongs to
  57496. */
  57497. constructor(
  57498. /**
  57499. * Define the name of the lens flare system
  57500. */
  57501. name: string, emitter: any, scene: Scene);
  57502. /**
  57503. * Define if the lens flare system is enabled.
  57504. */
  57505. get isEnabled(): boolean;
  57506. set isEnabled(value: boolean);
  57507. /**
  57508. * Get the scene the effects belongs to.
  57509. * @returns the scene holding the lens flare system
  57510. */
  57511. getScene(): Scene;
  57512. /**
  57513. * Get the emitter of the lens flare system.
  57514. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57515. * @returns the emitter of the lens flare system
  57516. */
  57517. getEmitter(): any;
  57518. /**
  57519. * Set the emitter of the lens flare system.
  57520. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57521. * @param newEmitter Define the new emitter of the system
  57522. */
  57523. setEmitter(newEmitter: any): void;
  57524. /**
  57525. * Get the lens flare system emitter position.
  57526. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57527. * @returns the position
  57528. */
  57529. getEmitterPosition(): Vector3;
  57530. /**
  57531. * @hidden
  57532. */
  57533. computeEffectivePosition(globalViewport: Viewport): boolean;
  57534. /** @hidden */
  57535. _isVisible(): boolean;
  57536. /**
  57537. * @hidden
  57538. */
  57539. render(): boolean;
  57540. /**
  57541. * Dispose and release the lens flare with its associated resources.
  57542. */
  57543. dispose(): void;
  57544. /**
  57545. * Parse a lens flare system from a JSON repressentation
  57546. * @param parsedLensFlareSystem Define the JSON to parse
  57547. * @param scene Define the scene the parsed system should be instantiated in
  57548. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57549. * @returns the parsed system
  57550. */
  57551. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57552. /**
  57553. * Serialize the current Lens Flare System into a JSON representation.
  57554. * @returns the serialized JSON
  57555. */
  57556. serialize(): any;
  57557. }
  57558. }
  57559. declare module BABYLON {
  57560. /**
  57561. * This represents one of the lens effect in a `lensFlareSystem`.
  57562. * It controls one of the indiviual texture used in the effect.
  57563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57564. */
  57565. export class LensFlare {
  57566. /**
  57567. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57568. */
  57569. size: number;
  57570. /**
  57571. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  57572. */
  57573. position: number;
  57574. /**
  57575. * Define the lens color.
  57576. */
  57577. color: Color3;
  57578. /**
  57579. * Define the lens texture.
  57580. */
  57581. texture: Nullable<Texture>;
  57582. /**
  57583. * Define the alpha mode to render this particular lens.
  57584. */
  57585. alphaMode: number;
  57586. private _system;
  57587. /**
  57588. * Creates a new Lens Flare.
  57589. * This represents one of the lens effect in a `lensFlareSystem`.
  57590. * It controls one of the indiviual texture used in the effect.
  57591. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57592. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57593. * @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.
  57594. * @param color Define the lens color
  57595. * @param imgUrl Define the lens texture url
  57596. * @param system Define the `lensFlareSystem` this flare is part of
  57597. * @returns The newly created Lens Flare
  57598. */
  57599. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57600. /**
  57601. * Instantiates a new Lens Flare.
  57602. * This represents one of the lens effect in a `lensFlareSystem`.
  57603. * It controls one of the indiviual texture used in the effect.
  57604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57605. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57606. * @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.
  57607. * @param color Define the lens color
  57608. * @param imgUrl Define the lens texture url
  57609. * @param system Define the `lensFlareSystem` this flare is part of
  57610. */
  57611. constructor(
  57612. /**
  57613. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57614. */
  57615. size: number,
  57616. /**
  57617. * 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.
  57618. */
  57619. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57620. /**
  57621. * Dispose and release the lens flare with its associated resources.
  57622. */
  57623. dispose(): void;
  57624. }
  57625. }
  57626. declare module BABYLON {
  57627. interface AbstractScene {
  57628. /**
  57629. * The list of lens flare system added to the scene
  57630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57631. */
  57632. lensFlareSystems: Array<LensFlareSystem>;
  57633. /**
  57634. * Removes the given lens flare system from this scene.
  57635. * @param toRemove The lens flare system to remove
  57636. * @returns The index of the removed lens flare system
  57637. */
  57638. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57639. /**
  57640. * Adds the given lens flare system to this scene
  57641. * @param newLensFlareSystem The lens flare system to add
  57642. */
  57643. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57644. /**
  57645. * Gets a lens flare system using its name
  57646. * @param name defines the name to look for
  57647. * @returns the lens flare system or null if not found
  57648. */
  57649. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57650. /**
  57651. * Gets a lens flare system using its id
  57652. * @param id defines the id to look for
  57653. * @returns the lens flare system or null if not found
  57654. */
  57655. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57656. }
  57657. /**
  57658. * Defines the lens flare scene component responsible to manage any lens flares
  57659. * in a given scene.
  57660. */
  57661. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57662. /**
  57663. * The component name helpfull to identify the component in the list of scene components.
  57664. */
  57665. readonly name: string;
  57666. /**
  57667. * The scene the component belongs to.
  57668. */
  57669. scene: Scene;
  57670. /**
  57671. * Creates a new instance of the component for the given scene
  57672. * @param scene Defines the scene to register the component in
  57673. */
  57674. constructor(scene: Scene);
  57675. /**
  57676. * Registers the component in a given scene
  57677. */
  57678. register(): void;
  57679. /**
  57680. * Rebuilds the elements related to this component in case of
  57681. * context lost for instance.
  57682. */
  57683. rebuild(): void;
  57684. /**
  57685. * Adds all the elements from the container to the scene
  57686. * @param container the container holding the elements
  57687. */
  57688. addFromContainer(container: AbstractScene): void;
  57689. /**
  57690. * Removes all the elements in the container from the scene
  57691. * @param container contains the elements to remove
  57692. * @param dispose if the removed element should be disposed (default: false)
  57693. */
  57694. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57695. /**
  57696. * Serializes the component data to the specified json object
  57697. * @param serializationObject The object to serialize to
  57698. */
  57699. serialize(serializationObject: any): void;
  57700. /**
  57701. * Disposes the component and the associated ressources.
  57702. */
  57703. dispose(): void;
  57704. private _draw;
  57705. }
  57706. }
  57707. declare module BABYLON {
  57708. /** @hidden */
  57709. export var depthPixelShader: {
  57710. name: string;
  57711. shader: string;
  57712. };
  57713. }
  57714. declare module BABYLON {
  57715. /** @hidden */
  57716. export var depthVertexShader: {
  57717. name: string;
  57718. shader: string;
  57719. };
  57720. }
  57721. declare module BABYLON {
  57722. /**
  57723. * This represents a depth renderer in Babylon.
  57724. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57725. */
  57726. export class DepthRenderer {
  57727. private _scene;
  57728. private _depthMap;
  57729. private _effect;
  57730. private readonly _storeNonLinearDepth;
  57731. private readonly _clearColor;
  57732. /** Get if the depth renderer is using packed depth or not */
  57733. readonly isPacked: boolean;
  57734. private _cachedDefines;
  57735. private _camera;
  57736. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57737. enabled: boolean;
  57738. /**
  57739. * Specifiess that the depth renderer will only be used within
  57740. * the camera it is created for.
  57741. * This can help forcing its rendering during the camera processing.
  57742. */
  57743. useOnlyInActiveCamera: boolean;
  57744. /** @hidden */
  57745. static _SceneComponentInitialization: (scene: Scene) => void;
  57746. /**
  57747. * Instantiates a depth renderer
  57748. * @param scene The scene the renderer belongs to
  57749. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57750. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57751. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57752. */
  57753. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57754. /**
  57755. * Creates the depth rendering effect and checks if the effect is ready.
  57756. * @param subMesh The submesh to be used to render the depth map of
  57757. * @param useInstances If multiple world instances should be used
  57758. * @returns if the depth renderer is ready to render the depth map
  57759. */
  57760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57761. /**
  57762. * Gets the texture which the depth map will be written to.
  57763. * @returns The depth map texture
  57764. */
  57765. getDepthMap(): RenderTargetTexture;
  57766. /**
  57767. * Disposes of the depth renderer.
  57768. */
  57769. dispose(): void;
  57770. }
  57771. }
  57772. declare module BABYLON {
  57773. /** @hidden */
  57774. export var minmaxReduxPixelShader: {
  57775. name: string;
  57776. shader: string;
  57777. };
  57778. }
  57779. declare module BABYLON {
  57780. /**
  57781. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57782. * and maximum values from all values of the texture.
  57783. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57784. * The source values are read from the red channel of the texture.
  57785. */
  57786. export class MinMaxReducer {
  57787. /**
  57788. * Observable triggered when the computation has been performed
  57789. */
  57790. onAfterReductionPerformed: Observable<{
  57791. min: number;
  57792. max: number;
  57793. }>;
  57794. protected _camera: Camera;
  57795. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57796. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57797. protected _postProcessManager: PostProcessManager;
  57798. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57799. protected _forceFullscreenViewport: boolean;
  57800. /**
  57801. * Creates a min/max reducer
  57802. * @param camera The camera to use for the post processes
  57803. */
  57804. constructor(camera: Camera);
  57805. /**
  57806. * Gets the texture used to read the values from.
  57807. */
  57808. get sourceTexture(): Nullable<RenderTargetTexture>;
  57809. /**
  57810. * Sets the source texture to read the values from.
  57811. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57812. * because in such textures '1' value must not be taken into account to compute the maximum
  57813. * as this value is used to clear the texture.
  57814. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57815. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57816. * @param depthRedux Indicates if the texture is a depth texture or not
  57817. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57818. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57819. */
  57820. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57821. /**
  57822. * Defines the refresh rate of the computation.
  57823. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57824. */
  57825. get refreshRate(): number;
  57826. set refreshRate(value: number);
  57827. protected _activated: boolean;
  57828. /**
  57829. * Gets the activation status of the reducer
  57830. */
  57831. get activated(): boolean;
  57832. /**
  57833. * Activates the reduction computation.
  57834. * When activated, the observers registered in onAfterReductionPerformed are
  57835. * called after the compuation is performed
  57836. */
  57837. activate(): void;
  57838. /**
  57839. * Deactivates the reduction computation.
  57840. */
  57841. deactivate(): void;
  57842. /**
  57843. * Disposes the min/max reducer
  57844. * @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.
  57845. */
  57846. dispose(disposeAll?: boolean): void;
  57847. }
  57848. }
  57849. declare module BABYLON {
  57850. /**
  57851. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57852. */
  57853. export class DepthReducer extends MinMaxReducer {
  57854. private _depthRenderer;
  57855. private _depthRendererId;
  57856. /**
  57857. * Gets the depth renderer used for the computation.
  57858. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57859. */
  57860. get depthRenderer(): Nullable<DepthRenderer>;
  57861. /**
  57862. * Creates a depth reducer
  57863. * @param camera The camera used to render the depth texture
  57864. */
  57865. constructor(camera: Camera);
  57866. /**
  57867. * Sets the depth renderer to use to generate the depth map
  57868. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57869. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57870. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57871. */
  57872. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57873. /** @hidden */
  57874. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57875. /**
  57876. * Activates the reduction computation.
  57877. * When activated, the observers registered in onAfterReductionPerformed are
  57878. * called after the compuation is performed
  57879. */
  57880. activate(): void;
  57881. /**
  57882. * Deactivates the reduction computation.
  57883. */
  57884. deactivate(): void;
  57885. /**
  57886. * Disposes the depth reducer
  57887. * @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.
  57888. */
  57889. dispose(disposeAll?: boolean): void;
  57890. }
  57891. }
  57892. declare module BABYLON {
  57893. /**
  57894. * A CSM implementation allowing casting shadows on large scenes.
  57895. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57896. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57897. */
  57898. export class CascadedShadowGenerator extends ShadowGenerator {
  57899. private static readonly frustumCornersNDCSpace;
  57900. /**
  57901. * Name of the CSM class
  57902. */
  57903. static CLASSNAME: string;
  57904. /**
  57905. * Defines the default number of cascades used by the CSM.
  57906. */
  57907. static readonly DEFAULT_CASCADES_COUNT: number;
  57908. /**
  57909. * Defines the minimum number of cascades used by the CSM.
  57910. */
  57911. static readonly MIN_CASCADES_COUNT: number;
  57912. /**
  57913. * Defines the maximum number of cascades used by the CSM.
  57914. */
  57915. static readonly MAX_CASCADES_COUNT: number;
  57916. protected _validateFilter(filter: number): number;
  57917. /**
  57918. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57919. */
  57920. penumbraDarkness: number;
  57921. private _numCascades;
  57922. /**
  57923. * Gets or set the number of cascades used by the CSM.
  57924. */
  57925. get numCascades(): number;
  57926. set numCascades(value: number);
  57927. /**
  57928. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57929. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57930. */
  57931. stabilizeCascades: boolean;
  57932. private _freezeShadowCastersBoundingInfo;
  57933. private _freezeShadowCastersBoundingInfoObservable;
  57934. /**
  57935. * Enables or disables the shadow casters bounding info computation.
  57936. * If your shadow casters don't move, you can disable this feature.
  57937. * If it is enabled, the bounding box computation is done every frame.
  57938. */
  57939. get freezeShadowCastersBoundingInfo(): boolean;
  57940. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57941. private _scbiMin;
  57942. private _scbiMax;
  57943. protected _computeShadowCastersBoundingInfo(): void;
  57944. protected _shadowCastersBoundingInfo: BoundingInfo;
  57945. /**
  57946. * Gets or sets the shadow casters bounding info.
  57947. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57948. * so that the system won't overwrite the bounds you provide
  57949. */
  57950. get shadowCastersBoundingInfo(): BoundingInfo;
  57951. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57952. protected _breaksAreDirty: boolean;
  57953. protected _minDistance: number;
  57954. protected _maxDistance: number;
  57955. /**
  57956. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57957. *
  57958. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57959. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57960. * @param min minimal distance for the breaks (default to 0.)
  57961. * @param max maximal distance for the breaks (default to 1.)
  57962. */
  57963. setMinMaxDistance(min: number, max: number): void;
  57964. /** Gets the minimal distance used in the cascade break computation */
  57965. get minDistance(): number;
  57966. /** Gets the maximal distance used in the cascade break computation */
  57967. get maxDistance(): number;
  57968. /**
  57969. * Gets the class name of that object
  57970. * @returns "CascadedShadowGenerator"
  57971. */
  57972. getClassName(): string;
  57973. private _cascadeMinExtents;
  57974. private _cascadeMaxExtents;
  57975. /**
  57976. * Gets a cascade minimum extents
  57977. * @param cascadeIndex index of the cascade
  57978. * @returns the minimum cascade extents
  57979. */
  57980. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57981. /**
  57982. * Gets a cascade maximum extents
  57983. * @param cascadeIndex index of the cascade
  57984. * @returns the maximum cascade extents
  57985. */
  57986. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57987. private _cascades;
  57988. private _currentLayer;
  57989. private _viewSpaceFrustumsZ;
  57990. private _viewMatrices;
  57991. private _projectionMatrices;
  57992. private _transformMatrices;
  57993. private _transformMatricesAsArray;
  57994. private _frustumLengths;
  57995. private _lightSizeUVCorrection;
  57996. private _depthCorrection;
  57997. private _frustumCornersWorldSpace;
  57998. private _frustumCenter;
  57999. private _shadowCameraPos;
  58000. private _shadowMaxZ;
  58001. /**
  58002. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58003. * It defaults to camera.maxZ
  58004. */
  58005. get shadowMaxZ(): number;
  58006. /**
  58007. * Sets the shadow max z distance.
  58008. */
  58009. set shadowMaxZ(value: number);
  58010. protected _debug: boolean;
  58011. /**
  58012. * Gets or sets the debug flag.
  58013. * When enabled, the cascades are materialized by different colors on the screen.
  58014. */
  58015. get debug(): boolean;
  58016. set debug(dbg: boolean);
  58017. private _depthClamp;
  58018. /**
  58019. * Gets or sets the depth clamping value.
  58020. *
  58021. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58022. * to account for the shadow casters far away.
  58023. *
  58024. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58025. */
  58026. get depthClamp(): boolean;
  58027. set depthClamp(value: boolean);
  58028. private _cascadeBlendPercentage;
  58029. /**
  58030. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58031. * It defaults to 0.1 (10% blending).
  58032. */
  58033. get cascadeBlendPercentage(): number;
  58034. set cascadeBlendPercentage(value: number);
  58035. private _lambda;
  58036. /**
  58037. * Gets or set the lambda parameter.
  58038. * This parameter is used to split the camera frustum and create the cascades.
  58039. * 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.
  58040. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58041. */
  58042. get lambda(): number;
  58043. set lambda(value: number);
  58044. /**
  58045. * Gets the view matrix corresponding to a given cascade
  58046. * @param cascadeNum cascade to retrieve the view matrix from
  58047. * @returns the cascade view matrix
  58048. */
  58049. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58050. /**
  58051. * Gets the projection matrix corresponding to a given cascade
  58052. * @param cascadeNum cascade to retrieve the projection matrix from
  58053. * @returns the cascade projection matrix
  58054. */
  58055. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58056. /**
  58057. * Gets the transformation matrix corresponding to a given cascade
  58058. * @param cascadeNum cascade to retrieve the transformation matrix from
  58059. * @returns the cascade transformation matrix
  58060. */
  58061. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58062. private _depthRenderer;
  58063. /**
  58064. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58065. *
  58066. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58067. *
  58068. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58069. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58070. * @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
  58071. */
  58072. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58073. private _depthReducer;
  58074. private _autoCalcDepthBounds;
  58075. /**
  58076. * Gets or sets the autoCalcDepthBounds property.
  58077. *
  58078. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58079. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58080. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58081. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58082. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58083. */
  58084. get autoCalcDepthBounds(): boolean;
  58085. set autoCalcDepthBounds(value: boolean);
  58086. /**
  58087. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58088. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58089. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58090. * for setting the refresh rate on the renderer yourself!
  58091. */
  58092. get autoCalcDepthBoundsRefreshRate(): number;
  58093. set autoCalcDepthBoundsRefreshRate(value: number);
  58094. /**
  58095. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58096. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58097. * you change the camera near/far planes!
  58098. */
  58099. splitFrustum(): void;
  58100. private _splitFrustum;
  58101. private _computeMatrices;
  58102. private _computeFrustumInWorldSpace;
  58103. private _computeCascadeFrustum;
  58104. /**
  58105. * Support test.
  58106. */
  58107. static get IsSupported(): boolean;
  58108. /** @hidden */
  58109. static _SceneComponentInitialization: (scene: Scene) => void;
  58110. /**
  58111. * Creates a Cascaded Shadow Generator object.
  58112. * A ShadowGenerator is the required tool to use the shadows.
  58113. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58114. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58115. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58116. * @param light The directional light object generating the shadows.
  58117. * @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.
  58118. */
  58119. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58120. protected _initializeGenerator(): void;
  58121. protected _createTargetRenderTexture(): void;
  58122. protected _initializeShadowMap(): void;
  58123. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58124. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58125. /**
  58126. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58127. * @param defines Defines of the material we want to update
  58128. * @param lightIndex Index of the light in the enabled light list of the material
  58129. */
  58130. prepareDefines(defines: any, lightIndex: number): void;
  58131. /**
  58132. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58133. * defined in the generator but impacting the effect).
  58134. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58135. * @param effect The effect we are binfing the information for
  58136. */
  58137. bindShadowLight(lightIndex: string, effect: Effect): void;
  58138. /**
  58139. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58140. * (eq to view projection * shadow projection matrices)
  58141. * @returns The transform matrix used to create the shadow map
  58142. */
  58143. getTransformMatrix(): Matrix;
  58144. /**
  58145. * Disposes the ShadowGenerator.
  58146. * Returns nothing.
  58147. */
  58148. dispose(): void;
  58149. /**
  58150. * Serializes the shadow generator setup to a json object.
  58151. * @returns The serialized JSON object
  58152. */
  58153. serialize(): any;
  58154. /**
  58155. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58156. * @param parsedShadowGenerator The JSON object to parse
  58157. * @param scene The scene to create the shadow map for
  58158. * @returns The parsed shadow generator
  58159. */
  58160. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58161. }
  58162. }
  58163. declare module BABYLON {
  58164. /**
  58165. * Defines the shadow generator component responsible to manage any shadow generators
  58166. * in a given scene.
  58167. */
  58168. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58169. /**
  58170. * The component name helpfull to identify the component in the list of scene components.
  58171. */
  58172. readonly name: string;
  58173. /**
  58174. * The scene the component belongs to.
  58175. */
  58176. scene: Scene;
  58177. /**
  58178. * Creates a new instance of the component for the given scene
  58179. * @param scene Defines the scene to register the component in
  58180. */
  58181. constructor(scene: Scene);
  58182. /**
  58183. * Registers the component in a given scene
  58184. */
  58185. register(): void;
  58186. /**
  58187. * Rebuilds the elements related to this component in case of
  58188. * context lost for instance.
  58189. */
  58190. rebuild(): void;
  58191. /**
  58192. * Serializes the component data to the specified json object
  58193. * @param serializationObject The object to serialize to
  58194. */
  58195. serialize(serializationObject: any): void;
  58196. /**
  58197. * Adds all the elements from the container to the scene
  58198. * @param container the container holding the elements
  58199. */
  58200. addFromContainer(container: AbstractScene): void;
  58201. /**
  58202. * Removes all the elements in the container from the scene
  58203. * @param container contains the elements to remove
  58204. * @param dispose if the removed element should be disposed (default: false)
  58205. */
  58206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58207. /**
  58208. * Rebuilds the elements related to this component in case of
  58209. * context lost for instance.
  58210. */
  58211. dispose(): void;
  58212. private _gatherRenderTargets;
  58213. }
  58214. }
  58215. declare module BABYLON {
  58216. /**
  58217. * A point light is a light defined by an unique point in world space.
  58218. * The light is emitted in every direction from this point.
  58219. * A good example of a point light is a standard light bulb.
  58220. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58221. */
  58222. export class PointLight extends ShadowLight {
  58223. private _shadowAngle;
  58224. /**
  58225. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58226. * This specifies what angle the shadow will use to be created.
  58227. *
  58228. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58229. */
  58230. get shadowAngle(): number;
  58231. /**
  58232. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58233. * This specifies what angle the shadow will use to be created.
  58234. *
  58235. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58236. */
  58237. set shadowAngle(value: number);
  58238. /**
  58239. * Gets the direction if it has been set.
  58240. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58241. */
  58242. get direction(): Vector3;
  58243. /**
  58244. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58245. */
  58246. set direction(value: Vector3);
  58247. /**
  58248. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58249. * A PointLight emits the light in every direction.
  58250. * It can cast shadows.
  58251. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58252. * ```javascript
  58253. * var pointLight = new PointLight("pl", camera.position, scene);
  58254. * ```
  58255. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58256. * @param name The light friendly name
  58257. * @param position The position of the point light in the scene
  58258. * @param scene The scene the lights belongs to
  58259. */
  58260. constructor(name: string, position: Vector3, scene: Scene);
  58261. /**
  58262. * Returns the string "PointLight"
  58263. * @returns the class name
  58264. */
  58265. getClassName(): string;
  58266. /**
  58267. * Returns the integer 0.
  58268. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58269. */
  58270. getTypeID(): number;
  58271. /**
  58272. * Specifies wether or not the shadowmap should be a cube texture.
  58273. * @returns true if the shadowmap needs to be a cube texture.
  58274. */
  58275. needCube(): boolean;
  58276. /**
  58277. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58278. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58279. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58280. */
  58281. getShadowDirection(faceIndex?: number): Vector3;
  58282. /**
  58283. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58284. * - fov = PI / 2
  58285. * - aspect ratio : 1.0
  58286. * - z-near and far equal to the active camera minZ and maxZ.
  58287. * Returns the PointLight.
  58288. */
  58289. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58290. protected _buildUniformLayout(): void;
  58291. /**
  58292. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58293. * @param effect The effect to update
  58294. * @param lightIndex The index of the light in the effect to update
  58295. * @returns The point light
  58296. */
  58297. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58298. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58299. /**
  58300. * Prepares the list of defines specific to the light type.
  58301. * @param defines the list of defines
  58302. * @param lightIndex defines the index of the light for the effect
  58303. */
  58304. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58305. }
  58306. }
  58307. declare module BABYLON {
  58308. /**
  58309. * Header information of HDR texture files.
  58310. */
  58311. export interface HDRInfo {
  58312. /**
  58313. * The height of the texture in pixels.
  58314. */
  58315. height: number;
  58316. /**
  58317. * The width of the texture in pixels.
  58318. */
  58319. width: number;
  58320. /**
  58321. * The index of the beginning of the data in the binary file.
  58322. */
  58323. dataPosition: number;
  58324. }
  58325. /**
  58326. * This groups tools to convert HDR texture to native colors array.
  58327. */
  58328. export class HDRTools {
  58329. private static Ldexp;
  58330. private static Rgbe2float;
  58331. private static readStringLine;
  58332. /**
  58333. * Reads header information from an RGBE texture stored in a native array.
  58334. * More information on this format are available here:
  58335. * https://en.wikipedia.org/wiki/RGBE_image_format
  58336. *
  58337. * @param uint8array The binary file stored in native array.
  58338. * @return The header information.
  58339. */
  58340. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58341. /**
  58342. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58343. * This RGBE texture needs to store the information as a panorama.
  58344. *
  58345. * More information on this format are available here:
  58346. * https://en.wikipedia.org/wiki/RGBE_image_format
  58347. *
  58348. * @param buffer The binary file stored in an array buffer.
  58349. * @param size The expected size of the extracted cubemap.
  58350. * @return The Cube Map information.
  58351. */
  58352. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58353. /**
  58354. * Returns the pixels data extracted from an RGBE texture.
  58355. * This pixels will be stored left to right up to down in the R G B order in one array.
  58356. *
  58357. * More information on this format are available here:
  58358. * https://en.wikipedia.org/wiki/RGBE_image_format
  58359. *
  58360. * @param uint8array The binary file stored in an array buffer.
  58361. * @param hdrInfo The header information of the file.
  58362. * @return The pixels data in RGB right to left up to down order.
  58363. */
  58364. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58365. private static RGBE_ReadPixels_RLE;
  58366. }
  58367. }
  58368. declare module BABYLON {
  58369. /**
  58370. * Effect Render Options
  58371. */
  58372. export interface IEffectRendererOptions {
  58373. /**
  58374. * Defines the vertices positions.
  58375. */
  58376. positions?: number[];
  58377. /**
  58378. * Defines the indices.
  58379. */
  58380. indices?: number[];
  58381. }
  58382. /**
  58383. * Helper class to render one or more effects.
  58384. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58385. */
  58386. export class EffectRenderer {
  58387. private engine;
  58388. private static _DefaultOptions;
  58389. private _vertexBuffers;
  58390. private _indexBuffer;
  58391. private _fullscreenViewport;
  58392. /**
  58393. * Creates an effect renderer
  58394. * @param engine the engine to use for rendering
  58395. * @param options defines the options of the effect renderer
  58396. */
  58397. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58398. /**
  58399. * Sets the current viewport in normalized coordinates 0-1
  58400. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58401. */
  58402. setViewport(viewport?: Viewport): void;
  58403. /**
  58404. * Binds the embedded attributes buffer to the effect.
  58405. * @param effect Defines the effect to bind the attributes for
  58406. */
  58407. bindBuffers(effect: Effect): void;
  58408. /**
  58409. * Sets the current effect wrapper to use during draw.
  58410. * The effect needs to be ready before calling this api.
  58411. * This also sets the default full screen position attribute.
  58412. * @param effectWrapper Defines the effect to draw with
  58413. */
  58414. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58415. /**
  58416. * Restores engine states
  58417. */
  58418. restoreStates(): void;
  58419. /**
  58420. * Draws a full screen quad.
  58421. */
  58422. draw(): void;
  58423. private isRenderTargetTexture;
  58424. /**
  58425. * renders one or more effects to a specified texture
  58426. * @param effectWrapper the effect to renderer
  58427. * @param outputTexture texture to draw to, if null it will render to the screen.
  58428. */
  58429. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58430. /**
  58431. * Disposes of the effect renderer
  58432. */
  58433. dispose(): void;
  58434. }
  58435. /**
  58436. * Options to create an EffectWrapper
  58437. */
  58438. interface EffectWrapperCreationOptions {
  58439. /**
  58440. * Engine to use to create the effect
  58441. */
  58442. engine: ThinEngine;
  58443. /**
  58444. * Fragment shader for the effect
  58445. */
  58446. fragmentShader: string;
  58447. /**
  58448. * Use the shader store instead of direct source code
  58449. */
  58450. useShaderStore?: boolean;
  58451. /**
  58452. * Vertex shader for the effect
  58453. */
  58454. vertexShader?: string;
  58455. /**
  58456. * Attributes to use in the shader
  58457. */
  58458. attributeNames?: Array<string>;
  58459. /**
  58460. * Uniforms to use in the shader
  58461. */
  58462. uniformNames?: Array<string>;
  58463. /**
  58464. * Texture sampler names to use in the shader
  58465. */
  58466. samplerNames?: Array<string>;
  58467. /**
  58468. * Defines to use in the shader
  58469. */
  58470. defines?: Array<string>;
  58471. /**
  58472. * Callback when effect is compiled
  58473. */
  58474. onCompiled?: Nullable<(effect: Effect) => void>;
  58475. /**
  58476. * The friendly name of the effect displayed in Spector.
  58477. */
  58478. name?: string;
  58479. }
  58480. /**
  58481. * Wraps an effect to be used for rendering
  58482. */
  58483. export class EffectWrapper {
  58484. /**
  58485. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58486. */
  58487. onApplyObservable: Observable<{}>;
  58488. /**
  58489. * The underlying effect
  58490. */
  58491. effect: Effect;
  58492. /**
  58493. * Creates an effect to be renderer
  58494. * @param creationOptions options to create the effect
  58495. */
  58496. constructor(creationOptions: EffectWrapperCreationOptions);
  58497. /**
  58498. * Disposes of the effect wrapper
  58499. */
  58500. dispose(): void;
  58501. }
  58502. }
  58503. declare module BABYLON {
  58504. /** @hidden */
  58505. export var hdrFilteringVertexShader: {
  58506. name: string;
  58507. shader: string;
  58508. };
  58509. }
  58510. declare module BABYLON {
  58511. /** @hidden */
  58512. export var hdrFilteringPixelShader: {
  58513. name: string;
  58514. shader: string;
  58515. };
  58516. }
  58517. declare module BABYLON {
  58518. /**
  58519. * Options for texture filtering
  58520. */
  58521. interface IHDRFilteringOptions {
  58522. /**
  58523. * Scales pixel intensity for the input HDR map.
  58524. */
  58525. hdrScale?: number;
  58526. /**
  58527. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58528. */
  58529. quality?: number;
  58530. }
  58531. /**
  58532. * Filters HDR maps to get correct renderings of PBR reflections
  58533. */
  58534. export class HDRFiltering {
  58535. private _engine;
  58536. private _effectRenderer;
  58537. private _effectWrapper;
  58538. private _lodGenerationOffset;
  58539. private _lodGenerationScale;
  58540. /**
  58541. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58542. * you care about baking speed.
  58543. */
  58544. quality: number;
  58545. /**
  58546. * Scales pixel intensity for the input HDR map.
  58547. */
  58548. hdrScale: number;
  58549. /**
  58550. * Instantiates HDR filter for reflection maps
  58551. *
  58552. * @param engine Thin engine
  58553. * @param options Options
  58554. */
  58555. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58556. private _createRenderTarget;
  58557. private _prefilterInternal;
  58558. private _createEffect;
  58559. /**
  58560. * Get a value indicating if the filter is ready to be used
  58561. * @param texture Texture to filter
  58562. * @returns true if the filter is ready
  58563. */
  58564. isReady(texture: BaseTexture): boolean;
  58565. /**
  58566. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58567. * Prefiltering will be invoked at the end of next rendering pass.
  58568. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58569. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58570. * @param texture Texture to filter
  58571. * @param onFinished Callback when filtering is done
  58572. * @return Promise called when prefiltering is done
  58573. */
  58574. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58575. }
  58576. }
  58577. declare module BABYLON {
  58578. /**
  58579. * This represents a texture coming from an HDR input.
  58580. *
  58581. * The only supported format is currently panorama picture stored in RGBE format.
  58582. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58583. */
  58584. export class HDRCubeTexture extends BaseTexture {
  58585. private static _facesMapping;
  58586. private _generateHarmonics;
  58587. private _noMipmap;
  58588. private _prefilterOnLoad;
  58589. private _textureMatrix;
  58590. private _size;
  58591. private _onLoad;
  58592. private _onError;
  58593. /**
  58594. * The texture URL.
  58595. */
  58596. url: string;
  58597. /**
  58598. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58599. */
  58600. coordinatesMode: number;
  58601. protected _isBlocking: boolean;
  58602. /**
  58603. * Sets wether or not the texture is blocking during loading.
  58604. */
  58605. set isBlocking(value: boolean);
  58606. /**
  58607. * Gets wether or not the texture is blocking during loading.
  58608. */
  58609. get isBlocking(): boolean;
  58610. protected _rotationY: number;
  58611. /**
  58612. * Sets texture matrix rotation angle around Y axis in radians.
  58613. */
  58614. set rotationY(value: number);
  58615. /**
  58616. * Gets texture matrix rotation angle around Y axis radians.
  58617. */
  58618. get rotationY(): number;
  58619. /**
  58620. * Gets or sets the center of the bounding box associated with the cube texture
  58621. * It must define where the camera used to render the texture was set
  58622. */
  58623. boundingBoxPosition: Vector3;
  58624. private _boundingBoxSize;
  58625. /**
  58626. * Gets or sets the size of the bounding box associated with the cube texture
  58627. * When defined, the cubemap will switch to local mode
  58628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58629. * @example https://www.babylonjs-playground.com/#RNASML
  58630. */
  58631. set boundingBoxSize(value: Vector3);
  58632. get boundingBoxSize(): Vector3;
  58633. /**
  58634. * Instantiates an HDRTexture from the following parameters.
  58635. *
  58636. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58637. * @param sceneOrEngine The scene or engine the texture will be used in
  58638. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58639. * @param noMipmap Forces to not generate the mipmap if true
  58640. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58641. * @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)
  58642. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58643. */
  58644. 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>);
  58645. /**
  58646. * Get the current class name of the texture useful for serialization or dynamic coding.
  58647. * @returns "HDRCubeTexture"
  58648. */
  58649. getClassName(): string;
  58650. /**
  58651. * Occurs when the file is raw .hdr file.
  58652. */
  58653. private loadTexture;
  58654. clone(): HDRCubeTexture;
  58655. delayLoad(): void;
  58656. /**
  58657. * Get the texture reflection matrix used to rotate/transform the reflection.
  58658. * @returns the reflection matrix
  58659. */
  58660. getReflectionTextureMatrix(): Matrix;
  58661. /**
  58662. * Set the texture reflection matrix used to rotate/transform the reflection.
  58663. * @param value Define the reflection matrix to set
  58664. */
  58665. setReflectionTextureMatrix(value: Matrix): void;
  58666. /**
  58667. * Parses a JSON representation of an HDR Texture in order to create the texture
  58668. * @param parsedTexture Define the JSON representation
  58669. * @param scene Define the scene the texture should be created in
  58670. * @param rootUrl Define the root url in case we need to load relative dependencies
  58671. * @returns the newly created texture after parsing
  58672. */
  58673. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58674. serialize(): any;
  58675. }
  58676. }
  58677. declare module BABYLON {
  58678. /**
  58679. * Class used to control physics engine
  58680. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58681. */
  58682. export class PhysicsEngine implements IPhysicsEngine {
  58683. private _physicsPlugin;
  58684. /**
  58685. * Global value used to control the smallest number supported by the simulation
  58686. */
  58687. static Epsilon: number;
  58688. private _impostors;
  58689. private _joints;
  58690. private _subTimeStep;
  58691. /**
  58692. * Gets the gravity vector used by the simulation
  58693. */
  58694. gravity: Vector3;
  58695. /**
  58696. * Factory used to create the default physics plugin.
  58697. * @returns The default physics plugin
  58698. */
  58699. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58700. /**
  58701. * Creates a new Physics Engine
  58702. * @param gravity defines the gravity vector used by the simulation
  58703. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58704. */
  58705. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58706. /**
  58707. * Sets the gravity vector used by the simulation
  58708. * @param gravity defines the gravity vector to use
  58709. */
  58710. setGravity(gravity: Vector3): void;
  58711. /**
  58712. * Set the time step of the physics engine.
  58713. * Default is 1/60.
  58714. * To slow it down, enter 1/600 for example.
  58715. * To speed it up, 1/30
  58716. * @param newTimeStep defines the new timestep to apply to this world.
  58717. */
  58718. setTimeStep(newTimeStep?: number): void;
  58719. /**
  58720. * Get the time step of the physics engine.
  58721. * @returns the current time step
  58722. */
  58723. getTimeStep(): number;
  58724. /**
  58725. * Set the sub time step of the physics engine.
  58726. * Default is 0 meaning there is no sub steps
  58727. * To increase physics resolution precision, set a small value (like 1 ms)
  58728. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58729. */
  58730. setSubTimeStep(subTimeStep?: number): void;
  58731. /**
  58732. * Get the sub time step of the physics engine.
  58733. * @returns the current sub time step
  58734. */
  58735. getSubTimeStep(): number;
  58736. /**
  58737. * Release all resources
  58738. */
  58739. dispose(): void;
  58740. /**
  58741. * Gets the name of the current physics plugin
  58742. * @returns the name of the plugin
  58743. */
  58744. getPhysicsPluginName(): string;
  58745. /**
  58746. * Adding a new impostor for the impostor tracking.
  58747. * This will be done by the impostor itself.
  58748. * @param impostor the impostor to add
  58749. */
  58750. addImpostor(impostor: PhysicsImpostor): void;
  58751. /**
  58752. * Remove an impostor from the engine.
  58753. * This impostor and its mesh will not longer be updated by the physics engine.
  58754. * @param impostor the impostor to remove
  58755. */
  58756. removeImpostor(impostor: PhysicsImpostor): void;
  58757. /**
  58758. * Add a joint to the physics engine
  58759. * @param mainImpostor defines the main impostor to which the joint is added.
  58760. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58761. * @param joint defines the joint that will connect both impostors.
  58762. */
  58763. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58764. /**
  58765. * Removes a joint from the simulation
  58766. * @param mainImpostor defines the impostor used with the joint
  58767. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58768. * @param joint defines the joint to remove
  58769. */
  58770. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58771. /**
  58772. * Called by the scene. No need to call it.
  58773. * @param delta defines the timespam between frames
  58774. */
  58775. _step(delta: number): void;
  58776. /**
  58777. * Gets the current plugin used to run the simulation
  58778. * @returns current plugin
  58779. */
  58780. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58781. /**
  58782. * Gets the list of physic impostors
  58783. * @returns an array of PhysicsImpostor
  58784. */
  58785. getImpostors(): Array<PhysicsImpostor>;
  58786. /**
  58787. * Gets the impostor for a physics enabled object
  58788. * @param object defines the object impersonated by the impostor
  58789. * @returns the PhysicsImpostor or null if not found
  58790. */
  58791. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58792. /**
  58793. * Gets the impostor for a physics body object
  58794. * @param body defines physics body used by the impostor
  58795. * @returns the PhysicsImpostor or null if not found
  58796. */
  58797. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58798. /**
  58799. * Does a raycast in the physics world
  58800. * @param from when should the ray start?
  58801. * @param to when should the ray end?
  58802. * @returns PhysicsRaycastResult
  58803. */
  58804. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /** @hidden */
  58809. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58810. private _useDeltaForWorldStep;
  58811. world: any;
  58812. name: string;
  58813. private _physicsMaterials;
  58814. private _fixedTimeStep;
  58815. private _cannonRaycastResult;
  58816. private _raycastResult;
  58817. private _physicsBodysToRemoveAfterStep;
  58818. private _firstFrame;
  58819. BJSCANNON: any;
  58820. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58821. setGravity(gravity: Vector3): void;
  58822. setTimeStep(timeStep: number): void;
  58823. getTimeStep(): number;
  58824. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58825. private _removeMarkedPhysicsBodiesFromWorld;
  58826. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58827. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58829. private _processChildMeshes;
  58830. removePhysicsBody(impostor: PhysicsImpostor): void;
  58831. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58832. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58833. private _addMaterial;
  58834. private _checkWithEpsilon;
  58835. private _createShape;
  58836. private _createHeightmap;
  58837. private _minus90X;
  58838. private _plus90X;
  58839. private _tmpPosition;
  58840. private _tmpDeltaPosition;
  58841. private _tmpUnityRotation;
  58842. private _updatePhysicsBodyTransformation;
  58843. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58844. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58845. isSupported(): boolean;
  58846. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58847. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58848. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58849. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58850. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58851. getBodyMass(impostor: PhysicsImpostor): number;
  58852. getBodyFriction(impostor: PhysicsImpostor): number;
  58853. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58854. getBodyRestitution(impostor: PhysicsImpostor): number;
  58855. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58856. sleepBody(impostor: PhysicsImpostor): void;
  58857. wakeUpBody(impostor: PhysicsImpostor): void;
  58858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58859. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58860. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58861. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58862. getRadius(impostor: PhysicsImpostor): number;
  58863. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58864. dispose(): void;
  58865. private _extendNamespace;
  58866. /**
  58867. * Does a raycast in the physics world
  58868. * @param from when should the ray start?
  58869. * @param to when should the ray end?
  58870. * @returns PhysicsRaycastResult
  58871. */
  58872. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58873. }
  58874. }
  58875. declare module BABYLON {
  58876. /** @hidden */
  58877. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58878. private _useDeltaForWorldStep;
  58879. world: any;
  58880. name: string;
  58881. BJSOIMO: any;
  58882. private _raycastResult;
  58883. private _fixedTimeStep;
  58884. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58885. setGravity(gravity: Vector3): void;
  58886. setTimeStep(timeStep: number): void;
  58887. getTimeStep(): number;
  58888. private _tmpImpostorsArray;
  58889. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58890. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58891. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58892. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58893. private _tmpPositionVector;
  58894. removePhysicsBody(impostor: PhysicsImpostor): void;
  58895. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58896. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58897. isSupported(): boolean;
  58898. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58899. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58900. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58901. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58902. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58903. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58905. getBodyMass(impostor: PhysicsImpostor): number;
  58906. getBodyFriction(impostor: PhysicsImpostor): number;
  58907. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58908. getBodyRestitution(impostor: PhysicsImpostor): number;
  58909. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58910. sleepBody(impostor: PhysicsImpostor): void;
  58911. wakeUpBody(impostor: PhysicsImpostor): void;
  58912. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58913. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58914. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58915. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58916. getRadius(impostor: PhysicsImpostor): number;
  58917. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58918. dispose(): void;
  58919. /**
  58920. * Does a raycast in the physics world
  58921. * @param from when should the ray start?
  58922. * @param to when should the ray end?
  58923. * @returns PhysicsRaycastResult
  58924. */
  58925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /**
  58930. * Class containing static functions to help procedurally build meshes
  58931. */
  58932. export class RibbonBuilder {
  58933. /**
  58934. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58935. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58936. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58937. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58938. * * 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
  58939. * * 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
  58940. * * 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
  58941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58942. * * 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
  58943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58944. * * 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
  58945. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58946. * * 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
  58947. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58949. * @param name defines the name of the mesh
  58950. * @param options defines the options used to create the mesh
  58951. * @param scene defines the hosting scene
  58952. * @returns the ribbon mesh
  58953. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58955. */
  58956. static CreateRibbon(name: string, options: {
  58957. pathArray: Vector3[][];
  58958. closeArray?: boolean;
  58959. closePath?: boolean;
  58960. offset?: number;
  58961. updatable?: boolean;
  58962. sideOrientation?: number;
  58963. frontUVs?: Vector4;
  58964. backUVs?: Vector4;
  58965. instance?: Mesh;
  58966. invertUV?: boolean;
  58967. uvs?: Vector2[];
  58968. colors?: Color4[];
  58969. }, scene?: Nullable<Scene>): Mesh;
  58970. }
  58971. }
  58972. declare module BABYLON {
  58973. /**
  58974. * Class containing static functions to help procedurally build meshes
  58975. */
  58976. export class ShapeBuilder {
  58977. /**
  58978. * 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.
  58979. * * 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.
  58980. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58981. * * 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.
  58982. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58983. * * 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
  58984. * * 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
  58985. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58987. * * 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
  58988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58990. * @param name defines the name of the mesh
  58991. * @param options defines the options used to create the mesh
  58992. * @param scene defines the hosting scene
  58993. * @returns the extruded shape mesh
  58994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58996. */
  58997. static ExtrudeShape(name: string, options: {
  58998. shape: Vector3[];
  58999. path: Vector3[];
  59000. scale?: number;
  59001. rotation?: number;
  59002. cap?: number;
  59003. updatable?: boolean;
  59004. sideOrientation?: number;
  59005. frontUVs?: Vector4;
  59006. backUVs?: Vector4;
  59007. instance?: Mesh;
  59008. invertUV?: boolean;
  59009. }, scene?: Nullable<Scene>): Mesh;
  59010. /**
  59011. * Creates an custom extruded shape mesh.
  59012. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59013. * * 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.
  59014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59015. * * 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
  59016. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59017. * * 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
  59018. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59019. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59020. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59021. * * 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
  59022. * * 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
  59023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59025. * * 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
  59026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59028. * @param name defines the name of the mesh
  59029. * @param options defines the options used to create the mesh
  59030. * @param scene defines the hosting scene
  59031. * @returns the custom extruded shape mesh
  59032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59035. */
  59036. static ExtrudeShapeCustom(name: string, options: {
  59037. shape: Vector3[];
  59038. path: Vector3[];
  59039. scaleFunction?: any;
  59040. rotationFunction?: any;
  59041. ribbonCloseArray?: boolean;
  59042. ribbonClosePath?: boolean;
  59043. cap?: number;
  59044. updatable?: boolean;
  59045. sideOrientation?: number;
  59046. frontUVs?: Vector4;
  59047. backUVs?: Vector4;
  59048. instance?: Mesh;
  59049. invertUV?: boolean;
  59050. }, scene?: Nullable<Scene>): Mesh;
  59051. private static _ExtrudeShapeGeneric;
  59052. }
  59053. }
  59054. declare module BABYLON {
  59055. /**
  59056. * AmmoJS Physics plugin
  59057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59058. * @see https://github.com/kripken/ammo.js/
  59059. */
  59060. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59061. private _useDeltaForWorldStep;
  59062. /**
  59063. * Reference to the Ammo library
  59064. */
  59065. bjsAMMO: any;
  59066. /**
  59067. * Created ammoJS world which physics bodies are added to
  59068. */
  59069. world: any;
  59070. /**
  59071. * Name of the plugin
  59072. */
  59073. name: string;
  59074. private _timeStep;
  59075. private _fixedTimeStep;
  59076. private _maxSteps;
  59077. private _tmpQuaternion;
  59078. private _tmpAmmoTransform;
  59079. private _tmpAmmoQuaternion;
  59080. private _tmpAmmoConcreteContactResultCallback;
  59081. private _collisionConfiguration;
  59082. private _dispatcher;
  59083. private _overlappingPairCache;
  59084. private _solver;
  59085. private _softBodySolver;
  59086. private _tmpAmmoVectorA;
  59087. private _tmpAmmoVectorB;
  59088. private _tmpAmmoVectorC;
  59089. private _tmpAmmoVectorD;
  59090. private _tmpContactCallbackResult;
  59091. private _tmpAmmoVectorRCA;
  59092. private _tmpAmmoVectorRCB;
  59093. private _raycastResult;
  59094. private static readonly DISABLE_COLLISION_FLAG;
  59095. private static readonly KINEMATIC_FLAG;
  59096. private static readonly DISABLE_DEACTIVATION_FLAG;
  59097. /**
  59098. * Initializes the ammoJS plugin
  59099. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59100. * @param ammoInjection can be used to inject your own ammo reference
  59101. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59102. */
  59103. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59104. /**
  59105. * Sets the gravity of the physics world (m/(s^2))
  59106. * @param gravity Gravity to set
  59107. */
  59108. setGravity(gravity: Vector3): void;
  59109. /**
  59110. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59111. * @param timeStep timestep to use in seconds
  59112. */
  59113. setTimeStep(timeStep: number): void;
  59114. /**
  59115. * 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)
  59116. * @param fixedTimeStep fixedTimeStep to use in seconds
  59117. */
  59118. setFixedTimeStep(fixedTimeStep: number): void;
  59119. /**
  59120. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59121. * @param maxSteps the maximum number of steps by the physics engine per frame
  59122. */
  59123. setMaxSteps(maxSteps: number): void;
  59124. /**
  59125. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59126. * @returns the current timestep in seconds
  59127. */
  59128. getTimeStep(): number;
  59129. /**
  59130. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59131. */
  59132. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59133. private _isImpostorInContact;
  59134. private _isImpostorPairInContact;
  59135. private _stepSimulation;
  59136. /**
  59137. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59138. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59139. * After the step the babylon meshes are set to the position of the physics imposters
  59140. * @param delta amount of time to step forward
  59141. * @param impostors array of imposters to update before/after the step
  59142. */
  59143. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59144. /**
  59145. * Update babylon mesh to match physics world object
  59146. * @param impostor imposter to match
  59147. */
  59148. private _afterSoftStep;
  59149. /**
  59150. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59151. * @param impostor imposter to match
  59152. */
  59153. private _ropeStep;
  59154. /**
  59155. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59156. * @param impostor imposter to match
  59157. */
  59158. private _softbodyOrClothStep;
  59159. private _tmpMatrix;
  59160. /**
  59161. * Applies an impulse on the imposter
  59162. * @param impostor imposter to apply impulse to
  59163. * @param force amount of force to be applied to the imposter
  59164. * @param contactPoint the location to apply the impulse on the imposter
  59165. */
  59166. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59167. /**
  59168. * Applies a force on the imposter
  59169. * @param impostor imposter to apply force
  59170. * @param force amount of force to be applied to the imposter
  59171. * @param contactPoint the location to apply the force on the imposter
  59172. */
  59173. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59174. /**
  59175. * Creates a physics body using the plugin
  59176. * @param impostor the imposter to create the physics body on
  59177. */
  59178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59179. /**
  59180. * Removes the physics body from the imposter and disposes of the body's memory
  59181. * @param impostor imposter to remove the physics body from
  59182. */
  59183. removePhysicsBody(impostor: PhysicsImpostor): void;
  59184. /**
  59185. * Generates a joint
  59186. * @param impostorJoint the imposter joint to create the joint with
  59187. */
  59188. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59189. /**
  59190. * Removes a joint
  59191. * @param impostorJoint the imposter joint to remove the joint from
  59192. */
  59193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59194. private _addMeshVerts;
  59195. /**
  59196. * Initialise the soft body vertices to match its object's (mesh) vertices
  59197. * Softbody vertices (nodes) are in world space and to match this
  59198. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59199. * @param impostor to create the softbody for
  59200. */
  59201. private _softVertexData;
  59202. /**
  59203. * Create an impostor's soft body
  59204. * @param impostor to create the softbody for
  59205. */
  59206. private _createSoftbody;
  59207. /**
  59208. * Create cloth for an impostor
  59209. * @param impostor to create the softbody for
  59210. */
  59211. private _createCloth;
  59212. /**
  59213. * Create rope for an impostor
  59214. * @param impostor to create the softbody for
  59215. */
  59216. private _createRope;
  59217. /**
  59218. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59219. * @param impostor to create the custom physics shape for
  59220. */
  59221. private _createCustom;
  59222. private _addHullVerts;
  59223. private _createShape;
  59224. /**
  59225. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59226. * @param impostor imposter containing the physics body and babylon object
  59227. */
  59228. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59229. /**
  59230. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59231. * @param impostor imposter containing the physics body and babylon object
  59232. * @param newPosition new position
  59233. * @param newRotation new rotation
  59234. */
  59235. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59236. /**
  59237. * If this plugin is supported
  59238. * @returns true if its supported
  59239. */
  59240. isSupported(): boolean;
  59241. /**
  59242. * Sets the linear velocity of the physics body
  59243. * @param impostor imposter to set the velocity on
  59244. * @param velocity velocity to set
  59245. */
  59246. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59247. /**
  59248. * Sets the angular velocity of the physics body
  59249. * @param impostor imposter to set the velocity on
  59250. * @param velocity velocity to set
  59251. */
  59252. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59253. /**
  59254. * gets the linear velocity
  59255. * @param impostor imposter to get linear velocity from
  59256. * @returns linear velocity
  59257. */
  59258. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59259. /**
  59260. * gets the angular velocity
  59261. * @param impostor imposter to get angular velocity from
  59262. * @returns angular velocity
  59263. */
  59264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59265. /**
  59266. * Sets the mass of physics body
  59267. * @param impostor imposter to set the mass on
  59268. * @param mass mass to set
  59269. */
  59270. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59271. /**
  59272. * Gets the mass of the physics body
  59273. * @param impostor imposter to get the mass from
  59274. * @returns mass
  59275. */
  59276. getBodyMass(impostor: PhysicsImpostor): number;
  59277. /**
  59278. * Gets friction of the impostor
  59279. * @param impostor impostor to get friction from
  59280. * @returns friction value
  59281. */
  59282. getBodyFriction(impostor: PhysicsImpostor): number;
  59283. /**
  59284. * Sets friction of the impostor
  59285. * @param impostor impostor to set friction on
  59286. * @param friction friction value
  59287. */
  59288. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59289. /**
  59290. * Gets restitution of the impostor
  59291. * @param impostor impostor to get restitution from
  59292. * @returns restitution value
  59293. */
  59294. getBodyRestitution(impostor: PhysicsImpostor): number;
  59295. /**
  59296. * Sets resitution of the impostor
  59297. * @param impostor impostor to set resitution on
  59298. * @param restitution resitution value
  59299. */
  59300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59301. /**
  59302. * Gets pressure inside the impostor
  59303. * @param impostor impostor to get pressure from
  59304. * @returns pressure value
  59305. */
  59306. getBodyPressure(impostor: PhysicsImpostor): number;
  59307. /**
  59308. * Sets pressure inside a soft body impostor
  59309. * Cloth and rope must remain 0 pressure
  59310. * @param impostor impostor to set pressure on
  59311. * @param pressure pressure value
  59312. */
  59313. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59314. /**
  59315. * Gets stiffness of the impostor
  59316. * @param impostor impostor to get stiffness from
  59317. * @returns pressure value
  59318. */
  59319. getBodyStiffness(impostor: PhysicsImpostor): number;
  59320. /**
  59321. * Sets stiffness of the impostor
  59322. * @param impostor impostor to set stiffness on
  59323. * @param stiffness stiffness value from 0 to 1
  59324. */
  59325. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59326. /**
  59327. * Gets velocityIterations of the impostor
  59328. * @param impostor impostor to get velocity iterations from
  59329. * @returns velocityIterations value
  59330. */
  59331. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59332. /**
  59333. * Sets velocityIterations of the impostor
  59334. * @param impostor impostor to set velocity iterations on
  59335. * @param velocityIterations velocityIterations value
  59336. */
  59337. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59338. /**
  59339. * Gets positionIterations of the impostor
  59340. * @param impostor impostor to get position iterations from
  59341. * @returns positionIterations value
  59342. */
  59343. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59344. /**
  59345. * Sets positionIterations of the impostor
  59346. * @param impostor impostor to set position on
  59347. * @param positionIterations positionIterations value
  59348. */
  59349. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59350. /**
  59351. * Append an anchor to a cloth object
  59352. * @param impostor is the cloth impostor to add anchor to
  59353. * @param otherImpostor is the rigid impostor to anchor to
  59354. * @param width ratio across width from 0 to 1
  59355. * @param height ratio up height from 0 to 1
  59356. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59357. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59358. */
  59359. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59360. /**
  59361. * Append an hook to a rope object
  59362. * @param impostor is the rope impostor to add hook to
  59363. * @param otherImpostor is the rigid impostor to hook to
  59364. * @param length ratio along the rope from 0 to 1
  59365. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59366. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59367. */
  59368. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59369. /**
  59370. * Sleeps the physics body and stops it from being active
  59371. * @param impostor impostor to sleep
  59372. */
  59373. sleepBody(impostor: PhysicsImpostor): void;
  59374. /**
  59375. * Activates the physics body
  59376. * @param impostor impostor to activate
  59377. */
  59378. wakeUpBody(impostor: PhysicsImpostor): void;
  59379. /**
  59380. * Updates the distance parameters of the joint
  59381. * @param joint joint to update
  59382. * @param maxDistance maximum distance of the joint
  59383. * @param minDistance minimum distance of the joint
  59384. */
  59385. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59386. /**
  59387. * Sets a motor on the joint
  59388. * @param joint joint to set motor on
  59389. * @param speed speed of the motor
  59390. * @param maxForce maximum force of the motor
  59391. * @param motorIndex index of the motor
  59392. */
  59393. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59394. /**
  59395. * Sets the motors limit
  59396. * @param joint joint to set limit on
  59397. * @param upperLimit upper limit
  59398. * @param lowerLimit lower limit
  59399. */
  59400. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59401. /**
  59402. * Syncs the position and rotation of a mesh with the impostor
  59403. * @param mesh mesh to sync
  59404. * @param impostor impostor to update the mesh with
  59405. */
  59406. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59407. /**
  59408. * Gets the radius of the impostor
  59409. * @param impostor impostor to get radius from
  59410. * @returns the radius
  59411. */
  59412. getRadius(impostor: PhysicsImpostor): number;
  59413. /**
  59414. * Gets the box size of the impostor
  59415. * @param impostor impostor to get box size from
  59416. * @param result the resulting box size
  59417. */
  59418. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59419. /**
  59420. * Disposes of the impostor
  59421. */
  59422. dispose(): void;
  59423. /**
  59424. * Does a raycast in the physics world
  59425. * @param from when should the ray start?
  59426. * @param to when should the ray end?
  59427. * @returns PhysicsRaycastResult
  59428. */
  59429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. interface AbstractScene {
  59434. /**
  59435. * The list of reflection probes added to the scene
  59436. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59437. */
  59438. reflectionProbes: Array<ReflectionProbe>;
  59439. /**
  59440. * Removes the given reflection probe from this scene.
  59441. * @param toRemove The reflection probe to remove
  59442. * @returns The index of the removed reflection probe
  59443. */
  59444. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59445. /**
  59446. * Adds the given reflection probe to this scene.
  59447. * @param newReflectionProbe The reflection probe to add
  59448. */
  59449. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59450. }
  59451. /**
  59452. * Class used to generate realtime reflection / refraction cube textures
  59453. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59454. */
  59455. export class ReflectionProbe {
  59456. /** defines the name of the probe */
  59457. name: string;
  59458. private _scene;
  59459. private _renderTargetTexture;
  59460. private _projectionMatrix;
  59461. private _viewMatrix;
  59462. private _target;
  59463. private _add;
  59464. private _attachedMesh;
  59465. private _invertYAxis;
  59466. /** Gets or sets probe position (center of the cube map) */
  59467. position: Vector3;
  59468. /**
  59469. * Creates a new reflection probe
  59470. * @param name defines the name of the probe
  59471. * @param size defines the texture resolution (for each face)
  59472. * @param scene defines the hosting scene
  59473. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59474. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59475. */
  59476. constructor(
  59477. /** defines the name of the probe */
  59478. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59479. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59480. get samples(): number;
  59481. set samples(value: number);
  59482. /** Gets or sets the refresh rate to use (on every frame by default) */
  59483. get refreshRate(): number;
  59484. set refreshRate(value: number);
  59485. /**
  59486. * Gets the hosting scene
  59487. * @returns a Scene
  59488. */
  59489. getScene(): Scene;
  59490. /** Gets the internal CubeTexture used to render to */
  59491. get cubeTexture(): RenderTargetTexture;
  59492. /** Gets the list of meshes to render */
  59493. get renderList(): Nullable<AbstractMesh[]>;
  59494. /**
  59495. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59496. * @param mesh defines the mesh to attach to
  59497. */
  59498. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59499. /**
  59500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59501. * @param renderingGroupId The rendering group id corresponding to its index
  59502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59503. */
  59504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59505. /**
  59506. * Clean all associated resources
  59507. */
  59508. dispose(): void;
  59509. /**
  59510. * Converts the reflection probe information to a readable string for debug purpose.
  59511. * @param fullDetails Supports for multiple levels of logging within scene loading
  59512. * @returns the human readable reflection probe info
  59513. */
  59514. toString(fullDetails?: boolean): string;
  59515. /**
  59516. * Get the class name of the relfection probe.
  59517. * @returns "ReflectionProbe"
  59518. */
  59519. getClassName(): string;
  59520. /**
  59521. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59522. * @returns The JSON representation of the texture
  59523. */
  59524. serialize(): any;
  59525. /**
  59526. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59527. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59528. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59529. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59530. * @returns The parsed reflection probe if successful
  59531. */
  59532. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59533. }
  59534. }
  59535. declare module BABYLON {
  59536. /** @hidden */
  59537. export var _BabylonLoaderRegistered: boolean;
  59538. /**
  59539. * Helps setting up some configuration for the babylon file loader.
  59540. */
  59541. export class BabylonFileLoaderConfiguration {
  59542. /**
  59543. * The loader does not allow injecting custom physix engine into the plugins.
  59544. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59545. * So you could set this variable to your engine import to make it work.
  59546. */
  59547. static LoaderInjectedPhysicsEngine: any;
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. /**
  59552. * The Physically based simple base material of BJS.
  59553. *
  59554. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59555. * It is used as the base class for both the specGloss and metalRough conventions.
  59556. */
  59557. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59558. /**
  59559. * Number of Simultaneous lights allowed on the material.
  59560. */
  59561. maxSimultaneousLights: number;
  59562. /**
  59563. * If sets to true, disables all the lights affecting the material.
  59564. */
  59565. disableLighting: boolean;
  59566. /**
  59567. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59568. */
  59569. environmentTexture: BaseTexture;
  59570. /**
  59571. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59572. */
  59573. invertNormalMapX: boolean;
  59574. /**
  59575. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59576. */
  59577. invertNormalMapY: boolean;
  59578. /**
  59579. * Normal map used in the model.
  59580. */
  59581. normalTexture: BaseTexture;
  59582. /**
  59583. * Emissivie color used to self-illuminate the model.
  59584. */
  59585. emissiveColor: Color3;
  59586. /**
  59587. * Emissivie texture used to self-illuminate the model.
  59588. */
  59589. emissiveTexture: BaseTexture;
  59590. /**
  59591. * Occlusion Channel Strenght.
  59592. */
  59593. occlusionStrength: number;
  59594. /**
  59595. * Occlusion Texture of the material (adding extra occlusion effects).
  59596. */
  59597. occlusionTexture: BaseTexture;
  59598. /**
  59599. * Defines the alpha limits in alpha test mode.
  59600. */
  59601. alphaCutOff: number;
  59602. /**
  59603. * Gets the current double sided mode.
  59604. */
  59605. get doubleSided(): boolean;
  59606. /**
  59607. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59608. */
  59609. set doubleSided(value: boolean);
  59610. /**
  59611. * Stores the pre-calculated light information of a mesh in a texture.
  59612. */
  59613. lightmapTexture: BaseTexture;
  59614. /**
  59615. * If true, the light map contains occlusion information instead of lighting info.
  59616. */
  59617. useLightmapAsShadowmap: boolean;
  59618. /**
  59619. * Instantiates a new PBRMaterial instance.
  59620. *
  59621. * @param name The material name
  59622. * @param scene The scene the material will be use in.
  59623. */
  59624. constructor(name: string, scene: Scene);
  59625. getClassName(): string;
  59626. }
  59627. }
  59628. declare module BABYLON {
  59629. /**
  59630. * The PBR material of BJS following the metal roughness convention.
  59631. *
  59632. * This fits to the PBR convention in the GLTF definition:
  59633. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59634. */
  59635. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59636. /**
  59637. * The base color has two different interpretations depending on the value of metalness.
  59638. * When the material is a metal, the base color is the specific measured reflectance value
  59639. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59640. * of the material.
  59641. */
  59642. baseColor: Color3;
  59643. /**
  59644. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59645. * well as opacity information in the alpha channel.
  59646. */
  59647. baseTexture: BaseTexture;
  59648. /**
  59649. * Specifies the metallic scalar value of the material.
  59650. * Can also be used to scale the metalness values of the metallic texture.
  59651. */
  59652. metallic: number;
  59653. /**
  59654. * Specifies the roughness scalar value of the material.
  59655. * Can also be used to scale the roughness values of the metallic texture.
  59656. */
  59657. roughness: number;
  59658. /**
  59659. * Texture containing both the metallic value in the B channel and the
  59660. * roughness value in the G channel to keep better precision.
  59661. */
  59662. metallicRoughnessTexture: BaseTexture;
  59663. /**
  59664. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59665. *
  59666. * @param name The material name
  59667. * @param scene The scene the material will be use in.
  59668. */
  59669. constructor(name: string, scene: Scene);
  59670. /**
  59671. * Return the currrent class name of the material.
  59672. */
  59673. getClassName(): string;
  59674. /**
  59675. * Makes a duplicate of the current material.
  59676. * @param name - name to use for the new material.
  59677. */
  59678. clone(name: string): PBRMetallicRoughnessMaterial;
  59679. /**
  59680. * Serialize the material to a parsable JSON object.
  59681. */
  59682. serialize(): any;
  59683. /**
  59684. * Parses a JSON object correponding to the serialize function.
  59685. */
  59686. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59687. }
  59688. }
  59689. declare module BABYLON {
  59690. /**
  59691. * The PBR material of BJS following the specular glossiness convention.
  59692. *
  59693. * This fits to the PBR convention in the GLTF definition:
  59694. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59695. */
  59696. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59697. /**
  59698. * Specifies the diffuse color of the material.
  59699. */
  59700. diffuseColor: Color3;
  59701. /**
  59702. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59703. * channel.
  59704. */
  59705. diffuseTexture: BaseTexture;
  59706. /**
  59707. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59708. */
  59709. specularColor: Color3;
  59710. /**
  59711. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59712. */
  59713. glossiness: number;
  59714. /**
  59715. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59716. */
  59717. specularGlossinessTexture: BaseTexture;
  59718. /**
  59719. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59720. *
  59721. * @param name The material name
  59722. * @param scene The scene the material will be use in.
  59723. */
  59724. constructor(name: string, scene: Scene);
  59725. /**
  59726. * Return the currrent class name of the material.
  59727. */
  59728. getClassName(): string;
  59729. /**
  59730. * Makes a duplicate of the current material.
  59731. * @param name - name to use for the new material.
  59732. */
  59733. clone(name: string): PBRSpecularGlossinessMaterial;
  59734. /**
  59735. * Serialize the material to a parsable JSON object.
  59736. */
  59737. serialize(): any;
  59738. /**
  59739. * Parses a JSON object correponding to the serialize function.
  59740. */
  59741. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59742. }
  59743. }
  59744. declare module BABYLON {
  59745. /**
  59746. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59747. * It can help converting any input color in a desired output one. This can then be used to create effects
  59748. * from sepia, black and white to sixties or futuristic rendering...
  59749. *
  59750. * The only supported format is currently 3dl.
  59751. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59752. */
  59753. export class ColorGradingTexture extends BaseTexture {
  59754. /**
  59755. * The texture URL.
  59756. */
  59757. url: string;
  59758. /**
  59759. * Empty line regex stored for GC.
  59760. */
  59761. private static _noneEmptyLineRegex;
  59762. private _textureMatrix;
  59763. private _onLoad;
  59764. /**
  59765. * Instantiates a ColorGradingTexture from the following parameters.
  59766. *
  59767. * @param url The location of the color gradind data (currently only supporting 3dl)
  59768. * @param sceneOrEngine The scene or engine the texture will be used in
  59769. * @param onLoad defines a callback triggered when the texture has been loaded
  59770. */
  59771. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59772. /**
  59773. * Fires the onload event from the constructor if requested.
  59774. */
  59775. private _triggerOnLoad;
  59776. /**
  59777. * Returns the texture matrix used in most of the material.
  59778. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59779. */
  59780. getTextureMatrix(): Matrix;
  59781. /**
  59782. * Occurs when the file being loaded is a .3dl LUT file.
  59783. */
  59784. private load3dlTexture;
  59785. /**
  59786. * Starts the loading process of the texture.
  59787. */
  59788. private loadTexture;
  59789. /**
  59790. * Clones the color gradind texture.
  59791. */
  59792. clone(): ColorGradingTexture;
  59793. /**
  59794. * Called during delayed load for textures.
  59795. */
  59796. delayLoad(): void;
  59797. /**
  59798. * Parses a color grading texture serialized by Babylon.
  59799. * @param parsedTexture The texture information being parsedTexture
  59800. * @param scene The scene to load the texture in
  59801. * @param rootUrl The root url of the data assets to load
  59802. * @return A color gradind texture
  59803. */
  59804. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59805. /**
  59806. * Serializes the LUT texture to json format.
  59807. */
  59808. serialize(): any;
  59809. }
  59810. }
  59811. declare module BABYLON {
  59812. /**
  59813. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59814. */
  59815. export class EquiRectangularCubeTexture extends BaseTexture {
  59816. /** The six faces of the cube. */
  59817. private static _FacesMapping;
  59818. private _noMipmap;
  59819. private _onLoad;
  59820. private _onError;
  59821. /** The size of the cubemap. */
  59822. private _size;
  59823. /** The buffer of the image. */
  59824. private _buffer;
  59825. /** The width of the input image. */
  59826. private _width;
  59827. /** The height of the input image. */
  59828. private _height;
  59829. /** The URL to the image. */
  59830. url: string;
  59831. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59832. coordinatesMode: number;
  59833. /**
  59834. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59835. * @param url The location of the image
  59836. * @param scene The scene the texture will be used in
  59837. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59838. * @param noMipmap Forces to not generate the mipmap if true
  59839. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59840. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59841. * @param onLoad — defines a callback called when texture is loaded
  59842. * @param onError — defines a callback called if there is an error
  59843. */
  59844. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59845. /**
  59846. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59847. */
  59848. private loadImage;
  59849. /**
  59850. * Convert the image buffer into a cubemap and create a CubeTexture.
  59851. */
  59852. private loadTexture;
  59853. /**
  59854. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59855. * @param buffer The ArrayBuffer that should be converted.
  59856. * @returns The buffer as Float32Array.
  59857. */
  59858. private getFloat32ArrayFromArrayBuffer;
  59859. /**
  59860. * Get the current class name of the texture useful for serialization or dynamic coding.
  59861. * @returns "EquiRectangularCubeTexture"
  59862. */
  59863. getClassName(): string;
  59864. /**
  59865. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59866. * @returns A clone of the current EquiRectangularCubeTexture.
  59867. */
  59868. clone(): EquiRectangularCubeTexture;
  59869. }
  59870. }
  59871. declare module BABYLON {
  59872. /**
  59873. * Defines the options related to the creation of an HtmlElementTexture
  59874. */
  59875. export interface IHtmlElementTextureOptions {
  59876. /**
  59877. * Defines wether mip maps should be created or not.
  59878. */
  59879. generateMipMaps?: boolean;
  59880. /**
  59881. * Defines the sampling mode of the texture.
  59882. */
  59883. samplingMode?: number;
  59884. /**
  59885. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59886. */
  59887. engine: Nullable<ThinEngine>;
  59888. /**
  59889. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59890. */
  59891. scene: Nullable<Scene>;
  59892. }
  59893. /**
  59894. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59895. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59896. * is automatically managed.
  59897. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59898. * in your application.
  59899. *
  59900. * As the update is not automatic, you need to call them manually.
  59901. */
  59902. export class HtmlElementTexture extends BaseTexture {
  59903. /**
  59904. * The texture URL.
  59905. */
  59906. element: HTMLVideoElement | HTMLCanvasElement;
  59907. private static readonly DefaultOptions;
  59908. private _textureMatrix;
  59909. private _isVideo;
  59910. private _generateMipMaps;
  59911. private _samplingMode;
  59912. /**
  59913. * Instantiates a HtmlElementTexture from the following parameters.
  59914. *
  59915. * @param name Defines the name of the texture
  59916. * @param element Defines the video or canvas the texture is filled with
  59917. * @param options Defines the other none mandatory texture creation options
  59918. */
  59919. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59920. private _createInternalTexture;
  59921. /**
  59922. * Returns the texture matrix used in most of the material.
  59923. */
  59924. getTextureMatrix(): Matrix;
  59925. /**
  59926. * Updates the content of the texture.
  59927. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59928. */
  59929. update(invertY?: Nullable<boolean>): void;
  59930. }
  59931. }
  59932. declare module BABYLON {
  59933. /**
  59934. * Based on jsTGALoader - Javascript loader for TGA file
  59935. * By Vincent Thibault
  59936. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59937. */
  59938. export class TGATools {
  59939. private static _TYPE_INDEXED;
  59940. private static _TYPE_RGB;
  59941. private static _TYPE_GREY;
  59942. private static _TYPE_RLE_INDEXED;
  59943. private static _TYPE_RLE_RGB;
  59944. private static _TYPE_RLE_GREY;
  59945. private static _ORIGIN_MASK;
  59946. private static _ORIGIN_SHIFT;
  59947. private static _ORIGIN_BL;
  59948. private static _ORIGIN_BR;
  59949. private static _ORIGIN_UL;
  59950. private static _ORIGIN_UR;
  59951. /**
  59952. * Gets the header of a TGA file
  59953. * @param data defines the TGA data
  59954. * @returns the header
  59955. */
  59956. static GetTGAHeader(data: Uint8Array): any;
  59957. /**
  59958. * Uploads TGA content to a Babylon Texture
  59959. * @hidden
  59960. */
  59961. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59962. /** @hidden */
  59963. 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;
  59964. /** @hidden */
  59965. 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;
  59966. /** @hidden */
  59967. 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;
  59968. /** @hidden */
  59969. 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;
  59970. /** @hidden */
  59971. 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;
  59972. /** @hidden */
  59973. 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;
  59974. }
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * Implementation of the TGA Texture Loader.
  59979. * @hidden
  59980. */
  59981. export class _TGATextureLoader implements IInternalTextureLoader {
  59982. /**
  59983. * Defines wether the loader supports cascade loading the different faces.
  59984. */
  59985. readonly supportCascades: boolean;
  59986. /**
  59987. * This returns if the loader support the current file information.
  59988. * @param extension defines the file extension of the file being loaded
  59989. * @returns true if the loader can load the specified file
  59990. */
  59991. canLoad(extension: string): boolean;
  59992. /**
  59993. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59994. * @param data contains the texture data
  59995. * @param texture defines the BabylonJS internal texture
  59996. * @param createPolynomials will be true if polynomials have been requested
  59997. * @param onLoad defines the callback to trigger once the texture is ready
  59998. * @param onError defines the callback to trigger in case of error
  59999. */
  60000. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60001. /**
  60002. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60003. * @param data contains the texture data
  60004. * @param texture defines the BabylonJS internal texture
  60005. * @param callback defines the method to call once ready to upload
  60006. */
  60007. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60008. }
  60009. }
  60010. declare module BABYLON {
  60011. /**
  60012. * Info about the .basis files
  60013. */
  60014. class BasisFileInfo {
  60015. /**
  60016. * If the file has alpha
  60017. */
  60018. hasAlpha: boolean;
  60019. /**
  60020. * Info about each image of the basis file
  60021. */
  60022. images: Array<{
  60023. levels: Array<{
  60024. width: number;
  60025. height: number;
  60026. transcodedPixels: ArrayBufferView;
  60027. }>;
  60028. }>;
  60029. }
  60030. /**
  60031. * Result of transcoding a basis file
  60032. */
  60033. class TranscodeResult {
  60034. /**
  60035. * Info about the .basis file
  60036. */
  60037. fileInfo: BasisFileInfo;
  60038. /**
  60039. * Format to use when loading the file
  60040. */
  60041. format: number;
  60042. }
  60043. /**
  60044. * Configuration options for the Basis transcoder
  60045. */
  60046. export class BasisTranscodeConfiguration {
  60047. /**
  60048. * Supported compression formats used to determine the supported output format of the transcoder
  60049. */
  60050. supportedCompressionFormats?: {
  60051. /**
  60052. * etc1 compression format
  60053. */
  60054. etc1?: boolean;
  60055. /**
  60056. * s3tc compression format
  60057. */
  60058. s3tc?: boolean;
  60059. /**
  60060. * pvrtc compression format
  60061. */
  60062. pvrtc?: boolean;
  60063. /**
  60064. * etc2 compression format
  60065. */
  60066. etc2?: boolean;
  60067. };
  60068. /**
  60069. * If mipmap levels should be loaded for transcoded images (Default: true)
  60070. */
  60071. loadMipmapLevels?: boolean;
  60072. /**
  60073. * Index of a single image to load (Default: all images)
  60074. */
  60075. loadSingleImage?: number;
  60076. }
  60077. /**
  60078. * Used to load .Basis files
  60079. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60080. */
  60081. export class BasisTools {
  60082. private static _IgnoreSupportedFormats;
  60083. /**
  60084. * URL to use when loading the basis transcoder
  60085. */
  60086. static JSModuleURL: string;
  60087. /**
  60088. * URL to use when loading the wasm module for the transcoder
  60089. */
  60090. static WasmModuleURL: string;
  60091. /**
  60092. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60093. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60094. * @returns internal format corresponding to the Basis format
  60095. */
  60096. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60097. private static _WorkerPromise;
  60098. private static _Worker;
  60099. private static _actionId;
  60100. private static _CreateWorkerAsync;
  60101. /**
  60102. * Transcodes a loaded image file to compressed pixel data
  60103. * @param data image data to transcode
  60104. * @param config configuration options for the transcoding
  60105. * @returns a promise resulting in the transcoded image
  60106. */
  60107. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60108. /**
  60109. * Loads a texture from the transcode result
  60110. * @param texture texture load to
  60111. * @param transcodeResult the result of transcoding the basis file to load from
  60112. */
  60113. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. /**
  60118. * Loader for .basis file format
  60119. */
  60120. export class _BasisTextureLoader implements IInternalTextureLoader {
  60121. /**
  60122. * Defines whether the loader supports cascade loading the different faces.
  60123. */
  60124. readonly supportCascades: boolean;
  60125. /**
  60126. * This returns if the loader support the current file information.
  60127. * @param extension defines the file extension of the file being loaded
  60128. * @returns true if the loader can load the specified file
  60129. */
  60130. canLoad(extension: string): boolean;
  60131. /**
  60132. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60133. * @param data contains the texture data
  60134. * @param texture defines the BabylonJS internal texture
  60135. * @param createPolynomials will be true if polynomials have been requested
  60136. * @param onLoad defines the callback to trigger once the texture is ready
  60137. * @param onError defines the callback to trigger in case of error
  60138. */
  60139. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60140. /**
  60141. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60142. * @param data contains the texture data
  60143. * @param texture defines the BabylonJS internal texture
  60144. * @param callback defines the method to call once ready to upload
  60145. */
  60146. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60147. }
  60148. }
  60149. declare module BABYLON {
  60150. /**
  60151. * Defines the basic options interface of a TexturePacker Frame
  60152. */
  60153. export interface ITexturePackerFrame {
  60154. /**
  60155. * The frame ID
  60156. */
  60157. id: number;
  60158. /**
  60159. * The frames Scale
  60160. */
  60161. scale: Vector2;
  60162. /**
  60163. * The Frames offset
  60164. */
  60165. offset: Vector2;
  60166. }
  60167. /**
  60168. * This is a support class for frame Data on texture packer sets.
  60169. */
  60170. export class TexturePackerFrame implements ITexturePackerFrame {
  60171. /**
  60172. * The frame ID
  60173. */
  60174. id: number;
  60175. /**
  60176. * The frames Scale
  60177. */
  60178. scale: Vector2;
  60179. /**
  60180. * The Frames offset
  60181. */
  60182. offset: Vector2;
  60183. /**
  60184. * Initializes a texture package frame.
  60185. * @param id The numerical frame identifier
  60186. * @param scale Scalar Vector2 for UV frame
  60187. * @param offset Vector2 for the frame position in UV units.
  60188. * @returns TexturePackerFrame
  60189. */
  60190. constructor(id: number, scale: Vector2, offset: Vector2);
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /**
  60195. * Defines the basic options interface of a TexturePacker
  60196. */
  60197. export interface ITexturePackerOptions {
  60198. /**
  60199. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60200. */
  60201. map?: string[];
  60202. /**
  60203. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60204. */
  60205. uvsIn?: string;
  60206. /**
  60207. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60208. */
  60209. uvsOut?: string;
  60210. /**
  60211. * number representing the layout style. Defaults to LAYOUT_STRIP
  60212. */
  60213. layout?: number;
  60214. /**
  60215. * number of columns if using custom column count layout(2). This defaults to 4.
  60216. */
  60217. colnum?: number;
  60218. /**
  60219. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60220. */
  60221. updateInputMeshes?: boolean;
  60222. /**
  60223. * boolean flag to dispose all the source textures. Defaults to true.
  60224. */
  60225. disposeSources?: boolean;
  60226. /**
  60227. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60228. */
  60229. fillBlanks?: boolean;
  60230. /**
  60231. * string value representing the context fill style color. Defaults to 'black'.
  60232. */
  60233. customFillColor?: string;
  60234. /**
  60235. * Width and Height Value of each Frame in the TexturePacker Sets
  60236. */
  60237. frameSize?: number;
  60238. /**
  60239. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60240. */
  60241. paddingRatio?: number;
  60242. /**
  60243. * Number that declares the fill method for the padding gutter.
  60244. */
  60245. paddingMode?: number;
  60246. /**
  60247. * If in SUBUV_COLOR padding mode what color to use.
  60248. */
  60249. paddingColor?: Color3 | Color4;
  60250. }
  60251. /**
  60252. * Defines the basic interface of a TexturePacker JSON File
  60253. */
  60254. export interface ITexturePackerJSON {
  60255. /**
  60256. * The frame ID
  60257. */
  60258. name: string;
  60259. /**
  60260. * The base64 channel data
  60261. */
  60262. sets: any;
  60263. /**
  60264. * The options of the Packer
  60265. */
  60266. options: ITexturePackerOptions;
  60267. /**
  60268. * The frame data of the Packer
  60269. */
  60270. frames: Array<number>;
  60271. }
  60272. /**
  60273. * This is a support class that generates a series of packed texture sets.
  60274. * @see https://doc.babylonjs.com/babylon101/materials
  60275. */
  60276. export class TexturePacker {
  60277. /** Packer Layout Constant 0 */
  60278. static readonly LAYOUT_STRIP: number;
  60279. /** Packer Layout Constant 1 */
  60280. static readonly LAYOUT_POWER2: number;
  60281. /** Packer Layout Constant 2 */
  60282. static readonly LAYOUT_COLNUM: number;
  60283. /** Packer Layout Constant 0 */
  60284. static readonly SUBUV_WRAP: number;
  60285. /** Packer Layout Constant 1 */
  60286. static readonly SUBUV_EXTEND: number;
  60287. /** Packer Layout Constant 2 */
  60288. static readonly SUBUV_COLOR: number;
  60289. /** The Name of the Texture Package */
  60290. name: string;
  60291. /** The scene scope of the TexturePacker */
  60292. scene: Scene;
  60293. /** The Meshes to target */
  60294. meshes: AbstractMesh[];
  60295. /** Arguments passed with the Constructor */
  60296. options: ITexturePackerOptions;
  60297. /** The promise that is started upon initialization */
  60298. promise: Nullable<Promise<TexturePacker | string>>;
  60299. /** The Container object for the channel sets that are generated */
  60300. sets: object;
  60301. /** The Container array for the frames that are generated */
  60302. frames: TexturePackerFrame[];
  60303. /** The expected number of textures the system is parsing. */
  60304. private _expecting;
  60305. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60306. private _paddingValue;
  60307. /**
  60308. * Initializes a texture package series from an array of meshes or a single mesh.
  60309. * @param name The name of the package
  60310. * @param meshes The target meshes to compose the package from
  60311. * @param options The arguments that texture packer should follow while building.
  60312. * @param scene The scene which the textures are scoped to.
  60313. * @returns TexturePacker
  60314. */
  60315. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60316. /**
  60317. * Starts the package process
  60318. * @param resolve The promises resolution function
  60319. * @returns TexturePacker
  60320. */
  60321. private _createFrames;
  60322. /**
  60323. * Calculates the Size of the Channel Sets
  60324. * @returns Vector2
  60325. */
  60326. private _calculateSize;
  60327. /**
  60328. * Calculates the UV data for the frames.
  60329. * @param baseSize the base frameSize
  60330. * @param padding the base frame padding
  60331. * @param dtSize size of the Dynamic Texture for that channel
  60332. * @param dtUnits is 1/dtSize
  60333. * @param update flag to update the input meshes
  60334. */
  60335. private _calculateMeshUVFrames;
  60336. /**
  60337. * Calculates the frames Offset.
  60338. * @param index of the frame
  60339. * @returns Vector2
  60340. */
  60341. private _getFrameOffset;
  60342. /**
  60343. * Updates a Mesh to the frame data
  60344. * @param mesh that is the target
  60345. * @param frameID or the frame index
  60346. */
  60347. private _updateMeshUV;
  60348. /**
  60349. * Updates a Meshes materials to use the texture packer channels
  60350. * @param m is the mesh to target
  60351. * @param force all channels on the packer to be set.
  60352. */
  60353. private _updateTextureReferences;
  60354. /**
  60355. * Public method to set a Mesh to a frame
  60356. * @param m that is the target
  60357. * @param frameID or the frame index
  60358. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60359. */
  60360. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60361. /**
  60362. * Starts the async promise to compile the texture packer.
  60363. * @returns Promise<void>
  60364. */
  60365. processAsync(): Promise<void>;
  60366. /**
  60367. * Disposes all textures associated with this packer
  60368. */
  60369. dispose(): void;
  60370. /**
  60371. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60372. * @param imageType is the image type to use.
  60373. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60374. */
  60375. download(imageType?: string, quality?: number): void;
  60376. /**
  60377. * Public method to load a texturePacker JSON file.
  60378. * @param data of the JSON file in string format.
  60379. */
  60380. updateFromJSON(data: string): void;
  60381. }
  60382. }
  60383. declare module BABYLON {
  60384. /**
  60385. * 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.
  60386. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60387. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60388. */
  60389. export class CustomProceduralTexture extends ProceduralTexture {
  60390. private _animate;
  60391. private _time;
  60392. private _config;
  60393. private _texturePath;
  60394. /**
  60395. * Instantiates a new Custom Procedural Texture.
  60396. * 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.
  60397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60399. * @param name Define the name of the texture
  60400. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60401. * @param size Define the size of the texture to create
  60402. * @param scene Define the scene the texture belongs to
  60403. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60404. * @param generateMipMaps Define if the texture should creates mip maps or not
  60405. */
  60406. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60407. private _loadJson;
  60408. /**
  60409. * Is the texture ready to be used ? (rendered at least once)
  60410. * @returns true if ready, otherwise, false.
  60411. */
  60412. isReady(): boolean;
  60413. /**
  60414. * Render the texture to its associated render target.
  60415. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60416. */
  60417. render(useCameraPostProcess?: boolean): void;
  60418. /**
  60419. * Update the list of dependant textures samplers in the shader.
  60420. */
  60421. updateTextures(): void;
  60422. /**
  60423. * Update the uniform values of the procedural texture in the shader.
  60424. */
  60425. updateShaderUniforms(): void;
  60426. /**
  60427. * Define if the texture animates or not.
  60428. */
  60429. get animate(): boolean;
  60430. set animate(value: boolean);
  60431. }
  60432. }
  60433. declare module BABYLON {
  60434. /** @hidden */
  60435. export var noisePixelShader: {
  60436. name: string;
  60437. shader: string;
  60438. };
  60439. }
  60440. declare module BABYLON {
  60441. /**
  60442. * Class used to generate noise procedural textures
  60443. */
  60444. export class NoiseProceduralTexture extends ProceduralTexture {
  60445. private _time;
  60446. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60447. brightness: number;
  60448. /** Defines the number of octaves to process */
  60449. octaves: number;
  60450. /** Defines the level of persistence (0.8 by default) */
  60451. persistence: number;
  60452. /** Gets or sets animation speed factor (default is 1) */
  60453. animationSpeedFactor: number;
  60454. /**
  60455. * Creates a new NoiseProceduralTexture
  60456. * @param name defines the name fo the texture
  60457. * @param size defines the size of the texture (default is 256)
  60458. * @param scene defines the hosting scene
  60459. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60460. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60461. */
  60462. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60463. private _updateShaderUniforms;
  60464. protected _getDefines(): string;
  60465. /** Generate the current state of the procedural texture */
  60466. render(useCameraPostProcess?: boolean): void;
  60467. /**
  60468. * Serializes this noise procedural texture
  60469. * @returns a serialized noise procedural texture object
  60470. */
  60471. serialize(): any;
  60472. /**
  60473. * Clone the texture.
  60474. * @returns the cloned texture
  60475. */
  60476. clone(): NoiseProceduralTexture;
  60477. /**
  60478. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60479. * @param parsedTexture defines parsed texture data
  60480. * @param scene defines the current scene
  60481. * @param rootUrl defines the root URL containing noise procedural texture information
  60482. * @returns a parsed NoiseProceduralTexture
  60483. */
  60484. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60485. }
  60486. }
  60487. declare module BABYLON {
  60488. /**
  60489. * Raw cube texture where the raw buffers are passed in
  60490. */
  60491. export class RawCubeTexture extends CubeTexture {
  60492. /**
  60493. * Creates a cube texture where the raw buffers are passed in.
  60494. * @param scene defines the scene the texture is attached to
  60495. * @param data defines the array of data to use to create each face
  60496. * @param size defines the size of the textures
  60497. * @param format defines the format of the data
  60498. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60499. * @param generateMipMaps defines if the engine should generate the mip levels
  60500. * @param invertY defines if data must be stored with Y axis inverted
  60501. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60502. * @param compression defines the compression used (null by default)
  60503. */
  60504. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60505. /**
  60506. * Updates the raw cube texture.
  60507. * @param data defines the data to store
  60508. * @param format defines the data format
  60509. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60510. * @param invertY defines if data must be stored with Y axis inverted
  60511. * @param compression defines the compression used (null by default)
  60512. * @param level defines which level of the texture to update
  60513. */
  60514. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60515. /**
  60516. * Updates a raw cube texture with RGBD encoded data.
  60517. * @param data defines the array of data [mipmap][face] to use to create each face
  60518. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60519. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60520. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60521. * @returns a promsie that resolves when the operation is complete
  60522. */
  60523. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60524. /**
  60525. * Clones the raw cube texture.
  60526. * @return a new cube texture
  60527. */
  60528. clone(): CubeTexture;
  60529. /** @hidden */
  60530. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60531. }
  60532. }
  60533. declare module BABYLON {
  60534. /**
  60535. * Class used to store 2D array textures containing user data
  60536. */
  60537. export class RawTexture2DArray extends Texture {
  60538. /** Gets or sets the texture format to use */
  60539. format: number;
  60540. /**
  60541. * Create a new RawTexture2DArray
  60542. * @param data defines the data of the texture
  60543. * @param width defines the width of the texture
  60544. * @param height defines the height of the texture
  60545. * @param depth defines the number of layers of the texture
  60546. * @param format defines the texture format to use
  60547. * @param scene defines the hosting scene
  60548. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60549. * @param invertY defines if texture must be stored with Y axis inverted
  60550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60551. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60552. */
  60553. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60554. /** Gets or sets the texture format to use */
  60555. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60556. /**
  60557. * Update the texture with new data
  60558. * @param data defines the data to store in the texture
  60559. */
  60560. update(data: ArrayBufferView): void;
  60561. }
  60562. }
  60563. declare module BABYLON {
  60564. /**
  60565. * Class used to store 3D textures containing user data
  60566. */
  60567. export class RawTexture3D extends Texture {
  60568. /** Gets or sets the texture format to use */
  60569. format: number;
  60570. /**
  60571. * Create a new RawTexture3D
  60572. * @param data defines the data of the texture
  60573. * @param width defines the width of the texture
  60574. * @param height defines the height of the texture
  60575. * @param depth defines the depth of the texture
  60576. * @param format defines the texture format to use
  60577. * @param scene defines the hosting scene
  60578. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60579. * @param invertY defines if texture must be stored with Y axis inverted
  60580. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60581. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60582. */
  60583. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60584. /** Gets or sets the texture format to use */
  60585. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60586. /**
  60587. * Update the texture with new data
  60588. * @param data defines the data to store in the texture
  60589. */
  60590. update(data: ArrayBufferView): void;
  60591. }
  60592. }
  60593. declare module BABYLON {
  60594. /**
  60595. * Creates a refraction texture used by refraction channel of the standard material.
  60596. * It is like a mirror but to see through a material.
  60597. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60598. */
  60599. export class RefractionTexture extends RenderTargetTexture {
  60600. /**
  60601. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60602. * 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.
  60603. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60604. */
  60605. refractionPlane: Plane;
  60606. /**
  60607. * Define how deep under the surface we should see.
  60608. */
  60609. depth: number;
  60610. /**
  60611. * Creates a refraction texture used by refraction channel of the standard material.
  60612. * It is like a mirror but to see through a material.
  60613. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60614. * @param name Define the texture name
  60615. * @param size Define the size of the underlying texture
  60616. * @param scene Define the scene the refraction belongs to
  60617. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60618. */
  60619. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60620. /**
  60621. * Clone the refraction texture.
  60622. * @returns the cloned texture
  60623. */
  60624. clone(): RefractionTexture;
  60625. /**
  60626. * Serialize the texture to a JSON representation you could use in Parse later on
  60627. * @returns the serialized JSON representation
  60628. */
  60629. serialize(): any;
  60630. }
  60631. }
  60632. declare module BABYLON {
  60633. /**
  60634. * Block used to add support for vertex skinning (bones)
  60635. */
  60636. export class BonesBlock extends NodeMaterialBlock {
  60637. /**
  60638. * Creates a new BonesBlock
  60639. * @param name defines the block name
  60640. */
  60641. constructor(name: string);
  60642. /**
  60643. * Initialize the block and prepare the context for build
  60644. * @param state defines the state that will be used for the build
  60645. */
  60646. initialize(state: NodeMaterialBuildState): void;
  60647. /**
  60648. * Gets the current class name
  60649. * @returns the class name
  60650. */
  60651. getClassName(): string;
  60652. /**
  60653. * Gets the matrix indices input component
  60654. */
  60655. get matricesIndices(): NodeMaterialConnectionPoint;
  60656. /**
  60657. * Gets the matrix weights input component
  60658. */
  60659. get matricesWeights(): NodeMaterialConnectionPoint;
  60660. /**
  60661. * Gets the extra matrix indices input component
  60662. */
  60663. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60664. /**
  60665. * Gets the extra matrix weights input component
  60666. */
  60667. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the world input component
  60670. */
  60671. get world(): NodeMaterialConnectionPoint;
  60672. /**
  60673. * Gets the output component
  60674. */
  60675. get output(): NodeMaterialConnectionPoint;
  60676. autoConfigure(material: NodeMaterial): void;
  60677. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60680. protected _buildBlock(state: NodeMaterialBuildState): this;
  60681. }
  60682. }
  60683. declare module BABYLON {
  60684. /**
  60685. * Block used to add support for instances
  60686. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60687. */
  60688. export class InstancesBlock extends NodeMaterialBlock {
  60689. /**
  60690. * Creates a new InstancesBlock
  60691. * @param name defines the block name
  60692. */
  60693. constructor(name: string);
  60694. /**
  60695. * Gets the current class name
  60696. * @returns the class name
  60697. */
  60698. getClassName(): string;
  60699. /**
  60700. * Gets the first world row input component
  60701. */
  60702. get world0(): NodeMaterialConnectionPoint;
  60703. /**
  60704. * Gets the second world row input component
  60705. */
  60706. get world1(): NodeMaterialConnectionPoint;
  60707. /**
  60708. * Gets the third world row input component
  60709. */
  60710. get world2(): NodeMaterialConnectionPoint;
  60711. /**
  60712. * Gets the forth world row input component
  60713. */
  60714. get world3(): NodeMaterialConnectionPoint;
  60715. /**
  60716. * Gets the world input component
  60717. */
  60718. get world(): NodeMaterialConnectionPoint;
  60719. /**
  60720. * Gets the output component
  60721. */
  60722. get output(): NodeMaterialConnectionPoint;
  60723. /**
  60724. * Gets the isntanceID component
  60725. */
  60726. get instanceID(): NodeMaterialConnectionPoint;
  60727. autoConfigure(material: NodeMaterial): void;
  60728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60729. protected _buildBlock(state: NodeMaterialBuildState): this;
  60730. }
  60731. }
  60732. declare module BABYLON {
  60733. /**
  60734. * Block used to add morph targets support to vertex shader
  60735. */
  60736. export class MorphTargetsBlock extends NodeMaterialBlock {
  60737. private _repeatableContentAnchor;
  60738. /**
  60739. * Create a new MorphTargetsBlock
  60740. * @param name defines the block name
  60741. */
  60742. constructor(name: string);
  60743. /**
  60744. * Gets the current class name
  60745. * @returns the class name
  60746. */
  60747. getClassName(): string;
  60748. /**
  60749. * Gets the position input component
  60750. */
  60751. get position(): NodeMaterialConnectionPoint;
  60752. /**
  60753. * Gets the normal input component
  60754. */
  60755. get normal(): NodeMaterialConnectionPoint;
  60756. /**
  60757. * Gets the tangent input component
  60758. */
  60759. get tangent(): NodeMaterialConnectionPoint;
  60760. /**
  60761. * Gets the tangent input component
  60762. */
  60763. get uv(): NodeMaterialConnectionPoint;
  60764. /**
  60765. * Gets the position output component
  60766. */
  60767. get positionOutput(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the normal output component
  60770. */
  60771. get normalOutput(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the tangent output component
  60774. */
  60775. get tangentOutput(): NodeMaterialConnectionPoint;
  60776. /**
  60777. * Gets the tangent output component
  60778. */
  60779. get uvOutput(): NodeMaterialConnectionPoint;
  60780. initialize(state: NodeMaterialBuildState): void;
  60781. autoConfigure(material: NodeMaterial): void;
  60782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60784. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60785. protected _buildBlock(state: NodeMaterialBuildState): this;
  60786. }
  60787. }
  60788. declare module BABYLON {
  60789. /**
  60790. * Block used to get data information from a light
  60791. */
  60792. export class LightInformationBlock extends NodeMaterialBlock {
  60793. private _lightDataUniformName;
  60794. private _lightColorUniformName;
  60795. private _lightTypeDefineName;
  60796. /**
  60797. * Gets or sets the light associated with this block
  60798. */
  60799. light: Nullable<Light>;
  60800. /**
  60801. * Creates a new LightInformationBlock
  60802. * @param name defines the block name
  60803. */
  60804. constructor(name: string);
  60805. /**
  60806. * Gets the current class name
  60807. * @returns the class name
  60808. */
  60809. getClassName(): string;
  60810. /**
  60811. * Gets the world position input component
  60812. */
  60813. get worldPosition(): NodeMaterialConnectionPoint;
  60814. /**
  60815. * Gets the direction output component
  60816. */
  60817. get direction(): NodeMaterialConnectionPoint;
  60818. /**
  60819. * Gets the direction output component
  60820. */
  60821. get color(): NodeMaterialConnectionPoint;
  60822. /**
  60823. * Gets the direction output component
  60824. */
  60825. get intensity(): NodeMaterialConnectionPoint;
  60826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60828. protected _buildBlock(state: NodeMaterialBuildState): this;
  60829. serialize(): any;
  60830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60831. }
  60832. }
  60833. declare module BABYLON {
  60834. /**
  60835. * Block used to add image processing support to fragment shader
  60836. */
  60837. export class ImageProcessingBlock extends NodeMaterialBlock {
  60838. /**
  60839. * Create a new ImageProcessingBlock
  60840. * @param name defines the block name
  60841. */
  60842. constructor(name: string);
  60843. /**
  60844. * Gets the current class name
  60845. * @returns the class name
  60846. */
  60847. getClassName(): string;
  60848. /**
  60849. * Gets the color input component
  60850. */
  60851. get color(): NodeMaterialConnectionPoint;
  60852. /**
  60853. * Gets the output component
  60854. */
  60855. get output(): NodeMaterialConnectionPoint;
  60856. /**
  60857. * Initialize the block and prepare the context for build
  60858. * @param state defines the state that will be used for the build
  60859. */
  60860. initialize(state: NodeMaterialBuildState): void;
  60861. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60863. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60864. protected _buildBlock(state: NodeMaterialBuildState): this;
  60865. }
  60866. }
  60867. declare module BABYLON {
  60868. /**
  60869. * Block used to pertub normals based on a normal map
  60870. */
  60871. export class PerturbNormalBlock extends NodeMaterialBlock {
  60872. private _tangentSpaceParameterName;
  60873. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60874. invertX: boolean;
  60875. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60876. invertY: boolean;
  60877. /**
  60878. * Create a new PerturbNormalBlock
  60879. * @param name defines the block name
  60880. */
  60881. constructor(name: string);
  60882. /**
  60883. * Gets the current class name
  60884. * @returns the class name
  60885. */
  60886. getClassName(): string;
  60887. /**
  60888. * Gets the world position input component
  60889. */
  60890. get worldPosition(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the world normal input component
  60893. */
  60894. get worldNormal(): NodeMaterialConnectionPoint;
  60895. /**
  60896. * Gets the world tangent input component
  60897. */
  60898. get worldTangent(): NodeMaterialConnectionPoint;
  60899. /**
  60900. * Gets the uv input component
  60901. */
  60902. get uv(): NodeMaterialConnectionPoint;
  60903. /**
  60904. * Gets the normal map color input component
  60905. */
  60906. get normalMapColor(): NodeMaterialConnectionPoint;
  60907. /**
  60908. * Gets the strength input component
  60909. */
  60910. get strength(): NodeMaterialConnectionPoint;
  60911. /**
  60912. * Gets the output component
  60913. */
  60914. get output(): NodeMaterialConnectionPoint;
  60915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60917. autoConfigure(material: NodeMaterial): void;
  60918. protected _buildBlock(state: NodeMaterialBuildState): this;
  60919. protected _dumpPropertiesCode(): string;
  60920. serialize(): any;
  60921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60922. }
  60923. }
  60924. declare module BABYLON {
  60925. /**
  60926. * Block used to discard a pixel if a value is smaller than a cutoff
  60927. */
  60928. export class DiscardBlock extends NodeMaterialBlock {
  60929. /**
  60930. * Create a new DiscardBlock
  60931. * @param name defines the block name
  60932. */
  60933. constructor(name: string);
  60934. /**
  60935. * Gets the current class name
  60936. * @returns the class name
  60937. */
  60938. getClassName(): string;
  60939. /**
  60940. * Gets the color input component
  60941. */
  60942. get value(): NodeMaterialConnectionPoint;
  60943. /**
  60944. * Gets the cutoff input component
  60945. */
  60946. get cutoff(): NodeMaterialConnectionPoint;
  60947. protected _buildBlock(state: NodeMaterialBuildState): this;
  60948. }
  60949. }
  60950. declare module BABYLON {
  60951. /**
  60952. * Block used to test if the fragment shader is front facing
  60953. */
  60954. export class FrontFacingBlock extends NodeMaterialBlock {
  60955. /**
  60956. * Creates a new FrontFacingBlock
  60957. * @param name defines the block name
  60958. */
  60959. constructor(name: string);
  60960. /**
  60961. * Gets the current class name
  60962. * @returns the class name
  60963. */
  60964. getClassName(): string;
  60965. /**
  60966. * Gets the output component
  60967. */
  60968. get output(): NodeMaterialConnectionPoint;
  60969. protected _buildBlock(state: NodeMaterialBuildState): this;
  60970. }
  60971. }
  60972. declare module BABYLON {
  60973. /**
  60974. * Block used to get the derivative value on x and y of a given input
  60975. */
  60976. export class DerivativeBlock extends NodeMaterialBlock {
  60977. /**
  60978. * Create a new DerivativeBlock
  60979. * @param name defines the block name
  60980. */
  60981. constructor(name: string);
  60982. /**
  60983. * Gets the current class name
  60984. * @returns the class name
  60985. */
  60986. getClassName(): string;
  60987. /**
  60988. * Gets the input component
  60989. */
  60990. get input(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the derivative output on x
  60993. */
  60994. get dx(): NodeMaterialConnectionPoint;
  60995. /**
  60996. * Gets the derivative output on y
  60997. */
  60998. get dy(): NodeMaterialConnectionPoint;
  60999. protected _buildBlock(state: NodeMaterialBuildState): this;
  61000. }
  61001. }
  61002. declare module BABYLON {
  61003. /**
  61004. * Block used to add support for scene fog
  61005. */
  61006. export class FogBlock extends NodeMaterialBlock {
  61007. private _fogDistanceName;
  61008. private _fogParameters;
  61009. /**
  61010. * Create a new FogBlock
  61011. * @param name defines the block name
  61012. */
  61013. constructor(name: string);
  61014. /**
  61015. * Gets the current class name
  61016. * @returns the class name
  61017. */
  61018. getClassName(): string;
  61019. /**
  61020. * Gets the world position input component
  61021. */
  61022. get worldPosition(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the view input component
  61025. */
  61026. get view(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the color input component
  61029. */
  61030. get input(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the fog color input component
  61033. */
  61034. get fogColor(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the output component
  61037. */
  61038. get output(): NodeMaterialConnectionPoint;
  61039. autoConfigure(material: NodeMaterial): void;
  61040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61042. protected _buildBlock(state: NodeMaterialBuildState): this;
  61043. }
  61044. }
  61045. declare module BABYLON {
  61046. /**
  61047. * Block used to add light in the fragment shader
  61048. */
  61049. export class LightBlock extends NodeMaterialBlock {
  61050. private _lightId;
  61051. /**
  61052. * Gets or sets the light associated with this block
  61053. */
  61054. light: Nullable<Light>;
  61055. /**
  61056. * Create a new LightBlock
  61057. * @param name defines the block name
  61058. */
  61059. constructor(name: string);
  61060. /**
  61061. * Gets the current class name
  61062. * @returns the class name
  61063. */
  61064. getClassName(): string;
  61065. /**
  61066. * Gets the world position input component
  61067. */
  61068. get worldPosition(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the world normal input component
  61071. */
  61072. get worldNormal(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the camera (or eye) position component
  61075. */
  61076. get cameraPosition(): NodeMaterialConnectionPoint;
  61077. /**
  61078. * Gets the glossiness component
  61079. */
  61080. get glossiness(): NodeMaterialConnectionPoint;
  61081. /**
  61082. * Gets the glossinness power component
  61083. */
  61084. get glossPower(): NodeMaterialConnectionPoint;
  61085. /**
  61086. * Gets the diffuse color component
  61087. */
  61088. get diffuseColor(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the specular color component
  61091. */
  61092. get specularColor(): NodeMaterialConnectionPoint;
  61093. /**
  61094. * Gets the diffuse output component
  61095. */
  61096. get diffuseOutput(): NodeMaterialConnectionPoint;
  61097. /**
  61098. * Gets the specular output component
  61099. */
  61100. get specularOutput(): NodeMaterialConnectionPoint;
  61101. /**
  61102. * Gets the shadow output component
  61103. */
  61104. get shadow(): NodeMaterialConnectionPoint;
  61105. autoConfigure(material: NodeMaterial): void;
  61106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61107. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61109. private _injectVertexCode;
  61110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61111. serialize(): any;
  61112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61113. }
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * Block used to read a reflection texture from a sampler
  61118. */
  61119. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61120. /**
  61121. * Create a new ReflectionTextureBlock
  61122. * @param name defines the block name
  61123. */
  61124. constructor(name: string);
  61125. /**
  61126. * Gets the current class name
  61127. * @returns the class name
  61128. */
  61129. getClassName(): string;
  61130. /**
  61131. * Gets the world position input component
  61132. */
  61133. get position(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the world position input component
  61136. */
  61137. get worldPosition(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the world normal input component
  61140. */
  61141. get worldNormal(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the world input component
  61144. */
  61145. get world(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the camera (or eye) position component
  61148. */
  61149. get cameraPosition(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the view input component
  61152. */
  61153. get view(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the rgb output component
  61156. */
  61157. get rgb(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the r output component
  61160. */
  61161. get r(): NodeMaterialConnectionPoint;
  61162. /**
  61163. * Gets the g output component
  61164. */
  61165. get g(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the b output component
  61168. */
  61169. get b(): NodeMaterialConnectionPoint;
  61170. autoConfigure(material: NodeMaterial): void;
  61171. protected _buildBlock(state: NodeMaterialBuildState): this;
  61172. }
  61173. }
  61174. declare module BABYLON {
  61175. /**
  61176. * Block used to add 2 vectors
  61177. */
  61178. export class AddBlock extends NodeMaterialBlock {
  61179. /**
  61180. * Creates a new AddBlock
  61181. * @param name defines the block name
  61182. */
  61183. constructor(name: string);
  61184. /**
  61185. * Gets the current class name
  61186. * @returns the class name
  61187. */
  61188. getClassName(): string;
  61189. /**
  61190. * Gets the left operand input component
  61191. */
  61192. get left(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the right operand input component
  61195. */
  61196. get right(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the output component
  61199. */
  61200. get output(): NodeMaterialConnectionPoint;
  61201. protected _buildBlock(state: NodeMaterialBuildState): this;
  61202. }
  61203. }
  61204. declare module BABYLON {
  61205. /**
  61206. * Block used to scale a vector by a float
  61207. */
  61208. export class ScaleBlock extends NodeMaterialBlock {
  61209. /**
  61210. * Creates a new ScaleBlock
  61211. * @param name defines the block name
  61212. */
  61213. constructor(name: string);
  61214. /**
  61215. * Gets the current class name
  61216. * @returns the class name
  61217. */
  61218. getClassName(): string;
  61219. /**
  61220. * Gets the input component
  61221. */
  61222. get input(): NodeMaterialConnectionPoint;
  61223. /**
  61224. * Gets the factor input component
  61225. */
  61226. get factor(): NodeMaterialConnectionPoint;
  61227. /**
  61228. * Gets the output component
  61229. */
  61230. get output(): NodeMaterialConnectionPoint;
  61231. protected _buildBlock(state: NodeMaterialBuildState): this;
  61232. }
  61233. }
  61234. declare module BABYLON {
  61235. /**
  61236. * Block used to clamp a float
  61237. */
  61238. export class ClampBlock extends NodeMaterialBlock {
  61239. /** Gets or sets the minimum range */
  61240. minimum: number;
  61241. /** Gets or sets the maximum range */
  61242. maximum: number;
  61243. /**
  61244. * Creates a new ClampBlock
  61245. * @param name defines the block name
  61246. */
  61247. constructor(name: string);
  61248. /**
  61249. * Gets the current class name
  61250. * @returns the class name
  61251. */
  61252. getClassName(): string;
  61253. /**
  61254. * Gets the value input component
  61255. */
  61256. get value(): NodeMaterialConnectionPoint;
  61257. /**
  61258. * Gets the output component
  61259. */
  61260. get output(): NodeMaterialConnectionPoint;
  61261. protected _buildBlock(state: NodeMaterialBuildState): this;
  61262. protected _dumpPropertiesCode(): string;
  61263. serialize(): any;
  61264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61265. }
  61266. }
  61267. declare module BABYLON {
  61268. /**
  61269. * Block used to apply a cross product between 2 vectors
  61270. */
  61271. export class CrossBlock extends NodeMaterialBlock {
  61272. /**
  61273. * Creates a new CrossBlock
  61274. * @param name defines the block name
  61275. */
  61276. constructor(name: string);
  61277. /**
  61278. * Gets the current class name
  61279. * @returns the class name
  61280. */
  61281. getClassName(): string;
  61282. /**
  61283. * Gets the left operand input component
  61284. */
  61285. get left(): NodeMaterialConnectionPoint;
  61286. /**
  61287. * Gets the right operand input component
  61288. */
  61289. get right(): NodeMaterialConnectionPoint;
  61290. /**
  61291. * Gets the output component
  61292. */
  61293. get output(): NodeMaterialConnectionPoint;
  61294. protected _buildBlock(state: NodeMaterialBuildState): this;
  61295. }
  61296. }
  61297. declare module BABYLON {
  61298. /**
  61299. * Block used to apply a dot product between 2 vectors
  61300. */
  61301. export class DotBlock extends NodeMaterialBlock {
  61302. /**
  61303. * Creates a new DotBlock
  61304. * @param name defines the block name
  61305. */
  61306. constructor(name: string);
  61307. /**
  61308. * Gets the current class name
  61309. * @returns the class name
  61310. */
  61311. getClassName(): string;
  61312. /**
  61313. * Gets the left operand input component
  61314. */
  61315. get left(): NodeMaterialConnectionPoint;
  61316. /**
  61317. * Gets the right operand input component
  61318. */
  61319. get right(): NodeMaterialConnectionPoint;
  61320. /**
  61321. * Gets the output component
  61322. */
  61323. get output(): NodeMaterialConnectionPoint;
  61324. protected _buildBlock(state: NodeMaterialBuildState): this;
  61325. }
  61326. }
  61327. declare module BABYLON {
  61328. /**
  61329. * Block used to normalize a vector
  61330. */
  61331. export class NormalizeBlock extends NodeMaterialBlock {
  61332. /**
  61333. * Creates a new NormalizeBlock
  61334. * @param name defines the block name
  61335. */
  61336. constructor(name: string);
  61337. /**
  61338. * Gets the current class name
  61339. * @returns the class name
  61340. */
  61341. getClassName(): string;
  61342. /**
  61343. * Gets the input component
  61344. */
  61345. get input(): NodeMaterialConnectionPoint;
  61346. /**
  61347. * Gets the output component
  61348. */
  61349. get output(): NodeMaterialConnectionPoint;
  61350. protected _buildBlock(state: NodeMaterialBuildState): this;
  61351. }
  61352. }
  61353. declare module BABYLON {
  61354. /**
  61355. * Operations supported by the Trigonometry block
  61356. */
  61357. export enum TrigonometryBlockOperations {
  61358. /** Cos */
  61359. Cos = 0,
  61360. /** Sin */
  61361. Sin = 1,
  61362. /** Abs */
  61363. Abs = 2,
  61364. /** Exp */
  61365. Exp = 3,
  61366. /** Exp2 */
  61367. Exp2 = 4,
  61368. /** Round */
  61369. Round = 5,
  61370. /** Floor */
  61371. Floor = 6,
  61372. /** Ceiling */
  61373. Ceiling = 7,
  61374. /** Square root */
  61375. Sqrt = 8,
  61376. /** Log */
  61377. Log = 9,
  61378. /** Tangent */
  61379. Tan = 10,
  61380. /** Arc tangent */
  61381. ArcTan = 11,
  61382. /** Arc cosinus */
  61383. ArcCos = 12,
  61384. /** Arc sinus */
  61385. ArcSin = 13,
  61386. /** Fraction */
  61387. Fract = 14,
  61388. /** Sign */
  61389. Sign = 15,
  61390. /** To radians (from degrees) */
  61391. Radians = 16,
  61392. /** To degrees (from radians) */
  61393. Degrees = 17
  61394. }
  61395. /**
  61396. * Block used to apply trigonometry operation to floats
  61397. */
  61398. export class TrigonometryBlock extends NodeMaterialBlock {
  61399. /**
  61400. * Gets or sets the operation applied by the block
  61401. */
  61402. operation: TrigonometryBlockOperations;
  61403. /**
  61404. * Creates a new TrigonometryBlock
  61405. * @param name defines the block name
  61406. */
  61407. constructor(name: string);
  61408. /**
  61409. * Gets the current class name
  61410. * @returns the class name
  61411. */
  61412. getClassName(): string;
  61413. /**
  61414. * Gets the input component
  61415. */
  61416. get input(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the output component
  61419. */
  61420. get output(): NodeMaterialConnectionPoint;
  61421. protected _buildBlock(state: NodeMaterialBuildState): this;
  61422. serialize(): any;
  61423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61424. protected _dumpPropertiesCode(): string;
  61425. }
  61426. }
  61427. declare module BABYLON {
  61428. /**
  61429. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61430. */
  61431. export class ColorMergerBlock extends NodeMaterialBlock {
  61432. /**
  61433. * Create a new ColorMergerBlock
  61434. * @param name defines the block name
  61435. */
  61436. constructor(name: string);
  61437. /**
  61438. * Gets the current class name
  61439. * @returns the class name
  61440. */
  61441. getClassName(): string;
  61442. /**
  61443. * Gets the rgb component (input)
  61444. */
  61445. get rgbIn(): NodeMaterialConnectionPoint;
  61446. /**
  61447. * Gets the r component (input)
  61448. */
  61449. get r(): NodeMaterialConnectionPoint;
  61450. /**
  61451. * Gets the g component (input)
  61452. */
  61453. get g(): NodeMaterialConnectionPoint;
  61454. /**
  61455. * Gets the b component (input)
  61456. */
  61457. get b(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the a component (input)
  61460. */
  61461. get a(): NodeMaterialConnectionPoint;
  61462. /**
  61463. * Gets the rgba component (output)
  61464. */
  61465. get rgba(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the rgb component (output)
  61468. */
  61469. get rgbOut(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the rgb component (output)
  61472. * @deprecated Please use rgbOut instead.
  61473. */
  61474. get rgb(): NodeMaterialConnectionPoint;
  61475. protected _buildBlock(state: NodeMaterialBuildState): this;
  61476. }
  61477. }
  61478. declare module BABYLON {
  61479. /**
  61480. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61481. */
  61482. export class VectorSplitterBlock extends NodeMaterialBlock {
  61483. /**
  61484. * Create a new VectorSplitterBlock
  61485. * @param name defines the block name
  61486. */
  61487. constructor(name: string);
  61488. /**
  61489. * Gets the current class name
  61490. * @returns the class name
  61491. */
  61492. getClassName(): string;
  61493. /**
  61494. * Gets the xyzw component (input)
  61495. */
  61496. get xyzw(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the xyz component (input)
  61499. */
  61500. get xyzIn(): NodeMaterialConnectionPoint;
  61501. /**
  61502. * Gets the xy component (input)
  61503. */
  61504. get xyIn(): NodeMaterialConnectionPoint;
  61505. /**
  61506. * Gets the xyz component (output)
  61507. */
  61508. get xyzOut(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the xy component (output)
  61511. */
  61512. get xyOut(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the x component (output)
  61515. */
  61516. get x(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the y component (output)
  61519. */
  61520. get y(): NodeMaterialConnectionPoint;
  61521. /**
  61522. * Gets the z component (output)
  61523. */
  61524. get z(): NodeMaterialConnectionPoint;
  61525. /**
  61526. * Gets the w component (output)
  61527. */
  61528. get w(): NodeMaterialConnectionPoint;
  61529. protected _inputRename(name: string): string;
  61530. protected _outputRename(name: string): string;
  61531. protected _buildBlock(state: NodeMaterialBuildState): this;
  61532. }
  61533. }
  61534. declare module BABYLON {
  61535. /**
  61536. * Block used to lerp between 2 values
  61537. */
  61538. export class LerpBlock extends NodeMaterialBlock {
  61539. /**
  61540. * Creates a new LerpBlock
  61541. * @param name defines the block name
  61542. */
  61543. constructor(name: string);
  61544. /**
  61545. * Gets the current class name
  61546. * @returns the class name
  61547. */
  61548. getClassName(): string;
  61549. /**
  61550. * Gets the left operand input component
  61551. */
  61552. get left(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the right operand input component
  61555. */
  61556. get right(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the gradient operand input component
  61559. */
  61560. get gradient(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the output component
  61563. */
  61564. get output(): NodeMaterialConnectionPoint;
  61565. protected _buildBlock(state: NodeMaterialBuildState): this;
  61566. }
  61567. }
  61568. declare module BABYLON {
  61569. /**
  61570. * Block used to divide 2 vectors
  61571. */
  61572. export class DivideBlock extends NodeMaterialBlock {
  61573. /**
  61574. * Creates a new DivideBlock
  61575. * @param name defines the block name
  61576. */
  61577. constructor(name: string);
  61578. /**
  61579. * Gets the current class name
  61580. * @returns the class name
  61581. */
  61582. getClassName(): string;
  61583. /**
  61584. * Gets the left operand input component
  61585. */
  61586. get left(): NodeMaterialConnectionPoint;
  61587. /**
  61588. * Gets the right operand input component
  61589. */
  61590. get right(): NodeMaterialConnectionPoint;
  61591. /**
  61592. * Gets the output component
  61593. */
  61594. get output(): NodeMaterialConnectionPoint;
  61595. protected _buildBlock(state: NodeMaterialBuildState): this;
  61596. }
  61597. }
  61598. declare module BABYLON {
  61599. /**
  61600. * Block used to subtract 2 vectors
  61601. */
  61602. export class SubtractBlock extends NodeMaterialBlock {
  61603. /**
  61604. * Creates a new SubtractBlock
  61605. * @param name defines the block name
  61606. */
  61607. constructor(name: string);
  61608. /**
  61609. * Gets the current class name
  61610. * @returns the class name
  61611. */
  61612. getClassName(): string;
  61613. /**
  61614. * Gets the left operand input component
  61615. */
  61616. get left(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the right operand input component
  61619. */
  61620. get right(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the output component
  61623. */
  61624. get output(): NodeMaterialConnectionPoint;
  61625. protected _buildBlock(state: NodeMaterialBuildState): this;
  61626. }
  61627. }
  61628. declare module BABYLON {
  61629. /**
  61630. * Block used to step a value
  61631. */
  61632. export class StepBlock extends NodeMaterialBlock {
  61633. /**
  61634. * Creates a new StepBlock
  61635. * @param name defines the block name
  61636. */
  61637. constructor(name: string);
  61638. /**
  61639. * Gets the current class name
  61640. * @returns the class name
  61641. */
  61642. getClassName(): string;
  61643. /**
  61644. * Gets the value operand input component
  61645. */
  61646. get value(): NodeMaterialConnectionPoint;
  61647. /**
  61648. * Gets the edge operand input component
  61649. */
  61650. get edge(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the output component
  61653. */
  61654. get output(): NodeMaterialConnectionPoint;
  61655. protected _buildBlock(state: NodeMaterialBuildState): this;
  61656. }
  61657. }
  61658. declare module BABYLON {
  61659. /**
  61660. * Block used to get the opposite (1 - x) of a value
  61661. */
  61662. export class OneMinusBlock extends NodeMaterialBlock {
  61663. /**
  61664. * Creates a new OneMinusBlock
  61665. * @param name defines the block name
  61666. */
  61667. constructor(name: string);
  61668. /**
  61669. * Gets the current class name
  61670. * @returns the class name
  61671. */
  61672. getClassName(): string;
  61673. /**
  61674. * Gets the input component
  61675. */
  61676. get input(): NodeMaterialConnectionPoint;
  61677. /**
  61678. * Gets the output component
  61679. */
  61680. get output(): NodeMaterialConnectionPoint;
  61681. protected _buildBlock(state: NodeMaterialBuildState): this;
  61682. }
  61683. }
  61684. declare module BABYLON {
  61685. /**
  61686. * Block used to get the view direction
  61687. */
  61688. export class ViewDirectionBlock extends NodeMaterialBlock {
  61689. /**
  61690. * Creates a new ViewDirectionBlock
  61691. * @param name defines the block name
  61692. */
  61693. constructor(name: string);
  61694. /**
  61695. * Gets the current class name
  61696. * @returns the class name
  61697. */
  61698. getClassName(): string;
  61699. /**
  61700. * Gets the world position component
  61701. */
  61702. get worldPosition(): NodeMaterialConnectionPoint;
  61703. /**
  61704. * Gets the camera position component
  61705. */
  61706. get cameraPosition(): NodeMaterialConnectionPoint;
  61707. /**
  61708. * Gets the output component
  61709. */
  61710. get output(): NodeMaterialConnectionPoint;
  61711. autoConfigure(material: NodeMaterial): void;
  61712. protected _buildBlock(state: NodeMaterialBuildState): this;
  61713. }
  61714. }
  61715. declare module BABYLON {
  61716. /**
  61717. * Block used to compute fresnel value
  61718. */
  61719. export class FresnelBlock extends NodeMaterialBlock {
  61720. /**
  61721. * Create a new FresnelBlock
  61722. * @param name defines the block name
  61723. */
  61724. constructor(name: string);
  61725. /**
  61726. * Gets the current class name
  61727. * @returns the class name
  61728. */
  61729. getClassName(): string;
  61730. /**
  61731. * Gets the world normal input component
  61732. */
  61733. get worldNormal(): NodeMaterialConnectionPoint;
  61734. /**
  61735. * Gets the view direction input component
  61736. */
  61737. get viewDirection(): NodeMaterialConnectionPoint;
  61738. /**
  61739. * Gets the bias input component
  61740. */
  61741. get bias(): NodeMaterialConnectionPoint;
  61742. /**
  61743. * Gets the camera (or eye) position component
  61744. */
  61745. get power(): NodeMaterialConnectionPoint;
  61746. /**
  61747. * Gets the fresnel output component
  61748. */
  61749. get fresnel(): NodeMaterialConnectionPoint;
  61750. autoConfigure(material: NodeMaterial): void;
  61751. protected _buildBlock(state: NodeMaterialBuildState): this;
  61752. }
  61753. }
  61754. declare module BABYLON {
  61755. /**
  61756. * Block used to get the max of 2 values
  61757. */
  61758. export class MaxBlock extends NodeMaterialBlock {
  61759. /**
  61760. * Creates a new MaxBlock
  61761. * @param name defines the block name
  61762. */
  61763. constructor(name: string);
  61764. /**
  61765. * Gets the current class name
  61766. * @returns the class name
  61767. */
  61768. getClassName(): string;
  61769. /**
  61770. * Gets the left operand input component
  61771. */
  61772. get left(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the right operand input component
  61775. */
  61776. get right(): NodeMaterialConnectionPoint;
  61777. /**
  61778. * Gets the output component
  61779. */
  61780. get output(): NodeMaterialConnectionPoint;
  61781. protected _buildBlock(state: NodeMaterialBuildState): this;
  61782. }
  61783. }
  61784. declare module BABYLON {
  61785. /**
  61786. * Block used to get the min of 2 values
  61787. */
  61788. export class MinBlock extends NodeMaterialBlock {
  61789. /**
  61790. * Creates a new MinBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the left operand input component
  61801. */
  61802. get left(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the right operand input component
  61805. */
  61806. get right(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the output component
  61809. */
  61810. get output(): NodeMaterialConnectionPoint;
  61811. protected _buildBlock(state: NodeMaterialBuildState): this;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * Block used to get the distance between 2 values
  61817. */
  61818. export class DistanceBlock extends NodeMaterialBlock {
  61819. /**
  61820. * Creates a new DistanceBlock
  61821. * @param name defines the block name
  61822. */
  61823. constructor(name: string);
  61824. /**
  61825. * Gets the current class name
  61826. * @returns the class name
  61827. */
  61828. getClassName(): string;
  61829. /**
  61830. * Gets the left operand input component
  61831. */
  61832. get left(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the right operand input component
  61835. */
  61836. get right(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the output component
  61839. */
  61840. get output(): NodeMaterialConnectionPoint;
  61841. protected _buildBlock(state: NodeMaterialBuildState): this;
  61842. }
  61843. }
  61844. declare module BABYLON {
  61845. /**
  61846. * Block used to get the length of a vector
  61847. */
  61848. export class LengthBlock extends NodeMaterialBlock {
  61849. /**
  61850. * Creates a new LengthBlock
  61851. * @param name defines the block name
  61852. */
  61853. constructor(name: string);
  61854. /**
  61855. * Gets the current class name
  61856. * @returns the class name
  61857. */
  61858. getClassName(): string;
  61859. /**
  61860. * Gets the value input component
  61861. */
  61862. get value(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the output component
  61865. */
  61866. get output(): NodeMaterialConnectionPoint;
  61867. protected _buildBlock(state: NodeMaterialBuildState): this;
  61868. }
  61869. }
  61870. declare module BABYLON {
  61871. /**
  61872. * Block used to get negative version of a value (i.e. x * -1)
  61873. */
  61874. export class NegateBlock extends NodeMaterialBlock {
  61875. /**
  61876. * Creates a new NegateBlock
  61877. * @param name defines the block name
  61878. */
  61879. constructor(name: string);
  61880. /**
  61881. * Gets the current class name
  61882. * @returns the class name
  61883. */
  61884. getClassName(): string;
  61885. /**
  61886. * Gets the value input component
  61887. */
  61888. get value(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the output component
  61891. */
  61892. get output(): NodeMaterialConnectionPoint;
  61893. protected _buildBlock(state: NodeMaterialBuildState): this;
  61894. }
  61895. }
  61896. declare module BABYLON {
  61897. /**
  61898. * Block used to get the value of the first parameter raised to the power of the second
  61899. */
  61900. export class PowBlock extends NodeMaterialBlock {
  61901. /**
  61902. * Creates a new PowBlock
  61903. * @param name defines the block name
  61904. */
  61905. constructor(name: string);
  61906. /**
  61907. * Gets the current class name
  61908. * @returns the class name
  61909. */
  61910. getClassName(): string;
  61911. /**
  61912. * Gets the value operand input component
  61913. */
  61914. get value(): NodeMaterialConnectionPoint;
  61915. /**
  61916. * Gets the power operand input component
  61917. */
  61918. get power(): NodeMaterialConnectionPoint;
  61919. /**
  61920. * Gets the output component
  61921. */
  61922. get output(): NodeMaterialConnectionPoint;
  61923. protected _buildBlock(state: NodeMaterialBuildState): this;
  61924. }
  61925. }
  61926. declare module BABYLON {
  61927. /**
  61928. * Block used to get a random number
  61929. */
  61930. export class RandomNumberBlock extends NodeMaterialBlock {
  61931. /**
  61932. * Creates a new RandomNumberBlock
  61933. * @param name defines the block name
  61934. */
  61935. constructor(name: string);
  61936. /**
  61937. * Gets the current class name
  61938. * @returns the class name
  61939. */
  61940. getClassName(): string;
  61941. /**
  61942. * Gets the seed input component
  61943. */
  61944. get seed(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the output component
  61947. */
  61948. get output(): NodeMaterialConnectionPoint;
  61949. protected _buildBlock(state: NodeMaterialBuildState): this;
  61950. }
  61951. }
  61952. declare module BABYLON {
  61953. /**
  61954. * Block used to compute arc tangent of 2 values
  61955. */
  61956. export class ArcTan2Block extends NodeMaterialBlock {
  61957. /**
  61958. * Creates a new ArcTan2Block
  61959. * @param name defines the block name
  61960. */
  61961. constructor(name: string);
  61962. /**
  61963. * Gets the current class name
  61964. * @returns the class name
  61965. */
  61966. getClassName(): string;
  61967. /**
  61968. * Gets the x operand input component
  61969. */
  61970. get x(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the y operand input component
  61973. */
  61974. get y(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the output component
  61977. */
  61978. get output(): NodeMaterialConnectionPoint;
  61979. protected _buildBlock(state: NodeMaterialBuildState): this;
  61980. }
  61981. }
  61982. declare module BABYLON {
  61983. /**
  61984. * Block used to smooth step a value
  61985. */
  61986. export class SmoothStepBlock extends NodeMaterialBlock {
  61987. /**
  61988. * Creates a new SmoothStepBlock
  61989. * @param name defines the block name
  61990. */
  61991. constructor(name: string);
  61992. /**
  61993. * Gets the current class name
  61994. * @returns the class name
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Gets the value operand input component
  61999. */
  62000. get value(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the first edge operand input component
  62003. */
  62004. get edge0(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the second edge operand input component
  62007. */
  62008. get edge1(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the output component
  62011. */
  62012. get output(): NodeMaterialConnectionPoint;
  62013. protected _buildBlock(state: NodeMaterialBuildState): this;
  62014. }
  62015. }
  62016. declare module BABYLON {
  62017. /**
  62018. * Block used to get the reciprocal (1 / x) of a value
  62019. */
  62020. export class ReciprocalBlock extends NodeMaterialBlock {
  62021. /**
  62022. * Creates a new ReciprocalBlock
  62023. * @param name defines the block name
  62024. */
  62025. constructor(name: string);
  62026. /**
  62027. * Gets the current class name
  62028. * @returns the class name
  62029. */
  62030. getClassName(): string;
  62031. /**
  62032. * Gets the input component
  62033. */
  62034. get input(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the output component
  62037. */
  62038. get output(): NodeMaterialConnectionPoint;
  62039. protected _buildBlock(state: NodeMaterialBuildState): this;
  62040. }
  62041. }
  62042. declare module BABYLON {
  62043. /**
  62044. * Block used to replace a color by another one
  62045. */
  62046. export class ReplaceColorBlock extends NodeMaterialBlock {
  62047. /**
  62048. * Creates a new ReplaceColorBlock
  62049. * @param name defines the block name
  62050. */
  62051. constructor(name: string);
  62052. /**
  62053. * Gets the current class name
  62054. * @returns the class name
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * Gets the value input component
  62059. */
  62060. get value(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the reference input component
  62063. */
  62064. get reference(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the distance input component
  62067. */
  62068. get distance(): NodeMaterialConnectionPoint;
  62069. /**
  62070. * Gets the replacement input component
  62071. */
  62072. get replacement(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the output component
  62075. */
  62076. get output(): NodeMaterialConnectionPoint;
  62077. protected _buildBlock(state: NodeMaterialBuildState): this;
  62078. }
  62079. }
  62080. declare module BABYLON {
  62081. /**
  62082. * Block used to posterize a value
  62083. * @see https://en.wikipedia.org/wiki/Posterization
  62084. */
  62085. export class PosterizeBlock extends NodeMaterialBlock {
  62086. /**
  62087. * Creates a new PosterizeBlock
  62088. * @param name defines the block name
  62089. */
  62090. constructor(name: string);
  62091. /**
  62092. * Gets the current class name
  62093. * @returns the class name
  62094. */
  62095. getClassName(): string;
  62096. /**
  62097. * Gets the value input component
  62098. */
  62099. get value(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the steps input component
  62102. */
  62103. get steps(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the output component
  62106. */
  62107. get output(): NodeMaterialConnectionPoint;
  62108. protected _buildBlock(state: NodeMaterialBuildState): this;
  62109. }
  62110. }
  62111. declare module BABYLON {
  62112. /**
  62113. * Operations supported by the Wave block
  62114. */
  62115. export enum WaveBlockKind {
  62116. /** SawTooth */
  62117. SawTooth = 0,
  62118. /** Square */
  62119. Square = 1,
  62120. /** Triangle */
  62121. Triangle = 2
  62122. }
  62123. /**
  62124. * Block used to apply wave operation to floats
  62125. */
  62126. export class WaveBlock extends NodeMaterialBlock {
  62127. /**
  62128. * Gets or sets the kibnd of wave to be applied by the block
  62129. */
  62130. kind: WaveBlockKind;
  62131. /**
  62132. * Creates a new WaveBlock
  62133. * @param name defines the block name
  62134. */
  62135. constructor(name: string);
  62136. /**
  62137. * Gets the current class name
  62138. * @returns the class name
  62139. */
  62140. getClassName(): string;
  62141. /**
  62142. * Gets the input component
  62143. */
  62144. get input(): NodeMaterialConnectionPoint;
  62145. /**
  62146. * Gets the output component
  62147. */
  62148. get output(): NodeMaterialConnectionPoint;
  62149. protected _buildBlock(state: NodeMaterialBuildState): this;
  62150. serialize(): any;
  62151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62152. }
  62153. }
  62154. declare module BABYLON {
  62155. /**
  62156. * Class used to store a color step for the GradientBlock
  62157. */
  62158. export class GradientBlockColorStep {
  62159. /**
  62160. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62161. */
  62162. step: number;
  62163. /**
  62164. * Gets or sets the color associated with this step
  62165. */
  62166. color: Color3;
  62167. /**
  62168. * Creates a new GradientBlockColorStep
  62169. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62170. * @param color defines the color associated with this step
  62171. */
  62172. constructor(
  62173. /**
  62174. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62175. */
  62176. step: number,
  62177. /**
  62178. * Gets or sets the color associated with this step
  62179. */
  62180. color: Color3);
  62181. }
  62182. /**
  62183. * Block used to return a color from a gradient based on an input value between 0 and 1
  62184. */
  62185. export class GradientBlock extends NodeMaterialBlock {
  62186. /**
  62187. * Gets or sets the list of color steps
  62188. */
  62189. colorSteps: GradientBlockColorStep[];
  62190. /**
  62191. * Creates a new GradientBlock
  62192. * @param name defines the block name
  62193. */
  62194. constructor(name: string);
  62195. /**
  62196. * Gets the current class name
  62197. * @returns the class name
  62198. */
  62199. getClassName(): string;
  62200. /**
  62201. * Gets the gradient input component
  62202. */
  62203. get gradient(): NodeMaterialConnectionPoint;
  62204. /**
  62205. * Gets the output component
  62206. */
  62207. get output(): NodeMaterialConnectionPoint;
  62208. private _writeColorConstant;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62210. serialize(): any;
  62211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62212. protected _dumpPropertiesCode(): string;
  62213. }
  62214. }
  62215. declare module BABYLON {
  62216. /**
  62217. * Block used to normalize lerp between 2 values
  62218. */
  62219. export class NLerpBlock extends NodeMaterialBlock {
  62220. /**
  62221. * Creates a new NLerpBlock
  62222. * @param name defines the block name
  62223. */
  62224. constructor(name: string);
  62225. /**
  62226. * Gets the current class name
  62227. * @returns the class name
  62228. */
  62229. getClassName(): string;
  62230. /**
  62231. * Gets the left operand input component
  62232. */
  62233. get left(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the right operand input component
  62236. */
  62237. get right(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the gradient operand input component
  62240. */
  62241. get gradient(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the output component
  62244. */
  62245. get output(): NodeMaterialConnectionPoint;
  62246. protected _buildBlock(state: NodeMaterialBuildState): this;
  62247. }
  62248. }
  62249. declare module BABYLON {
  62250. /**
  62251. * block used to Generate a Worley Noise 3D Noise Pattern
  62252. */
  62253. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62254. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62255. manhattanDistance: boolean;
  62256. /**
  62257. * Creates a new WorleyNoise3DBlock
  62258. * @param name defines the block name
  62259. */
  62260. constructor(name: string);
  62261. /**
  62262. * Gets the current class name
  62263. * @returns the class name
  62264. */
  62265. getClassName(): string;
  62266. /**
  62267. * Gets the seed input component
  62268. */
  62269. get seed(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the jitter input component
  62272. */
  62273. get jitter(): NodeMaterialConnectionPoint;
  62274. /**
  62275. * Gets the output component
  62276. */
  62277. get output(): NodeMaterialConnectionPoint;
  62278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62279. /**
  62280. * Exposes the properties to the UI?
  62281. */
  62282. protected _dumpPropertiesCode(): string;
  62283. /**
  62284. * Exposes the properties to the Seralize?
  62285. */
  62286. serialize(): any;
  62287. /**
  62288. * Exposes the properties to the deseralize?
  62289. */
  62290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62296. */
  62297. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62298. /**
  62299. * Creates a new SimplexPerlin3DBlock
  62300. * @param name defines the block name
  62301. */
  62302. constructor(name: string);
  62303. /**
  62304. * Gets the current class name
  62305. * @returns the class name
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * Gets the seed operand input component
  62310. */
  62311. get seed(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the output component
  62314. */
  62315. get output(): NodeMaterialConnectionPoint;
  62316. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62317. }
  62318. }
  62319. declare module BABYLON {
  62320. /**
  62321. * Block used to blend normals
  62322. */
  62323. export class NormalBlendBlock extends NodeMaterialBlock {
  62324. /**
  62325. * Creates a new NormalBlendBlock
  62326. * @param name defines the block name
  62327. */
  62328. constructor(name: string);
  62329. /**
  62330. * Gets the current class name
  62331. * @returns the class name
  62332. */
  62333. getClassName(): string;
  62334. /**
  62335. * Gets the first input component
  62336. */
  62337. get normalMap0(): NodeMaterialConnectionPoint;
  62338. /**
  62339. * Gets the second input component
  62340. */
  62341. get normalMap1(): NodeMaterialConnectionPoint;
  62342. /**
  62343. * Gets the output component
  62344. */
  62345. get output(): NodeMaterialConnectionPoint;
  62346. protected _buildBlock(state: NodeMaterialBuildState): this;
  62347. }
  62348. }
  62349. declare module BABYLON {
  62350. /**
  62351. * Block used to rotate a 2d vector by a given angle
  62352. */
  62353. export class Rotate2dBlock extends NodeMaterialBlock {
  62354. /**
  62355. * Creates a new Rotate2dBlock
  62356. * @param name defines the block name
  62357. */
  62358. constructor(name: string);
  62359. /**
  62360. * Gets the current class name
  62361. * @returns the class name
  62362. */
  62363. getClassName(): string;
  62364. /**
  62365. * Gets the input vector
  62366. */
  62367. get input(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the input angle
  62370. */
  62371. get angle(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the output component
  62374. */
  62375. get output(): NodeMaterialConnectionPoint;
  62376. autoConfigure(material: NodeMaterial): void;
  62377. protected _buildBlock(state: NodeMaterialBuildState): this;
  62378. }
  62379. }
  62380. declare module BABYLON {
  62381. /**
  62382. * Block used to get the reflected vector from a direction and a normal
  62383. */
  62384. export class ReflectBlock extends NodeMaterialBlock {
  62385. /**
  62386. * Creates a new ReflectBlock
  62387. * @param name defines the block name
  62388. */
  62389. constructor(name: string);
  62390. /**
  62391. * Gets the current class name
  62392. * @returns the class name
  62393. */
  62394. getClassName(): string;
  62395. /**
  62396. * Gets the incident component
  62397. */
  62398. get incident(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the normal component
  62401. */
  62402. get normal(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the output component
  62405. */
  62406. get output(): NodeMaterialConnectionPoint;
  62407. protected _buildBlock(state: NodeMaterialBuildState): this;
  62408. }
  62409. }
  62410. declare module BABYLON {
  62411. /**
  62412. * Block used to get the refracted vector from a direction and a normal
  62413. */
  62414. export class RefractBlock extends NodeMaterialBlock {
  62415. /**
  62416. * Creates a new RefractBlock
  62417. * @param name defines the block name
  62418. */
  62419. constructor(name: string);
  62420. /**
  62421. * Gets the current class name
  62422. * @returns the class name
  62423. */
  62424. getClassName(): string;
  62425. /**
  62426. * Gets the incident component
  62427. */
  62428. get incident(): NodeMaterialConnectionPoint;
  62429. /**
  62430. * Gets the normal component
  62431. */
  62432. get normal(): NodeMaterialConnectionPoint;
  62433. /**
  62434. * Gets the index of refraction component
  62435. */
  62436. get ior(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the output component
  62439. */
  62440. get output(): NodeMaterialConnectionPoint;
  62441. protected _buildBlock(state: NodeMaterialBuildState): this;
  62442. }
  62443. }
  62444. declare module BABYLON {
  62445. /**
  62446. * Block used to desaturate a color
  62447. */
  62448. export class DesaturateBlock extends NodeMaterialBlock {
  62449. /**
  62450. * Creates a new DesaturateBlock
  62451. * @param name defines the block name
  62452. */
  62453. constructor(name: string);
  62454. /**
  62455. * Gets the current class name
  62456. * @returns the class name
  62457. */
  62458. getClassName(): string;
  62459. /**
  62460. * Gets the color operand input component
  62461. */
  62462. get color(): NodeMaterialConnectionPoint;
  62463. /**
  62464. * Gets the level operand input component
  62465. */
  62466. get level(): NodeMaterialConnectionPoint;
  62467. /**
  62468. * Gets the output component
  62469. */
  62470. get output(): NodeMaterialConnectionPoint;
  62471. protected _buildBlock(state: NodeMaterialBuildState): this;
  62472. }
  62473. }
  62474. declare module BABYLON {
  62475. /**
  62476. * Block used to implement the ambient occlusion module of the PBR material
  62477. */
  62478. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62479. /**
  62480. * Create a new AmbientOcclusionBlock
  62481. * @param name defines the block name
  62482. */
  62483. constructor(name: string);
  62484. /**
  62485. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62486. */
  62487. useAmbientInGrayScale: boolean;
  62488. /**
  62489. * Initialize the block and prepare the context for build
  62490. * @param state defines the state that will be used for the build
  62491. */
  62492. initialize(state: NodeMaterialBuildState): void;
  62493. /**
  62494. * Gets the current class name
  62495. * @returns the class name
  62496. */
  62497. getClassName(): string;
  62498. /**
  62499. * Gets the texture input component
  62500. */
  62501. get texture(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the texture intensity component
  62504. */
  62505. get intensity(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the direct light intensity input component
  62508. */
  62509. get directLightIntensity(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the ambient occlusion object output component
  62512. */
  62513. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the main code of the block (fragment side)
  62516. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62517. * @returns the shader code
  62518. */
  62519. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62521. protected _buildBlock(state: NodeMaterialBuildState): this;
  62522. protected _dumpPropertiesCode(): string;
  62523. serialize(): any;
  62524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62525. }
  62526. }
  62527. declare module BABYLON {
  62528. /**
  62529. * Block used to implement the reflection module of the PBR material
  62530. */
  62531. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62532. /** @hidden */
  62533. _defineLODReflectionAlpha: string;
  62534. /** @hidden */
  62535. _defineLinearSpecularReflection: string;
  62536. private _vEnvironmentIrradianceName;
  62537. /** @hidden */
  62538. _vReflectionMicrosurfaceInfosName: string;
  62539. /** @hidden */
  62540. _vReflectionInfosName: string;
  62541. private _scene;
  62542. /**
  62543. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62544. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62545. * It's less burden on the user side in the editor part.
  62546. */
  62547. /** @hidden */
  62548. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62549. /** @hidden */
  62550. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62551. /** @hidden */
  62552. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62553. /**
  62554. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62555. * diffuse part of the IBL.
  62556. */
  62557. useSphericalHarmonics: boolean;
  62558. /**
  62559. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62560. */
  62561. forceIrradianceInFragment: boolean;
  62562. /**
  62563. * Create a new ReflectionBlock
  62564. * @param name defines the block name
  62565. */
  62566. constructor(name: string);
  62567. /**
  62568. * Gets the current class name
  62569. * @returns the class name
  62570. */
  62571. getClassName(): string;
  62572. /**
  62573. * Gets the position input component
  62574. */
  62575. get position(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the world position input component
  62578. */
  62579. get worldPosition(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the world normal input component
  62582. */
  62583. get worldNormal(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the world input component
  62586. */
  62587. get world(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the camera (or eye) position component
  62590. */
  62591. get cameraPosition(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the view input component
  62594. */
  62595. get view(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the color input component
  62598. */
  62599. get color(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the reflection object output component
  62602. */
  62603. get reflection(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62606. */
  62607. get hasTexture(): boolean;
  62608. /**
  62609. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62610. */
  62611. get reflectionColor(): string;
  62612. protected _getTexture(): Nullable<BaseTexture>;
  62613. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62615. /**
  62616. * Gets the code to inject in the vertex shader
  62617. * @param state current state of the node material building
  62618. * @returns the shader code
  62619. */
  62620. handleVertexSide(state: NodeMaterialBuildState): string;
  62621. /**
  62622. * Gets the main code of the block (fragment side)
  62623. * @param state current state of the node material building
  62624. * @param normalVarName name of the existing variable corresponding to the normal
  62625. * @returns the shader code
  62626. */
  62627. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62628. protected _buildBlock(state: NodeMaterialBuildState): this;
  62629. protected _dumpPropertiesCode(): string;
  62630. serialize(): any;
  62631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62632. }
  62633. }
  62634. declare module BABYLON {
  62635. /**
  62636. * Block used to implement the sheen module of the PBR material
  62637. */
  62638. export class SheenBlock extends NodeMaterialBlock {
  62639. /**
  62640. * Create a new SheenBlock
  62641. * @param name defines the block name
  62642. */
  62643. constructor(name: string);
  62644. /**
  62645. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62646. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62647. * making it easier to setup and tweak the effect
  62648. */
  62649. albedoScaling: boolean;
  62650. /**
  62651. * Defines if the sheen is linked to the sheen color.
  62652. */
  62653. linkSheenWithAlbedo: boolean;
  62654. /**
  62655. * Initialize the block and prepare the context for build
  62656. * @param state defines the state that will be used for the build
  62657. */
  62658. initialize(state: NodeMaterialBuildState): void;
  62659. /**
  62660. * Gets the current class name
  62661. * @returns the class name
  62662. */
  62663. getClassName(): string;
  62664. /**
  62665. * Gets the intensity input component
  62666. */
  62667. get intensity(): NodeMaterialConnectionPoint;
  62668. /**
  62669. * Gets the color input component
  62670. */
  62671. get color(): NodeMaterialConnectionPoint;
  62672. /**
  62673. * Gets the roughness input component
  62674. */
  62675. get roughness(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the texture input component
  62678. */
  62679. get texture(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the sheen object output component
  62682. */
  62683. get sheen(): NodeMaterialConnectionPoint;
  62684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62685. /**
  62686. * Gets the main code of the block (fragment side)
  62687. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62688. * @returns the shader code
  62689. */
  62690. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62691. protected _buildBlock(state: NodeMaterialBuildState): this;
  62692. protected _dumpPropertiesCode(): string;
  62693. serialize(): any;
  62694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62695. }
  62696. }
  62697. declare module BABYLON {
  62698. /**
  62699. * Block used to implement the reflectivity module of the PBR material
  62700. */
  62701. export class ReflectivityBlock extends NodeMaterialBlock {
  62702. /**
  62703. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62704. */
  62705. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62706. /**
  62707. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62708. */
  62709. useMetallnessFromMetallicTextureBlue: boolean;
  62710. /**
  62711. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62712. */
  62713. useRoughnessFromMetallicTextureAlpha: boolean;
  62714. /**
  62715. * Specifies if the metallic texture contains the roughness information in its green channel.
  62716. */
  62717. useRoughnessFromMetallicTextureGreen: boolean;
  62718. /**
  62719. * Create a new ReflectivityBlock
  62720. * @param name defines the block name
  62721. */
  62722. constructor(name: string);
  62723. /**
  62724. * Initialize the block and prepare the context for build
  62725. * @param state defines the state that will be used for the build
  62726. */
  62727. initialize(state: NodeMaterialBuildState): void;
  62728. /**
  62729. * Gets the current class name
  62730. * @returns the class name
  62731. */
  62732. getClassName(): string;
  62733. /**
  62734. * Gets the metallic input component
  62735. */
  62736. get metallic(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the roughness input component
  62739. */
  62740. get roughness(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the texture input component
  62743. */
  62744. get texture(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the reflectivity object output component
  62747. */
  62748. get reflectivity(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the main code of the block (fragment side)
  62751. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62752. * @returns the shader code
  62753. */
  62754. getCode(aoIntensityVarName: string): string;
  62755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62756. protected _buildBlock(state: NodeMaterialBuildState): this;
  62757. protected _dumpPropertiesCode(): string;
  62758. serialize(): any;
  62759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /**
  62764. * Block used to implement the anisotropy module of the PBR material
  62765. */
  62766. export class AnisotropyBlock extends NodeMaterialBlock {
  62767. /**
  62768. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62769. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62770. * It's less burden on the user side in the editor part.
  62771. */
  62772. /** @hidden */
  62773. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62774. /** @hidden */
  62775. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62776. /**
  62777. * Create a new AnisotropyBlock
  62778. * @param name defines the block name
  62779. */
  62780. constructor(name: string);
  62781. /**
  62782. * Initialize the block and prepare the context for build
  62783. * @param state defines the state that will be used for the build
  62784. */
  62785. initialize(state: NodeMaterialBuildState): void;
  62786. /**
  62787. * Gets the current class name
  62788. * @returns the class name
  62789. */
  62790. getClassName(): string;
  62791. /**
  62792. * Gets the intensity input component
  62793. */
  62794. get intensity(): NodeMaterialConnectionPoint;
  62795. /**
  62796. * Gets the direction input component
  62797. */
  62798. get direction(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the texture input component
  62801. */
  62802. get texture(): NodeMaterialConnectionPoint;
  62803. /**
  62804. * Gets the uv input component
  62805. */
  62806. get uv(): NodeMaterialConnectionPoint;
  62807. /**
  62808. * Gets the worldTangent input component
  62809. */
  62810. get worldTangent(): NodeMaterialConnectionPoint;
  62811. /**
  62812. * Gets the anisotropy object output component
  62813. */
  62814. get anisotropy(): NodeMaterialConnectionPoint;
  62815. private _generateTBNSpace;
  62816. /**
  62817. * Gets the main code of the block (fragment side)
  62818. * @param state current state of the node material building
  62819. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62820. * @returns the shader code
  62821. */
  62822. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62824. protected _buildBlock(state: NodeMaterialBuildState): this;
  62825. }
  62826. }
  62827. declare module BABYLON {
  62828. /**
  62829. * Block used to implement the clear coat module of the PBR material
  62830. */
  62831. export class ClearCoatBlock extends NodeMaterialBlock {
  62832. private _scene;
  62833. /**
  62834. * Create a new ClearCoatBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Initialize the block and prepare the context for build
  62840. * @param state defines the state that will be used for the build
  62841. */
  62842. initialize(state: NodeMaterialBuildState): void;
  62843. /**
  62844. * Gets the current class name
  62845. * @returns the class name
  62846. */
  62847. getClassName(): string;
  62848. /**
  62849. * Gets the intensity input component
  62850. */
  62851. get intensity(): NodeMaterialConnectionPoint;
  62852. /**
  62853. * Gets the roughness input component
  62854. */
  62855. get roughness(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the ior input component
  62858. */
  62859. get ior(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the texture input component
  62862. */
  62863. get texture(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the bump texture input component
  62866. */
  62867. get bumpTexture(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the uv input component
  62870. */
  62871. get uv(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the tint color input component
  62874. */
  62875. get tintColor(): NodeMaterialConnectionPoint;
  62876. /**
  62877. * Gets the tint "at distance" input component
  62878. */
  62879. get tintAtDistance(): NodeMaterialConnectionPoint;
  62880. /**
  62881. * Gets the tint thickness input component
  62882. */
  62883. get tintThickness(): NodeMaterialConnectionPoint;
  62884. /**
  62885. * Gets the tint texture input component
  62886. */
  62887. get tintTexture(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the world tangent input component
  62890. */
  62891. get worldTangent(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the clear coat object output component
  62894. */
  62895. get clearcoat(): NodeMaterialConnectionPoint;
  62896. autoConfigure(material: NodeMaterial): void;
  62897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62899. private _generateTBNSpace;
  62900. /**
  62901. * Gets the main code of the block (fragment side)
  62902. * @param state current state of the node material building
  62903. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62904. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62905. * @param worldPosVarName name of the variable holding the world position
  62906. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62907. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62908. * @param worldNormalVarName name of the variable holding the world normal
  62909. * @returns the shader code
  62910. */
  62911. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62912. protected _buildBlock(state: NodeMaterialBuildState): this;
  62913. }
  62914. }
  62915. declare module BABYLON {
  62916. /**
  62917. * Block used to implement the sub surface module of the PBR material
  62918. */
  62919. export class SubSurfaceBlock extends NodeMaterialBlock {
  62920. /**
  62921. * Create a new SubSurfaceBlock
  62922. * @param name defines the block name
  62923. */
  62924. constructor(name: string);
  62925. /**
  62926. * Stores the intensity of the different subsurface effects in the thickness texture.
  62927. * * the green channel is the translucency intensity.
  62928. * * the blue channel is the scattering intensity.
  62929. * * the alpha channel is the refraction intensity.
  62930. */
  62931. useMaskFromThicknessTexture: boolean;
  62932. /**
  62933. * Initialize the block and prepare the context for build
  62934. * @param state defines the state that will be used for the build
  62935. */
  62936. initialize(state: NodeMaterialBuildState): void;
  62937. /**
  62938. * Gets the current class name
  62939. * @returns the class name
  62940. */
  62941. getClassName(): string;
  62942. /**
  62943. * Gets the min thickness input component
  62944. */
  62945. get minThickness(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the max thickness input component
  62948. */
  62949. get maxThickness(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the thickness texture component
  62952. */
  62953. get thicknessTexture(): NodeMaterialConnectionPoint;
  62954. /**
  62955. * Gets the tint color input component
  62956. */
  62957. get tintColor(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the translucency intensity input component
  62960. */
  62961. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the translucency diffusion distance input component
  62964. */
  62965. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the refraction object parameters
  62968. */
  62969. get refraction(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the sub surface object output component
  62972. */
  62973. get subsurface(): NodeMaterialConnectionPoint;
  62974. autoConfigure(material: NodeMaterial): void;
  62975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62976. /**
  62977. * Gets the main code of the block (fragment side)
  62978. * @param state current state of the node material building
  62979. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62980. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62981. * @param worldPosVarName name of the variable holding the world position
  62982. * @returns the shader code
  62983. */
  62984. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62985. protected _buildBlock(state: NodeMaterialBuildState): this;
  62986. }
  62987. }
  62988. declare module BABYLON {
  62989. /**
  62990. * Block used to implement the PBR metallic/roughness model
  62991. */
  62992. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62993. /**
  62994. * Gets or sets the light associated with this block
  62995. */
  62996. light: Nullable<Light>;
  62997. private _lightId;
  62998. private _scene;
  62999. private _environmentBRDFTexture;
  63000. private _environmentBrdfSamplerName;
  63001. private _vNormalWName;
  63002. private _invertNormalName;
  63003. /**
  63004. * Create a new ReflectionBlock
  63005. * @param name defines the block name
  63006. */
  63007. constructor(name: string);
  63008. /**
  63009. * Intensity of the direct lights e.g. the four lights available in your scene.
  63010. * This impacts both the direct diffuse and specular highlights.
  63011. */
  63012. directIntensity: number;
  63013. /**
  63014. * Intensity of the environment e.g. how much the environment will light the object
  63015. * either through harmonics for rough material or through the refelction for shiny ones.
  63016. */
  63017. environmentIntensity: number;
  63018. /**
  63019. * This is a special control allowing the reduction of the specular highlights coming from the
  63020. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63021. */
  63022. specularIntensity: number;
  63023. /**
  63024. * Defines the falloff type used in this material.
  63025. * It by default is Physical.
  63026. */
  63027. lightFalloff: number;
  63028. /**
  63029. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63030. */
  63031. useAlphaFromAlbedoTexture: boolean;
  63032. /**
  63033. * Specifies that alpha test should be used
  63034. */
  63035. useAlphaTest: boolean;
  63036. /**
  63037. * Defines the alpha limits in alpha test mode.
  63038. */
  63039. alphaTestCutoff: number;
  63040. /**
  63041. * Specifies that alpha blending should be used
  63042. */
  63043. useAlphaBlending: boolean;
  63044. /**
  63045. * Defines if the alpha value should be determined via the rgb values.
  63046. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63047. */
  63048. opacityRGB: boolean;
  63049. /**
  63050. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63051. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63052. */
  63053. useRadianceOverAlpha: boolean;
  63054. /**
  63055. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63057. */
  63058. useSpecularOverAlpha: boolean;
  63059. /**
  63060. * Enables specular anti aliasing in the PBR shader.
  63061. * It will both interacts on the Geometry for analytical and IBL lighting.
  63062. * It also prefilter the roughness map based on the bump values.
  63063. */
  63064. enableSpecularAntiAliasing: boolean;
  63065. /**
  63066. * Defines if the material uses energy conservation.
  63067. */
  63068. useEnergyConservation: boolean;
  63069. /**
  63070. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63071. * too much the area relying on ambient texture to define their ambient occlusion.
  63072. */
  63073. useRadianceOcclusion: boolean;
  63074. /**
  63075. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63076. * makes the reflect vector face the model (under horizon).
  63077. */
  63078. useHorizonOcclusion: boolean;
  63079. /**
  63080. * If set to true, no lighting calculations will be applied.
  63081. */
  63082. unlit: boolean;
  63083. /**
  63084. * Force normal to face away from face.
  63085. */
  63086. forceNormalForward: boolean;
  63087. /**
  63088. * Defines the material debug mode.
  63089. * It helps seeing only some components of the material while troubleshooting.
  63090. */
  63091. debugMode: number;
  63092. /**
  63093. * Specify from where on screen the debug mode should start.
  63094. * The value goes from -1 (full screen) to 1 (not visible)
  63095. * It helps with side by side comparison against the final render
  63096. * This defaults to 0
  63097. */
  63098. debugLimit: number;
  63099. /**
  63100. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63101. * You can use the factor to better multiply the final value.
  63102. */
  63103. debugFactor: number;
  63104. /**
  63105. * Initialize the block and prepare the context for build
  63106. * @param state defines the state that will be used for the build
  63107. */
  63108. initialize(state: NodeMaterialBuildState): void;
  63109. /**
  63110. * Gets the current class name
  63111. * @returns the class name
  63112. */
  63113. getClassName(): string;
  63114. /**
  63115. * Gets the world position input component
  63116. */
  63117. get worldPosition(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the world normal input component
  63120. */
  63121. get worldNormal(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the perturbed normal input component
  63124. */
  63125. get perturbedNormal(): NodeMaterialConnectionPoint;
  63126. /**
  63127. * Gets the camera position input component
  63128. */
  63129. get cameraPosition(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the base color input component
  63132. */
  63133. get baseColor(): NodeMaterialConnectionPoint;
  63134. /**
  63135. * Gets the base texture input component
  63136. */
  63137. get baseTexture(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the opacity texture input component
  63140. */
  63141. get opacityTexture(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the ambient color input component
  63144. */
  63145. get ambientColor(): NodeMaterialConnectionPoint;
  63146. /**
  63147. * Gets the reflectivity object parameters
  63148. */
  63149. get reflectivity(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the ambient occlusion object parameters
  63152. */
  63153. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the reflection object parameters
  63156. */
  63157. get reflection(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the sheen object parameters
  63160. */
  63161. get sheen(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the clear coat object parameters
  63164. */
  63165. get clearcoat(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the sub surface object parameters
  63168. */
  63169. get subsurface(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the anisotropy object parameters
  63172. */
  63173. get anisotropy(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the ambient output component
  63176. */
  63177. get ambient(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the diffuse output component
  63180. */
  63181. get diffuse(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the specular output component
  63184. */
  63185. get specular(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the sheen output component
  63188. */
  63189. get sheenDir(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the clear coat output component
  63192. */
  63193. get clearcoatDir(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the indirect diffuse output component
  63196. */
  63197. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63198. /**
  63199. * Gets the indirect specular output component
  63200. */
  63201. get specularIndirect(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the indirect sheen output component
  63204. */
  63205. get sheenIndirect(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the indirect clear coat output component
  63208. */
  63209. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63210. /**
  63211. * Gets the refraction output component
  63212. */
  63213. get refraction(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the global lighting output component
  63216. */
  63217. get lighting(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the shadow output component
  63220. */
  63221. get shadow(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the alpha output component
  63224. */
  63225. get alpha(): NodeMaterialConnectionPoint;
  63226. autoConfigure(material: NodeMaterial): void;
  63227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63228. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63230. private _injectVertexCode;
  63231. /**
  63232. * Gets the code corresponding to the albedo/opacity module
  63233. * @returns the shader code
  63234. */
  63235. getAlbedoOpacityCode(): string;
  63236. protected _buildBlock(state: NodeMaterialBuildState): this;
  63237. protected _dumpPropertiesCode(): string;
  63238. serialize(): any;
  63239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. /**
  63244. * Block used to compute value of one parameter modulo another
  63245. */
  63246. export class ModBlock extends NodeMaterialBlock {
  63247. /**
  63248. * Creates a new ModBlock
  63249. * @param name defines the block name
  63250. */
  63251. constructor(name: string);
  63252. /**
  63253. * Gets the current class name
  63254. * @returns the class name
  63255. */
  63256. getClassName(): string;
  63257. /**
  63258. * Gets the left operand input component
  63259. */
  63260. get left(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the right operand input component
  63263. */
  63264. get right(): NodeMaterialConnectionPoint;
  63265. /**
  63266. * Gets the output component
  63267. */
  63268. get output(): NodeMaterialConnectionPoint;
  63269. protected _buildBlock(state: NodeMaterialBuildState): this;
  63270. }
  63271. }
  63272. declare module BABYLON {
  63273. /**
  63274. * Helper class to push actions to a pool of workers.
  63275. */
  63276. export class WorkerPool implements IDisposable {
  63277. private _workerInfos;
  63278. private _pendingActions;
  63279. /**
  63280. * Constructor
  63281. * @param workers Array of workers to use for actions
  63282. */
  63283. constructor(workers: Array<Worker>);
  63284. /**
  63285. * Terminates all workers and clears any pending actions.
  63286. */
  63287. dispose(): void;
  63288. /**
  63289. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63290. * pended until a worker has completed its action.
  63291. * @param action The action to perform. Call onComplete when the action is complete.
  63292. */
  63293. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63294. private _execute;
  63295. }
  63296. }
  63297. declare module BABYLON {
  63298. /**
  63299. * Configuration for Draco compression
  63300. */
  63301. export interface IDracoCompressionConfiguration {
  63302. /**
  63303. * Configuration for the decoder.
  63304. */
  63305. decoder: {
  63306. /**
  63307. * The url to the WebAssembly module.
  63308. */
  63309. wasmUrl?: string;
  63310. /**
  63311. * The url to the WebAssembly binary.
  63312. */
  63313. wasmBinaryUrl?: string;
  63314. /**
  63315. * The url to the fallback JavaScript module.
  63316. */
  63317. fallbackUrl?: string;
  63318. };
  63319. }
  63320. /**
  63321. * Draco compression (https://google.github.io/draco/)
  63322. *
  63323. * This class wraps the Draco module.
  63324. *
  63325. * **Encoder**
  63326. *
  63327. * The encoder is not currently implemented.
  63328. *
  63329. * **Decoder**
  63330. *
  63331. * 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.
  63332. *
  63333. * To update the configuration, use the following code:
  63334. * ```javascript
  63335. * DracoCompression.Configuration = {
  63336. * decoder: {
  63337. * wasmUrl: "<url to the WebAssembly library>",
  63338. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63339. * fallbackUrl: "<url to the fallback JavaScript library>",
  63340. * }
  63341. * };
  63342. * ```
  63343. *
  63344. * 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.
  63345. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63346. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63347. *
  63348. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63349. * ```javascript
  63350. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63351. * ```
  63352. *
  63353. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63354. */
  63355. export class DracoCompression implements IDisposable {
  63356. private _workerPoolPromise?;
  63357. private _decoderModulePromise?;
  63358. /**
  63359. * The configuration. Defaults to the following urls:
  63360. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63361. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63362. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63363. */
  63364. static Configuration: IDracoCompressionConfiguration;
  63365. /**
  63366. * Returns true if the decoder configuration is available.
  63367. */
  63368. static get DecoderAvailable(): boolean;
  63369. /**
  63370. * Default number of workers to create when creating the draco compression object.
  63371. */
  63372. static DefaultNumWorkers: number;
  63373. private static GetDefaultNumWorkers;
  63374. private static _Default;
  63375. /**
  63376. * Default instance for the draco compression object.
  63377. */
  63378. static get Default(): DracoCompression;
  63379. /**
  63380. * Constructor
  63381. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63382. */
  63383. constructor(numWorkers?: number);
  63384. /**
  63385. * Stop all async operations and release resources.
  63386. */
  63387. dispose(): void;
  63388. /**
  63389. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63390. * @returns a promise that resolves when ready
  63391. */
  63392. whenReadyAsync(): Promise<void>;
  63393. /**
  63394. * Decode Draco compressed mesh data to vertex data.
  63395. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63396. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63397. * @returns A promise that resolves with the decoded vertex data
  63398. */
  63399. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63400. [kind: string]: number;
  63401. }): Promise<VertexData>;
  63402. }
  63403. }
  63404. declare module BABYLON {
  63405. /**
  63406. * Class for building Constructive Solid Geometry
  63407. */
  63408. export class CSG {
  63409. private polygons;
  63410. /**
  63411. * The world matrix
  63412. */
  63413. matrix: Matrix;
  63414. /**
  63415. * Stores the position
  63416. */
  63417. position: Vector3;
  63418. /**
  63419. * Stores the rotation
  63420. */
  63421. rotation: Vector3;
  63422. /**
  63423. * Stores the rotation quaternion
  63424. */
  63425. rotationQuaternion: Nullable<Quaternion>;
  63426. /**
  63427. * Stores the scaling vector
  63428. */
  63429. scaling: Vector3;
  63430. /**
  63431. * Convert the Mesh to CSG
  63432. * @param mesh The Mesh to convert to CSG
  63433. * @returns A new CSG from the Mesh
  63434. */
  63435. static FromMesh(mesh: Mesh): CSG;
  63436. /**
  63437. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63438. * @param polygons Polygons used to construct a CSG solid
  63439. */
  63440. private static FromPolygons;
  63441. /**
  63442. * Clones, or makes a deep copy, of the CSG
  63443. * @returns A new CSG
  63444. */
  63445. clone(): CSG;
  63446. /**
  63447. * Unions this CSG with another CSG
  63448. * @param csg The CSG to union against this CSG
  63449. * @returns The unioned CSG
  63450. */
  63451. union(csg: CSG): CSG;
  63452. /**
  63453. * Unions this CSG with another CSG in place
  63454. * @param csg The CSG to union against this CSG
  63455. */
  63456. unionInPlace(csg: CSG): void;
  63457. /**
  63458. * Subtracts this CSG with another CSG
  63459. * @param csg The CSG to subtract against this CSG
  63460. * @returns A new CSG
  63461. */
  63462. subtract(csg: CSG): CSG;
  63463. /**
  63464. * Subtracts this CSG with another CSG in place
  63465. * @param csg The CSG to subtact against this CSG
  63466. */
  63467. subtractInPlace(csg: CSG): void;
  63468. /**
  63469. * Intersect this CSG with another CSG
  63470. * @param csg The CSG to intersect against this CSG
  63471. * @returns A new CSG
  63472. */
  63473. intersect(csg: CSG): CSG;
  63474. /**
  63475. * Intersects this CSG with another CSG in place
  63476. * @param csg The CSG to intersect against this CSG
  63477. */
  63478. intersectInPlace(csg: CSG): void;
  63479. /**
  63480. * Return a new CSG solid with solid and empty space switched. This solid is
  63481. * not modified.
  63482. * @returns A new CSG solid with solid and empty space switched
  63483. */
  63484. inverse(): CSG;
  63485. /**
  63486. * Inverses the CSG in place
  63487. */
  63488. inverseInPlace(): void;
  63489. /**
  63490. * This is used to keep meshes transformations so they can be restored
  63491. * when we build back a Babylon Mesh
  63492. * NB : All CSG operations are performed in world coordinates
  63493. * @param csg The CSG to copy the transform attributes from
  63494. * @returns This CSG
  63495. */
  63496. copyTransformAttributes(csg: CSG): CSG;
  63497. /**
  63498. * Build Raw mesh from CSG
  63499. * Coordinates here are in world space
  63500. * @param name The name of the mesh geometry
  63501. * @param scene The Scene
  63502. * @param keepSubMeshes Specifies if the submeshes should be kept
  63503. * @returns A new Mesh
  63504. */
  63505. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63506. /**
  63507. * Build Mesh from CSG taking material and transforms into account
  63508. * @param name The name of the Mesh
  63509. * @param material The material of the Mesh
  63510. * @param scene The Scene
  63511. * @param keepSubMeshes Specifies if submeshes should be kept
  63512. * @returns The new Mesh
  63513. */
  63514. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63515. }
  63516. }
  63517. declare module BABYLON {
  63518. /**
  63519. * Class used to create a trail following a mesh
  63520. */
  63521. export class TrailMesh extends Mesh {
  63522. private _generator;
  63523. private _autoStart;
  63524. private _running;
  63525. private _diameter;
  63526. private _length;
  63527. private _sectionPolygonPointsCount;
  63528. private _sectionVectors;
  63529. private _sectionNormalVectors;
  63530. private _beforeRenderObserver;
  63531. /**
  63532. * @constructor
  63533. * @param name The value used by scene.getMeshByName() to do a lookup.
  63534. * @param generator The mesh or transform node to generate a trail.
  63535. * @param scene The scene to add this mesh to.
  63536. * @param diameter Diameter of trailing mesh. Default is 1.
  63537. * @param length Length of trailing mesh. Default is 60.
  63538. * @param autoStart Automatically start trailing mesh. Default true.
  63539. */
  63540. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63541. /**
  63542. * "TrailMesh"
  63543. * @returns "TrailMesh"
  63544. */
  63545. getClassName(): string;
  63546. private _createMesh;
  63547. /**
  63548. * Start trailing mesh.
  63549. */
  63550. start(): void;
  63551. /**
  63552. * Stop trailing mesh.
  63553. */
  63554. stop(): void;
  63555. /**
  63556. * Update trailing mesh geometry.
  63557. */
  63558. update(): void;
  63559. /**
  63560. * Returns a new TrailMesh object.
  63561. * @param name is a string, the name given to the new mesh
  63562. * @param newGenerator use new generator object for cloned trail mesh
  63563. * @returns a new mesh
  63564. */
  63565. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63566. /**
  63567. * Serializes this trail mesh
  63568. * @param serializationObject object to write serialization to
  63569. */
  63570. serialize(serializationObject: any): void;
  63571. /**
  63572. * Parses a serialized trail mesh
  63573. * @param parsedMesh the serialized mesh
  63574. * @param scene the scene to create the trail mesh in
  63575. * @returns the created trail mesh
  63576. */
  63577. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63578. }
  63579. }
  63580. declare module BABYLON {
  63581. /**
  63582. * Class containing static functions to help procedurally build meshes
  63583. */
  63584. export class TiledBoxBuilder {
  63585. /**
  63586. * Creates a box mesh
  63587. * 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)
  63588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63590. * * 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
  63591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63592. * @param name defines the name of the mesh
  63593. * @param options defines the options used to create the mesh
  63594. * @param scene defines the hosting scene
  63595. * @returns the box mesh
  63596. */
  63597. static CreateTiledBox(name: string, options: {
  63598. pattern?: number;
  63599. width?: number;
  63600. height?: number;
  63601. depth?: number;
  63602. tileSize?: number;
  63603. tileWidth?: number;
  63604. tileHeight?: number;
  63605. alignHorizontal?: number;
  63606. alignVertical?: number;
  63607. faceUV?: Vector4[];
  63608. faceColors?: Color4[];
  63609. sideOrientation?: number;
  63610. updatable?: boolean;
  63611. }, scene?: Nullable<Scene>): Mesh;
  63612. }
  63613. }
  63614. declare module BABYLON {
  63615. /**
  63616. * Class containing static functions to help procedurally build meshes
  63617. */
  63618. export class TorusKnotBuilder {
  63619. /**
  63620. * Creates a torus knot mesh
  63621. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63622. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63623. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63624. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63626. * * 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
  63627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63628. * @param name defines the name of the mesh
  63629. * @param options defines the options used to create the mesh
  63630. * @param scene defines the hosting scene
  63631. * @returns the torus knot mesh
  63632. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63633. */
  63634. static CreateTorusKnot(name: string, options: {
  63635. radius?: number;
  63636. tube?: number;
  63637. radialSegments?: number;
  63638. tubularSegments?: number;
  63639. p?: number;
  63640. q?: number;
  63641. updatable?: boolean;
  63642. sideOrientation?: number;
  63643. frontUVs?: Vector4;
  63644. backUVs?: Vector4;
  63645. }, scene: any): Mesh;
  63646. }
  63647. }
  63648. declare module BABYLON {
  63649. /**
  63650. * Polygon
  63651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63652. */
  63653. export class Polygon {
  63654. /**
  63655. * Creates a rectangle
  63656. * @param xmin bottom X coord
  63657. * @param ymin bottom Y coord
  63658. * @param xmax top X coord
  63659. * @param ymax top Y coord
  63660. * @returns points that make the resulting rectation
  63661. */
  63662. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63663. /**
  63664. * Creates a circle
  63665. * @param radius radius of circle
  63666. * @param cx scale in x
  63667. * @param cy scale in y
  63668. * @param numberOfSides number of sides that make up the circle
  63669. * @returns points that make the resulting circle
  63670. */
  63671. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63672. /**
  63673. * Creates a polygon from input string
  63674. * @param input Input polygon data
  63675. * @returns the parsed points
  63676. */
  63677. static Parse(input: string): Vector2[];
  63678. /**
  63679. * Starts building a polygon from x and y coordinates
  63680. * @param x x coordinate
  63681. * @param y y coordinate
  63682. * @returns the started path2
  63683. */
  63684. static StartingAt(x: number, y: number): Path2;
  63685. }
  63686. /**
  63687. * Builds a polygon
  63688. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63689. */
  63690. export class PolygonMeshBuilder {
  63691. private _points;
  63692. private _outlinepoints;
  63693. private _holes;
  63694. private _name;
  63695. private _scene;
  63696. private _epoints;
  63697. private _eholes;
  63698. private _addToepoint;
  63699. /**
  63700. * Babylon reference to the earcut plugin.
  63701. */
  63702. bjsEarcut: any;
  63703. /**
  63704. * Creates a PolygonMeshBuilder
  63705. * @param name name of the builder
  63706. * @param contours Path of the polygon
  63707. * @param scene scene to add to when creating the mesh
  63708. * @param earcutInjection can be used to inject your own earcut reference
  63709. */
  63710. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63711. /**
  63712. * Adds a whole within the polygon
  63713. * @param hole Array of points defining the hole
  63714. * @returns this
  63715. */
  63716. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63717. /**
  63718. * Creates the polygon
  63719. * @param updatable If the mesh should be updatable
  63720. * @param depth The depth of the mesh created
  63721. * @returns the created mesh
  63722. */
  63723. build(updatable?: boolean, depth?: number): Mesh;
  63724. /**
  63725. * Creates the polygon
  63726. * @param depth The depth of the mesh created
  63727. * @returns the created VertexData
  63728. */
  63729. buildVertexData(depth?: number): VertexData;
  63730. /**
  63731. * Adds a side to the polygon
  63732. * @param positions points that make the polygon
  63733. * @param normals normals of the polygon
  63734. * @param uvs uvs of the polygon
  63735. * @param indices indices of the polygon
  63736. * @param bounds bounds of the polygon
  63737. * @param points points of the polygon
  63738. * @param depth depth of the polygon
  63739. * @param flip flip of the polygon
  63740. */
  63741. private addSide;
  63742. }
  63743. }
  63744. declare module BABYLON {
  63745. /**
  63746. * Class containing static functions to help procedurally build meshes
  63747. */
  63748. export class PolygonBuilder {
  63749. /**
  63750. * Creates a polygon mesh
  63751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63752. * * 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
  63753. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63755. * * 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)
  63756. * * Remember you can only change the shape positions, not their number when updating a polygon
  63757. * @param name defines the name of the mesh
  63758. * @param options defines the options used to create the mesh
  63759. * @param scene defines the hosting scene
  63760. * @param earcutInjection can be used to inject your own earcut reference
  63761. * @returns the polygon mesh
  63762. */
  63763. static CreatePolygon(name: string, options: {
  63764. shape: Vector3[];
  63765. holes?: Vector3[][];
  63766. depth?: number;
  63767. faceUV?: Vector4[];
  63768. faceColors?: Color4[];
  63769. updatable?: boolean;
  63770. sideOrientation?: number;
  63771. frontUVs?: Vector4;
  63772. backUVs?: Vector4;
  63773. wrap?: boolean;
  63774. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63775. /**
  63776. * Creates an extruded polygon mesh, with depth in the Y direction.
  63777. * * 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)
  63778. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63779. * @param name defines the name of the mesh
  63780. * @param options defines the options used to create the mesh
  63781. * @param scene defines the hosting scene
  63782. * @param earcutInjection can be used to inject your own earcut reference
  63783. * @returns the polygon mesh
  63784. */
  63785. static ExtrudePolygon(name: string, options: {
  63786. shape: Vector3[];
  63787. holes?: Vector3[][];
  63788. depth?: number;
  63789. faceUV?: Vector4[];
  63790. faceColors?: Color4[];
  63791. updatable?: boolean;
  63792. sideOrientation?: number;
  63793. frontUVs?: Vector4;
  63794. backUVs?: Vector4;
  63795. wrap?: boolean;
  63796. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63797. }
  63798. }
  63799. declare module BABYLON {
  63800. /**
  63801. * Class containing static functions to help procedurally build meshes
  63802. */
  63803. export class LatheBuilder {
  63804. /**
  63805. * Creates lathe mesh.
  63806. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63807. * * 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
  63808. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63809. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63810. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63811. * * 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
  63812. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63813. * * 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
  63814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63815. * * 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
  63816. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63818. * @param name defines the name of the mesh
  63819. * @param options defines the options used to create the mesh
  63820. * @param scene defines the hosting scene
  63821. * @returns the lathe mesh
  63822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63823. */
  63824. static CreateLathe(name: string, options: {
  63825. shape: Vector3[];
  63826. radius?: number;
  63827. tessellation?: number;
  63828. clip?: number;
  63829. arc?: number;
  63830. closed?: boolean;
  63831. updatable?: boolean;
  63832. sideOrientation?: number;
  63833. frontUVs?: Vector4;
  63834. backUVs?: Vector4;
  63835. cap?: number;
  63836. invertUV?: boolean;
  63837. }, scene?: Nullable<Scene>): Mesh;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * Class containing static functions to help procedurally build meshes
  63843. */
  63844. export class TiledPlaneBuilder {
  63845. /**
  63846. * Creates a tiled plane mesh
  63847. * * The parameter `pattern` will, depending on value, do nothing or
  63848. * * * flip (reflect about central vertical) alternate tiles across and up
  63849. * * * flip every tile on alternate rows
  63850. * * * rotate (180 degs) alternate tiles across and up
  63851. * * * rotate every tile on alternate rows
  63852. * * * flip and rotate alternate tiles across and up
  63853. * * * flip and rotate every tile on alternate rows
  63854. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63855. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63856. * * 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
  63857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63858. * * 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)
  63859. * * 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)
  63860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63861. * @param name defines the name of the mesh
  63862. * @param options defines the options used to create the mesh
  63863. * @param scene defines the hosting scene
  63864. * @returns the box mesh
  63865. */
  63866. static CreateTiledPlane(name: string, options: {
  63867. pattern?: number;
  63868. tileSize?: number;
  63869. tileWidth?: number;
  63870. tileHeight?: number;
  63871. size?: number;
  63872. width?: number;
  63873. height?: number;
  63874. alignHorizontal?: number;
  63875. alignVertical?: number;
  63876. sideOrientation?: number;
  63877. frontUVs?: Vector4;
  63878. backUVs?: Vector4;
  63879. updatable?: boolean;
  63880. }, scene?: Nullable<Scene>): Mesh;
  63881. }
  63882. }
  63883. declare module BABYLON {
  63884. /**
  63885. * Class containing static functions to help procedurally build meshes
  63886. */
  63887. export class TubeBuilder {
  63888. /**
  63889. * Creates a tube mesh.
  63890. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63891. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63892. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63893. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63894. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63895. * * 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)
  63896. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63897. * * 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
  63898. * * 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
  63899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63900. * * 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
  63901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63903. * @param name defines the name of the mesh
  63904. * @param options defines the options used to create the mesh
  63905. * @param scene defines the hosting scene
  63906. * @returns the tube mesh
  63907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63908. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63909. */
  63910. static CreateTube(name: string, options: {
  63911. path: Vector3[];
  63912. radius?: number;
  63913. tessellation?: number;
  63914. radiusFunction?: {
  63915. (i: number, distance: number): number;
  63916. };
  63917. cap?: number;
  63918. arc?: number;
  63919. updatable?: boolean;
  63920. sideOrientation?: number;
  63921. frontUVs?: Vector4;
  63922. backUVs?: Vector4;
  63923. instance?: Mesh;
  63924. invertUV?: boolean;
  63925. }, scene?: Nullable<Scene>): Mesh;
  63926. }
  63927. }
  63928. declare module BABYLON {
  63929. /**
  63930. * Class containing static functions to help procedurally build meshes
  63931. */
  63932. export class IcoSphereBuilder {
  63933. /**
  63934. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63935. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63936. * * 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`)
  63937. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63938. * * 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
  63939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63940. * * 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
  63941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63942. * @param name defines the name of the mesh
  63943. * @param options defines the options used to create the mesh
  63944. * @param scene defines the hosting scene
  63945. * @returns the icosahedron mesh
  63946. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63947. */
  63948. static CreateIcoSphere(name: string, options: {
  63949. radius?: number;
  63950. radiusX?: number;
  63951. radiusY?: number;
  63952. radiusZ?: number;
  63953. flat?: boolean;
  63954. subdivisions?: number;
  63955. sideOrientation?: number;
  63956. frontUVs?: Vector4;
  63957. backUVs?: Vector4;
  63958. updatable?: boolean;
  63959. }, scene?: Nullable<Scene>): Mesh;
  63960. }
  63961. }
  63962. declare module BABYLON {
  63963. /**
  63964. * Class containing static functions to help procedurally build meshes
  63965. */
  63966. export class DecalBuilder {
  63967. /**
  63968. * Creates a decal mesh.
  63969. * 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
  63970. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63971. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63972. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63973. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63974. * @param name defines the name of the mesh
  63975. * @param sourceMesh defines the mesh where the decal must be applied
  63976. * @param options defines the options used to create the mesh
  63977. * @param scene defines the hosting scene
  63978. * @returns the decal mesh
  63979. * @see https://doc.babylonjs.com/how_to/decals
  63980. */
  63981. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63982. position?: Vector3;
  63983. normal?: Vector3;
  63984. size?: Vector3;
  63985. angle?: number;
  63986. }): Mesh;
  63987. }
  63988. }
  63989. declare module BABYLON {
  63990. /**
  63991. * Class containing static functions to help procedurally build meshes
  63992. */
  63993. export class MeshBuilder {
  63994. /**
  63995. * Creates a box mesh
  63996. * * The parameter `size` sets the size (float) of each box side (default 1)
  63997. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63998. * * 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)
  63999. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64001. * * 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
  64002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64003. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64004. * @param name defines the name of the mesh
  64005. * @param options defines the options used to create the mesh
  64006. * @param scene defines the hosting scene
  64007. * @returns the box mesh
  64008. */
  64009. static CreateBox(name: string, options: {
  64010. size?: number;
  64011. width?: number;
  64012. height?: number;
  64013. depth?: number;
  64014. faceUV?: Vector4[];
  64015. faceColors?: Color4[];
  64016. sideOrientation?: number;
  64017. frontUVs?: Vector4;
  64018. backUVs?: Vector4;
  64019. wrap?: boolean;
  64020. topBaseAt?: number;
  64021. bottomBaseAt?: number;
  64022. updatable?: boolean;
  64023. }, scene?: Nullable<Scene>): Mesh;
  64024. /**
  64025. * Creates a tiled box mesh
  64026. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64028. * @param name defines the name of the mesh
  64029. * @param options defines the options used to create the mesh
  64030. * @param scene defines the hosting scene
  64031. * @returns the tiled box mesh
  64032. */
  64033. static CreateTiledBox(name: string, options: {
  64034. pattern?: number;
  64035. size?: number;
  64036. width?: number;
  64037. height?: number;
  64038. depth: number;
  64039. tileSize?: number;
  64040. tileWidth?: number;
  64041. tileHeight?: number;
  64042. faceUV?: Vector4[];
  64043. faceColors?: Color4[];
  64044. alignHorizontal?: number;
  64045. alignVertical?: number;
  64046. sideOrientation?: number;
  64047. updatable?: boolean;
  64048. }, scene?: Nullable<Scene>): Mesh;
  64049. /**
  64050. * Creates a sphere mesh
  64051. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64052. * * 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`)
  64053. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64054. * * 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
  64055. * * 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)
  64056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64057. * * 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
  64058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64059. * @param name defines the name of the mesh
  64060. * @param options defines the options used to create the mesh
  64061. * @param scene defines the hosting scene
  64062. * @returns the sphere mesh
  64063. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64064. */
  64065. static CreateSphere(name: string, options: {
  64066. segments?: number;
  64067. diameter?: number;
  64068. diameterX?: number;
  64069. diameterY?: number;
  64070. diameterZ?: number;
  64071. arc?: number;
  64072. slice?: number;
  64073. sideOrientation?: number;
  64074. frontUVs?: Vector4;
  64075. backUVs?: Vector4;
  64076. updatable?: boolean;
  64077. }, scene?: Nullable<Scene>): Mesh;
  64078. /**
  64079. * Creates a plane polygonal mesh. By default, this is a disc
  64080. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64081. * * 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
  64082. * * 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
  64083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64084. * * 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
  64085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64086. * @param name defines the name of the mesh
  64087. * @param options defines the options used to create the mesh
  64088. * @param scene defines the hosting scene
  64089. * @returns the plane polygonal mesh
  64090. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64091. */
  64092. static CreateDisc(name: string, options: {
  64093. radius?: number;
  64094. tessellation?: number;
  64095. arc?: number;
  64096. updatable?: boolean;
  64097. sideOrientation?: number;
  64098. frontUVs?: Vector4;
  64099. backUVs?: Vector4;
  64100. }, scene?: Nullable<Scene>): Mesh;
  64101. /**
  64102. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64103. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64104. * * 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`)
  64105. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64106. * * 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
  64107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64108. * * 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
  64109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64110. * @param name defines the name of the mesh
  64111. * @param options defines the options used to create the mesh
  64112. * @param scene defines the hosting scene
  64113. * @returns the icosahedron mesh
  64114. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64115. */
  64116. static CreateIcoSphere(name: string, options: {
  64117. radius?: number;
  64118. radiusX?: number;
  64119. radiusY?: number;
  64120. radiusZ?: number;
  64121. flat?: boolean;
  64122. subdivisions?: number;
  64123. sideOrientation?: number;
  64124. frontUVs?: Vector4;
  64125. backUVs?: Vector4;
  64126. updatable?: boolean;
  64127. }, scene?: Nullable<Scene>): Mesh;
  64128. /**
  64129. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64130. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64131. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64132. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64133. * * 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
  64134. * * 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
  64135. * * 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
  64136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64137. * * 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
  64138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64139. * * 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
  64140. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64141. * * 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
  64142. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64144. * @param name defines the name of the mesh
  64145. * @param options defines the options used to create the mesh
  64146. * @param scene defines the hosting scene
  64147. * @returns the ribbon mesh
  64148. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64149. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64150. */
  64151. static CreateRibbon(name: string, options: {
  64152. pathArray: Vector3[][];
  64153. closeArray?: boolean;
  64154. closePath?: boolean;
  64155. offset?: number;
  64156. updatable?: boolean;
  64157. sideOrientation?: number;
  64158. frontUVs?: Vector4;
  64159. backUVs?: Vector4;
  64160. instance?: Mesh;
  64161. invertUV?: boolean;
  64162. uvs?: Vector2[];
  64163. colors?: Color4[];
  64164. }, scene?: Nullable<Scene>): Mesh;
  64165. /**
  64166. * Creates a cylinder or a cone mesh
  64167. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64168. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64169. * * 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.
  64170. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64171. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64172. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64173. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64174. * * 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).
  64175. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64176. * * 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).
  64177. * * 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
  64178. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64179. * * 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
  64180. * * 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.
  64181. * * If `enclose` is false, a ring surface is one element.
  64182. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64183. * * 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
  64184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64185. * * 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
  64186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64187. * @param name defines the name of the mesh
  64188. * @param options defines the options used to create the mesh
  64189. * @param scene defines the hosting scene
  64190. * @returns the cylinder mesh
  64191. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64192. */
  64193. static CreateCylinder(name: string, options: {
  64194. height?: number;
  64195. diameterTop?: number;
  64196. diameterBottom?: number;
  64197. diameter?: number;
  64198. tessellation?: number;
  64199. subdivisions?: number;
  64200. arc?: number;
  64201. faceColors?: Color4[];
  64202. faceUV?: Vector4[];
  64203. updatable?: boolean;
  64204. hasRings?: boolean;
  64205. enclose?: boolean;
  64206. cap?: number;
  64207. sideOrientation?: number;
  64208. frontUVs?: Vector4;
  64209. backUVs?: Vector4;
  64210. }, scene?: Nullable<Scene>): Mesh;
  64211. /**
  64212. * Creates a torus mesh
  64213. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64214. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64215. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64217. * * 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
  64218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64219. * @param name defines the name of the mesh
  64220. * @param options defines the options used to create the mesh
  64221. * @param scene defines the hosting scene
  64222. * @returns the torus mesh
  64223. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64224. */
  64225. static CreateTorus(name: string, options: {
  64226. diameter?: number;
  64227. thickness?: number;
  64228. tessellation?: number;
  64229. updatable?: boolean;
  64230. sideOrientation?: number;
  64231. frontUVs?: Vector4;
  64232. backUVs?: Vector4;
  64233. }, scene?: Nullable<Scene>): Mesh;
  64234. /**
  64235. * Creates a torus knot mesh
  64236. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64237. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64238. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64239. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64241. * * 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
  64242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64243. * @param name defines the name of the mesh
  64244. * @param options defines the options used to create the mesh
  64245. * @param scene defines the hosting scene
  64246. * @returns the torus knot mesh
  64247. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64248. */
  64249. static CreateTorusKnot(name: string, options: {
  64250. radius?: number;
  64251. tube?: number;
  64252. radialSegments?: number;
  64253. tubularSegments?: number;
  64254. p?: number;
  64255. q?: number;
  64256. updatable?: boolean;
  64257. sideOrientation?: number;
  64258. frontUVs?: Vector4;
  64259. backUVs?: Vector4;
  64260. }, scene?: Nullable<Scene>): Mesh;
  64261. /**
  64262. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64263. * * 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
  64264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64265. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64266. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64267. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64268. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64269. * * 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
  64270. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64273. * @param name defines the name of the new line system
  64274. * @param options defines the options used to create the line system
  64275. * @param scene defines the hosting scene
  64276. * @returns a new line system mesh
  64277. */
  64278. static CreateLineSystem(name: string, options: {
  64279. lines: Vector3[][];
  64280. updatable?: boolean;
  64281. instance?: Nullable<LinesMesh>;
  64282. colors?: Nullable<Color4[][]>;
  64283. useVertexAlpha?: boolean;
  64284. }, scene: Nullable<Scene>): LinesMesh;
  64285. /**
  64286. * Creates a line mesh
  64287. * 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
  64288. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64289. * * The parameter `points` is an array successive Vector3
  64290. * * 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
  64291. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64292. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64293. * * When updating an instance, remember that only point positions can change, not the number of points
  64294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64296. * @param name defines the name of the new line system
  64297. * @param options defines the options used to create the line system
  64298. * @param scene defines the hosting scene
  64299. * @returns a new line mesh
  64300. */
  64301. static CreateLines(name: string, options: {
  64302. points: Vector3[];
  64303. updatable?: boolean;
  64304. instance?: Nullable<LinesMesh>;
  64305. colors?: Color4[];
  64306. useVertexAlpha?: boolean;
  64307. }, scene?: Nullable<Scene>): LinesMesh;
  64308. /**
  64309. * Creates a dashed line mesh
  64310. * * 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
  64311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64312. * * The parameter `points` is an array successive Vector3
  64313. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64314. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64315. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64316. * * 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
  64317. * * When updating an instance, remember that only point positions can change, not the number of points
  64318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64319. * @param name defines the name of the mesh
  64320. * @param options defines the options used to create the mesh
  64321. * @param scene defines the hosting scene
  64322. * @returns the dashed line mesh
  64323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64324. */
  64325. static CreateDashedLines(name: string, options: {
  64326. points: Vector3[];
  64327. dashSize?: number;
  64328. gapSize?: number;
  64329. dashNb?: number;
  64330. updatable?: boolean;
  64331. instance?: LinesMesh;
  64332. }, scene?: Nullable<Scene>): LinesMesh;
  64333. /**
  64334. * 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.
  64335. * * 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.
  64336. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64337. * * 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.
  64338. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64339. * * 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
  64340. * * 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
  64341. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64343. * * 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
  64344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64346. * @param name defines the name of the mesh
  64347. * @param options defines the options used to create the mesh
  64348. * @param scene defines the hosting scene
  64349. * @returns the extruded shape mesh
  64350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64352. */
  64353. static ExtrudeShape(name: string, options: {
  64354. shape: Vector3[];
  64355. path: Vector3[];
  64356. scale?: number;
  64357. rotation?: number;
  64358. cap?: number;
  64359. updatable?: boolean;
  64360. sideOrientation?: number;
  64361. frontUVs?: Vector4;
  64362. backUVs?: Vector4;
  64363. instance?: Mesh;
  64364. invertUV?: boolean;
  64365. }, scene?: Nullable<Scene>): Mesh;
  64366. /**
  64367. * Creates an custom extruded shape mesh.
  64368. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64369. * * 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.
  64370. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64371. * * 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
  64372. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64373. * * 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
  64374. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64375. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64376. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64377. * * 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
  64378. * * 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
  64379. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  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 custom extruded shape mesh
  64388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64391. */
  64392. static ExtrudeShapeCustom(name: string, options: {
  64393. shape: Vector3[];
  64394. path: Vector3[];
  64395. scaleFunction?: any;
  64396. rotationFunction?: any;
  64397. ribbonCloseArray?: boolean;
  64398. ribbonClosePath?: boolean;
  64399. cap?: number;
  64400. updatable?: boolean;
  64401. sideOrientation?: number;
  64402. frontUVs?: Vector4;
  64403. backUVs?: Vector4;
  64404. instance?: Mesh;
  64405. invertUV?: boolean;
  64406. }, scene?: Nullable<Scene>): Mesh;
  64407. /**
  64408. * Creates lathe mesh.
  64409. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64410. * * 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
  64411. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64412. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64413. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64414. * * 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
  64415. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64416. * * 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
  64417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64418. * * 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
  64419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64421. * @param name defines the name of the mesh
  64422. * @param options defines the options used to create the mesh
  64423. * @param scene defines the hosting scene
  64424. * @returns the lathe mesh
  64425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64426. */
  64427. static CreateLathe(name: string, options: {
  64428. shape: Vector3[];
  64429. radius?: number;
  64430. tessellation?: number;
  64431. clip?: number;
  64432. arc?: number;
  64433. closed?: boolean;
  64434. updatable?: boolean;
  64435. sideOrientation?: number;
  64436. frontUVs?: Vector4;
  64437. backUVs?: Vector4;
  64438. cap?: number;
  64439. invertUV?: boolean;
  64440. }, scene?: Nullable<Scene>): Mesh;
  64441. /**
  64442. * Creates a tiled plane mesh
  64443. * * You can set a limited pattern arrangement with the tiles
  64444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64445. * * 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
  64446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64447. * @param name defines the name of the mesh
  64448. * @param options defines the options used to create the mesh
  64449. * @param scene defines the hosting scene
  64450. * @returns the plane mesh
  64451. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64452. */
  64453. static CreateTiledPlane(name: string, options: {
  64454. pattern?: number;
  64455. tileSize?: number;
  64456. tileWidth?: number;
  64457. tileHeight?: number;
  64458. size?: number;
  64459. width?: number;
  64460. height?: number;
  64461. alignHorizontal?: number;
  64462. alignVertical?: number;
  64463. sideOrientation?: number;
  64464. frontUVs?: Vector4;
  64465. backUVs?: Vector4;
  64466. updatable?: boolean;
  64467. }, scene?: Nullable<Scene>): Mesh;
  64468. /**
  64469. * Creates a plane mesh
  64470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64474. * * 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
  64475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64476. * @param name defines the name of the mesh
  64477. * @param options defines the options used to create the mesh
  64478. * @param scene defines the hosting scene
  64479. * @returns the plane mesh
  64480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64481. */
  64482. static CreatePlane(name: string, options: {
  64483. size?: number;
  64484. width?: number;
  64485. height?: number;
  64486. sideOrientation?: number;
  64487. frontUVs?: Vector4;
  64488. backUVs?: Vector4;
  64489. updatable?: boolean;
  64490. sourcePlane?: Plane;
  64491. }, scene?: Nullable<Scene>): Mesh;
  64492. /**
  64493. * Creates a ground mesh
  64494. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64495. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64497. * @param name defines the name of the mesh
  64498. * @param options defines the options used to create the mesh
  64499. * @param scene defines the hosting scene
  64500. * @returns the ground mesh
  64501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64502. */
  64503. static CreateGround(name: string, options: {
  64504. width?: number;
  64505. height?: number;
  64506. subdivisions?: number;
  64507. subdivisionsX?: number;
  64508. subdivisionsY?: number;
  64509. updatable?: boolean;
  64510. }, scene?: Nullable<Scene>): Mesh;
  64511. /**
  64512. * Creates a tiled ground mesh
  64513. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64514. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64515. * * 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
  64516. * * 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
  64517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64518. * @param name defines the name of the mesh
  64519. * @param options defines the options used to create the mesh
  64520. * @param scene defines the hosting scene
  64521. * @returns the tiled ground mesh
  64522. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64523. */
  64524. static CreateTiledGround(name: string, options: {
  64525. xmin: number;
  64526. zmin: number;
  64527. xmax: number;
  64528. zmax: number;
  64529. subdivisions?: {
  64530. w: number;
  64531. h: number;
  64532. };
  64533. precision?: {
  64534. w: number;
  64535. h: number;
  64536. };
  64537. updatable?: boolean;
  64538. }, scene?: Nullable<Scene>): Mesh;
  64539. /**
  64540. * Creates a ground mesh from a height map
  64541. * * The parameter `url` sets the URL of the height map image resource.
  64542. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64543. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64544. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64545. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64546. * * 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.
  64547. * * 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).
  64548. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64550. * @param name defines the name of the mesh
  64551. * @param url defines the url to the height map
  64552. * @param options defines the options used to create the mesh
  64553. * @param scene defines the hosting scene
  64554. * @returns the ground mesh
  64555. * @see https://doc.babylonjs.com/babylon101/height_map
  64556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64557. */
  64558. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64559. width?: number;
  64560. height?: number;
  64561. subdivisions?: number;
  64562. minHeight?: number;
  64563. maxHeight?: number;
  64564. colorFilter?: Color3;
  64565. alphaFilter?: number;
  64566. updatable?: boolean;
  64567. onReady?: (mesh: GroundMesh) => void;
  64568. }, scene?: Nullable<Scene>): GroundMesh;
  64569. /**
  64570. * Creates a polygon mesh
  64571. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64572. * * 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
  64573. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64575. * * 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)
  64576. * * Remember you can only change the shape positions, not their number when updating a polygon
  64577. * @param name defines the name of the mesh
  64578. * @param options defines the options used to create the mesh
  64579. * @param scene defines the hosting scene
  64580. * @param earcutInjection can be used to inject your own earcut reference
  64581. * @returns the polygon mesh
  64582. */
  64583. static CreatePolygon(name: string, options: {
  64584. shape: Vector3[];
  64585. holes?: Vector3[][];
  64586. depth?: number;
  64587. faceUV?: Vector4[];
  64588. faceColors?: Color4[];
  64589. updatable?: boolean;
  64590. sideOrientation?: number;
  64591. frontUVs?: Vector4;
  64592. backUVs?: Vector4;
  64593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64594. /**
  64595. * Creates an extruded polygon mesh, with depth in the Y direction.
  64596. * * 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)
  64597. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64598. * @param name defines the name of the mesh
  64599. * @param options defines the options used to create the mesh
  64600. * @param scene defines the hosting scene
  64601. * @param earcutInjection can be used to inject your own earcut reference
  64602. * @returns the polygon mesh
  64603. */
  64604. static ExtrudePolygon(name: string, options: {
  64605. shape: Vector3[];
  64606. holes?: Vector3[][];
  64607. depth?: number;
  64608. faceUV?: Vector4[];
  64609. faceColors?: Color4[];
  64610. updatable?: boolean;
  64611. sideOrientation?: number;
  64612. frontUVs?: Vector4;
  64613. backUVs?: Vector4;
  64614. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64615. /**
  64616. * Creates a tube mesh.
  64617. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64618. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64619. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64620. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64621. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64622. * * 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)
  64623. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64624. * * 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
  64625. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64630. * @param name defines the name of the mesh
  64631. * @param options defines the options used to create the mesh
  64632. * @param scene defines the hosting scene
  64633. * @returns the tube mesh
  64634. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64635. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64636. */
  64637. static CreateTube(name: string, options: {
  64638. path: Vector3[];
  64639. radius?: number;
  64640. tessellation?: number;
  64641. radiusFunction?: {
  64642. (i: number, distance: number): number;
  64643. };
  64644. cap?: number;
  64645. arc?: number;
  64646. updatable?: boolean;
  64647. sideOrientation?: number;
  64648. frontUVs?: Vector4;
  64649. backUVs?: Vector4;
  64650. instance?: Mesh;
  64651. invertUV?: boolean;
  64652. }, scene?: Nullable<Scene>): Mesh;
  64653. /**
  64654. * Creates a polyhedron mesh
  64655. * * 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
  64656. * * The parameter `size` (positive float, default 1) sets the polygon size
  64657. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64658. * * 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`
  64659. * * 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
  64660. * * 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)`)
  64661. * * 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
  64662. * * 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
  64663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64664. * * 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
  64665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64666. * @param name defines the name of the mesh
  64667. * @param options defines the options used to create the mesh
  64668. * @param scene defines the hosting scene
  64669. * @returns the polyhedron mesh
  64670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64671. */
  64672. static CreatePolyhedron(name: string, options: {
  64673. type?: number;
  64674. size?: number;
  64675. sizeX?: number;
  64676. sizeY?: number;
  64677. sizeZ?: number;
  64678. custom?: any;
  64679. faceUV?: Vector4[];
  64680. faceColors?: Color4[];
  64681. flat?: boolean;
  64682. updatable?: boolean;
  64683. sideOrientation?: number;
  64684. frontUVs?: Vector4;
  64685. backUVs?: Vector4;
  64686. }, scene?: Nullable<Scene>): Mesh;
  64687. /**
  64688. * Creates a decal mesh.
  64689. * 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
  64690. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64691. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64692. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64693. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64694. * @param name defines the name of the mesh
  64695. * @param sourceMesh defines the mesh where the decal must be applied
  64696. * @param options defines the options used to create the mesh
  64697. * @param scene defines the hosting scene
  64698. * @returns the decal mesh
  64699. * @see https://doc.babylonjs.com/how_to/decals
  64700. */
  64701. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64702. position?: Vector3;
  64703. normal?: Vector3;
  64704. size?: Vector3;
  64705. angle?: number;
  64706. }): Mesh;
  64707. }
  64708. }
  64709. declare module BABYLON {
  64710. /**
  64711. * A simplifier interface for future simplification implementations
  64712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64713. */
  64714. export interface ISimplifier {
  64715. /**
  64716. * Simplification of a given mesh according to the given settings.
  64717. * Since this requires computation, it is assumed that the function runs async.
  64718. * @param settings The settings of the simplification, including quality and distance
  64719. * @param successCallback A callback that will be called after the mesh was simplified.
  64720. * @param errorCallback in case of an error, this callback will be called. optional.
  64721. */
  64722. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64723. }
  64724. /**
  64725. * Expected simplification settings.
  64726. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64727. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64728. */
  64729. export interface ISimplificationSettings {
  64730. /**
  64731. * Gets or sets the expected quality
  64732. */
  64733. quality: number;
  64734. /**
  64735. * Gets or sets the distance when this optimized version should be used
  64736. */
  64737. distance: number;
  64738. /**
  64739. * Gets an already optimized mesh
  64740. */
  64741. optimizeMesh?: boolean;
  64742. }
  64743. /**
  64744. * Class used to specify simplification options
  64745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64746. */
  64747. export class SimplificationSettings implements ISimplificationSettings {
  64748. /** expected quality */
  64749. quality: number;
  64750. /** distance when this optimized version should be used */
  64751. distance: number;
  64752. /** already optimized mesh */
  64753. optimizeMesh?: boolean | undefined;
  64754. /**
  64755. * Creates a SimplificationSettings
  64756. * @param quality expected quality
  64757. * @param distance distance when this optimized version should be used
  64758. * @param optimizeMesh already optimized mesh
  64759. */
  64760. constructor(
  64761. /** expected quality */
  64762. quality: number,
  64763. /** distance when this optimized version should be used */
  64764. distance: number,
  64765. /** already optimized mesh */
  64766. optimizeMesh?: boolean | undefined);
  64767. }
  64768. /**
  64769. * Interface used to define a simplification task
  64770. */
  64771. export interface ISimplificationTask {
  64772. /**
  64773. * Array of settings
  64774. */
  64775. settings: Array<ISimplificationSettings>;
  64776. /**
  64777. * Simplification type
  64778. */
  64779. simplificationType: SimplificationType;
  64780. /**
  64781. * Mesh to simplify
  64782. */
  64783. mesh: Mesh;
  64784. /**
  64785. * Callback called on success
  64786. */
  64787. successCallback?: () => void;
  64788. /**
  64789. * Defines if parallel processing can be used
  64790. */
  64791. parallelProcessing: boolean;
  64792. }
  64793. /**
  64794. * Queue used to order the simplification tasks
  64795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64796. */
  64797. export class SimplificationQueue {
  64798. private _simplificationArray;
  64799. /**
  64800. * Gets a boolean indicating that the process is still running
  64801. */
  64802. running: boolean;
  64803. /**
  64804. * Creates a new queue
  64805. */
  64806. constructor();
  64807. /**
  64808. * Adds a new simplification task
  64809. * @param task defines a task to add
  64810. */
  64811. addTask(task: ISimplificationTask): void;
  64812. /**
  64813. * Execute next task
  64814. */
  64815. executeNext(): void;
  64816. /**
  64817. * Execute a simplification task
  64818. * @param task defines the task to run
  64819. */
  64820. runSimplification(task: ISimplificationTask): void;
  64821. private getSimplifier;
  64822. }
  64823. /**
  64824. * The implemented types of simplification
  64825. * At the moment only Quadratic Error Decimation is implemented
  64826. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64827. */
  64828. export enum SimplificationType {
  64829. /** Quadratic error decimation */
  64830. QUADRATIC = 0
  64831. }
  64832. /**
  64833. * An implementation of the Quadratic Error simplification algorithm.
  64834. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64835. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64836. * @author RaananW
  64837. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64838. */
  64839. export class QuadraticErrorSimplification implements ISimplifier {
  64840. private _mesh;
  64841. private triangles;
  64842. private vertices;
  64843. private references;
  64844. private _reconstructedMesh;
  64845. /** Gets or sets the number pf sync interations */
  64846. syncIterations: number;
  64847. /** Gets or sets the aggressiveness of the simplifier */
  64848. aggressiveness: number;
  64849. /** Gets or sets the number of allowed iterations for decimation */
  64850. decimationIterations: number;
  64851. /** Gets or sets the espilon to use for bounding box computation */
  64852. boundingBoxEpsilon: number;
  64853. /**
  64854. * Creates a new QuadraticErrorSimplification
  64855. * @param _mesh defines the target mesh
  64856. */
  64857. constructor(_mesh: Mesh);
  64858. /**
  64859. * Simplification of a given mesh according to the given settings.
  64860. * Since this requires computation, it is assumed that the function runs async.
  64861. * @param settings The settings of the simplification, including quality and distance
  64862. * @param successCallback A callback that will be called after the mesh was simplified.
  64863. */
  64864. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64865. private runDecimation;
  64866. private initWithMesh;
  64867. private init;
  64868. private reconstructMesh;
  64869. private initDecimatedMesh;
  64870. private isFlipped;
  64871. private updateTriangles;
  64872. private identifyBorder;
  64873. private updateMesh;
  64874. private vertexError;
  64875. private calculateError;
  64876. }
  64877. }
  64878. declare module BABYLON {
  64879. interface Scene {
  64880. /** @hidden (Backing field) */
  64881. _simplificationQueue: SimplificationQueue;
  64882. /**
  64883. * Gets or sets the simplification queue attached to the scene
  64884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64885. */
  64886. simplificationQueue: SimplificationQueue;
  64887. }
  64888. interface Mesh {
  64889. /**
  64890. * Simplify the mesh according to the given array of settings.
  64891. * Function will return immediately and will simplify async
  64892. * @param settings a collection of simplification settings
  64893. * @param parallelProcessing should all levels calculate parallel or one after the other
  64894. * @param simplificationType the type of simplification to run
  64895. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64896. * @returns the current mesh
  64897. */
  64898. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64899. }
  64900. /**
  64901. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64902. * created in a scene
  64903. */
  64904. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64905. /**
  64906. * The component name helpfull to identify the component in the list of scene components.
  64907. */
  64908. readonly name: string;
  64909. /**
  64910. * The scene the component belongs to.
  64911. */
  64912. scene: Scene;
  64913. /**
  64914. * Creates a new instance of the component for the given scene
  64915. * @param scene Defines the scene to register the component in
  64916. */
  64917. constructor(scene: Scene);
  64918. /**
  64919. * Registers the component in a given scene
  64920. */
  64921. register(): void;
  64922. /**
  64923. * Rebuilds the elements related to this component in case of
  64924. * context lost for instance.
  64925. */
  64926. rebuild(): void;
  64927. /**
  64928. * Disposes the component and the associated ressources
  64929. */
  64930. dispose(): void;
  64931. private _beforeCameraUpdate;
  64932. }
  64933. }
  64934. declare module BABYLON {
  64935. interface Mesh {
  64936. /**
  64937. * Creates a new thin instance
  64938. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  64939. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64940. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  64941. */
  64942. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  64943. /**
  64944. * Adds the transformation (matrix) of the current mesh as a thin instance
  64945. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64946. * @returns the thin instance index number
  64947. */
  64948. thinInstanceAddSelf(refresh: boolean): number;
  64949. /**
  64950. * Registers a custom attribute to be used with thin instances
  64951. * @param kind name of the attribute
  64952. * @param stride size in floats of the attribute
  64953. */
  64954. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  64955. /**
  64956. * Sets the matrix of a thin instance
  64957. * @param index index of the thin instance
  64958. * @param matrix matrix to set
  64959. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64960. */
  64961. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  64962. /**
  64963. * Sets the value of a custom attribute for a thin instance
  64964. * @param kind name of the attribute
  64965. * @param index index of the thin instance
  64966. * @param value value to set
  64967. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64968. */
  64969. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  64970. /**
  64971. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  64972. */
  64973. thinInstanceCount: number;
  64974. /**
  64975. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  64976. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  64977. * @param buffer buffer to set
  64978. * @param stride size in floats of each value of the buffer
  64979. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  64980. */
  64981. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  64982. /**
  64983. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  64984. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  64985. */
  64986. thinInstanceBufferUpdated(kind: string): void;
  64987. /**
  64988. * Refreshes the bounding info, taking into account all the thin instances defined
  64989. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  64990. */
  64991. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  64992. /** @hidden */
  64993. _thinInstanceInitializeUserStorage(): void;
  64994. /** @hidden */
  64995. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  64996. /** @hidden */
  64997. _userThinInstanceBuffersStorage: {
  64998. data: {
  64999. [key: string]: Float32Array;
  65000. };
  65001. sizes: {
  65002. [key: string]: number;
  65003. };
  65004. vertexBuffers: {
  65005. [key: string]: Nullable<VertexBuffer>;
  65006. };
  65007. strides: {
  65008. [key: string]: number;
  65009. };
  65010. };
  65011. }
  65012. }
  65013. declare module BABYLON {
  65014. /**
  65015. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65016. */
  65017. export interface INavigationEnginePlugin {
  65018. /**
  65019. * plugin name
  65020. */
  65021. name: string;
  65022. /**
  65023. * Creates a navigation mesh
  65024. * @param meshes array of all the geometry used to compute the navigatio mesh
  65025. * @param parameters bunch of parameters used to filter geometry
  65026. */
  65027. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65028. /**
  65029. * Create a navigation mesh debug mesh
  65030. * @param scene is where the mesh will be added
  65031. * @returns debug display mesh
  65032. */
  65033. createDebugNavMesh(scene: Scene): Mesh;
  65034. /**
  65035. * Get a navigation mesh constrained position, closest to the parameter position
  65036. * @param position world position
  65037. * @returns the closest point to position constrained by the navigation mesh
  65038. */
  65039. getClosestPoint(position: Vector3): Vector3;
  65040. /**
  65041. * Get a navigation mesh constrained position, closest to the parameter position
  65042. * @param position world position
  65043. * @param result output the closest point to position constrained by the navigation mesh
  65044. */
  65045. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65046. /**
  65047. * Get a navigation mesh constrained position, within a particular radius
  65048. * @param position world position
  65049. * @param maxRadius the maximum distance to the constrained world position
  65050. * @returns the closest point to position constrained by the navigation mesh
  65051. */
  65052. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65053. /**
  65054. * Get a navigation mesh constrained position, within a particular radius
  65055. * @param position world position
  65056. * @param maxRadius the maximum distance to the constrained world position
  65057. * @param result output the closest point to position constrained by the navigation mesh
  65058. */
  65059. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65060. /**
  65061. * Compute the final position from a segment made of destination-position
  65062. * @param position world position
  65063. * @param destination world position
  65064. * @returns the resulting point along the navmesh
  65065. */
  65066. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65067. /**
  65068. * Compute the final position from a segment made of destination-position
  65069. * @param position world position
  65070. * @param destination world position
  65071. * @param result output the resulting point along the navmesh
  65072. */
  65073. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65074. /**
  65075. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65076. * @param start world position
  65077. * @param end world position
  65078. * @returns array containing world position composing the path
  65079. */
  65080. computePath(start: Vector3, end: Vector3): Vector3[];
  65081. /**
  65082. * If this plugin is supported
  65083. * @returns true if plugin is supported
  65084. */
  65085. isSupported(): boolean;
  65086. /**
  65087. * Create a new Crowd so you can add agents
  65088. * @param maxAgents the maximum agent count in the crowd
  65089. * @param maxAgentRadius the maximum radius an agent can have
  65090. * @param scene to attach the crowd to
  65091. * @returns the crowd you can add agents to
  65092. */
  65093. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65094. /**
  65095. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65096. * The queries will try to find a solution within those bounds
  65097. * default is (1,1,1)
  65098. * @param extent x,y,z value that define the extent around the queries point of reference
  65099. */
  65100. setDefaultQueryExtent(extent: Vector3): void;
  65101. /**
  65102. * Get the Bounding box extent specified by setDefaultQueryExtent
  65103. * @returns the box extent values
  65104. */
  65105. getDefaultQueryExtent(): Vector3;
  65106. /**
  65107. * build the navmesh from a previously saved state using getNavmeshData
  65108. * @param data the Uint8Array returned by getNavmeshData
  65109. */
  65110. buildFromNavmeshData(data: Uint8Array): void;
  65111. /**
  65112. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65113. * @returns data the Uint8Array that can be saved and reused
  65114. */
  65115. getNavmeshData(): Uint8Array;
  65116. /**
  65117. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65118. * @param result output the box extent values
  65119. */
  65120. getDefaultQueryExtentToRef(result: Vector3): void;
  65121. /**
  65122. * Release all resources
  65123. */
  65124. dispose(): void;
  65125. }
  65126. /**
  65127. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65128. */
  65129. export interface ICrowd {
  65130. /**
  65131. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65132. * You can attach anything to that node. The node position is updated in the scene update tick.
  65133. * @param pos world position that will be constrained by the navigation mesh
  65134. * @param parameters agent parameters
  65135. * @param transform hooked to the agent that will be update by the scene
  65136. * @returns agent index
  65137. */
  65138. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65139. /**
  65140. * Returns the agent position in world space
  65141. * @param index agent index returned by addAgent
  65142. * @returns world space position
  65143. */
  65144. getAgentPosition(index: number): Vector3;
  65145. /**
  65146. * Gets the agent position result in world space
  65147. * @param index agent index returned by addAgent
  65148. * @param result output world space position
  65149. */
  65150. getAgentPositionToRef(index: number, result: Vector3): void;
  65151. /**
  65152. * Gets the agent velocity in world space
  65153. * @param index agent index returned by addAgent
  65154. * @returns world space velocity
  65155. */
  65156. getAgentVelocity(index: number): Vector3;
  65157. /**
  65158. * Gets the agent velocity result in world space
  65159. * @param index agent index returned by addAgent
  65160. * @param result output world space velocity
  65161. */
  65162. getAgentVelocityToRef(index: number, result: Vector3): void;
  65163. /**
  65164. * remove a particular agent previously created
  65165. * @param index agent index returned by addAgent
  65166. */
  65167. removeAgent(index: number): void;
  65168. /**
  65169. * get the list of all agents attached to this crowd
  65170. * @returns list of agent indices
  65171. */
  65172. getAgents(): number[];
  65173. /**
  65174. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65175. * @param deltaTime in seconds
  65176. */
  65177. update(deltaTime: number): void;
  65178. /**
  65179. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65180. * @param index agent index returned by addAgent
  65181. * @param destination targeted world position
  65182. */
  65183. agentGoto(index: number, destination: Vector3): void;
  65184. /**
  65185. * Teleport the agent to a new position
  65186. * @param index agent index returned by addAgent
  65187. * @param destination targeted world position
  65188. */
  65189. agentTeleport(index: number, destination: Vector3): void;
  65190. /**
  65191. * Update agent parameters
  65192. * @param index agent index returned by addAgent
  65193. * @param parameters agent parameters
  65194. */
  65195. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65196. /**
  65197. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65198. * The queries will try to find a solution within those bounds
  65199. * default is (1,1,1)
  65200. * @param extent x,y,z value that define the extent around the queries point of reference
  65201. */
  65202. setDefaultQueryExtent(extent: Vector3): void;
  65203. /**
  65204. * Get the Bounding box extent specified by setDefaultQueryExtent
  65205. * @returns the box extent values
  65206. */
  65207. getDefaultQueryExtent(): Vector3;
  65208. /**
  65209. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65210. * @param result output the box extent values
  65211. */
  65212. getDefaultQueryExtentToRef(result: Vector3): void;
  65213. /**
  65214. * Release all resources
  65215. */
  65216. dispose(): void;
  65217. }
  65218. /**
  65219. * Configures an agent
  65220. */
  65221. export interface IAgentParameters {
  65222. /**
  65223. * Agent radius. [Limit: >= 0]
  65224. */
  65225. radius: number;
  65226. /**
  65227. * Agent height. [Limit: > 0]
  65228. */
  65229. height: number;
  65230. /**
  65231. * Maximum allowed acceleration. [Limit: >= 0]
  65232. */
  65233. maxAcceleration: number;
  65234. /**
  65235. * Maximum allowed speed. [Limit: >= 0]
  65236. */
  65237. maxSpeed: number;
  65238. /**
  65239. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65240. */
  65241. collisionQueryRange: number;
  65242. /**
  65243. * The path visibility optimization range. [Limit: > 0]
  65244. */
  65245. pathOptimizationRange: number;
  65246. /**
  65247. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65248. */
  65249. separationWeight: number;
  65250. }
  65251. /**
  65252. * Configures the navigation mesh creation
  65253. */
  65254. export interface INavMeshParameters {
  65255. /**
  65256. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65257. */
  65258. cs: number;
  65259. /**
  65260. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65261. */
  65262. ch: number;
  65263. /**
  65264. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65265. */
  65266. walkableSlopeAngle: number;
  65267. /**
  65268. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65269. * be considered walkable. [Limit: >= 3] [Units: vx]
  65270. */
  65271. walkableHeight: number;
  65272. /**
  65273. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65274. */
  65275. walkableClimb: number;
  65276. /**
  65277. * The distance to erode/shrink the walkable area of the heightfield away from
  65278. * obstructions. [Limit: >=0] [Units: vx]
  65279. */
  65280. walkableRadius: number;
  65281. /**
  65282. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65283. */
  65284. maxEdgeLen: number;
  65285. /**
  65286. * The maximum distance a simplfied contour's border edges should deviate
  65287. * the original raw contour. [Limit: >=0] [Units: vx]
  65288. */
  65289. maxSimplificationError: number;
  65290. /**
  65291. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65292. */
  65293. minRegionArea: number;
  65294. /**
  65295. * Any regions with a span count smaller than this value will, if possible,
  65296. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65297. */
  65298. mergeRegionArea: number;
  65299. /**
  65300. * The maximum number of vertices allowed for polygons generated during the
  65301. * contour to polygon conversion process. [Limit: >= 3]
  65302. */
  65303. maxVertsPerPoly: number;
  65304. /**
  65305. * Sets the sampling distance to use when generating the detail mesh.
  65306. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65307. */
  65308. detailSampleDist: number;
  65309. /**
  65310. * The maximum distance the detail mesh surface should deviate from heightfield
  65311. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65312. */
  65313. detailSampleMaxError: number;
  65314. }
  65315. }
  65316. declare module BABYLON {
  65317. /**
  65318. * RecastJS navigation plugin
  65319. */
  65320. export class RecastJSPlugin implements INavigationEnginePlugin {
  65321. /**
  65322. * Reference to the Recast library
  65323. */
  65324. bjsRECAST: any;
  65325. /**
  65326. * plugin name
  65327. */
  65328. name: string;
  65329. /**
  65330. * the first navmesh created. We might extend this to support multiple navmeshes
  65331. */
  65332. navMesh: any;
  65333. /**
  65334. * Initializes the recastJS plugin
  65335. * @param recastInjection can be used to inject your own recast reference
  65336. */
  65337. constructor(recastInjection?: any);
  65338. /**
  65339. * Creates a navigation mesh
  65340. * @param meshes array of all the geometry used to compute the navigatio mesh
  65341. * @param parameters bunch of parameters used to filter geometry
  65342. */
  65343. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65344. /**
  65345. * Create a navigation mesh debug mesh
  65346. * @param scene is where the mesh will be added
  65347. * @returns debug display mesh
  65348. */
  65349. createDebugNavMesh(scene: Scene): Mesh;
  65350. /**
  65351. * Get a navigation mesh constrained position, closest to the parameter position
  65352. * @param position world position
  65353. * @returns the closest point to position constrained by the navigation mesh
  65354. */
  65355. getClosestPoint(position: Vector3): Vector3;
  65356. /**
  65357. * Get a navigation mesh constrained position, closest to the parameter position
  65358. * @param position world position
  65359. * @param result output the closest point to position constrained by the navigation mesh
  65360. */
  65361. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65362. /**
  65363. * Get a navigation mesh constrained position, within a particular radius
  65364. * @param position world position
  65365. * @param maxRadius the maximum distance to the constrained world position
  65366. * @returns the closest point to position constrained by the navigation mesh
  65367. */
  65368. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65369. /**
  65370. * Get a navigation mesh constrained position, within a particular radius
  65371. * @param position world position
  65372. * @param maxRadius the maximum distance to the constrained world position
  65373. * @param result output the closest point to position constrained by the navigation mesh
  65374. */
  65375. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65376. /**
  65377. * Compute the final position from a segment made of destination-position
  65378. * @param position world position
  65379. * @param destination world position
  65380. * @returns the resulting point along the navmesh
  65381. */
  65382. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65383. /**
  65384. * Compute the final position from a segment made of destination-position
  65385. * @param position world position
  65386. * @param destination world position
  65387. * @param result output the resulting point along the navmesh
  65388. */
  65389. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65390. /**
  65391. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65392. * @param start world position
  65393. * @param end world position
  65394. * @returns array containing world position composing the path
  65395. */
  65396. computePath(start: Vector3, end: Vector3): Vector3[];
  65397. /**
  65398. * Create a new Crowd so you can add agents
  65399. * @param maxAgents the maximum agent count in the crowd
  65400. * @param maxAgentRadius the maximum radius an agent can have
  65401. * @param scene to attach the crowd to
  65402. * @returns the crowd you can add agents to
  65403. */
  65404. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65405. /**
  65406. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65407. * The queries will try to find a solution within those bounds
  65408. * default is (1,1,1)
  65409. * @param extent x,y,z value that define the extent around the queries point of reference
  65410. */
  65411. setDefaultQueryExtent(extent: Vector3): void;
  65412. /**
  65413. * Get the Bounding box extent specified by setDefaultQueryExtent
  65414. * @returns the box extent values
  65415. */
  65416. getDefaultQueryExtent(): Vector3;
  65417. /**
  65418. * build the navmesh from a previously saved state using getNavmeshData
  65419. * @param data the Uint8Array returned by getNavmeshData
  65420. */
  65421. buildFromNavmeshData(data: Uint8Array): void;
  65422. /**
  65423. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65424. * @returns data the Uint8Array that can be saved and reused
  65425. */
  65426. getNavmeshData(): Uint8Array;
  65427. /**
  65428. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65429. * @param result output the box extent values
  65430. */
  65431. getDefaultQueryExtentToRef(result: Vector3): void;
  65432. /**
  65433. * Disposes
  65434. */
  65435. dispose(): void;
  65436. /**
  65437. * If this plugin is supported
  65438. * @returns true if plugin is supported
  65439. */
  65440. isSupported(): boolean;
  65441. }
  65442. /**
  65443. * Recast detour crowd implementation
  65444. */
  65445. export class RecastJSCrowd implements ICrowd {
  65446. /**
  65447. * Recast/detour plugin
  65448. */
  65449. bjsRECASTPlugin: RecastJSPlugin;
  65450. /**
  65451. * Link to the detour crowd
  65452. */
  65453. recastCrowd: any;
  65454. /**
  65455. * One transform per agent
  65456. */
  65457. transforms: TransformNode[];
  65458. /**
  65459. * All agents created
  65460. */
  65461. agents: number[];
  65462. /**
  65463. * Link to the scene is kept to unregister the crowd from the scene
  65464. */
  65465. private _scene;
  65466. /**
  65467. * Observer for crowd updates
  65468. */
  65469. private _onBeforeAnimationsObserver;
  65470. /**
  65471. * Constructor
  65472. * @param plugin recastJS plugin
  65473. * @param maxAgents the maximum agent count in the crowd
  65474. * @param maxAgentRadius the maximum radius an agent can have
  65475. * @param scene to attach the crowd to
  65476. * @returns the crowd you can add agents to
  65477. */
  65478. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65479. /**
  65480. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65481. * You can attach anything to that node. The node position is updated in the scene update tick.
  65482. * @param pos world position that will be constrained by the navigation mesh
  65483. * @param parameters agent parameters
  65484. * @param transform hooked to the agent that will be update by the scene
  65485. * @returns agent index
  65486. */
  65487. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65488. /**
  65489. * Returns the agent position in world space
  65490. * @param index agent index returned by addAgent
  65491. * @returns world space position
  65492. */
  65493. getAgentPosition(index: number): Vector3;
  65494. /**
  65495. * Returns the agent position result in world space
  65496. * @param index agent index returned by addAgent
  65497. * @param result output world space position
  65498. */
  65499. getAgentPositionToRef(index: number, result: Vector3): void;
  65500. /**
  65501. * Returns the agent velocity in world space
  65502. * @param index agent index returned by addAgent
  65503. * @returns world space velocity
  65504. */
  65505. getAgentVelocity(index: number): Vector3;
  65506. /**
  65507. * Returns the agent velocity result in world space
  65508. * @param index agent index returned by addAgent
  65509. * @param result output world space velocity
  65510. */
  65511. getAgentVelocityToRef(index: number, result: Vector3): void;
  65512. /**
  65513. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65514. * @param index agent index returned by addAgent
  65515. * @param destination targeted world position
  65516. */
  65517. agentGoto(index: number, destination: Vector3): void;
  65518. /**
  65519. * Teleport the agent to a new position
  65520. * @param index agent index returned by addAgent
  65521. * @param destination targeted world position
  65522. */
  65523. agentTeleport(index: number, destination: Vector3): void;
  65524. /**
  65525. * Update agent parameters
  65526. * @param index agent index returned by addAgent
  65527. * @param parameters agent parameters
  65528. */
  65529. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65530. /**
  65531. * remove a particular agent previously created
  65532. * @param index agent index returned by addAgent
  65533. */
  65534. removeAgent(index: number): void;
  65535. /**
  65536. * get the list of all agents attached to this crowd
  65537. * @returns list of agent indices
  65538. */
  65539. getAgents(): number[];
  65540. /**
  65541. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65542. * @param deltaTime in seconds
  65543. */
  65544. update(deltaTime: number): void;
  65545. /**
  65546. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65547. * The queries will try to find a solution within those bounds
  65548. * default is (1,1,1)
  65549. * @param extent x,y,z value that define the extent around the queries point of reference
  65550. */
  65551. setDefaultQueryExtent(extent: Vector3): void;
  65552. /**
  65553. * Get the Bounding box extent specified by setDefaultQueryExtent
  65554. * @returns the box extent values
  65555. */
  65556. getDefaultQueryExtent(): Vector3;
  65557. /**
  65558. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65559. * @param result output the box extent values
  65560. */
  65561. getDefaultQueryExtentToRef(result: Vector3): void;
  65562. /**
  65563. * Release all resources
  65564. */
  65565. dispose(): void;
  65566. }
  65567. }
  65568. declare module BABYLON {
  65569. /**
  65570. * Class used to enable access to IndexedDB
  65571. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65572. */
  65573. export class Database implements IOfflineProvider {
  65574. private _callbackManifestChecked;
  65575. private _currentSceneUrl;
  65576. private _db;
  65577. private _enableSceneOffline;
  65578. private _enableTexturesOffline;
  65579. private _manifestVersionFound;
  65580. private _mustUpdateRessources;
  65581. private _hasReachedQuota;
  65582. private _isSupported;
  65583. private _idbFactory;
  65584. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65585. private static IsUASupportingBlobStorage;
  65586. /**
  65587. * Gets a boolean indicating if Database storate is enabled (off by default)
  65588. */
  65589. static IDBStorageEnabled: boolean;
  65590. /**
  65591. * Gets a boolean indicating if scene must be saved in the database
  65592. */
  65593. get enableSceneOffline(): boolean;
  65594. /**
  65595. * Gets a boolean indicating if textures must be saved in the database
  65596. */
  65597. get enableTexturesOffline(): boolean;
  65598. /**
  65599. * Creates a new Database
  65600. * @param urlToScene defines the url to load the scene
  65601. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65602. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65603. */
  65604. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65605. private static _ParseURL;
  65606. private static _ReturnFullUrlLocation;
  65607. private _checkManifestFile;
  65608. /**
  65609. * Open the database and make it available
  65610. * @param successCallback defines the callback to call on success
  65611. * @param errorCallback defines the callback to call on error
  65612. */
  65613. open(successCallback: () => void, errorCallback: () => void): void;
  65614. /**
  65615. * Loads an image from the database
  65616. * @param url defines the url to load from
  65617. * @param image defines the target DOM image
  65618. */
  65619. loadImage(url: string, image: HTMLImageElement): void;
  65620. private _loadImageFromDBAsync;
  65621. private _saveImageIntoDBAsync;
  65622. private _checkVersionFromDB;
  65623. private _loadVersionFromDBAsync;
  65624. private _saveVersionIntoDBAsync;
  65625. /**
  65626. * Loads a file from database
  65627. * @param url defines the URL to load from
  65628. * @param sceneLoaded defines a callback to call on success
  65629. * @param progressCallBack defines a callback to call when progress changed
  65630. * @param errorCallback defines a callback to call on error
  65631. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65632. */
  65633. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65634. private _loadFileAsync;
  65635. private _saveFileAsync;
  65636. /**
  65637. * Validates if xhr data is correct
  65638. * @param xhr defines the request to validate
  65639. * @param dataType defines the expected data type
  65640. * @returns true if data is correct
  65641. */
  65642. private static _ValidateXHRData;
  65643. }
  65644. }
  65645. declare module BABYLON {
  65646. /** @hidden */
  65647. export var gpuUpdateParticlesPixelShader: {
  65648. name: string;
  65649. shader: string;
  65650. };
  65651. }
  65652. declare module BABYLON {
  65653. /** @hidden */
  65654. export var gpuUpdateParticlesVertexShader: {
  65655. name: string;
  65656. shader: string;
  65657. };
  65658. }
  65659. declare module BABYLON {
  65660. /** @hidden */
  65661. export var clipPlaneFragmentDeclaration2: {
  65662. name: string;
  65663. shader: string;
  65664. };
  65665. }
  65666. declare module BABYLON {
  65667. /** @hidden */
  65668. export var gpuRenderParticlesPixelShader: {
  65669. name: string;
  65670. shader: string;
  65671. };
  65672. }
  65673. declare module BABYLON {
  65674. /** @hidden */
  65675. export var clipPlaneVertexDeclaration2: {
  65676. name: string;
  65677. shader: string;
  65678. };
  65679. }
  65680. declare module BABYLON {
  65681. /** @hidden */
  65682. export var gpuRenderParticlesVertexShader: {
  65683. name: string;
  65684. shader: string;
  65685. };
  65686. }
  65687. declare module BABYLON {
  65688. /**
  65689. * This represents a GPU particle system in Babylon
  65690. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65691. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65692. */
  65693. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65694. /**
  65695. * The layer mask we are rendering the particles through.
  65696. */
  65697. layerMask: number;
  65698. private _capacity;
  65699. private _activeCount;
  65700. private _currentActiveCount;
  65701. private _accumulatedCount;
  65702. private _renderEffect;
  65703. private _updateEffect;
  65704. private _buffer0;
  65705. private _buffer1;
  65706. private _spriteBuffer;
  65707. private _updateVAO;
  65708. private _renderVAO;
  65709. private _targetIndex;
  65710. private _sourceBuffer;
  65711. private _targetBuffer;
  65712. private _engine;
  65713. private _currentRenderId;
  65714. private _started;
  65715. private _stopped;
  65716. private _timeDelta;
  65717. private _randomTexture;
  65718. private _randomTexture2;
  65719. private _attributesStrideSize;
  65720. private _updateEffectOptions;
  65721. private _randomTextureSize;
  65722. private _actualFrame;
  65723. private _customEffect;
  65724. private readonly _rawTextureWidth;
  65725. /**
  65726. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65727. */
  65728. static get IsSupported(): boolean;
  65729. /**
  65730. * An event triggered when the system is disposed.
  65731. */
  65732. onDisposeObservable: Observable<IParticleSystem>;
  65733. /**
  65734. * Gets the maximum number of particles active at the same time.
  65735. * @returns The max number of active particles.
  65736. */
  65737. getCapacity(): number;
  65738. /**
  65739. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65740. * to override the particles.
  65741. */
  65742. forceDepthWrite: boolean;
  65743. /**
  65744. * Gets or set the number of active particles
  65745. */
  65746. get activeParticleCount(): number;
  65747. set activeParticleCount(value: number);
  65748. private _preWarmDone;
  65749. /**
  65750. * Specifies if the particles are updated in emitter local space or world space.
  65751. */
  65752. isLocal: boolean;
  65753. /**
  65754. * Is this system ready to be used/rendered
  65755. * @return true if the system is ready
  65756. */
  65757. isReady(): boolean;
  65758. /**
  65759. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65760. * @returns True if it has been started, otherwise false.
  65761. */
  65762. isStarted(): boolean;
  65763. /**
  65764. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65765. * @returns True if it has been stopped, otherwise false.
  65766. */
  65767. isStopped(): boolean;
  65768. /**
  65769. * Gets a boolean indicating that the system is stopping
  65770. * @returns true if the system is currently stopping
  65771. */
  65772. isStopping(): boolean;
  65773. /**
  65774. * Gets the number of particles active at the same time.
  65775. * @returns The number of active particles.
  65776. */
  65777. getActiveCount(): number;
  65778. /**
  65779. * Starts the particle system and begins to emit
  65780. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65781. */
  65782. start(delay?: number): void;
  65783. /**
  65784. * Stops the particle system.
  65785. */
  65786. stop(): void;
  65787. /**
  65788. * Remove all active particles
  65789. */
  65790. reset(): void;
  65791. /**
  65792. * Returns the string "GPUParticleSystem"
  65793. * @returns a string containing the class name
  65794. */
  65795. getClassName(): string;
  65796. /**
  65797. * Gets the custom effect used to render the particles
  65798. * @param blendMode Blend mode for which the effect should be retrieved
  65799. * @returns The effect
  65800. */
  65801. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65802. /**
  65803. * Sets the custom effect used to render the particles
  65804. * @param effect The effect to set
  65805. * @param blendMode Blend mode for which the effect should be set
  65806. */
  65807. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65808. /** @hidden */
  65809. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65810. /**
  65811. * Observable that will be called just before the particles are drawn
  65812. */
  65813. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65814. /**
  65815. * Gets the name of the particle vertex shader
  65816. */
  65817. get vertexShaderName(): string;
  65818. private _colorGradientsTexture;
  65819. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65820. /**
  65821. * Adds a new color gradient
  65822. * @param gradient defines the gradient to use (between 0 and 1)
  65823. * @param color1 defines the color to affect to the specified gradient
  65824. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65825. * @returns the current particle system
  65826. */
  65827. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65828. private _refreshColorGradient;
  65829. /** Force the system to rebuild all gradients that need to be resync */
  65830. forceRefreshGradients(): void;
  65831. /**
  65832. * Remove a specific color gradient
  65833. * @param gradient defines the gradient to remove
  65834. * @returns the current particle system
  65835. */
  65836. removeColorGradient(gradient: number): GPUParticleSystem;
  65837. private _angularSpeedGradientsTexture;
  65838. private _sizeGradientsTexture;
  65839. private _velocityGradientsTexture;
  65840. private _limitVelocityGradientsTexture;
  65841. private _dragGradientsTexture;
  65842. private _addFactorGradient;
  65843. /**
  65844. * Adds a new size gradient
  65845. * @param gradient defines the gradient to use (between 0 and 1)
  65846. * @param factor defines the size factor to affect to the specified gradient
  65847. * @returns the current particle system
  65848. */
  65849. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65850. /**
  65851. * Remove a specific size gradient
  65852. * @param gradient defines the gradient to remove
  65853. * @returns the current particle system
  65854. */
  65855. removeSizeGradient(gradient: number): GPUParticleSystem;
  65856. private _refreshFactorGradient;
  65857. /**
  65858. * Adds a new angular speed gradient
  65859. * @param gradient defines the gradient to use (between 0 and 1)
  65860. * @param factor defines the angular speed to affect to the specified gradient
  65861. * @returns the current particle system
  65862. */
  65863. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65864. /**
  65865. * Remove a specific angular speed gradient
  65866. * @param gradient defines the gradient to remove
  65867. * @returns the current particle system
  65868. */
  65869. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65870. /**
  65871. * Adds a new velocity gradient
  65872. * @param gradient defines the gradient to use (between 0 and 1)
  65873. * @param factor defines the velocity to affect to the specified gradient
  65874. * @returns the current particle system
  65875. */
  65876. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65877. /**
  65878. * Remove a specific velocity gradient
  65879. * @param gradient defines the gradient to remove
  65880. * @returns the current particle system
  65881. */
  65882. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65883. /**
  65884. * Adds a new limit velocity gradient
  65885. * @param gradient defines the gradient to use (between 0 and 1)
  65886. * @param factor defines the limit velocity value to affect to the specified gradient
  65887. * @returns the current particle system
  65888. */
  65889. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65890. /**
  65891. * Remove a specific limit velocity gradient
  65892. * @param gradient defines the gradient to remove
  65893. * @returns the current particle system
  65894. */
  65895. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65896. /**
  65897. * Adds a new drag gradient
  65898. * @param gradient defines the gradient to use (between 0 and 1)
  65899. * @param factor defines the drag value to affect to the specified gradient
  65900. * @returns the current particle system
  65901. */
  65902. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65903. /**
  65904. * Remove a specific drag gradient
  65905. * @param gradient defines the gradient to remove
  65906. * @returns the current particle system
  65907. */
  65908. removeDragGradient(gradient: number): GPUParticleSystem;
  65909. /**
  65910. * Not supported by GPUParticleSystem
  65911. * @param gradient defines the gradient to use (between 0 and 1)
  65912. * @param factor defines the emit rate value to affect to the specified gradient
  65913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65914. * @returns the current particle system
  65915. */
  65916. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65917. /**
  65918. * Not supported by GPUParticleSystem
  65919. * @param gradient defines the gradient to remove
  65920. * @returns the current particle system
  65921. */
  65922. removeEmitRateGradient(gradient: number): IParticleSystem;
  65923. /**
  65924. * Not supported by GPUParticleSystem
  65925. * @param gradient defines the gradient to use (between 0 and 1)
  65926. * @param factor defines the start size value to affect to the specified gradient
  65927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65928. * @returns the current particle system
  65929. */
  65930. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65931. /**
  65932. * Not supported by GPUParticleSystem
  65933. * @param gradient defines the gradient to remove
  65934. * @returns the current particle system
  65935. */
  65936. removeStartSizeGradient(gradient: number): IParticleSystem;
  65937. /**
  65938. * Not supported by GPUParticleSystem
  65939. * @param gradient defines the gradient to use (between 0 and 1)
  65940. * @param min defines the color remap minimal range
  65941. * @param max defines the color remap maximal range
  65942. * @returns the current particle system
  65943. */
  65944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65945. /**
  65946. * Not supported by GPUParticleSystem
  65947. * @param gradient defines the gradient to remove
  65948. * @returns the current particle system
  65949. */
  65950. removeColorRemapGradient(): IParticleSystem;
  65951. /**
  65952. * Not supported by GPUParticleSystem
  65953. * @param gradient defines the gradient to use (between 0 and 1)
  65954. * @param min defines the alpha remap minimal range
  65955. * @param max defines the alpha remap maximal range
  65956. * @returns the current particle system
  65957. */
  65958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65959. /**
  65960. * Not supported by GPUParticleSystem
  65961. * @param gradient defines the gradient to remove
  65962. * @returns the current particle system
  65963. */
  65964. removeAlphaRemapGradient(): IParticleSystem;
  65965. /**
  65966. * Not supported by GPUParticleSystem
  65967. * @param gradient defines the gradient to use (between 0 and 1)
  65968. * @param color defines the color to affect to the specified gradient
  65969. * @returns the current particle system
  65970. */
  65971. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65972. /**
  65973. * Not supported by GPUParticleSystem
  65974. * @param gradient defines the gradient to remove
  65975. * @returns the current particle system
  65976. */
  65977. removeRampGradient(): IParticleSystem;
  65978. /**
  65979. * Not supported by GPUParticleSystem
  65980. * @returns the list of ramp gradients
  65981. */
  65982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65983. /**
  65984. * Not supported by GPUParticleSystem
  65985. * Gets or sets a boolean indicating that ramp gradients must be used
  65986. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65987. */
  65988. get useRampGradients(): boolean;
  65989. set useRampGradients(value: boolean);
  65990. /**
  65991. * Not supported by GPUParticleSystem
  65992. * @param gradient defines the gradient to use (between 0 and 1)
  65993. * @param factor defines the life time factor to affect to the specified gradient
  65994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65995. * @returns the current particle system
  65996. */
  65997. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65998. /**
  65999. * Not supported by GPUParticleSystem
  66000. * @param gradient defines the gradient to remove
  66001. * @returns the current particle system
  66002. */
  66003. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66004. /**
  66005. * Instantiates a GPU particle system.
  66006. * 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.
  66007. * @param name The name of the particle system
  66008. * @param options The options used to create the system
  66009. * @param scene The scene the particle system belongs to
  66010. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66011. * @param customEffect a custom effect used to change the way particles are rendered by default
  66012. */
  66013. constructor(name: string, options: Partial<{
  66014. capacity: number;
  66015. randomTextureSize: number;
  66016. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66017. protected _reset(): void;
  66018. private _createUpdateVAO;
  66019. private _createRenderVAO;
  66020. private _initialize;
  66021. /** @hidden */
  66022. _recreateUpdateEffect(): void;
  66023. private _getEffect;
  66024. /**
  66025. * Fill the defines array according to the current settings of the particle system
  66026. * @param defines Array to be updated
  66027. * @param blendMode blend mode to take into account when updating the array
  66028. */
  66029. fillDefines(defines: Array<string>, blendMode?: number): void;
  66030. /**
  66031. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66032. * @param uniforms Uniforms array to fill
  66033. * @param attributes Attributes array to fill
  66034. * @param samplers Samplers array to fill
  66035. */
  66036. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66037. /** @hidden */
  66038. _recreateRenderEffect(): Effect;
  66039. /**
  66040. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66041. * @param preWarm defines if we are in the pre-warmimg phase
  66042. */
  66043. animate(preWarm?: boolean): void;
  66044. private _createFactorGradientTexture;
  66045. private _createSizeGradientTexture;
  66046. private _createAngularSpeedGradientTexture;
  66047. private _createVelocityGradientTexture;
  66048. private _createLimitVelocityGradientTexture;
  66049. private _createDragGradientTexture;
  66050. private _createColorGradientTexture;
  66051. /**
  66052. * Renders the particle system in its current state
  66053. * @param preWarm defines if the system should only update the particles but not render them
  66054. * @returns the current number of particles
  66055. */
  66056. render(preWarm?: boolean): number;
  66057. /**
  66058. * Rebuilds the particle system
  66059. */
  66060. rebuild(): void;
  66061. private _releaseBuffers;
  66062. private _releaseVAOs;
  66063. /**
  66064. * Disposes the particle system and free the associated resources
  66065. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66066. */
  66067. dispose(disposeTexture?: boolean): void;
  66068. /**
  66069. * Clones the particle system.
  66070. * @param name The name of the cloned object
  66071. * @param newEmitter The new emitter to use
  66072. * @returns the cloned particle system
  66073. */
  66074. clone(name: string, newEmitter: any): GPUParticleSystem;
  66075. /**
  66076. * Serializes the particle system to a JSON object
  66077. * @param serializeTexture defines if the texture must be serialized as well
  66078. * @returns the JSON object
  66079. */
  66080. serialize(serializeTexture?: boolean): any;
  66081. /**
  66082. * Parses a JSON object to create a GPU particle system.
  66083. * @param parsedParticleSystem The JSON object to parse
  66084. * @param scene The scene to create the particle system in
  66085. * @param rootUrl The root url to use to load external dependencies like texture
  66086. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66087. * @returns the parsed GPU particle system
  66088. */
  66089. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66090. }
  66091. }
  66092. declare module BABYLON {
  66093. /**
  66094. * Represents a set of particle systems working together to create a specific effect
  66095. */
  66096. export class ParticleSystemSet implements IDisposable {
  66097. /**
  66098. * Gets or sets base Assets URL
  66099. */
  66100. static BaseAssetsUrl: string;
  66101. private _emitterCreationOptions;
  66102. private _emitterNode;
  66103. /**
  66104. * Gets the particle system list
  66105. */
  66106. systems: IParticleSystem[];
  66107. /**
  66108. * Gets the emitter node used with this set
  66109. */
  66110. get emitterNode(): Nullable<TransformNode>;
  66111. /**
  66112. * Creates a new emitter mesh as a sphere
  66113. * @param options defines the options used to create the sphere
  66114. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66115. * @param scene defines the hosting scene
  66116. */
  66117. setEmitterAsSphere(options: {
  66118. diameter: number;
  66119. segments: number;
  66120. color: Color3;
  66121. }, renderingGroupId: number, scene: Scene): void;
  66122. /**
  66123. * Starts all particle systems of the set
  66124. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66125. */
  66126. start(emitter?: AbstractMesh): void;
  66127. /**
  66128. * Release all associated resources
  66129. */
  66130. dispose(): void;
  66131. /**
  66132. * Serialize the set into a JSON compatible object
  66133. * @param serializeTexture defines if the texture must be serialized as well
  66134. * @returns a JSON compatible representation of the set
  66135. */
  66136. serialize(serializeTexture?: boolean): any;
  66137. /**
  66138. * Parse a new ParticleSystemSet from a serialized source
  66139. * @param data defines a JSON compatible representation of the set
  66140. * @param scene defines the hosting scene
  66141. * @param gpu defines if we want GPU particles or CPU particles
  66142. * @returns a new ParticleSystemSet
  66143. */
  66144. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66145. }
  66146. }
  66147. declare module BABYLON {
  66148. /**
  66149. * This class is made for on one-liner static method to help creating particle system set.
  66150. */
  66151. export class ParticleHelper {
  66152. /**
  66153. * Gets or sets base Assets URL
  66154. */
  66155. static BaseAssetsUrl: string;
  66156. /** Define the Url to load snippets */
  66157. static SnippetUrl: string;
  66158. /**
  66159. * Create a default particle system that you can tweak
  66160. * @param emitter defines the emitter to use
  66161. * @param capacity defines the system capacity (default is 500 particles)
  66162. * @param scene defines the hosting scene
  66163. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66164. * @returns the new Particle system
  66165. */
  66166. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66167. /**
  66168. * This is the main static method (one-liner) of this helper to create different particle systems
  66169. * @param type This string represents the type to the particle system to create
  66170. * @param scene The scene where the particle system should live
  66171. * @param gpu If the system will use gpu
  66172. * @returns the ParticleSystemSet created
  66173. */
  66174. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66175. /**
  66176. * Static function used to export a particle system to a ParticleSystemSet variable.
  66177. * Please note that the emitter shape is not exported
  66178. * @param systems defines the particle systems to export
  66179. * @returns the created particle system set
  66180. */
  66181. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66182. /**
  66183. * Creates a particle system from a snippet saved in a remote file
  66184. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66185. * @param url defines the url to load from
  66186. * @param scene defines the hosting scene
  66187. * @param gpu If the system will use gpu
  66188. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66189. * @returns a promise that will resolve to the new particle system
  66190. */
  66191. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66192. /**
  66193. * Creates a particle system from a snippet saved by the particle system editor
  66194. * @param snippetId defines the snippet to load
  66195. * @param scene defines the hosting scene
  66196. * @param gpu If the system will use gpu
  66197. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66198. * @returns a promise that will resolve to the new particle system
  66199. */
  66200. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66201. }
  66202. }
  66203. declare module BABYLON {
  66204. interface Engine {
  66205. /**
  66206. * Create an effect to use with particle systems.
  66207. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66208. * the particle system for which you want to create a custom effect in the last parameter
  66209. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66210. * @param uniformsNames defines a list of attribute names
  66211. * @param samplers defines an array of string used to represent textures
  66212. * @param defines defines the string containing the defines to use to compile the shaders
  66213. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66214. * @param onCompiled defines a function to call when the effect creation is successful
  66215. * @param onError defines a function to call when the effect creation has failed
  66216. * @param particleSystem the particle system you want to create the effect for
  66217. * @returns the new Effect
  66218. */
  66219. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66220. }
  66221. interface Mesh {
  66222. /**
  66223. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66224. * @returns an array of IParticleSystem
  66225. */
  66226. getEmittedParticleSystems(): IParticleSystem[];
  66227. /**
  66228. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66229. * @returns an array of IParticleSystem
  66230. */
  66231. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66232. }
  66233. }
  66234. declare module BABYLON {
  66235. /** Defines the 4 color options */
  66236. export enum PointColor {
  66237. /** color value */
  66238. Color = 2,
  66239. /** uv value */
  66240. UV = 1,
  66241. /** random value */
  66242. Random = 0,
  66243. /** stated value */
  66244. Stated = 3
  66245. }
  66246. /**
  66247. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66248. * 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.
  66249. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66250. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66251. *
  66252. * Full documentation here : TO BE ENTERED
  66253. */
  66254. export class PointsCloudSystem implements IDisposable {
  66255. /**
  66256. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66257. * Example : var p = SPS.particles[i];
  66258. */
  66259. particles: CloudPoint[];
  66260. /**
  66261. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66262. */
  66263. nbParticles: number;
  66264. /**
  66265. * This a counter for your own usage. It's not set by any SPS functions.
  66266. */
  66267. counter: number;
  66268. /**
  66269. * The PCS name. This name is also given to the underlying mesh.
  66270. */
  66271. name: string;
  66272. /**
  66273. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66274. */
  66275. mesh: Mesh;
  66276. /**
  66277. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66278. * Please read :
  66279. */
  66280. vars: any;
  66281. /**
  66282. * @hidden
  66283. */
  66284. _size: number;
  66285. private _scene;
  66286. private _promises;
  66287. private _positions;
  66288. private _indices;
  66289. private _normals;
  66290. private _colors;
  66291. private _uvs;
  66292. private _indices32;
  66293. private _positions32;
  66294. private _colors32;
  66295. private _uvs32;
  66296. private _updatable;
  66297. private _isVisibilityBoxLocked;
  66298. private _alwaysVisible;
  66299. private _groups;
  66300. private _groupCounter;
  66301. private _computeParticleColor;
  66302. private _computeParticleTexture;
  66303. private _computeParticleRotation;
  66304. private _computeBoundingBox;
  66305. private _isReady;
  66306. /**
  66307. * Creates a PCS (Points Cloud System) object
  66308. * @param name (String) is the PCS name, this will be the underlying mesh name
  66309. * @param pointSize (number) is the size for each point
  66310. * @param scene (Scene) is the scene in which the PCS is added
  66311. * @param options defines the options of the PCS e.g.
  66312. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66313. */
  66314. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66315. updatable?: boolean;
  66316. });
  66317. /**
  66318. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66319. * If no points were added to the PCS, the returned mesh is just a single point.
  66320. * @returns a promise for the created mesh
  66321. */
  66322. buildMeshAsync(): Promise<Mesh>;
  66323. /**
  66324. * @hidden
  66325. */
  66326. private _buildMesh;
  66327. private _addParticle;
  66328. private _randomUnitVector;
  66329. private _getColorIndicesForCoord;
  66330. private _setPointsColorOrUV;
  66331. private _colorFromTexture;
  66332. private _calculateDensity;
  66333. /**
  66334. * Adds points to the PCS in random positions within a unit sphere
  66335. * @param nb (positive integer) the number of particles to be created from this model
  66336. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66337. * @returns the number of groups in the system
  66338. */
  66339. addPoints(nb: number, pointFunction?: any): number;
  66340. /**
  66341. * Adds points to the PCS from the surface of the model shape
  66342. * @param mesh is any Mesh object that will be used as a surface model for the points
  66343. * @param nb (positive integer) the number of particles to be created from this model
  66344. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66345. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66346. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66347. * @returns the number of groups in the system
  66348. */
  66349. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66350. /**
  66351. * Adds points to the PCS inside the model shape
  66352. * @param mesh is any Mesh object that will be used as a surface model for the points
  66353. * @param nb (positive integer) the number of particles to be created from this model
  66354. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66355. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66356. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66357. * @returns the number of groups in the system
  66358. */
  66359. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66360. /**
  66361. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66362. * This method calls `updateParticle()` for each particle of the SPS.
  66363. * For an animated SPS, it is usually called within the render loop.
  66364. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66365. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66366. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66367. * @returns the PCS.
  66368. */
  66369. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66370. /**
  66371. * Disposes the PCS.
  66372. */
  66373. dispose(): void;
  66374. /**
  66375. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66376. * doc :
  66377. * @returns the PCS.
  66378. */
  66379. refreshVisibleSize(): PointsCloudSystem;
  66380. /**
  66381. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66382. * @param size the size (float) of the visibility box
  66383. * note : this doesn't lock the PCS mesh bounding box.
  66384. * doc :
  66385. */
  66386. setVisibilityBox(size: number): void;
  66387. /**
  66388. * Gets whether the PCS is always visible or not
  66389. * doc :
  66390. */
  66391. get isAlwaysVisible(): boolean;
  66392. /**
  66393. * Sets the PCS as always visible or not
  66394. * doc :
  66395. */
  66396. set isAlwaysVisible(val: boolean);
  66397. /**
  66398. * Tells to `setParticles()` to compute the particle rotations or not
  66399. * Default value : false. The PCS is faster when it's set to false
  66400. * Note : particle rotations are only applied to parent particles
  66401. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66402. */
  66403. set computeParticleRotation(val: boolean);
  66404. /**
  66405. * Tells to `setParticles()` to compute the particle colors or not.
  66406. * Default value : true. The PCS is faster when it's set to false.
  66407. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66408. */
  66409. set computeParticleColor(val: boolean);
  66410. set computeParticleTexture(val: boolean);
  66411. /**
  66412. * Gets if `setParticles()` computes the particle colors or not.
  66413. * Default value : false. The PCS is faster when it's set to false.
  66414. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66415. */
  66416. get computeParticleColor(): boolean;
  66417. /**
  66418. * Gets if `setParticles()` computes the particle textures or not.
  66419. * Default value : false. The PCS is faster when it's set to false.
  66420. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66421. */
  66422. get computeParticleTexture(): boolean;
  66423. /**
  66424. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66425. */
  66426. set computeBoundingBox(val: boolean);
  66427. /**
  66428. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66429. */
  66430. get computeBoundingBox(): boolean;
  66431. /**
  66432. * This function does nothing. It may be overwritten to set all the particle first values.
  66433. * The PCS doesn't call this function, you may have to call it by your own.
  66434. * doc :
  66435. */
  66436. initParticles(): void;
  66437. /**
  66438. * This function does nothing. It may be overwritten to recycle a particle
  66439. * The PCS doesn't call this function, you can to call it
  66440. * doc :
  66441. * @param particle The particle to recycle
  66442. * @returns the recycled particle
  66443. */
  66444. recycleParticle(particle: CloudPoint): CloudPoint;
  66445. /**
  66446. * Updates a particle : this function should be overwritten by the user.
  66447. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66448. * doc :
  66449. * @example : just set a particle position or velocity and recycle conditions
  66450. * @param particle The particle to update
  66451. * @returns the updated particle
  66452. */
  66453. updateParticle(particle: CloudPoint): CloudPoint;
  66454. /**
  66455. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66456. * This does nothing and may be overwritten by the user.
  66457. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66458. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66459. * @param update the boolean update value actually passed to setParticles()
  66460. */
  66461. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66462. /**
  66463. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66464. * This will be passed three parameters.
  66465. * This does nothing and may be overwritten by the user.
  66466. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66467. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66468. * @param update the boolean update value actually passed to setParticles()
  66469. */
  66470. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66471. }
  66472. }
  66473. declare module BABYLON {
  66474. /**
  66475. * Represents one particle of a points cloud system.
  66476. */
  66477. export class CloudPoint {
  66478. /**
  66479. * particle global index
  66480. */
  66481. idx: number;
  66482. /**
  66483. * The color of the particle
  66484. */
  66485. color: Nullable<Color4>;
  66486. /**
  66487. * The world space position of the particle.
  66488. */
  66489. position: Vector3;
  66490. /**
  66491. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66492. */
  66493. rotation: Vector3;
  66494. /**
  66495. * The world space rotation quaternion of the particle.
  66496. */
  66497. rotationQuaternion: Nullable<Quaternion>;
  66498. /**
  66499. * The uv of the particle.
  66500. */
  66501. uv: Nullable<Vector2>;
  66502. /**
  66503. * The current speed of the particle.
  66504. */
  66505. velocity: Vector3;
  66506. /**
  66507. * The pivot point in the particle local space.
  66508. */
  66509. pivot: Vector3;
  66510. /**
  66511. * Must the particle be translated from its pivot point in its local space ?
  66512. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66513. * Default : false
  66514. */
  66515. translateFromPivot: boolean;
  66516. /**
  66517. * Index of this particle in the global "positions" array (Internal use)
  66518. * @hidden
  66519. */
  66520. _pos: number;
  66521. /**
  66522. * @hidden Index of this particle in the global "indices" array (Internal use)
  66523. */
  66524. _ind: number;
  66525. /**
  66526. * Group this particle belongs to
  66527. */
  66528. _group: PointsGroup;
  66529. /**
  66530. * Group id of this particle
  66531. */
  66532. groupId: number;
  66533. /**
  66534. * Index of the particle in its group id (Internal use)
  66535. */
  66536. idxInGroup: number;
  66537. /**
  66538. * @hidden Particle BoundingInfo object (Internal use)
  66539. */
  66540. _boundingInfo: BoundingInfo;
  66541. /**
  66542. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66543. */
  66544. _pcs: PointsCloudSystem;
  66545. /**
  66546. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66547. */
  66548. _stillInvisible: boolean;
  66549. /**
  66550. * @hidden Last computed particle rotation matrix
  66551. */
  66552. _rotationMatrix: number[];
  66553. /**
  66554. * Parent particle Id, if any.
  66555. * Default null.
  66556. */
  66557. parentId: Nullable<number>;
  66558. /**
  66559. * @hidden Internal global position in the PCS.
  66560. */
  66561. _globalPosition: Vector3;
  66562. /**
  66563. * Creates a Point Cloud object.
  66564. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66565. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66566. * @param group (PointsGroup) is the group the particle belongs to
  66567. * @param groupId (integer) is the group identifier in the PCS.
  66568. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66569. * @param pcs defines the PCS it is associated to
  66570. */
  66571. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66572. /**
  66573. * get point size
  66574. */
  66575. get size(): Vector3;
  66576. /**
  66577. * Set point size
  66578. */
  66579. set size(scale: Vector3);
  66580. /**
  66581. * Legacy support, changed quaternion to rotationQuaternion
  66582. */
  66583. get quaternion(): Nullable<Quaternion>;
  66584. /**
  66585. * Legacy support, changed quaternion to rotationQuaternion
  66586. */
  66587. set quaternion(q: Nullable<Quaternion>);
  66588. /**
  66589. * Returns a boolean. True if the particle intersects a mesh, else false
  66590. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66591. * @param target is the object (point or mesh) what the intersection is computed against
  66592. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66593. * @returns true if it intersects
  66594. */
  66595. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66596. /**
  66597. * get the rotation matrix of the particle
  66598. * @hidden
  66599. */
  66600. getRotationMatrix(m: Matrix): void;
  66601. }
  66602. /**
  66603. * Represents a group of points in a points cloud system
  66604. * * PCS internal tool, don't use it manually.
  66605. */
  66606. export class PointsGroup {
  66607. /**
  66608. * The group id
  66609. * @hidden
  66610. */
  66611. groupID: number;
  66612. /**
  66613. * image data for group (internal use)
  66614. * @hidden
  66615. */
  66616. _groupImageData: Nullable<ArrayBufferView>;
  66617. /**
  66618. * Image Width (internal use)
  66619. * @hidden
  66620. */
  66621. _groupImgWidth: number;
  66622. /**
  66623. * Image Height (internal use)
  66624. * @hidden
  66625. */
  66626. _groupImgHeight: number;
  66627. /**
  66628. * Custom position function (internal use)
  66629. * @hidden
  66630. */
  66631. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66632. /**
  66633. * density per facet for surface points
  66634. * @hidden
  66635. */
  66636. _groupDensity: number[];
  66637. /**
  66638. * Only when points are colored by texture carries pointer to texture list array
  66639. * @hidden
  66640. */
  66641. _textureNb: number;
  66642. /**
  66643. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66644. * PCS internal tool, don't use it manually.
  66645. * @hidden
  66646. */
  66647. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66648. }
  66649. }
  66650. declare module BABYLON {
  66651. interface Scene {
  66652. /** @hidden (Backing field) */
  66653. _physicsEngine: Nullable<IPhysicsEngine>;
  66654. /** @hidden */
  66655. _physicsTimeAccumulator: number;
  66656. /**
  66657. * Gets the current physics engine
  66658. * @returns a IPhysicsEngine or null if none attached
  66659. */
  66660. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66661. /**
  66662. * Enables physics to the current scene
  66663. * @param gravity defines the scene's gravity for the physics engine
  66664. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66665. * @return a boolean indicating if the physics engine was initialized
  66666. */
  66667. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66668. /**
  66669. * Disables and disposes the physics engine associated with the scene
  66670. */
  66671. disablePhysicsEngine(): void;
  66672. /**
  66673. * Gets a boolean indicating if there is an active physics engine
  66674. * @returns a boolean indicating if there is an active physics engine
  66675. */
  66676. isPhysicsEnabled(): boolean;
  66677. /**
  66678. * Deletes a physics compound impostor
  66679. * @param compound defines the compound to delete
  66680. */
  66681. deleteCompoundImpostor(compound: any): void;
  66682. /**
  66683. * An event triggered when physic simulation is about to be run
  66684. */
  66685. onBeforePhysicsObservable: Observable<Scene>;
  66686. /**
  66687. * An event triggered when physic simulation has been done
  66688. */
  66689. onAfterPhysicsObservable: Observable<Scene>;
  66690. }
  66691. interface AbstractMesh {
  66692. /** @hidden */
  66693. _physicsImpostor: Nullable<PhysicsImpostor>;
  66694. /**
  66695. * Gets or sets impostor used for physic simulation
  66696. * @see http://doc.babylonjs.com/features/physics_engine
  66697. */
  66698. physicsImpostor: Nullable<PhysicsImpostor>;
  66699. /**
  66700. * Gets the current physics impostor
  66701. * @see http://doc.babylonjs.com/features/physics_engine
  66702. * @returns a physics impostor or null
  66703. */
  66704. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66705. /** Apply a physic impulse to the mesh
  66706. * @param force defines the force to apply
  66707. * @param contactPoint defines where to apply the force
  66708. * @returns the current mesh
  66709. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66710. */
  66711. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66712. /**
  66713. * Creates a physic joint between two meshes
  66714. * @param otherMesh defines the other mesh to use
  66715. * @param pivot1 defines the pivot to use on this mesh
  66716. * @param pivot2 defines the pivot to use on the other mesh
  66717. * @param options defines additional options (can be plugin dependent)
  66718. * @returns the current mesh
  66719. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66720. */
  66721. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66722. /** @hidden */
  66723. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66724. }
  66725. /**
  66726. * Defines the physics engine scene component responsible to manage a physics engine
  66727. */
  66728. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66729. /**
  66730. * The component name helpful to identify the component in the list of scene components.
  66731. */
  66732. readonly name: string;
  66733. /**
  66734. * The scene the component belongs to.
  66735. */
  66736. scene: Scene;
  66737. /**
  66738. * Creates a new instance of the component for the given scene
  66739. * @param scene Defines the scene to register the component in
  66740. */
  66741. constructor(scene: Scene);
  66742. /**
  66743. * Registers the component in a given scene
  66744. */
  66745. register(): void;
  66746. /**
  66747. * Rebuilds the elements related to this component in case of
  66748. * context lost for instance.
  66749. */
  66750. rebuild(): void;
  66751. /**
  66752. * Disposes the component and the associated ressources
  66753. */
  66754. dispose(): void;
  66755. }
  66756. }
  66757. declare module BABYLON {
  66758. /**
  66759. * A helper for physics simulations
  66760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66761. */
  66762. export class PhysicsHelper {
  66763. private _scene;
  66764. private _physicsEngine;
  66765. /**
  66766. * Initializes the Physics helper
  66767. * @param scene Babylon.js scene
  66768. */
  66769. constructor(scene: Scene);
  66770. /**
  66771. * Applies a radial explosion impulse
  66772. * @param origin the origin of the explosion
  66773. * @param radiusOrEventOptions the radius or the options of radial explosion
  66774. * @param strength the explosion strength
  66775. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66776. * @returns A physics radial explosion event, or null
  66777. */
  66778. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66779. /**
  66780. * Applies a radial explosion force
  66781. * @param origin the origin of the explosion
  66782. * @param radiusOrEventOptions the radius or the options of radial explosion
  66783. * @param strength the explosion strength
  66784. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66785. * @returns A physics radial explosion event, or null
  66786. */
  66787. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66788. /**
  66789. * Creates a gravitational field
  66790. * @param origin the origin of the explosion
  66791. * @param radiusOrEventOptions the radius or the options of radial explosion
  66792. * @param strength the explosion strength
  66793. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66794. * @returns A physics gravitational field event, or null
  66795. */
  66796. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66797. /**
  66798. * Creates a physics updraft event
  66799. * @param origin the origin of the updraft
  66800. * @param radiusOrEventOptions the radius or the options of the updraft
  66801. * @param strength the strength of the updraft
  66802. * @param height the height of the updraft
  66803. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66804. * @returns A physics updraft event, or null
  66805. */
  66806. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66807. /**
  66808. * Creates a physics vortex event
  66809. * @param origin the of the vortex
  66810. * @param radiusOrEventOptions the radius or the options of the vortex
  66811. * @param strength the strength of the vortex
  66812. * @param height the height of the vortex
  66813. * @returns a Physics vortex event, or null
  66814. * A physics vortex event or null
  66815. */
  66816. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66817. }
  66818. /**
  66819. * Represents a physics radial explosion event
  66820. */
  66821. class PhysicsRadialExplosionEvent {
  66822. private _scene;
  66823. private _options;
  66824. private _sphere;
  66825. private _dataFetched;
  66826. /**
  66827. * Initializes a radial explosioin event
  66828. * @param _scene BabylonJS scene
  66829. * @param _options The options for the vortex event
  66830. */
  66831. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66832. /**
  66833. * Returns the data related to the radial explosion event (sphere).
  66834. * @returns The radial explosion event data
  66835. */
  66836. getData(): PhysicsRadialExplosionEventData;
  66837. /**
  66838. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66839. * @param impostor A physics imposter
  66840. * @param origin the origin of the explosion
  66841. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66842. */
  66843. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66844. /**
  66845. * Triggers affecterd impostors callbacks
  66846. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66847. */
  66848. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66849. /**
  66850. * Disposes the sphere.
  66851. * @param force Specifies if the sphere should be disposed by force
  66852. */
  66853. dispose(force?: boolean): void;
  66854. /*** Helpers ***/
  66855. private _prepareSphere;
  66856. private _intersectsWithSphere;
  66857. }
  66858. /**
  66859. * Represents a gravitational field event
  66860. */
  66861. class PhysicsGravitationalFieldEvent {
  66862. private _physicsHelper;
  66863. private _scene;
  66864. private _origin;
  66865. private _options;
  66866. private _tickCallback;
  66867. private _sphere;
  66868. private _dataFetched;
  66869. /**
  66870. * Initializes the physics gravitational field event
  66871. * @param _physicsHelper A physics helper
  66872. * @param _scene BabylonJS scene
  66873. * @param _origin The origin position of the gravitational field event
  66874. * @param _options The options for the vortex event
  66875. */
  66876. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66877. /**
  66878. * Returns the data related to the gravitational field event (sphere).
  66879. * @returns A gravitational field event
  66880. */
  66881. getData(): PhysicsGravitationalFieldEventData;
  66882. /**
  66883. * Enables the gravitational field.
  66884. */
  66885. enable(): void;
  66886. /**
  66887. * Disables the gravitational field.
  66888. */
  66889. disable(): void;
  66890. /**
  66891. * Disposes the sphere.
  66892. * @param force The force to dispose from the gravitational field event
  66893. */
  66894. dispose(force?: boolean): void;
  66895. private _tick;
  66896. }
  66897. /**
  66898. * Represents a physics updraft event
  66899. */
  66900. class PhysicsUpdraftEvent {
  66901. private _scene;
  66902. private _origin;
  66903. private _options;
  66904. private _physicsEngine;
  66905. private _originTop;
  66906. private _originDirection;
  66907. private _tickCallback;
  66908. private _cylinder;
  66909. private _cylinderPosition;
  66910. private _dataFetched;
  66911. /**
  66912. * Initializes the physics updraft event
  66913. * @param _scene BabylonJS scene
  66914. * @param _origin The origin position of the updraft
  66915. * @param _options The options for the updraft event
  66916. */
  66917. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66918. /**
  66919. * Returns the data related to the updraft event (cylinder).
  66920. * @returns A physics updraft event
  66921. */
  66922. getData(): PhysicsUpdraftEventData;
  66923. /**
  66924. * Enables the updraft.
  66925. */
  66926. enable(): void;
  66927. /**
  66928. * Disables the updraft.
  66929. */
  66930. disable(): void;
  66931. /**
  66932. * Disposes the cylinder.
  66933. * @param force Specifies if the updraft should be disposed by force
  66934. */
  66935. dispose(force?: boolean): void;
  66936. private getImpostorHitData;
  66937. private _tick;
  66938. /*** Helpers ***/
  66939. private _prepareCylinder;
  66940. private _intersectsWithCylinder;
  66941. }
  66942. /**
  66943. * Represents a physics vortex event
  66944. */
  66945. class PhysicsVortexEvent {
  66946. private _scene;
  66947. private _origin;
  66948. private _options;
  66949. private _physicsEngine;
  66950. private _originTop;
  66951. private _tickCallback;
  66952. private _cylinder;
  66953. private _cylinderPosition;
  66954. private _dataFetched;
  66955. /**
  66956. * Initializes the physics vortex event
  66957. * @param _scene The BabylonJS scene
  66958. * @param _origin The origin position of the vortex
  66959. * @param _options The options for the vortex event
  66960. */
  66961. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66962. /**
  66963. * Returns the data related to the vortex event (cylinder).
  66964. * @returns The physics vortex event data
  66965. */
  66966. getData(): PhysicsVortexEventData;
  66967. /**
  66968. * Enables the vortex.
  66969. */
  66970. enable(): void;
  66971. /**
  66972. * Disables the cortex.
  66973. */
  66974. disable(): void;
  66975. /**
  66976. * Disposes the sphere.
  66977. * @param force
  66978. */
  66979. dispose(force?: boolean): void;
  66980. private getImpostorHitData;
  66981. private _tick;
  66982. /*** Helpers ***/
  66983. private _prepareCylinder;
  66984. private _intersectsWithCylinder;
  66985. }
  66986. /**
  66987. * Options fot the radial explosion event
  66988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66989. */
  66990. export class PhysicsRadialExplosionEventOptions {
  66991. /**
  66992. * The radius of the sphere for the radial explosion.
  66993. */
  66994. radius: number;
  66995. /**
  66996. * The strenth of the explosion.
  66997. */
  66998. strength: number;
  66999. /**
  67000. * The strenght of the force in correspondence to the distance of the affected object
  67001. */
  67002. falloff: PhysicsRadialImpulseFalloff;
  67003. /**
  67004. * Sphere options for the radial explosion.
  67005. */
  67006. sphere: {
  67007. segments: number;
  67008. diameter: number;
  67009. };
  67010. /**
  67011. * Sphere options for the radial explosion.
  67012. */
  67013. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67014. }
  67015. /**
  67016. * Options fot the updraft event
  67017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67018. */
  67019. export class PhysicsUpdraftEventOptions {
  67020. /**
  67021. * The radius of the cylinder for the vortex
  67022. */
  67023. radius: number;
  67024. /**
  67025. * The strenth of the updraft.
  67026. */
  67027. strength: number;
  67028. /**
  67029. * The height of the cylinder for the updraft.
  67030. */
  67031. height: number;
  67032. /**
  67033. * The mode for the the updraft.
  67034. */
  67035. updraftMode: PhysicsUpdraftMode;
  67036. }
  67037. /**
  67038. * Options fot the vortex event
  67039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67040. */
  67041. export class PhysicsVortexEventOptions {
  67042. /**
  67043. * The radius of the cylinder for the vortex
  67044. */
  67045. radius: number;
  67046. /**
  67047. * The strenth of the vortex.
  67048. */
  67049. strength: number;
  67050. /**
  67051. * The height of the cylinder for the vortex.
  67052. */
  67053. height: number;
  67054. /**
  67055. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67056. */
  67057. centripetalForceThreshold: number;
  67058. /**
  67059. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67060. */
  67061. centripetalForceMultiplier: number;
  67062. /**
  67063. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67064. */
  67065. centrifugalForceMultiplier: number;
  67066. /**
  67067. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67068. */
  67069. updraftForceMultiplier: number;
  67070. }
  67071. /**
  67072. * The strenght of the force in correspondence to the distance of the affected object
  67073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67074. */
  67075. export enum PhysicsRadialImpulseFalloff {
  67076. /** Defines that impulse is constant in strength across it's whole radius */
  67077. Constant = 0,
  67078. /** Defines that impulse gets weaker if it's further from the origin */
  67079. Linear = 1
  67080. }
  67081. /**
  67082. * The strength of the force in correspondence to the distance of the affected object
  67083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67084. */
  67085. export enum PhysicsUpdraftMode {
  67086. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67087. Center = 0,
  67088. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67089. Perpendicular = 1
  67090. }
  67091. /**
  67092. * Interface for a physics hit data
  67093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67094. */
  67095. export interface PhysicsHitData {
  67096. /**
  67097. * The force applied at the contact point
  67098. */
  67099. force: Vector3;
  67100. /**
  67101. * The contact point
  67102. */
  67103. contactPoint: Vector3;
  67104. /**
  67105. * The distance from the origin to the contact point
  67106. */
  67107. distanceFromOrigin: number;
  67108. }
  67109. /**
  67110. * Interface for radial explosion event data
  67111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67112. */
  67113. export interface PhysicsRadialExplosionEventData {
  67114. /**
  67115. * A sphere used for the radial explosion event
  67116. */
  67117. sphere: Mesh;
  67118. }
  67119. /**
  67120. * Interface for gravitational field event data
  67121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67122. */
  67123. export interface PhysicsGravitationalFieldEventData {
  67124. /**
  67125. * A sphere mesh used for the gravitational field event
  67126. */
  67127. sphere: Mesh;
  67128. }
  67129. /**
  67130. * Interface for updraft event data
  67131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67132. */
  67133. export interface PhysicsUpdraftEventData {
  67134. /**
  67135. * A cylinder used for the updraft event
  67136. */
  67137. cylinder: Mesh;
  67138. }
  67139. /**
  67140. * Interface for vortex event data
  67141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67142. */
  67143. export interface PhysicsVortexEventData {
  67144. /**
  67145. * A cylinder used for the vortex event
  67146. */
  67147. cylinder: Mesh;
  67148. }
  67149. /**
  67150. * Interface for an affected physics impostor
  67151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67152. */
  67153. export interface PhysicsAffectedImpostorWithData {
  67154. /**
  67155. * The impostor affected by the effect
  67156. */
  67157. impostor: PhysicsImpostor;
  67158. /**
  67159. * The data about the hit/horce from the explosion
  67160. */
  67161. hitData: PhysicsHitData;
  67162. }
  67163. }
  67164. declare module BABYLON {
  67165. /** @hidden */
  67166. export var blackAndWhitePixelShader: {
  67167. name: string;
  67168. shader: string;
  67169. };
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * Post process used to render in black and white
  67174. */
  67175. export class BlackAndWhitePostProcess extends PostProcess {
  67176. /**
  67177. * Linear about to convert he result to black and white (default: 1)
  67178. */
  67179. degree: number;
  67180. /**
  67181. * Creates a black and white post process
  67182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67183. * @param name The name of the effect.
  67184. * @param options The required width/height ratio to downsize to before computing the render pass.
  67185. * @param camera The camera to apply the render pass to.
  67186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67187. * @param engine The engine which the post process will be applied. (default: current engine)
  67188. * @param reusable If the post process can be reused on the same frame. (default: false)
  67189. */
  67190. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67191. }
  67192. }
  67193. declare module BABYLON {
  67194. /**
  67195. * This represents a set of one or more post processes in Babylon.
  67196. * A post process can be used to apply a shader to a texture after it is rendered.
  67197. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67198. */
  67199. export class PostProcessRenderEffect {
  67200. private _postProcesses;
  67201. private _getPostProcesses;
  67202. private _singleInstance;
  67203. private _cameras;
  67204. private _indicesForCamera;
  67205. /**
  67206. * Name of the effect
  67207. * @hidden
  67208. */
  67209. _name: string;
  67210. /**
  67211. * Instantiates a post process render effect.
  67212. * A post process can be used to apply a shader to a texture after it is rendered.
  67213. * @param engine The engine the effect is tied to
  67214. * @param name The name of the effect
  67215. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67216. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67217. */
  67218. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67219. /**
  67220. * Checks if all the post processes in the effect are supported.
  67221. */
  67222. get isSupported(): boolean;
  67223. /**
  67224. * Updates the current state of the effect
  67225. * @hidden
  67226. */
  67227. _update(): void;
  67228. /**
  67229. * Attaches the effect on cameras
  67230. * @param cameras The camera to attach to.
  67231. * @hidden
  67232. */
  67233. _attachCameras(cameras: Camera): void;
  67234. /**
  67235. * Attaches the effect on cameras
  67236. * @param cameras The camera to attach to.
  67237. * @hidden
  67238. */
  67239. _attachCameras(cameras: Camera[]): void;
  67240. /**
  67241. * Detaches the effect on cameras
  67242. * @param cameras The camera to detatch from.
  67243. * @hidden
  67244. */
  67245. _detachCameras(cameras: Camera): void;
  67246. /**
  67247. * Detatches the effect on cameras
  67248. * @param cameras The camera to detatch from.
  67249. * @hidden
  67250. */
  67251. _detachCameras(cameras: Camera[]): void;
  67252. /**
  67253. * Enables the effect on given cameras
  67254. * @param cameras The camera to enable.
  67255. * @hidden
  67256. */
  67257. _enable(cameras: Camera): void;
  67258. /**
  67259. * Enables the effect on given cameras
  67260. * @param cameras The camera to enable.
  67261. * @hidden
  67262. */
  67263. _enable(cameras: Nullable<Camera[]>): void;
  67264. /**
  67265. * Disables the effect on the given cameras
  67266. * @param cameras The camera to disable.
  67267. * @hidden
  67268. */
  67269. _disable(cameras: Camera): void;
  67270. /**
  67271. * Disables the effect on the given cameras
  67272. * @param cameras The camera to disable.
  67273. * @hidden
  67274. */
  67275. _disable(cameras: Nullable<Camera[]>): void;
  67276. /**
  67277. * Gets a list of the post processes contained in the effect.
  67278. * @param camera The camera to get the post processes on.
  67279. * @returns The list of the post processes in the effect.
  67280. */
  67281. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67282. }
  67283. }
  67284. declare module BABYLON {
  67285. /** @hidden */
  67286. export var extractHighlightsPixelShader: {
  67287. name: string;
  67288. shader: string;
  67289. };
  67290. }
  67291. declare module BABYLON {
  67292. /**
  67293. * 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.
  67294. */
  67295. export class ExtractHighlightsPostProcess extends PostProcess {
  67296. /**
  67297. * The luminance threshold, pixels below this value will be set to black.
  67298. */
  67299. threshold: number;
  67300. /** @hidden */
  67301. _exposure: number;
  67302. /**
  67303. * Post process which has the input texture to be used when performing highlight extraction
  67304. * @hidden
  67305. */
  67306. _inputPostProcess: Nullable<PostProcess>;
  67307. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67308. }
  67309. }
  67310. declare module BABYLON {
  67311. /** @hidden */
  67312. export var bloomMergePixelShader: {
  67313. name: string;
  67314. shader: string;
  67315. };
  67316. }
  67317. declare module BABYLON {
  67318. /**
  67319. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67320. */
  67321. export class BloomMergePostProcess extends PostProcess {
  67322. /** Weight of the bloom to be added to the original input. */
  67323. weight: number;
  67324. /**
  67325. * Creates a new instance of @see BloomMergePostProcess
  67326. * @param name The name of the effect.
  67327. * @param originalFromInput Post process which's input will be used for the merge.
  67328. * @param blurred Blurred highlights post process which's output will be used.
  67329. * @param weight Weight of the bloom to be added to the original input.
  67330. * @param options The required width/height ratio to downsize to before computing the render pass.
  67331. * @param camera The camera to apply the render pass to.
  67332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67333. * @param engine The engine which the post process will be applied. (default: current engine)
  67334. * @param reusable If the post process can be reused on the same frame. (default: false)
  67335. * @param textureType Type of textures used when performing the post process. (default: 0)
  67336. * @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)
  67337. */
  67338. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67339. /** Weight of the bloom to be added to the original input. */
  67340. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67341. }
  67342. }
  67343. declare module BABYLON {
  67344. /**
  67345. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67346. */
  67347. export class BloomEffect extends PostProcessRenderEffect {
  67348. private bloomScale;
  67349. /**
  67350. * @hidden Internal
  67351. */
  67352. _effects: Array<PostProcess>;
  67353. /**
  67354. * @hidden Internal
  67355. */
  67356. _downscale: ExtractHighlightsPostProcess;
  67357. private _blurX;
  67358. private _blurY;
  67359. private _merge;
  67360. /**
  67361. * The luminance threshold to find bright areas of the image to bloom.
  67362. */
  67363. get threshold(): number;
  67364. set threshold(value: number);
  67365. /**
  67366. * The strength of the bloom.
  67367. */
  67368. get weight(): number;
  67369. set weight(value: number);
  67370. /**
  67371. * Specifies the size of the bloom blur kernel, relative to the final output size
  67372. */
  67373. get kernel(): number;
  67374. set kernel(value: number);
  67375. /**
  67376. * Creates a new instance of @see BloomEffect
  67377. * @param scene The scene the effect belongs to.
  67378. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67379. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67380. * @param bloomWeight The the strength of bloom.
  67381. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67382. * @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)
  67383. */
  67384. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67385. /**
  67386. * Disposes each of the internal effects for a given camera.
  67387. * @param camera The camera to dispose the effect on.
  67388. */
  67389. disposeEffects(camera: Camera): void;
  67390. /**
  67391. * @hidden Internal
  67392. */
  67393. _updateEffects(): void;
  67394. /**
  67395. * Internal
  67396. * @returns if all the contained post processes are ready.
  67397. * @hidden
  67398. */
  67399. _isReady(): boolean;
  67400. }
  67401. }
  67402. declare module BABYLON {
  67403. /** @hidden */
  67404. export var chromaticAberrationPixelShader: {
  67405. name: string;
  67406. shader: string;
  67407. };
  67408. }
  67409. declare module BABYLON {
  67410. /**
  67411. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67412. */
  67413. export class ChromaticAberrationPostProcess extends PostProcess {
  67414. /**
  67415. * The amount of seperation of rgb channels (default: 30)
  67416. */
  67417. aberrationAmount: number;
  67418. /**
  67419. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67420. */
  67421. radialIntensity: number;
  67422. /**
  67423. * 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))
  67424. */
  67425. direction: Vector2;
  67426. /**
  67427. * 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))
  67428. */
  67429. centerPosition: Vector2;
  67430. /**
  67431. * Creates a new instance ChromaticAberrationPostProcess
  67432. * @param name The name of the effect.
  67433. * @param screenWidth The width of the screen to apply the effect on.
  67434. * @param screenHeight The height of the screen to apply the effect on.
  67435. * @param options The required width/height ratio to downsize to before computing the render pass.
  67436. * @param camera The camera to apply the render pass to.
  67437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67438. * @param engine The engine which the post process will be applied. (default: current engine)
  67439. * @param reusable If the post process can be reused on the same frame. (default: false)
  67440. * @param textureType Type of textures used when performing the post process. (default: 0)
  67441. * @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)
  67442. */
  67443. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67444. }
  67445. }
  67446. declare module BABYLON {
  67447. /** @hidden */
  67448. export var circleOfConfusionPixelShader: {
  67449. name: string;
  67450. shader: string;
  67451. };
  67452. }
  67453. declare module BABYLON {
  67454. /**
  67455. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67456. */
  67457. export class CircleOfConfusionPostProcess extends PostProcess {
  67458. /**
  67459. * 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.
  67460. */
  67461. lensSize: number;
  67462. /**
  67463. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67464. */
  67465. fStop: number;
  67466. /**
  67467. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67468. */
  67469. focusDistance: number;
  67470. /**
  67471. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67472. */
  67473. focalLength: number;
  67474. private _depthTexture;
  67475. /**
  67476. * Creates a new instance CircleOfConfusionPostProcess
  67477. * @param name The name of the effect.
  67478. * @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.
  67479. * @param options The required width/height ratio to downsize to before computing the render pass.
  67480. * @param camera The camera to apply the render pass to.
  67481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67482. * @param engine The engine which the post process will be applied. (default: current engine)
  67483. * @param reusable If the post process can be reused on the same frame. (default: false)
  67484. * @param textureType Type of textures used when performing the post process. (default: 0)
  67485. * @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)
  67486. */
  67487. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67488. /**
  67489. * 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.
  67490. */
  67491. set depthTexture(value: RenderTargetTexture);
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /** @hidden */
  67496. export var colorCorrectionPixelShader: {
  67497. name: string;
  67498. shader: string;
  67499. };
  67500. }
  67501. declare module BABYLON {
  67502. /**
  67503. *
  67504. * This post-process allows the modification of rendered colors by using
  67505. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67506. *
  67507. * The object needs to be provided an url to a texture containing the color
  67508. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67509. * Use an image editing software to tweak the LUT to match your needs.
  67510. *
  67511. * For an example of a color LUT, see here:
  67512. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67513. * For explanations on color grading, see here:
  67514. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67515. *
  67516. */
  67517. export class ColorCorrectionPostProcess extends PostProcess {
  67518. private _colorTableTexture;
  67519. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67520. }
  67521. }
  67522. declare module BABYLON {
  67523. /** @hidden */
  67524. export var convolutionPixelShader: {
  67525. name: string;
  67526. shader: string;
  67527. };
  67528. }
  67529. declare module BABYLON {
  67530. /**
  67531. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67532. * input texture to perform effects such as edge detection or sharpening
  67533. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67534. */
  67535. export class ConvolutionPostProcess extends PostProcess {
  67536. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67537. kernel: number[];
  67538. /**
  67539. * Creates a new instance ConvolutionPostProcess
  67540. * @param name The name of the effect.
  67541. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67542. * @param options The required width/height ratio to downsize to before computing the render pass.
  67543. * @param camera The camera to apply the render pass to.
  67544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67545. * @param engine The engine which the post process will be applied. (default: current engine)
  67546. * @param reusable If the post process can be reused on the same frame. (default: false)
  67547. * @param textureType Type of textures used when performing the post process. (default: 0)
  67548. */
  67549. constructor(name: string,
  67550. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67551. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67552. /**
  67553. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67554. */
  67555. static EdgeDetect0Kernel: number[];
  67556. /**
  67557. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67558. */
  67559. static EdgeDetect1Kernel: number[];
  67560. /**
  67561. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67562. */
  67563. static EdgeDetect2Kernel: number[];
  67564. /**
  67565. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67566. */
  67567. static SharpenKernel: number[];
  67568. /**
  67569. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67570. */
  67571. static EmbossKernel: number[];
  67572. /**
  67573. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67574. */
  67575. static GaussianKernel: number[];
  67576. }
  67577. }
  67578. declare module BABYLON {
  67579. /**
  67580. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67581. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67582. * based on samples that have a large difference in distance than the center pixel.
  67583. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67584. */
  67585. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67586. direction: Vector2;
  67587. /**
  67588. * Creates a new instance CircleOfConfusionPostProcess
  67589. * @param name The name of the effect.
  67590. * @param scene The scene the effect belongs to.
  67591. * @param direction The direction the blur should be applied.
  67592. * @param kernel The size of the kernel used to blur.
  67593. * @param options The required width/height ratio to downsize to before computing the render pass.
  67594. * @param camera The camera to apply the render pass to.
  67595. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67596. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67598. * @param engine The engine which the post process will be applied. (default: current engine)
  67599. * @param reusable If the post process can be reused on the same frame. (default: false)
  67600. * @param textureType Type of textures used when performing the post process. (default: 0)
  67601. * @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)
  67602. */
  67603. 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);
  67604. }
  67605. }
  67606. declare module BABYLON {
  67607. /** @hidden */
  67608. export var depthOfFieldMergePixelShader: {
  67609. name: string;
  67610. shader: string;
  67611. };
  67612. }
  67613. declare module BABYLON {
  67614. /**
  67615. * Options to be set when merging outputs from the default pipeline.
  67616. */
  67617. export class DepthOfFieldMergePostProcessOptions {
  67618. /**
  67619. * The original image to merge on top of
  67620. */
  67621. originalFromInput: PostProcess;
  67622. /**
  67623. * Parameters to perform the merge of the depth of field effect
  67624. */
  67625. depthOfField?: {
  67626. circleOfConfusion: PostProcess;
  67627. blurSteps: Array<PostProcess>;
  67628. };
  67629. /**
  67630. * Parameters to perform the merge of bloom effect
  67631. */
  67632. bloom?: {
  67633. blurred: PostProcess;
  67634. weight: number;
  67635. };
  67636. }
  67637. /**
  67638. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67639. */
  67640. export class DepthOfFieldMergePostProcess extends PostProcess {
  67641. private blurSteps;
  67642. /**
  67643. * Creates a new instance of DepthOfFieldMergePostProcess
  67644. * @param name The name of the effect.
  67645. * @param originalFromInput Post process which's input will be used for the merge.
  67646. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67647. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67648. * @param options The required width/height ratio to downsize to before computing the render pass.
  67649. * @param camera The camera to apply the render pass to.
  67650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67651. * @param engine The engine which the post process will be applied. (default: current engine)
  67652. * @param reusable If the post process can be reused on the same frame. (default: false)
  67653. * @param textureType Type of textures used when performing the post process. (default: 0)
  67654. * @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)
  67655. */
  67656. 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);
  67657. /**
  67658. * Updates the effect with the current post process compile time values and recompiles the shader.
  67659. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67660. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67661. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67662. * @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
  67663. * @param onCompiled Called when the shader has been compiled.
  67664. * @param onError Called if there is an error when compiling a shader.
  67665. */
  67666. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67667. }
  67668. }
  67669. declare module BABYLON {
  67670. /**
  67671. * Specifies the level of max blur that should be applied when using the depth of field effect
  67672. */
  67673. export enum DepthOfFieldEffectBlurLevel {
  67674. /**
  67675. * Subtle blur
  67676. */
  67677. Low = 0,
  67678. /**
  67679. * Medium blur
  67680. */
  67681. Medium = 1,
  67682. /**
  67683. * Large blur
  67684. */
  67685. High = 2
  67686. }
  67687. /**
  67688. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67689. */
  67690. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67691. private _circleOfConfusion;
  67692. /**
  67693. * @hidden Internal, blurs from high to low
  67694. */
  67695. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67696. private _depthOfFieldBlurY;
  67697. private _dofMerge;
  67698. /**
  67699. * @hidden Internal post processes in depth of field effect
  67700. */
  67701. _effects: Array<PostProcess>;
  67702. /**
  67703. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67704. */
  67705. set focalLength(value: number);
  67706. get focalLength(): number;
  67707. /**
  67708. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67709. */
  67710. set fStop(value: number);
  67711. get fStop(): number;
  67712. /**
  67713. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67714. */
  67715. set focusDistance(value: number);
  67716. get focusDistance(): number;
  67717. /**
  67718. * 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.
  67719. */
  67720. set lensSize(value: number);
  67721. get lensSize(): number;
  67722. /**
  67723. * Creates a new instance DepthOfFieldEffect
  67724. * @param scene The scene the effect belongs to.
  67725. * @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.
  67726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67727. * @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)
  67728. */
  67729. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67730. /**
  67731. * Get the current class name of the current effet
  67732. * @returns "DepthOfFieldEffect"
  67733. */
  67734. getClassName(): string;
  67735. /**
  67736. * 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.
  67737. */
  67738. set depthTexture(value: RenderTargetTexture);
  67739. /**
  67740. * Disposes each of the internal effects for a given camera.
  67741. * @param camera The camera to dispose the effect on.
  67742. */
  67743. disposeEffects(camera: Camera): void;
  67744. /**
  67745. * @hidden Internal
  67746. */
  67747. _updateEffects(): void;
  67748. /**
  67749. * Internal
  67750. * @returns if all the contained post processes are ready.
  67751. * @hidden
  67752. */
  67753. _isReady(): boolean;
  67754. }
  67755. }
  67756. declare module BABYLON {
  67757. /** @hidden */
  67758. export var displayPassPixelShader: {
  67759. name: string;
  67760. shader: string;
  67761. };
  67762. }
  67763. declare module BABYLON {
  67764. /**
  67765. * DisplayPassPostProcess which produces an output the same as it's input
  67766. */
  67767. export class DisplayPassPostProcess extends PostProcess {
  67768. /**
  67769. * Creates the DisplayPassPostProcess
  67770. * @param name The name of the effect.
  67771. * @param options The required width/height ratio to downsize to before computing the render pass.
  67772. * @param camera The camera to apply the render pass to.
  67773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67774. * @param engine The engine which the post process will be applied. (default: current engine)
  67775. * @param reusable If the post process can be reused on the same frame. (default: false)
  67776. */
  67777. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67778. }
  67779. }
  67780. declare module BABYLON {
  67781. /** @hidden */
  67782. export var filterPixelShader: {
  67783. name: string;
  67784. shader: string;
  67785. };
  67786. }
  67787. declare module BABYLON {
  67788. /**
  67789. * Applies a kernel filter to the image
  67790. */
  67791. export class FilterPostProcess extends PostProcess {
  67792. /** The matrix to be applied to the image */
  67793. kernelMatrix: Matrix;
  67794. /**
  67795. *
  67796. * @param name The name of the effect.
  67797. * @param kernelMatrix The matrix to be applied to the image
  67798. * @param options The required width/height ratio to downsize to before computing the render pass.
  67799. * @param camera The camera to apply the render pass to.
  67800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67801. * @param engine The engine which the post process will be applied. (default: current engine)
  67802. * @param reusable If the post process can be reused on the same frame. (default: false)
  67803. */
  67804. constructor(name: string,
  67805. /** The matrix to be applied to the image */
  67806. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67807. }
  67808. }
  67809. declare module BABYLON {
  67810. /** @hidden */
  67811. export var fxaaPixelShader: {
  67812. name: string;
  67813. shader: string;
  67814. };
  67815. }
  67816. declare module BABYLON {
  67817. /** @hidden */
  67818. export var fxaaVertexShader: {
  67819. name: string;
  67820. shader: string;
  67821. };
  67822. }
  67823. declare module BABYLON {
  67824. /**
  67825. * Fxaa post process
  67826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67827. */
  67828. export class FxaaPostProcess extends PostProcess {
  67829. /** @hidden */
  67830. texelWidth: number;
  67831. /** @hidden */
  67832. texelHeight: number;
  67833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67834. private _getDefines;
  67835. }
  67836. }
  67837. declare module BABYLON {
  67838. /** @hidden */
  67839. export var grainPixelShader: {
  67840. name: string;
  67841. shader: string;
  67842. };
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. * The GrainPostProcess adds noise to the image at mid luminance levels
  67847. */
  67848. export class GrainPostProcess extends PostProcess {
  67849. /**
  67850. * The intensity of the grain added (default: 30)
  67851. */
  67852. intensity: number;
  67853. /**
  67854. * If the grain should be randomized on every frame
  67855. */
  67856. animated: boolean;
  67857. /**
  67858. * Creates a new instance of @see GrainPostProcess
  67859. * @param name The name of the effect.
  67860. * @param options The required width/height ratio to downsize to before computing the render pass.
  67861. * @param camera The camera to apply the render pass to.
  67862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67863. * @param engine The engine which the post process will be applied. (default: current engine)
  67864. * @param reusable If the post process can be reused on the same frame. (default: false)
  67865. * @param textureType Type of textures used when performing the post process. (default: 0)
  67866. * @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)
  67867. */
  67868. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /** @hidden */
  67873. export var highlightsPixelShader: {
  67874. name: string;
  67875. shader: string;
  67876. };
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * Extracts highlights from the image
  67881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67882. */
  67883. export class HighlightsPostProcess extends PostProcess {
  67884. /**
  67885. * Extracts highlights from the image
  67886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67887. * @param name The name of the effect.
  67888. * @param options The required width/height ratio to downsize to before computing the render pass.
  67889. * @param camera The camera to apply the render pass to.
  67890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67891. * @param engine The engine which the post process will be applied. (default: current engine)
  67892. * @param reusable If the post process can be reused on the same frame. (default: false)
  67893. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67894. */
  67895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67896. }
  67897. }
  67898. declare module BABYLON {
  67899. /** @hidden */
  67900. export var mrtFragmentDeclaration: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module BABYLON {
  67906. /** @hidden */
  67907. export var geometryPixelShader: {
  67908. name: string;
  67909. shader: string;
  67910. };
  67911. }
  67912. declare module BABYLON {
  67913. /** @hidden */
  67914. export var geometryVertexShader: {
  67915. name: string;
  67916. shader: string;
  67917. };
  67918. }
  67919. declare module BABYLON {
  67920. /** @hidden */
  67921. interface ISavedTransformationMatrix {
  67922. world: Matrix;
  67923. viewProjection: Matrix;
  67924. }
  67925. /**
  67926. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67927. */
  67928. export class GeometryBufferRenderer {
  67929. /**
  67930. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67931. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67932. */
  67933. static readonly POSITION_TEXTURE_TYPE: number;
  67934. /**
  67935. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67936. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67937. */
  67938. static readonly VELOCITY_TEXTURE_TYPE: number;
  67939. /**
  67940. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67941. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67942. */
  67943. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67944. /**
  67945. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67946. * in order to compute objects velocities when enableVelocity is set to "true"
  67947. * @hidden
  67948. */
  67949. _previousTransformationMatrices: {
  67950. [index: number]: ISavedTransformationMatrix;
  67951. };
  67952. /**
  67953. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67954. * in order to compute objects velocities when enableVelocity is set to "true"
  67955. * @hidden
  67956. */
  67957. _previousBonesTransformationMatrices: {
  67958. [index: number]: Float32Array;
  67959. };
  67960. /**
  67961. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67962. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67963. */
  67964. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67965. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67966. renderTransparentMeshes: boolean;
  67967. private _scene;
  67968. private _multiRenderTarget;
  67969. private _ratio;
  67970. private _enablePosition;
  67971. private _enableVelocity;
  67972. private _enableReflectivity;
  67973. private _positionIndex;
  67974. private _velocityIndex;
  67975. private _reflectivityIndex;
  67976. protected _effect: Effect;
  67977. protected _cachedDefines: string;
  67978. /**
  67979. * Set the render list (meshes to be rendered) used in the G buffer.
  67980. */
  67981. set renderList(meshes: Mesh[]);
  67982. /**
  67983. * Gets wether or not G buffer are supported by the running hardware.
  67984. * This requires draw buffer supports
  67985. */
  67986. get isSupported(): boolean;
  67987. /**
  67988. * Returns the index of the given texture type in the G-Buffer textures array
  67989. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67990. * @returns the index of the given texture type in the G-Buffer textures array
  67991. */
  67992. getTextureIndex(textureType: number): number;
  67993. /**
  67994. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67995. */
  67996. get enablePosition(): boolean;
  67997. /**
  67998. * Sets whether or not objects positions are enabled for the G buffer.
  67999. */
  68000. set enablePosition(enable: boolean);
  68001. /**
  68002. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68003. */
  68004. get enableVelocity(): boolean;
  68005. /**
  68006. * Sets wether or not objects velocities are enabled for the G buffer.
  68007. */
  68008. set enableVelocity(enable: boolean);
  68009. /**
  68010. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68011. */
  68012. get enableReflectivity(): boolean;
  68013. /**
  68014. * Sets wether or not objects roughness are enabled for the G buffer.
  68015. */
  68016. set enableReflectivity(enable: boolean);
  68017. /**
  68018. * Gets the scene associated with the buffer.
  68019. */
  68020. get scene(): Scene;
  68021. /**
  68022. * Gets the ratio used by the buffer during its creation.
  68023. * How big is the buffer related to the main canvas.
  68024. */
  68025. get ratio(): number;
  68026. /** @hidden */
  68027. static _SceneComponentInitialization: (scene: Scene) => void;
  68028. /**
  68029. * Creates a new G Buffer for the scene
  68030. * @param scene The scene the buffer belongs to
  68031. * @param ratio How big is the buffer related to the main canvas.
  68032. */
  68033. constructor(scene: Scene, ratio?: number);
  68034. /**
  68035. * Checks wether everything is ready to render a submesh to the G buffer.
  68036. * @param subMesh the submesh to check readiness for
  68037. * @param useInstances is the mesh drawn using instance or not
  68038. * @returns true if ready otherwise false
  68039. */
  68040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68041. /**
  68042. * Gets the current underlying G Buffer.
  68043. * @returns the buffer
  68044. */
  68045. getGBuffer(): MultiRenderTarget;
  68046. /**
  68047. * Gets the number of samples used to render the buffer (anti aliasing).
  68048. */
  68049. get samples(): number;
  68050. /**
  68051. * Sets the number of samples used to render the buffer (anti aliasing).
  68052. */
  68053. set samples(value: number);
  68054. /**
  68055. * Disposes the renderer and frees up associated resources.
  68056. */
  68057. dispose(): void;
  68058. protected _createRenderTargets(): void;
  68059. private _copyBonesTransformationMatrices;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. interface Scene {
  68064. /** @hidden (Backing field) */
  68065. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68066. /**
  68067. * Gets or Sets the current geometry buffer associated to the scene.
  68068. */
  68069. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68070. /**
  68071. * Enables a GeometryBufferRender and associates it with the scene
  68072. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68073. * @returns the GeometryBufferRenderer
  68074. */
  68075. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68076. /**
  68077. * Disables the GeometryBufferRender associated with the scene
  68078. */
  68079. disableGeometryBufferRenderer(): void;
  68080. }
  68081. /**
  68082. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68083. * in several rendering techniques.
  68084. */
  68085. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68086. /**
  68087. * The component name helpful to identify the component in the list of scene components.
  68088. */
  68089. readonly name: string;
  68090. /**
  68091. * The scene the component belongs to.
  68092. */
  68093. scene: Scene;
  68094. /**
  68095. * Creates a new instance of the component for the given scene
  68096. * @param scene Defines the scene to register the component in
  68097. */
  68098. constructor(scene: Scene);
  68099. /**
  68100. * Registers the component in a given scene
  68101. */
  68102. register(): void;
  68103. /**
  68104. * Rebuilds the elements related to this component in case of
  68105. * context lost for instance.
  68106. */
  68107. rebuild(): void;
  68108. /**
  68109. * Disposes the component and the associated ressources
  68110. */
  68111. dispose(): void;
  68112. private _gatherRenderTargets;
  68113. }
  68114. }
  68115. declare module BABYLON {
  68116. /** @hidden */
  68117. export var motionBlurPixelShader: {
  68118. name: string;
  68119. shader: string;
  68120. };
  68121. }
  68122. declare module BABYLON {
  68123. /**
  68124. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68125. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68126. * As an example, all you have to do is to create the post-process:
  68127. * var mb = new BABYLON.MotionBlurPostProcess(
  68128. * 'mb', // The name of the effect.
  68129. * scene, // The scene containing the objects to blur according to their velocity.
  68130. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68131. * camera // The camera to apply the render pass to.
  68132. * );
  68133. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68134. */
  68135. export class MotionBlurPostProcess extends PostProcess {
  68136. /**
  68137. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68138. */
  68139. motionStrength: number;
  68140. /**
  68141. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68142. */
  68143. get motionBlurSamples(): number;
  68144. /**
  68145. * Sets the number of iterations to be used for motion blur quality
  68146. */
  68147. set motionBlurSamples(samples: number);
  68148. private _motionBlurSamples;
  68149. private _geometryBufferRenderer;
  68150. /**
  68151. * Creates a new instance MotionBlurPostProcess
  68152. * @param name The name of the effect.
  68153. * @param scene The scene containing the objects to blur according to their velocity.
  68154. * @param options The required width/height ratio to downsize to before computing the render pass.
  68155. * @param camera The camera to apply the render pass to.
  68156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68157. * @param engine The engine which the post process will be applied. (default: current engine)
  68158. * @param reusable If the post process can be reused on the same frame. (default: false)
  68159. * @param textureType Type of textures used when performing the post process. (default: 0)
  68160. * @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)
  68161. */
  68162. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68163. /**
  68164. * Excludes the given skinned mesh from computing bones velocities.
  68165. * 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.
  68166. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68167. */
  68168. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68169. /**
  68170. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68171. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68172. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68173. */
  68174. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68175. /**
  68176. * Disposes the post process.
  68177. * @param camera The camera to dispose the post process on.
  68178. */
  68179. dispose(camera?: Camera): void;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /** @hidden */
  68184. export var refractionPixelShader: {
  68185. name: string;
  68186. shader: string;
  68187. };
  68188. }
  68189. declare module BABYLON {
  68190. /**
  68191. * Post process which applies a refractin texture
  68192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68193. */
  68194. export class RefractionPostProcess extends PostProcess {
  68195. /** the base color of the refraction (used to taint the rendering) */
  68196. color: Color3;
  68197. /** simulated refraction depth */
  68198. depth: number;
  68199. /** the coefficient of the base color (0 to remove base color tainting) */
  68200. colorLevel: number;
  68201. private _refTexture;
  68202. private _ownRefractionTexture;
  68203. /**
  68204. * Gets or sets the refraction texture
  68205. * Please note that you are responsible for disposing the texture if you set it manually
  68206. */
  68207. get refractionTexture(): Texture;
  68208. set refractionTexture(value: Texture);
  68209. /**
  68210. * Initializes the RefractionPostProcess
  68211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68212. * @param name The name of the effect.
  68213. * @param refractionTextureUrl Url of the refraction texture to use
  68214. * @param color the base color of the refraction (used to taint the rendering)
  68215. * @param depth simulated refraction depth
  68216. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68217. * @param camera The camera to apply the render pass to.
  68218. * @param options The required width/height ratio to downsize to before computing the render pass.
  68219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68220. * @param engine The engine which the post process will be applied. (default: current engine)
  68221. * @param reusable If the post process can be reused on the same frame. (default: false)
  68222. */
  68223. constructor(name: string, refractionTextureUrl: string,
  68224. /** the base color of the refraction (used to taint the rendering) */
  68225. color: Color3,
  68226. /** simulated refraction depth */
  68227. depth: number,
  68228. /** the coefficient of the base color (0 to remove base color tainting) */
  68229. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68230. /**
  68231. * Disposes of the post process
  68232. * @param camera Camera to dispose post process on
  68233. */
  68234. dispose(camera: Camera): void;
  68235. }
  68236. }
  68237. declare module BABYLON {
  68238. /** @hidden */
  68239. export var sharpenPixelShader: {
  68240. name: string;
  68241. shader: string;
  68242. };
  68243. }
  68244. declare module BABYLON {
  68245. /**
  68246. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68247. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68248. */
  68249. export class SharpenPostProcess extends PostProcess {
  68250. /**
  68251. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68252. */
  68253. colorAmount: number;
  68254. /**
  68255. * How much sharpness should be applied (default: 0.3)
  68256. */
  68257. edgeAmount: number;
  68258. /**
  68259. * Creates a new instance ConvolutionPostProcess
  68260. * @param name The name of the effect.
  68261. * @param options The required width/height ratio to downsize to before computing the render pass.
  68262. * @param camera The camera to apply the render pass to.
  68263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68264. * @param engine The engine which the post process will be applied. (default: current engine)
  68265. * @param reusable If the post process can be reused on the same frame. (default: false)
  68266. * @param textureType Type of textures used when performing the post process. (default: 0)
  68267. * @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)
  68268. */
  68269. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68270. }
  68271. }
  68272. declare module BABYLON {
  68273. /**
  68274. * PostProcessRenderPipeline
  68275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68276. */
  68277. export class PostProcessRenderPipeline {
  68278. private engine;
  68279. private _renderEffects;
  68280. private _renderEffectsForIsolatedPass;
  68281. /**
  68282. * List of inspectable custom properties (used by the Inspector)
  68283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68284. */
  68285. inspectableCustomProperties: IInspectable[];
  68286. /**
  68287. * @hidden
  68288. */
  68289. protected _cameras: Camera[];
  68290. /** @hidden */
  68291. _name: string;
  68292. /**
  68293. * Gets pipeline name
  68294. */
  68295. get name(): string;
  68296. /** Gets the list of attached cameras */
  68297. get cameras(): Camera[];
  68298. /**
  68299. * Initializes a PostProcessRenderPipeline
  68300. * @param engine engine to add the pipeline to
  68301. * @param name name of the pipeline
  68302. */
  68303. constructor(engine: Engine, name: string);
  68304. /**
  68305. * Gets the class name
  68306. * @returns "PostProcessRenderPipeline"
  68307. */
  68308. getClassName(): string;
  68309. /**
  68310. * If all the render effects in the pipeline are supported
  68311. */
  68312. get isSupported(): boolean;
  68313. /**
  68314. * Adds an effect to the pipeline
  68315. * @param renderEffect the effect to add
  68316. */
  68317. addEffect(renderEffect: PostProcessRenderEffect): void;
  68318. /** @hidden */
  68319. _rebuild(): void;
  68320. /** @hidden */
  68321. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68322. /** @hidden */
  68323. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68324. /** @hidden */
  68325. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68326. /** @hidden */
  68327. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68328. /** @hidden */
  68329. _attachCameras(cameras: Camera, unique: boolean): void;
  68330. /** @hidden */
  68331. _attachCameras(cameras: Camera[], unique: boolean): void;
  68332. /** @hidden */
  68333. _detachCameras(cameras: Camera): void;
  68334. /** @hidden */
  68335. _detachCameras(cameras: Nullable<Camera[]>): void;
  68336. /** @hidden */
  68337. _update(): void;
  68338. /** @hidden */
  68339. _reset(): void;
  68340. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68341. /**
  68342. * Disposes of the pipeline
  68343. */
  68344. dispose(): void;
  68345. }
  68346. }
  68347. declare module BABYLON {
  68348. /**
  68349. * PostProcessRenderPipelineManager class
  68350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68351. */
  68352. export class PostProcessRenderPipelineManager {
  68353. private _renderPipelines;
  68354. /**
  68355. * Initializes a PostProcessRenderPipelineManager
  68356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68357. */
  68358. constructor();
  68359. /**
  68360. * Gets the list of supported render pipelines
  68361. */
  68362. get supportedPipelines(): PostProcessRenderPipeline[];
  68363. /**
  68364. * Adds a pipeline to the manager
  68365. * @param renderPipeline The pipeline to add
  68366. */
  68367. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68368. /**
  68369. * Attaches a camera to the pipeline
  68370. * @param renderPipelineName The name of the pipeline to attach to
  68371. * @param cameras the camera to attach
  68372. * @param unique if the camera can be attached multiple times to the pipeline
  68373. */
  68374. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68375. /**
  68376. * Detaches a camera from the pipeline
  68377. * @param renderPipelineName The name of the pipeline to detach from
  68378. * @param cameras the camera to detach
  68379. */
  68380. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68381. /**
  68382. * Enables an effect by name on a pipeline
  68383. * @param renderPipelineName the name of the pipeline to enable the effect in
  68384. * @param renderEffectName the name of the effect to enable
  68385. * @param cameras the cameras that the effect should be enabled on
  68386. */
  68387. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68388. /**
  68389. * Disables an effect by name on a pipeline
  68390. * @param renderPipelineName the name of the pipeline to disable the effect in
  68391. * @param renderEffectName the name of the effect to disable
  68392. * @param cameras the cameras that the effect should be disabled on
  68393. */
  68394. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68395. /**
  68396. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68397. */
  68398. update(): void;
  68399. /** @hidden */
  68400. _rebuild(): void;
  68401. /**
  68402. * Disposes of the manager and pipelines
  68403. */
  68404. dispose(): void;
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. interface Scene {
  68409. /** @hidden (Backing field) */
  68410. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68411. /**
  68412. * Gets the postprocess render pipeline manager
  68413. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68414. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68415. */
  68416. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68417. }
  68418. /**
  68419. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68420. */
  68421. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68422. /**
  68423. * The component name helpfull to identify the component in the list of scene components.
  68424. */
  68425. readonly name: string;
  68426. /**
  68427. * The scene the component belongs to.
  68428. */
  68429. scene: Scene;
  68430. /**
  68431. * Creates a new instance of the component for the given scene
  68432. * @param scene Defines the scene to register the component in
  68433. */
  68434. constructor(scene: Scene);
  68435. /**
  68436. * Registers the component in a given scene
  68437. */
  68438. register(): void;
  68439. /**
  68440. * Rebuilds the elements related to this component in case of
  68441. * context lost for instance.
  68442. */
  68443. rebuild(): void;
  68444. /**
  68445. * Disposes the component and the associated ressources
  68446. */
  68447. dispose(): void;
  68448. private _gatherRenderTargets;
  68449. }
  68450. }
  68451. declare module BABYLON {
  68452. /**
  68453. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68454. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68455. */
  68456. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68457. private _scene;
  68458. private _camerasToBeAttached;
  68459. /**
  68460. * ID of the sharpen post process,
  68461. */
  68462. private readonly SharpenPostProcessId;
  68463. /**
  68464. * @ignore
  68465. * ID of the image processing post process;
  68466. */
  68467. readonly ImageProcessingPostProcessId: string;
  68468. /**
  68469. * @ignore
  68470. * ID of the Fast Approximate Anti-Aliasing post process;
  68471. */
  68472. readonly FxaaPostProcessId: string;
  68473. /**
  68474. * ID of the chromatic aberration post process,
  68475. */
  68476. private readonly ChromaticAberrationPostProcessId;
  68477. /**
  68478. * ID of the grain post process
  68479. */
  68480. private readonly GrainPostProcessId;
  68481. /**
  68482. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68483. */
  68484. sharpen: SharpenPostProcess;
  68485. private _sharpenEffect;
  68486. private bloom;
  68487. /**
  68488. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68489. */
  68490. depthOfField: DepthOfFieldEffect;
  68491. /**
  68492. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68493. */
  68494. fxaa: FxaaPostProcess;
  68495. /**
  68496. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68497. */
  68498. imageProcessing: ImageProcessingPostProcess;
  68499. /**
  68500. * Chromatic aberration post process which will shift rgb colors in the image
  68501. */
  68502. chromaticAberration: ChromaticAberrationPostProcess;
  68503. private _chromaticAberrationEffect;
  68504. /**
  68505. * Grain post process which add noise to the image
  68506. */
  68507. grain: GrainPostProcess;
  68508. private _grainEffect;
  68509. /**
  68510. * Glow post process which adds a glow to emissive areas of the image
  68511. */
  68512. private _glowLayer;
  68513. /**
  68514. * Animations which can be used to tweak settings over a period of time
  68515. */
  68516. animations: Animation[];
  68517. private _imageProcessingConfigurationObserver;
  68518. private _sharpenEnabled;
  68519. private _bloomEnabled;
  68520. private _depthOfFieldEnabled;
  68521. private _depthOfFieldBlurLevel;
  68522. private _fxaaEnabled;
  68523. private _imageProcessingEnabled;
  68524. private _defaultPipelineTextureType;
  68525. private _bloomScale;
  68526. private _chromaticAberrationEnabled;
  68527. private _grainEnabled;
  68528. private _buildAllowed;
  68529. /**
  68530. * Gets active scene
  68531. */
  68532. get scene(): Scene;
  68533. /**
  68534. * Enable or disable the sharpen process from the pipeline
  68535. */
  68536. set sharpenEnabled(enabled: boolean);
  68537. get sharpenEnabled(): boolean;
  68538. private _resizeObserver;
  68539. private _hardwareScaleLevel;
  68540. private _bloomKernel;
  68541. /**
  68542. * Specifies the size of the bloom blur kernel, relative to the final output size
  68543. */
  68544. get bloomKernel(): number;
  68545. set bloomKernel(value: number);
  68546. /**
  68547. * Specifies the weight of the bloom in the final rendering
  68548. */
  68549. private _bloomWeight;
  68550. /**
  68551. * Specifies the luma threshold for the area that will be blurred by the bloom
  68552. */
  68553. private _bloomThreshold;
  68554. private _hdr;
  68555. /**
  68556. * The strength of the bloom.
  68557. */
  68558. set bloomWeight(value: number);
  68559. get bloomWeight(): number;
  68560. /**
  68561. * The strength of the bloom.
  68562. */
  68563. set bloomThreshold(value: number);
  68564. get bloomThreshold(): number;
  68565. /**
  68566. * The scale of the bloom, lower value will provide better performance.
  68567. */
  68568. set bloomScale(value: number);
  68569. get bloomScale(): number;
  68570. /**
  68571. * Enable or disable the bloom from the pipeline
  68572. */
  68573. set bloomEnabled(enabled: boolean);
  68574. get bloomEnabled(): boolean;
  68575. private _rebuildBloom;
  68576. /**
  68577. * If the depth of field is enabled.
  68578. */
  68579. get depthOfFieldEnabled(): boolean;
  68580. set depthOfFieldEnabled(enabled: boolean);
  68581. /**
  68582. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68583. */
  68584. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68585. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68586. /**
  68587. * If the anti aliasing is enabled.
  68588. */
  68589. set fxaaEnabled(enabled: boolean);
  68590. get fxaaEnabled(): boolean;
  68591. private _samples;
  68592. /**
  68593. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68594. */
  68595. set samples(sampleCount: number);
  68596. get samples(): number;
  68597. /**
  68598. * If image processing is enabled.
  68599. */
  68600. set imageProcessingEnabled(enabled: boolean);
  68601. get imageProcessingEnabled(): boolean;
  68602. /**
  68603. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68604. */
  68605. set glowLayerEnabled(enabled: boolean);
  68606. get glowLayerEnabled(): boolean;
  68607. /**
  68608. * Gets the glow layer (or null if not defined)
  68609. */
  68610. get glowLayer(): Nullable<GlowLayer>;
  68611. /**
  68612. * Enable or disable the chromaticAberration process from the pipeline
  68613. */
  68614. set chromaticAberrationEnabled(enabled: boolean);
  68615. get chromaticAberrationEnabled(): boolean;
  68616. /**
  68617. * Enable or disable the grain process from the pipeline
  68618. */
  68619. set grainEnabled(enabled: boolean);
  68620. get grainEnabled(): boolean;
  68621. /**
  68622. * @constructor
  68623. * @param name - The rendering pipeline name (default: "")
  68624. * @param hdr - If high dynamic range textures should be used (default: true)
  68625. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68626. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68627. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68628. */
  68629. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68630. /**
  68631. * Get the class name
  68632. * @returns "DefaultRenderingPipeline"
  68633. */
  68634. getClassName(): string;
  68635. /**
  68636. * Force the compilation of the entire pipeline.
  68637. */
  68638. prepare(): void;
  68639. private _hasCleared;
  68640. private _prevPostProcess;
  68641. private _prevPrevPostProcess;
  68642. private _setAutoClearAndTextureSharing;
  68643. private _depthOfFieldSceneObserver;
  68644. private _buildPipeline;
  68645. private _disposePostProcesses;
  68646. /**
  68647. * Adds a camera to the pipeline
  68648. * @param camera the camera to be added
  68649. */
  68650. addCamera(camera: Camera): void;
  68651. /**
  68652. * Removes a camera from the pipeline
  68653. * @param camera the camera to remove
  68654. */
  68655. removeCamera(camera: Camera): void;
  68656. /**
  68657. * Dispose of the pipeline and stop all post processes
  68658. */
  68659. dispose(): void;
  68660. /**
  68661. * Serialize the rendering pipeline (Used when exporting)
  68662. * @returns the serialized object
  68663. */
  68664. serialize(): any;
  68665. /**
  68666. * Parse the serialized pipeline
  68667. * @param source Source pipeline.
  68668. * @param scene The scene to load the pipeline to.
  68669. * @param rootUrl The URL of the serialized pipeline.
  68670. * @returns An instantiated pipeline from the serialized object.
  68671. */
  68672. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68673. }
  68674. }
  68675. declare module BABYLON {
  68676. /** @hidden */
  68677. export var lensHighlightsPixelShader: {
  68678. name: string;
  68679. shader: string;
  68680. };
  68681. }
  68682. declare module BABYLON {
  68683. /** @hidden */
  68684. export var depthOfFieldPixelShader: {
  68685. name: string;
  68686. shader: string;
  68687. };
  68688. }
  68689. declare module BABYLON {
  68690. /**
  68691. * BABYLON.JS Chromatic Aberration GLSL Shader
  68692. * Author: Olivier Guyot
  68693. * Separates very slightly R, G and B colors on the edges of the screen
  68694. * Inspired by Francois Tarlier & Martins Upitis
  68695. */
  68696. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68697. /**
  68698. * @ignore
  68699. * The chromatic aberration PostProcess id in the pipeline
  68700. */
  68701. LensChromaticAberrationEffect: string;
  68702. /**
  68703. * @ignore
  68704. * The highlights enhancing PostProcess id in the pipeline
  68705. */
  68706. HighlightsEnhancingEffect: string;
  68707. /**
  68708. * @ignore
  68709. * The depth-of-field PostProcess id in the pipeline
  68710. */
  68711. LensDepthOfFieldEffect: string;
  68712. private _scene;
  68713. private _depthTexture;
  68714. private _grainTexture;
  68715. private _chromaticAberrationPostProcess;
  68716. private _highlightsPostProcess;
  68717. private _depthOfFieldPostProcess;
  68718. private _edgeBlur;
  68719. private _grainAmount;
  68720. private _chromaticAberration;
  68721. private _distortion;
  68722. private _highlightsGain;
  68723. private _highlightsThreshold;
  68724. private _dofDistance;
  68725. private _dofAperture;
  68726. private _dofDarken;
  68727. private _dofPentagon;
  68728. private _blurNoise;
  68729. /**
  68730. * @constructor
  68731. *
  68732. * Effect parameters are as follow:
  68733. * {
  68734. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68735. * edge_blur: number; // from 0 to x (1 for realism)
  68736. * distortion: number; // from 0 to x (1 for realism)
  68737. * grain_amount: number; // from 0 to 1
  68738. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68739. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68740. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68741. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68742. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68743. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68744. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68745. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68746. * }
  68747. * Note: if an effect parameter is unset, effect is disabled
  68748. *
  68749. * @param name The rendering pipeline name
  68750. * @param parameters - An object containing all parameters (see above)
  68751. * @param scene The scene linked to this pipeline
  68752. * @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)
  68753. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68754. */
  68755. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68756. /**
  68757. * Get the class name
  68758. * @returns "LensRenderingPipeline"
  68759. */
  68760. getClassName(): string;
  68761. /**
  68762. * Gets associated scene
  68763. */
  68764. get scene(): Scene;
  68765. /**
  68766. * Gets or sets the edge blur
  68767. */
  68768. get edgeBlur(): number;
  68769. set edgeBlur(value: number);
  68770. /**
  68771. * Gets or sets the grain amount
  68772. */
  68773. get grainAmount(): number;
  68774. set grainAmount(value: number);
  68775. /**
  68776. * Gets or sets the chromatic aberration amount
  68777. */
  68778. get chromaticAberration(): number;
  68779. set chromaticAberration(value: number);
  68780. /**
  68781. * Gets or sets the depth of field aperture
  68782. */
  68783. get dofAperture(): number;
  68784. set dofAperture(value: number);
  68785. /**
  68786. * Gets or sets the edge distortion
  68787. */
  68788. get edgeDistortion(): number;
  68789. set edgeDistortion(value: number);
  68790. /**
  68791. * Gets or sets the depth of field distortion
  68792. */
  68793. get dofDistortion(): number;
  68794. set dofDistortion(value: number);
  68795. /**
  68796. * Gets or sets the darken out of focus amount
  68797. */
  68798. get darkenOutOfFocus(): number;
  68799. set darkenOutOfFocus(value: number);
  68800. /**
  68801. * Gets or sets a boolean indicating if blur noise is enabled
  68802. */
  68803. get blurNoise(): boolean;
  68804. set blurNoise(value: boolean);
  68805. /**
  68806. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68807. */
  68808. get pentagonBokeh(): boolean;
  68809. set pentagonBokeh(value: boolean);
  68810. /**
  68811. * Gets or sets the highlight grain amount
  68812. */
  68813. get highlightsGain(): number;
  68814. set highlightsGain(value: number);
  68815. /**
  68816. * Gets or sets the highlight threshold
  68817. */
  68818. get highlightsThreshold(): number;
  68819. set highlightsThreshold(value: number);
  68820. /**
  68821. * Sets the amount of blur at the edges
  68822. * @param amount blur amount
  68823. */
  68824. setEdgeBlur(amount: number): void;
  68825. /**
  68826. * Sets edge blur to 0
  68827. */
  68828. disableEdgeBlur(): void;
  68829. /**
  68830. * Sets the amout of grain
  68831. * @param amount Amount of grain
  68832. */
  68833. setGrainAmount(amount: number): void;
  68834. /**
  68835. * Set grain amount to 0
  68836. */
  68837. disableGrain(): void;
  68838. /**
  68839. * Sets the chromatic aberration amount
  68840. * @param amount amount of chromatic aberration
  68841. */
  68842. setChromaticAberration(amount: number): void;
  68843. /**
  68844. * Sets chromatic aberration amount to 0
  68845. */
  68846. disableChromaticAberration(): void;
  68847. /**
  68848. * Sets the EdgeDistortion amount
  68849. * @param amount amount of EdgeDistortion
  68850. */
  68851. setEdgeDistortion(amount: number): void;
  68852. /**
  68853. * Sets edge distortion to 0
  68854. */
  68855. disableEdgeDistortion(): void;
  68856. /**
  68857. * Sets the FocusDistance amount
  68858. * @param amount amount of FocusDistance
  68859. */
  68860. setFocusDistance(amount: number): void;
  68861. /**
  68862. * Disables depth of field
  68863. */
  68864. disableDepthOfField(): void;
  68865. /**
  68866. * Sets the Aperture amount
  68867. * @param amount amount of Aperture
  68868. */
  68869. setAperture(amount: number): void;
  68870. /**
  68871. * Sets the DarkenOutOfFocus amount
  68872. * @param amount amount of DarkenOutOfFocus
  68873. */
  68874. setDarkenOutOfFocus(amount: number): void;
  68875. private _pentagonBokehIsEnabled;
  68876. /**
  68877. * Creates a pentagon bokeh effect
  68878. */
  68879. enablePentagonBokeh(): void;
  68880. /**
  68881. * Disables the pentagon bokeh effect
  68882. */
  68883. disablePentagonBokeh(): void;
  68884. /**
  68885. * Enables noise blur
  68886. */
  68887. enableNoiseBlur(): void;
  68888. /**
  68889. * Disables noise blur
  68890. */
  68891. disableNoiseBlur(): void;
  68892. /**
  68893. * Sets the HighlightsGain amount
  68894. * @param amount amount of HighlightsGain
  68895. */
  68896. setHighlightsGain(amount: number): void;
  68897. /**
  68898. * Sets the HighlightsThreshold amount
  68899. * @param amount amount of HighlightsThreshold
  68900. */
  68901. setHighlightsThreshold(amount: number): void;
  68902. /**
  68903. * Disables highlights
  68904. */
  68905. disableHighlights(): void;
  68906. /**
  68907. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68908. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68909. */
  68910. dispose(disableDepthRender?: boolean): void;
  68911. private _createChromaticAberrationPostProcess;
  68912. private _createHighlightsPostProcess;
  68913. private _createDepthOfFieldPostProcess;
  68914. private _createGrainTexture;
  68915. }
  68916. }
  68917. declare module BABYLON {
  68918. /** @hidden */
  68919. export var ssao2PixelShader: {
  68920. name: string;
  68921. shader: string;
  68922. };
  68923. }
  68924. declare module BABYLON {
  68925. /** @hidden */
  68926. export var ssaoCombinePixelShader: {
  68927. name: string;
  68928. shader: string;
  68929. };
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * Render pipeline to produce ssao effect
  68934. */
  68935. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68936. /**
  68937. * @ignore
  68938. * The PassPostProcess id in the pipeline that contains the original scene color
  68939. */
  68940. SSAOOriginalSceneColorEffect: string;
  68941. /**
  68942. * @ignore
  68943. * The SSAO PostProcess id in the pipeline
  68944. */
  68945. SSAORenderEffect: string;
  68946. /**
  68947. * @ignore
  68948. * The horizontal blur PostProcess id in the pipeline
  68949. */
  68950. SSAOBlurHRenderEffect: string;
  68951. /**
  68952. * @ignore
  68953. * The vertical blur PostProcess id in the pipeline
  68954. */
  68955. SSAOBlurVRenderEffect: string;
  68956. /**
  68957. * @ignore
  68958. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68959. */
  68960. SSAOCombineRenderEffect: string;
  68961. /**
  68962. * The output strength of the SSAO post-process. Default value is 1.0.
  68963. */
  68964. totalStrength: number;
  68965. /**
  68966. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68967. */
  68968. maxZ: number;
  68969. /**
  68970. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68971. */
  68972. minZAspect: number;
  68973. private _samples;
  68974. /**
  68975. * Number of samples used for the SSAO calculations. Default value is 8
  68976. */
  68977. set samples(n: number);
  68978. get samples(): number;
  68979. private _textureSamples;
  68980. /**
  68981. * Number of samples to use for antialiasing
  68982. */
  68983. set textureSamples(n: number);
  68984. get textureSamples(): number;
  68985. /**
  68986. * Ratio object used for SSAO ratio and blur ratio
  68987. */
  68988. private _ratio;
  68989. /**
  68990. * Dynamically generated sphere sampler.
  68991. */
  68992. private _sampleSphere;
  68993. /**
  68994. * Blur filter offsets
  68995. */
  68996. private _samplerOffsets;
  68997. private _expensiveBlur;
  68998. /**
  68999. * If bilateral blur should be used
  69000. */
  69001. set expensiveBlur(b: boolean);
  69002. get expensiveBlur(): boolean;
  69003. /**
  69004. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69005. */
  69006. radius: number;
  69007. /**
  69008. * The base color of the SSAO post-process
  69009. * The final result is "base + ssao" between [0, 1]
  69010. */
  69011. base: number;
  69012. /**
  69013. * Support test.
  69014. */
  69015. static get IsSupported(): boolean;
  69016. private _scene;
  69017. private _depthTexture;
  69018. private _normalTexture;
  69019. private _randomTexture;
  69020. private _originalColorPostProcess;
  69021. private _ssaoPostProcess;
  69022. private _blurHPostProcess;
  69023. private _blurVPostProcess;
  69024. private _ssaoCombinePostProcess;
  69025. /**
  69026. * Gets active scene
  69027. */
  69028. get scene(): Scene;
  69029. /**
  69030. * @constructor
  69031. * @param name The rendering pipeline name
  69032. * @param scene The scene linked to this pipeline
  69033. * @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 }
  69034. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69035. */
  69036. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69037. /**
  69038. * Get the class name
  69039. * @returns "SSAO2RenderingPipeline"
  69040. */
  69041. getClassName(): string;
  69042. /**
  69043. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69044. */
  69045. dispose(disableGeometryBufferRenderer?: boolean): void;
  69046. private _createBlurPostProcess;
  69047. /** @hidden */
  69048. _rebuild(): void;
  69049. private _bits;
  69050. private _radicalInverse_VdC;
  69051. private _hammersley;
  69052. private _hemisphereSample_uniform;
  69053. private _generateHemisphere;
  69054. private _createSSAOPostProcess;
  69055. private _createSSAOCombinePostProcess;
  69056. private _createRandomTexture;
  69057. /**
  69058. * Serialize the rendering pipeline (Used when exporting)
  69059. * @returns the serialized object
  69060. */
  69061. serialize(): any;
  69062. /**
  69063. * Parse the serialized pipeline
  69064. * @param source Source pipeline.
  69065. * @param scene The scene to load the pipeline to.
  69066. * @param rootUrl The URL of the serialized pipeline.
  69067. * @returns An instantiated pipeline from the serialized object.
  69068. */
  69069. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69070. }
  69071. }
  69072. declare module BABYLON {
  69073. /** @hidden */
  69074. export var ssaoPixelShader: {
  69075. name: string;
  69076. shader: string;
  69077. };
  69078. }
  69079. declare module BABYLON {
  69080. /**
  69081. * Render pipeline to produce ssao effect
  69082. */
  69083. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69084. /**
  69085. * @ignore
  69086. * The PassPostProcess id in the pipeline that contains the original scene color
  69087. */
  69088. SSAOOriginalSceneColorEffect: string;
  69089. /**
  69090. * @ignore
  69091. * The SSAO PostProcess id in the pipeline
  69092. */
  69093. SSAORenderEffect: string;
  69094. /**
  69095. * @ignore
  69096. * The horizontal blur PostProcess id in the pipeline
  69097. */
  69098. SSAOBlurHRenderEffect: string;
  69099. /**
  69100. * @ignore
  69101. * The vertical blur PostProcess id in the pipeline
  69102. */
  69103. SSAOBlurVRenderEffect: string;
  69104. /**
  69105. * @ignore
  69106. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69107. */
  69108. SSAOCombineRenderEffect: string;
  69109. /**
  69110. * The output strength of the SSAO post-process. Default value is 1.0.
  69111. */
  69112. totalStrength: number;
  69113. /**
  69114. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69115. */
  69116. radius: number;
  69117. /**
  69118. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69119. * Must not be equal to fallOff and superior to fallOff.
  69120. * Default value is 0.0075
  69121. */
  69122. area: number;
  69123. /**
  69124. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69125. * Must not be equal to area and inferior to area.
  69126. * Default value is 0.000001
  69127. */
  69128. fallOff: number;
  69129. /**
  69130. * The base color of the SSAO post-process
  69131. * The final result is "base + ssao" between [0, 1]
  69132. */
  69133. base: number;
  69134. private _scene;
  69135. private _depthTexture;
  69136. private _randomTexture;
  69137. private _originalColorPostProcess;
  69138. private _ssaoPostProcess;
  69139. private _blurHPostProcess;
  69140. private _blurVPostProcess;
  69141. private _ssaoCombinePostProcess;
  69142. private _firstUpdate;
  69143. /**
  69144. * Gets active scene
  69145. */
  69146. get scene(): Scene;
  69147. /**
  69148. * @constructor
  69149. * @param name - The rendering pipeline name
  69150. * @param scene - The scene linked to this pipeline
  69151. * @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 }
  69152. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69153. */
  69154. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69155. /**
  69156. * Get the class name
  69157. * @returns "SSAORenderingPipeline"
  69158. */
  69159. getClassName(): string;
  69160. /**
  69161. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69162. */
  69163. dispose(disableDepthRender?: boolean): void;
  69164. private _createBlurPostProcess;
  69165. /** @hidden */
  69166. _rebuild(): void;
  69167. private _createSSAOPostProcess;
  69168. private _createSSAOCombinePostProcess;
  69169. private _createRandomTexture;
  69170. }
  69171. }
  69172. declare module BABYLON {
  69173. /** @hidden */
  69174. export var screenSpaceReflectionPixelShader: {
  69175. name: string;
  69176. shader: string;
  69177. };
  69178. }
  69179. declare module BABYLON {
  69180. /**
  69181. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69182. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69183. */
  69184. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69185. /**
  69186. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69187. */
  69188. threshold: number;
  69189. /**
  69190. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69191. */
  69192. strength: number;
  69193. /**
  69194. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69195. */
  69196. reflectionSpecularFalloffExponent: number;
  69197. /**
  69198. * 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]
  69199. */
  69200. step: number;
  69201. /**
  69202. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69203. */
  69204. roughnessFactor: number;
  69205. private _geometryBufferRenderer;
  69206. private _enableSmoothReflections;
  69207. private _reflectionSamples;
  69208. private _smoothSteps;
  69209. /**
  69210. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69211. * @param name The name of the effect.
  69212. * @param scene The scene containing the objects to calculate reflections.
  69213. * @param options The required width/height ratio to downsize to before computing the render pass.
  69214. * @param camera The camera to apply the render pass to.
  69215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69216. * @param engine The engine which the post process will be applied. (default: current engine)
  69217. * @param reusable If the post process can be reused on the same frame. (default: false)
  69218. * @param textureType Type of textures used when performing the post process. (default: 0)
  69219. * @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)
  69220. */
  69221. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69222. /**
  69223. * Gets wether or not smoothing reflections is enabled.
  69224. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69225. */
  69226. get enableSmoothReflections(): boolean;
  69227. /**
  69228. * Sets wether or not smoothing reflections is enabled.
  69229. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69230. */
  69231. set enableSmoothReflections(enabled: boolean);
  69232. /**
  69233. * Gets the number of samples taken while computing reflections. More samples count is high,
  69234. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69235. */
  69236. get reflectionSamples(): number;
  69237. /**
  69238. * Sets the number of samples taken while computing reflections. More samples count is high,
  69239. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69240. */
  69241. set reflectionSamples(samples: number);
  69242. /**
  69243. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69244. * more the post-process will require GPU power and can generate a drop in FPS.
  69245. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69246. */
  69247. get smoothSteps(): number;
  69248. set smoothSteps(steps: number);
  69249. private _updateEffectDefines;
  69250. }
  69251. }
  69252. declare module BABYLON {
  69253. /** @hidden */
  69254. export var standardPixelShader: {
  69255. name: string;
  69256. shader: string;
  69257. };
  69258. }
  69259. declare module BABYLON {
  69260. /**
  69261. * Standard rendering pipeline
  69262. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69263. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69264. */
  69265. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69266. /**
  69267. * Public members
  69268. */
  69269. /**
  69270. * Post-process which contains the original scene color before the pipeline applies all the effects
  69271. */
  69272. originalPostProcess: Nullable<PostProcess>;
  69273. /**
  69274. * Post-process used to down scale an image x4
  69275. */
  69276. downSampleX4PostProcess: Nullable<PostProcess>;
  69277. /**
  69278. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69279. */
  69280. brightPassPostProcess: Nullable<PostProcess>;
  69281. /**
  69282. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69283. */
  69284. blurHPostProcesses: PostProcess[];
  69285. /**
  69286. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69287. */
  69288. blurVPostProcesses: PostProcess[];
  69289. /**
  69290. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69291. */
  69292. textureAdderPostProcess: Nullable<PostProcess>;
  69293. /**
  69294. * Post-process used to create volumetric lighting effect
  69295. */
  69296. volumetricLightPostProcess: Nullable<PostProcess>;
  69297. /**
  69298. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69299. */
  69300. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69301. /**
  69302. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69303. */
  69304. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69305. /**
  69306. * Post-process used to merge the volumetric light effect and the real scene color
  69307. */
  69308. volumetricLightMergePostProces: Nullable<PostProcess>;
  69309. /**
  69310. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69311. */
  69312. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69313. /**
  69314. * Base post-process used to calculate the average luminance of the final image for HDR
  69315. */
  69316. luminancePostProcess: Nullable<PostProcess>;
  69317. /**
  69318. * Post-processes used to create down sample post-processes in order to get
  69319. * the average luminance of the final image for HDR
  69320. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69321. */
  69322. luminanceDownSamplePostProcesses: PostProcess[];
  69323. /**
  69324. * Post-process used to create a HDR effect (light adaptation)
  69325. */
  69326. hdrPostProcess: Nullable<PostProcess>;
  69327. /**
  69328. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69329. */
  69330. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69331. /**
  69332. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69333. */
  69334. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69335. /**
  69336. * Post-process used to merge the final HDR post-process and the real scene color
  69337. */
  69338. hdrFinalPostProcess: Nullable<PostProcess>;
  69339. /**
  69340. * Post-process used to create a lens flare effect
  69341. */
  69342. lensFlarePostProcess: Nullable<PostProcess>;
  69343. /**
  69344. * Post-process that merges the result of the lens flare post-process and the real scene color
  69345. */
  69346. lensFlareComposePostProcess: Nullable<PostProcess>;
  69347. /**
  69348. * Post-process used to create a motion blur effect
  69349. */
  69350. motionBlurPostProcess: Nullable<PostProcess>;
  69351. /**
  69352. * Post-process used to create a depth of field effect
  69353. */
  69354. depthOfFieldPostProcess: Nullable<PostProcess>;
  69355. /**
  69356. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69357. */
  69358. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69359. /**
  69360. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69361. */
  69362. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69363. /**
  69364. * Represents the brightness threshold in order to configure the illuminated surfaces
  69365. */
  69366. brightThreshold: number;
  69367. /**
  69368. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69369. */
  69370. blurWidth: number;
  69371. /**
  69372. * Sets if the blur for highlighted surfaces must be only horizontal
  69373. */
  69374. horizontalBlur: boolean;
  69375. /**
  69376. * Gets the overall exposure used by the pipeline
  69377. */
  69378. get exposure(): number;
  69379. /**
  69380. * Sets the overall exposure used by the pipeline
  69381. */
  69382. set exposure(value: number);
  69383. /**
  69384. * Texture used typically to simulate "dirty" on camera lens
  69385. */
  69386. lensTexture: Nullable<Texture>;
  69387. /**
  69388. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69389. */
  69390. volumetricLightCoefficient: number;
  69391. /**
  69392. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69393. */
  69394. volumetricLightPower: number;
  69395. /**
  69396. * Used the set the blur intensity to smooth the volumetric lights
  69397. */
  69398. volumetricLightBlurScale: number;
  69399. /**
  69400. * Light (spot or directional) used to generate the volumetric lights rays
  69401. * The source light must have a shadow generate so the pipeline can get its
  69402. * depth map
  69403. */
  69404. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69405. /**
  69406. * For eye adaptation, represents the minimum luminance the eye can see
  69407. */
  69408. hdrMinimumLuminance: number;
  69409. /**
  69410. * For eye adaptation, represents the decrease luminance speed
  69411. */
  69412. hdrDecreaseRate: number;
  69413. /**
  69414. * For eye adaptation, represents the increase luminance speed
  69415. */
  69416. hdrIncreaseRate: number;
  69417. /**
  69418. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69419. */
  69420. get hdrAutoExposure(): boolean;
  69421. /**
  69422. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69423. */
  69424. set hdrAutoExposure(value: boolean);
  69425. /**
  69426. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69427. */
  69428. lensColorTexture: Nullable<Texture>;
  69429. /**
  69430. * The overall strengh for the lens flare effect
  69431. */
  69432. lensFlareStrength: number;
  69433. /**
  69434. * Dispersion coefficient for lens flare ghosts
  69435. */
  69436. lensFlareGhostDispersal: number;
  69437. /**
  69438. * Main lens flare halo width
  69439. */
  69440. lensFlareHaloWidth: number;
  69441. /**
  69442. * Based on the lens distortion effect, defines how much the lens flare result
  69443. * is distorted
  69444. */
  69445. lensFlareDistortionStrength: number;
  69446. /**
  69447. * Configures the blur intensity used for for lens flare (halo)
  69448. */
  69449. lensFlareBlurWidth: number;
  69450. /**
  69451. * Lens star texture must be used to simulate rays on the flares and is available
  69452. * in the documentation
  69453. */
  69454. lensStarTexture: Nullable<Texture>;
  69455. /**
  69456. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69457. * flare effect by taking account of the dirt texture
  69458. */
  69459. lensFlareDirtTexture: Nullable<Texture>;
  69460. /**
  69461. * Represents the focal length for the depth of field effect
  69462. */
  69463. depthOfFieldDistance: number;
  69464. /**
  69465. * Represents the blur intensity for the blurred part of the depth of field effect
  69466. */
  69467. depthOfFieldBlurWidth: number;
  69468. /**
  69469. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69470. */
  69471. get motionStrength(): number;
  69472. /**
  69473. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69474. */
  69475. set motionStrength(strength: number);
  69476. /**
  69477. * Gets wether or not the motion blur post-process is object based or screen based.
  69478. */
  69479. get objectBasedMotionBlur(): boolean;
  69480. /**
  69481. * Sets wether or not the motion blur post-process should be object based or screen based
  69482. */
  69483. set objectBasedMotionBlur(value: boolean);
  69484. /**
  69485. * List of animations for the pipeline (IAnimatable implementation)
  69486. */
  69487. animations: Animation[];
  69488. /**
  69489. * Private members
  69490. */
  69491. private _scene;
  69492. private _currentDepthOfFieldSource;
  69493. private _basePostProcess;
  69494. private _fixedExposure;
  69495. private _currentExposure;
  69496. private _hdrAutoExposure;
  69497. private _hdrCurrentLuminance;
  69498. private _motionStrength;
  69499. private _isObjectBasedMotionBlur;
  69500. private _floatTextureType;
  69501. private _camerasToBeAttached;
  69502. private _ratio;
  69503. private _bloomEnabled;
  69504. private _depthOfFieldEnabled;
  69505. private _vlsEnabled;
  69506. private _lensFlareEnabled;
  69507. private _hdrEnabled;
  69508. private _motionBlurEnabled;
  69509. private _fxaaEnabled;
  69510. private _screenSpaceReflectionsEnabled;
  69511. private _motionBlurSamples;
  69512. private _volumetricLightStepsCount;
  69513. private _samples;
  69514. /**
  69515. * @ignore
  69516. * Specifies if the bloom pipeline is enabled
  69517. */
  69518. get BloomEnabled(): boolean;
  69519. set BloomEnabled(enabled: boolean);
  69520. /**
  69521. * @ignore
  69522. * Specifies if the depth of field pipeline is enabed
  69523. */
  69524. get DepthOfFieldEnabled(): boolean;
  69525. set DepthOfFieldEnabled(enabled: boolean);
  69526. /**
  69527. * @ignore
  69528. * Specifies if the lens flare pipeline is enabed
  69529. */
  69530. get LensFlareEnabled(): boolean;
  69531. set LensFlareEnabled(enabled: boolean);
  69532. /**
  69533. * @ignore
  69534. * Specifies if the HDR pipeline is enabled
  69535. */
  69536. get HDREnabled(): boolean;
  69537. set HDREnabled(enabled: boolean);
  69538. /**
  69539. * @ignore
  69540. * Specifies if the volumetric lights scattering effect is enabled
  69541. */
  69542. get VLSEnabled(): boolean;
  69543. set VLSEnabled(enabled: boolean);
  69544. /**
  69545. * @ignore
  69546. * Specifies if the motion blur effect is enabled
  69547. */
  69548. get MotionBlurEnabled(): boolean;
  69549. set MotionBlurEnabled(enabled: boolean);
  69550. /**
  69551. * Specifies if anti-aliasing is enabled
  69552. */
  69553. get fxaaEnabled(): boolean;
  69554. set fxaaEnabled(enabled: boolean);
  69555. /**
  69556. * Specifies if screen space reflections are enabled.
  69557. */
  69558. get screenSpaceReflectionsEnabled(): boolean;
  69559. set screenSpaceReflectionsEnabled(enabled: boolean);
  69560. /**
  69561. * Specifies the number of steps used to calculate the volumetric lights
  69562. * Typically in interval [50, 200]
  69563. */
  69564. get volumetricLightStepsCount(): number;
  69565. set volumetricLightStepsCount(count: number);
  69566. /**
  69567. * Specifies the number of samples used for the motion blur effect
  69568. * Typically in interval [16, 64]
  69569. */
  69570. get motionBlurSamples(): number;
  69571. set motionBlurSamples(samples: number);
  69572. /**
  69573. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69574. */
  69575. get samples(): number;
  69576. set samples(sampleCount: number);
  69577. /**
  69578. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69579. * @constructor
  69580. * @param name The rendering pipeline name
  69581. * @param scene The scene linked to this pipeline
  69582. * @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)
  69583. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69584. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69585. */
  69586. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69587. private _buildPipeline;
  69588. private _createDownSampleX4PostProcess;
  69589. private _createBrightPassPostProcess;
  69590. private _createBlurPostProcesses;
  69591. private _createTextureAdderPostProcess;
  69592. private _createVolumetricLightPostProcess;
  69593. private _createLuminancePostProcesses;
  69594. private _createHdrPostProcess;
  69595. private _createLensFlarePostProcess;
  69596. private _createDepthOfFieldPostProcess;
  69597. private _createMotionBlurPostProcess;
  69598. private _getDepthTexture;
  69599. private _disposePostProcesses;
  69600. /**
  69601. * Dispose of the pipeline and stop all post processes
  69602. */
  69603. dispose(): void;
  69604. /**
  69605. * Serialize the rendering pipeline (Used when exporting)
  69606. * @returns the serialized object
  69607. */
  69608. serialize(): any;
  69609. /**
  69610. * Parse the serialized pipeline
  69611. * @param source Source pipeline.
  69612. * @param scene The scene to load the pipeline to.
  69613. * @param rootUrl The URL of the serialized pipeline.
  69614. * @returns An instantiated pipeline from the serialized object.
  69615. */
  69616. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69617. /**
  69618. * Luminance steps
  69619. */
  69620. static LuminanceSteps: number;
  69621. }
  69622. }
  69623. declare module BABYLON {
  69624. /** @hidden */
  69625. export var stereoscopicInterlacePixelShader: {
  69626. name: string;
  69627. shader: string;
  69628. };
  69629. }
  69630. declare module BABYLON {
  69631. /**
  69632. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69633. */
  69634. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69635. private _stepSize;
  69636. private _passedProcess;
  69637. /**
  69638. * Initializes a StereoscopicInterlacePostProcessI
  69639. * @param name The name of the effect.
  69640. * @param rigCameras The rig cameras to be appled to the post process
  69641. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69642. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69644. * @param engine The engine which the post process will be applied. (default: current engine)
  69645. * @param reusable If the post process can be reused on the same frame. (default: false)
  69646. */
  69647. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69648. }
  69649. /**
  69650. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69651. */
  69652. export class StereoscopicInterlacePostProcess extends PostProcess {
  69653. private _stepSize;
  69654. private _passedProcess;
  69655. /**
  69656. * Initializes a StereoscopicInterlacePostProcess
  69657. * @param name The name of the effect.
  69658. * @param rigCameras The rig cameras to be appled to the post process
  69659. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69661. * @param engine The engine which the post process will be applied. (default: current engine)
  69662. * @param reusable If the post process can be reused on the same frame. (default: false)
  69663. */
  69664. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /** @hidden */
  69669. export var tonemapPixelShader: {
  69670. name: string;
  69671. shader: string;
  69672. };
  69673. }
  69674. declare module BABYLON {
  69675. /** Defines operator used for tonemapping */
  69676. export enum TonemappingOperator {
  69677. /** Hable */
  69678. Hable = 0,
  69679. /** Reinhard */
  69680. Reinhard = 1,
  69681. /** HejiDawson */
  69682. HejiDawson = 2,
  69683. /** Photographic */
  69684. Photographic = 3
  69685. }
  69686. /**
  69687. * Defines a post process to apply tone mapping
  69688. */
  69689. export class TonemapPostProcess extends PostProcess {
  69690. private _operator;
  69691. /** Defines the required exposure adjustement */
  69692. exposureAdjustment: number;
  69693. /**
  69694. * Creates a new TonemapPostProcess
  69695. * @param name defines the name of the postprocess
  69696. * @param _operator defines the operator to use
  69697. * @param exposureAdjustment defines the required exposure adjustement
  69698. * @param camera defines the camera to use (can be null)
  69699. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69700. * @param engine defines the hosting engine (can be ignore if camera is set)
  69701. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69702. */
  69703. constructor(name: string, _operator: TonemappingOperator,
  69704. /** Defines the required exposure adjustement */
  69705. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /** @hidden */
  69710. export var volumetricLightScatteringPixelShader: {
  69711. name: string;
  69712. shader: string;
  69713. };
  69714. }
  69715. declare module BABYLON {
  69716. /** @hidden */
  69717. export var volumetricLightScatteringPassVertexShader: {
  69718. name: string;
  69719. shader: string;
  69720. };
  69721. }
  69722. declare module BABYLON {
  69723. /** @hidden */
  69724. export var volumetricLightScatteringPassPixelShader: {
  69725. name: string;
  69726. shader: string;
  69727. };
  69728. }
  69729. declare module BABYLON {
  69730. /**
  69731. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69732. */
  69733. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69734. private _volumetricLightScatteringPass;
  69735. private _volumetricLightScatteringRTT;
  69736. private _viewPort;
  69737. private _screenCoordinates;
  69738. private _cachedDefines;
  69739. /**
  69740. * If not undefined, the mesh position is computed from the attached node position
  69741. */
  69742. attachedNode: {
  69743. position: Vector3;
  69744. };
  69745. /**
  69746. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69747. */
  69748. customMeshPosition: Vector3;
  69749. /**
  69750. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69751. */
  69752. useCustomMeshPosition: boolean;
  69753. /**
  69754. * If the post-process should inverse the light scattering direction
  69755. */
  69756. invert: boolean;
  69757. /**
  69758. * The internal mesh used by the post-process
  69759. */
  69760. mesh: Mesh;
  69761. /**
  69762. * @hidden
  69763. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69764. */
  69765. get useDiffuseColor(): boolean;
  69766. set useDiffuseColor(useDiffuseColor: boolean);
  69767. /**
  69768. * Array containing the excluded meshes not rendered in the internal pass
  69769. */
  69770. excludedMeshes: AbstractMesh[];
  69771. /**
  69772. * Controls the overall intensity of the post-process
  69773. */
  69774. exposure: number;
  69775. /**
  69776. * Dissipates each sample's contribution in range [0, 1]
  69777. */
  69778. decay: number;
  69779. /**
  69780. * Controls the overall intensity of each sample
  69781. */
  69782. weight: number;
  69783. /**
  69784. * Controls the density of each sample
  69785. */
  69786. density: number;
  69787. /**
  69788. * @constructor
  69789. * @param name The post-process name
  69790. * @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)
  69791. * @param camera The camera that the post-process will be attached to
  69792. * @param mesh The mesh used to create the light scattering
  69793. * @param samples The post-process quality, default 100
  69794. * @param samplingModeThe post-process filtering mode
  69795. * @param engine The babylon engine
  69796. * @param reusable If the post-process is reusable
  69797. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69798. */
  69799. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69800. /**
  69801. * Returns the string "VolumetricLightScatteringPostProcess"
  69802. * @returns "VolumetricLightScatteringPostProcess"
  69803. */
  69804. getClassName(): string;
  69805. private _isReady;
  69806. /**
  69807. * Sets the new light position for light scattering effect
  69808. * @param position The new custom light position
  69809. */
  69810. setCustomMeshPosition(position: Vector3): void;
  69811. /**
  69812. * Returns the light position for light scattering effect
  69813. * @return Vector3 The custom light position
  69814. */
  69815. getCustomMeshPosition(): Vector3;
  69816. /**
  69817. * Disposes the internal assets and detaches the post-process from the camera
  69818. */
  69819. dispose(camera: Camera): void;
  69820. /**
  69821. * Returns the render target texture used by the post-process
  69822. * @return the render target texture used by the post-process
  69823. */
  69824. getPass(): RenderTargetTexture;
  69825. private _meshExcluded;
  69826. private _createPass;
  69827. private _updateMeshScreenCoordinates;
  69828. /**
  69829. * Creates a default mesh for the Volumeric Light Scattering post-process
  69830. * @param name The mesh name
  69831. * @param scene The scene where to create the mesh
  69832. * @return the default mesh
  69833. */
  69834. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69835. }
  69836. }
  69837. declare module BABYLON {
  69838. interface Scene {
  69839. /** @hidden (Backing field) */
  69840. _boundingBoxRenderer: BoundingBoxRenderer;
  69841. /** @hidden (Backing field) */
  69842. _forceShowBoundingBoxes: boolean;
  69843. /**
  69844. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69845. */
  69846. forceShowBoundingBoxes: boolean;
  69847. /**
  69848. * Gets the bounding box renderer associated with the scene
  69849. * @returns a BoundingBoxRenderer
  69850. */
  69851. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69852. }
  69853. interface AbstractMesh {
  69854. /** @hidden (Backing field) */
  69855. _showBoundingBox: boolean;
  69856. /**
  69857. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69858. */
  69859. showBoundingBox: boolean;
  69860. }
  69861. /**
  69862. * Component responsible of rendering the bounding box of the meshes in a scene.
  69863. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69864. */
  69865. export class BoundingBoxRenderer implements ISceneComponent {
  69866. /**
  69867. * The component name helpfull to identify the component in the list of scene components.
  69868. */
  69869. readonly name: string;
  69870. /**
  69871. * The scene the component belongs to.
  69872. */
  69873. scene: Scene;
  69874. /**
  69875. * Color of the bounding box lines placed in front of an object
  69876. */
  69877. frontColor: Color3;
  69878. /**
  69879. * Color of the bounding box lines placed behind an object
  69880. */
  69881. backColor: Color3;
  69882. /**
  69883. * Defines if the renderer should show the back lines or not
  69884. */
  69885. showBackLines: boolean;
  69886. /**
  69887. * Observable raised before rendering a bounding box
  69888. */
  69889. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69890. /**
  69891. * Observable raised after rendering a bounding box
  69892. */
  69893. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69894. /**
  69895. * @hidden
  69896. */
  69897. renderList: SmartArray<BoundingBox>;
  69898. private _colorShader;
  69899. private _vertexBuffers;
  69900. private _indexBuffer;
  69901. private _fillIndexBuffer;
  69902. private _fillIndexData;
  69903. /**
  69904. * Instantiates a new bounding box renderer in a scene.
  69905. * @param scene the scene the renderer renders in
  69906. */
  69907. constructor(scene: Scene);
  69908. /**
  69909. * Registers the component in a given scene
  69910. */
  69911. register(): void;
  69912. private _evaluateSubMesh;
  69913. private _activeMesh;
  69914. private _prepareRessources;
  69915. private _createIndexBuffer;
  69916. /**
  69917. * Rebuilds the elements related to this component in case of
  69918. * context lost for instance.
  69919. */
  69920. rebuild(): void;
  69921. /**
  69922. * @hidden
  69923. */
  69924. reset(): void;
  69925. /**
  69926. * Render the bounding boxes of a specific rendering group
  69927. * @param renderingGroupId defines the rendering group to render
  69928. */
  69929. render(renderingGroupId: number): void;
  69930. /**
  69931. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69932. * @param mesh Define the mesh to render the occlusion bounding box for
  69933. */
  69934. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69935. /**
  69936. * Dispose and release the resources attached to this renderer.
  69937. */
  69938. dispose(): void;
  69939. }
  69940. }
  69941. declare module BABYLON {
  69942. interface Scene {
  69943. /** @hidden (Backing field) */
  69944. _depthRenderer: {
  69945. [id: string]: DepthRenderer;
  69946. };
  69947. /**
  69948. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69949. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69950. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69951. * @returns the created depth renderer
  69952. */
  69953. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69954. /**
  69955. * Disables a depth renderer for a given camera
  69956. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69957. */
  69958. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69959. }
  69960. /**
  69961. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69962. * in several rendering techniques.
  69963. */
  69964. export class DepthRendererSceneComponent implements ISceneComponent {
  69965. /**
  69966. * The component name helpfull to identify the component in the list of scene components.
  69967. */
  69968. readonly name: string;
  69969. /**
  69970. * The scene the component belongs to.
  69971. */
  69972. scene: Scene;
  69973. /**
  69974. * Creates a new instance of the component for the given scene
  69975. * @param scene Defines the scene to register the component in
  69976. */
  69977. constructor(scene: Scene);
  69978. /**
  69979. * Registers the component in a given scene
  69980. */
  69981. register(): void;
  69982. /**
  69983. * Rebuilds the elements related to this component in case of
  69984. * context lost for instance.
  69985. */
  69986. rebuild(): void;
  69987. /**
  69988. * Disposes the component and the associated ressources
  69989. */
  69990. dispose(): void;
  69991. private _gatherRenderTargets;
  69992. private _gatherActiveCameraRenderTargets;
  69993. }
  69994. }
  69995. declare module BABYLON {
  69996. /** @hidden */
  69997. export var outlinePixelShader: {
  69998. name: string;
  69999. shader: string;
  70000. };
  70001. }
  70002. declare module BABYLON {
  70003. /** @hidden */
  70004. export var outlineVertexShader: {
  70005. name: string;
  70006. shader: string;
  70007. };
  70008. }
  70009. declare module BABYLON {
  70010. interface Scene {
  70011. /** @hidden */
  70012. _outlineRenderer: OutlineRenderer;
  70013. /**
  70014. * Gets the outline renderer associated with the scene
  70015. * @returns a OutlineRenderer
  70016. */
  70017. getOutlineRenderer(): OutlineRenderer;
  70018. }
  70019. interface AbstractMesh {
  70020. /** @hidden (Backing field) */
  70021. _renderOutline: boolean;
  70022. /**
  70023. * Gets or sets a boolean indicating if the outline must be rendered as well
  70024. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70025. */
  70026. renderOutline: boolean;
  70027. /** @hidden (Backing field) */
  70028. _renderOverlay: boolean;
  70029. /**
  70030. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70031. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70032. */
  70033. renderOverlay: boolean;
  70034. }
  70035. /**
  70036. * This class is responsible to draw bothe outline/overlay of meshes.
  70037. * It should not be used directly but through the available method on mesh.
  70038. */
  70039. export class OutlineRenderer implements ISceneComponent {
  70040. /**
  70041. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70042. */
  70043. private static _StencilReference;
  70044. /**
  70045. * The name of the component. Each component must have a unique name.
  70046. */
  70047. name: string;
  70048. /**
  70049. * The scene the component belongs to.
  70050. */
  70051. scene: Scene;
  70052. /**
  70053. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70054. */
  70055. zOffset: number;
  70056. private _engine;
  70057. private _effect;
  70058. private _cachedDefines;
  70059. private _savedDepthWrite;
  70060. /**
  70061. * Instantiates a new outline renderer. (There could be only one per scene).
  70062. * @param scene Defines the scene it belongs to
  70063. */
  70064. constructor(scene: Scene);
  70065. /**
  70066. * Register the component to one instance of a scene.
  70067. */
  70068. register(): void;
  70069. /**
  70070. * Rebuilds the elements related to this component in case of
  70071. * context lost for instance.
  70072. */
  70073. rebuild(): void;
  70074. /**
  70075. * Disposes the component and the associated ressources.
  70076. */
  70077. dispose(): void;
  70078. /**
  70079. * Renders the outline in the canvas.
  70080. * @param subMesh Defines the sumesh to render
  70081. * @param batch Defines the batch of meshes in case of instances
  70082. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70083. */
  70084. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70085. /**
  70086. * Returns whether or not the outline renderer is ready for a given submesh.
  70087. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70088. * @param subMesh Defines the submesh to check readyness for
  70089. * @param useInstances Defines wheter wee are trying to render instances or not
  70090. * @returns true if ready otherwise false
  70091. */
  70092. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70093. private _beforeRenderingMesh;
  70094. private _afterRenderingMesh;
  70095. }
  70096. }
  70097. declare module BABYLON {
  70098. /**
  70099. * Defines the basic options interface of a Sprite Frame Source Size.
  70100. */
  70101. export interface ISpriteJSONSpriteSourceSize {
  70102. /**
  70103. * number of the original width of the Frame
  70104. */
  70105. w: number;
  70106. /**
  70107. * number of the original height of the Frame
  70108. */
  70109. h: number;
  70110. }
  70111. /**
  70112. * Defines the basic options interface of a Sprite Frame Data.
  70113. */
  70114. export interface ISpriteJSONSpriteFrameData {
  70115. /**
  70116. * number of the x offset of the Frame
  70117. */
  70118. x: number;
  70119. /**
  70120. * number of the y offset of the Frame
  70121. */
  70122. y: number;
  70123. /**
  70124. * number of the width of the Frame
  70125. */
  70126. w: number;
  70127. /**
  70128. * number of the height of the Frame
  70129. */
  70130. h: number;
  70131. }
  70132. /**
  70133. * Defines the basic options interface of a JSON Sprite.
  70134. */
  70135. export interface ISpriteJSONSprite {
  70136. /**
  70137. * string name of the Frame
  70138. */
  70139. filename: string;
  70140. /**
  70141. * ISpriteJSONSpriteFrame basic object of the frame data
  70142. */
  70143. frame: ISpriteJSONSpriteFrameData;
  70144. /**
  70145. * boolean to flag is the frame was rotated.
  70146. */
  70147. rotated: boolean;
  70148. /**
  70149. * boolean to flag is the frame was trimmed.
  70150. */
  70151. trimmed: boolean;
  70152. /**
  70153. * ISpriteJSONSpriteFrame basic object of the source data
  70154. */
  70155. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70156. /**
  70157. * ISpriteJSONSpriteFrame basic object of the source data
  70158. */
  70159. sourceSize: ISpriteJSONSpriteSourceSize;
  70160. }
  70161. /**
  70162. * Defines the basic options interface of a JSON atlas.
  70163. */
  70164. export interface ISpriteJSONAtlas {
  70165. /**
  70166. * Array of objects that contain the frame data.
  70167. */
  70168. frames: Array<ISpriteJSONSprite>;
  70169. /**
  70170. * object basic object containing the sprite meta data.
  70171. */
  70172. meta?: object;
  70173. }
  70174. }
  70175. declare module BABYLON {
  70176. /** @hidden */
  70177. export var spriteMapPixelShader: {
  70178. name: string;
  70179. shader: string;
  70180. };
  70181. }
  70182. declare module BABYLON {
  70183. /** @hidden */
  70184. export var spriteMapVertexShader: {
  70185. name: string;
  70186. shader: string;
  70187. };
  70188. }
  70189. declare module BABYLON {
  70190. /**
  70191. * Defines the basic options interface of a SpriteMap
  70192. */
  70193. export interface ISpriteMapOptions {
  70194. /**
  70195. * Vector2 of the number of cells in the grid.
  70196. */
  70197. stageSize?: Vector2;
  70198. /**
  70199. * Vector2 of the size of the output plane in World Units.
  70200. */
  70201. outputSize?: Vector2;
  70202. /**
  70203. * Vector3 of the position of the output plane in World Units.
  70204. */
  70205. outputPosition?: Vector3;
  70206. /**
  70207. * Vector3 of the rotation of the output plane.
  70208. */
  70209. outputRotation?: Vector3;
  70210. /**
  70211. * number of layers that the system will reserve in resources.
  70212. */
  70213. layerCount?: number;
  70214. /**
  70215. * number of max animation frames a single cell will reserve in resources.
  70216. */
  70217. maxAnimationFrames?: number;
  70218. /**
  70219. * number cell index of the base tile when the system compiles.
  70220. */
  70221. baseTile?: number;
  70222. /**
  70223. * boolean flip the sprite after its been repositioned by the framing data.
  70224. */
  70225. flipU?: boolean;
  70226. /**
  70227. * Vector3 scalar of the global RGB values of the SpriteMap.
  70228. */
  70229. colorMultiply?: Vector3;
  70230. }
  70231. /**
  70232. * Defines the IDisposable interface in order to be cleanable from resources.
  70233. */
  70234. export interface ISpriteMap extends IDisposable {
  70235. /**
  70236. * String name of the SpriteMap.
  70237. */
  70238. name: string;
  70239. /**
  70240. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70241. */
  70242. atlasJSON: ISpriteJSONAtlas;
  70243. /**
  70244. * Texture of the SpriteMap.
  70245. */
  70246. spriteSheet: Texture;
  70247. /**
  70248. * The parameters to initialize the SpriteMap with.
  70249. */
  70250. options: ISpriteMapOptions;
  70251. }
  70252. /**
  70253. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70254. */
  70255. export class SpriteMap implements ISpriteMap {
  70256. /** The Name of the spriteMap */
  70257. name: string;
  70258. /** The JSON file with the frame and meta data */
  70259. atlasJSON: ISpriteJSONAtlas;
  70260. /** The systems Sprite Sheet Texture */
  70261. spriteSheet: Texture;
  70262. /** Arguments passed with the Constructor */
  70263. options: ISpriteMapOptions;
  70264. /** Public Sprite Storage array, parsed from atlasJSON */
  70265. sprites: Array<ISpriteJSONSprite>;
  70266. /** Returns the Number of Sprites in the System */
  70267. get spriteCount(): number;
  70268. /** Returns the Position of Output Plane*/
  70269. get position(): Vector3;
  70270. /** Returns the Position of Output Plane*/
  70271. set position(v: Vector3);
  70272. /** Returns the Rotation of Output Plane*/
  70273. get rotation(): Vector3;
  70274. /** Returns the Rotation of Output Plane*/
  70275. set rotation(v: Vector3);
  70276. /** Sets the AnimationMap*/
  70277. get animationMap(): RawTexture;
  70278. /** Sets the AnimationMap*/
  70279. set animationMap(v: RawTexture);
  70280. /** Scene that the SpriteMap was created in */
  70281. private _scene;
  70282. /** Texture Buffer of Float32 that holds tile frame data*/
  70283. private _frameMap;
  70284. /** Texture Buffers of Float32 that holds tileMap data*/
  70285. private _tileMaps;
  70286. /** Texture Buffer of Float32 that holds Animation Data*/
  70287. private _animationMap;
  70288. /** Custom ShaderMaterial Central to the System*/
  70289. private _material;
  70290. /** Custom ShaderMaterial Central to the System*/
  70291. private _output;
  70292. /** Systems Time Ticker*/
  70293. private _time;
  70294. /**
  70295. * Creates a new SpriteMap
  70296. * @param name defines the SpriteMaps Name
  70297. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70298. * @param spriteSheet is the Texture that the Sprites are on.
  70299. * @param options a basic deployment configuration
  70300. * @param scene The Scene that the map is deployed on
  70301. */
  70302. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70303. /**
  70304. * Returns tileID location
  70305. * @returns Vector2 the cell position ID
  70306. */
  70307. getTileID(): Vector2;
  70308. /**
  70309. * Gets the UV location of the mouse over the SpriteMap.
  70310. * @returns Vector2 the UV position of the mouse interaction
  70311. */
  70312. getMousePosition(): Vector2;
  70313. /**
  70314. * Creates the "frame" texture Buffer
  70315. * -------------------------------------
  70316. * Structure of frames
  70317. * "filename": "Falling-Water-2.png",
  70318. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70319. * "rotated": true,
  70320. * "trimmed": true,
  70321. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70322. * "sourceSize": {"w":32,"h":32}
  70323. * @returns RawTexture of the frameMap
  70324. */
  70325. private _createFrameBuffer;
  70326. /**
  70327. * Creates the tileMap texture Buffer
  70328. * @param buffer normally and array of numbers, or a false to generate from scratch
  70329. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70330. * @returns RawTexture of the tileMap
  70331. */
  70332. private _createTileBuffer;
  70333. /**
  70334. * Modifies the data of the tileMaps
  70335. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70336. * @param pos is the iVector2 Coordinates of the Tile
  70337. * @param tile The SpriteIndex of the new Tile
  70338. */
  70339. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70340. /**
  70341. * Creates the animationMap texture Buffer
  70342. * @param buffer normally and array of numbers, or a false to generate from scratch
  70343. * @returns RawTexture of the animationMap
  70344. */
  70345. private _createTileAnimationBuffer;
  70346. /**
  70347. * Modifies the data of the animationMap
  70348. * @param cellID is the Index of the Sprite
  70349. * @param _frame is the target Animation frame
  70350. * @param toCell is the Target Index of the next frame of the animation
  70351. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70352. * @param speed is a global scalar of the time variable on the map.
  70353. */
  70354. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70355. /**
  70356. * Exports the .tilemaps file
  70357. */
  70358. saveTileMaps(): void;
  70359. /**
  70360. * Imports the .tilemaps file
  70361. * @param url of the .tilemaps file
  70362. */
  70363. loadTileMaps(url: string): void;
  70364. /**
  70365. * Release associated resources
  70366. */
  70367. dispose(): void;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /**
  70372. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70373. * @see http://doc.babylonjs.com/babylon101/sprites
  70374. */
  70375. export class SpritePackedManager extends SpriteManager {
  70376. /** defines the packed manager's name */
  70377. name: string;
  70378. /**
  70379. * Creates a new sprite manager from a packed sprite sheet
  70380. * @param name defines the manager's name
  70381. * @param imgUrl defines the sprite sheet url
  70382. * @param capacity defines the maximum allowed number of sprites
  70383. * @param scene defines the hosting scene
  70384. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70385. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70386. * @param samplingMode defines the smapling mode to use with spritesheet
  70387. * @param fromPacked set to true; do not alter
  70388. */
  70389. constructor(
  70390. /** defines the packed manager's name */
  70391. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /**
  70396. * Defines the list of states available for a task inside a AssetsManager
  70397. */
  70398. export enum AssetTaskState {
  70399. /**
  70400. * Initialization
  70401. */
  70402. INIT = 0,
  70403. /**
  70404. * Running
  70405. */
  70406. RUNNING = 1,
  70407. /**
  70408. * Done
  70409. */
  70410. DONE = 2,
  70411. /**
  70412. * Error
  70413. */
  70414. ERROR = 3
  70415. }
  70416. /**
  70417. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70418. */
  70419. export abstract class AbstractAssetTask {
  70420. /**
  70421. * Task name
  70422. */ name: string;
  70423. /**
  70424. * Callback called when the task is successful
  70425. */
  70426. onSuccess: (task: any) => void;
  70427. /**
  70428. * Callback called when the task is not successful
  70429. */
  70430. onError: (task: any, message?: string, exception?: any) => void;
  70431. /**
  70432. * Creates a new AssetsManager
  70433. * @param name defines the name of the task
  70434. */
  70435. constructor(
  70436. /**
  70437. * Task name
  70438. */ name: string);
  70439. private _isCompleted;
  70440. private _taskState;
  70441. private _errorObject;
  70442. /**
  70443. * Get if the task is completed
  70444. */
  70445. get isCompleted(): boolean;
  70446. /**
  70447. * Gets the current state of the task
  70448. */
  70449. get taskState(): AssetTaskState;
  70450. /**
  70451. * Gets the current error object (if task is in error)
  70452. */
  70453. get errorObject(): {
  70454. message?: string;
  70455. exception?: any;
  70456. };
  70457. /**
  70458. * Internal only
  70459. * @hidden
  70460. */
  70461. _setErrorObject(message?: string, exception?: any): void;
  70462. /**
  70463. * Execute the current task
  70464. * @param scene defines the scene where you want your assets to be loaded
  70465. * @param onSuccess is a callback called when the task is successfully executed
  70466. * @param onError is a callback called if an error occurs
  70467. */
  70468. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70469. /**
  70470. * Execute the current task
  70471. * @param scene defines the scene where you want your assets to be loaded
  70472. * @param onSuccess is a callback called when the task is successfully executed
  70473. * @param onError is a callback called if an error occurs
  70474. */
  70475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70476. /**
  70477. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70478. * This can be used with failed tasks that have the reason for failure fixed.
  70479. */
  70480. reset(): void;
  70481. private onErrorCallback;
  70482. private onDoneCallback;
  70483. }
  70484. /**
  70485. * Define the interface used by progress events raised during assets loading
  70486. */
  70487. export interface IAssetsProgressEvent {
  70488. /**
  70489. * Defines the number of remaining tasks to process
  70490. */
  70491. remainingCount: number;
  70492. /**
  70493. * Defines the total number of tasks
  70494. */
  70495. totalCount: number;
  70496. /**
  70497. * Defines the task that was just processed
  70498. */
  70499. task: AbstractAssetTask;
  70500. }
  70501. /**
  70502. * Class used to share progress information about assets loading
  70503. */
  70504. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70505. /**
  70506. * Defines the number of remaining tasks to process
  70507. */
  70508. remainingCount: number;
  70509. /**
  70510. * Defines the total number of tasks
  70511. */
  70512. totalCount: number;
  70513. /**
  70514. * Defines the task that was just processed
  70515. */
  70516. task: AbstractAssetTask;
  70517. /**
  70518. * Creates a AssetsProgressEvent
  70519. * @param remainingCount defines the number of remaining tasks to process
  70520. * @param totalCount defines the total number of tasks
  70521. * @param task defines the task that was just processed
  70522. */
  70523. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70524. }
  70525. /**
  70526. * Define a task used by AssetsManager to load meshes
  70527. */
  70528. export class MeshAssetTask extends AbstractAssetTask {
  70529. /**
  70530. * Defines the name of the task
  70531. */
  70532. name: string;
  70533. /**
  70534. * Defines the list of mesh's names you want to load
  70535. */
  70536. meshesNames: any;
  70537. /**
  70538. * Defines the root url to use as a base to load your meshes and associated resources
  70539. */
  70540. rootUrl: string;
  70541. /**
  70542. * Defines the filename or File of the scene to load from
  70543. */
  70544. sceneFilename: string | File;
  70545. /**
  70546. * Gets the list of loaded meshes
  70547. */
  70548. loadedMeshes: Array<AbstractMesh>;
  70549. /**
  70550. * Gets the list of loaded particle systems
  70551. */
  70552. loadedParticleSystems: Array<IParticleSystem>;
  70553. /**
  70554. * Gets the list of loaded skeletons
  70555. */
  70556. loadedSkeletons: Array<Skeleton>;
  70557. /**
  70558. * Gets the list of loaded animation groups
  70559. */
  70560. loadedAnimationGroups: Array<AnimationGroup>;
  70561. /**
  70562. * Callback called when the task is successful
  70563. */
  70564. onSuccess: (task: MeshAssetTask) => void;
  70565. /**
  70566. * Callback called when the task is successful
  70567. */
  70568. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70569. /**
  70570. * Creates a new MeshAssetTask
  70571. * @param name defines the name of the task
  70572. * @param meshesNames defines the list of mesh's names you want to load
  70573. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70574. * @param sceneFilename defines the filename or File of the scene to load from
  70575. */
  70576. constructor(
  70577. /**
  70578. * Defines the name of the task
  70579. */
  70580. name: string,
  70581. /**
  70582. * Defines the list of mesh's names you want to load
  70583. */
  70584. meshesNames: any,
  70585. /**
  70586. * Defines the root url to use as a base to load your meshes and associated resources
  70587. */
  70588. rootUrl: string,
  70589. /**
  70590. * Defines the filename or File of the scene to load from
  70591. */
  70592. sceneFilename: string | File);
  70593. /**
  70594. * Execute the current task
  70595. * @param scene defines the scene where you want your assets to be loaded
  70596. * @param onSuccess is a callback called when the task is successfully executed
  70597. * @param onError is a callback called if an error occurs
  70598. */
  70599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70600. }
  70601. /**
  70602. * Define a task used by AssetsManager to load text content
  70603. */
  70604. export class TextFileAssetTask extends AbstractAssetTask {
  70605. /**
  70606. * Defines the name of the task
  70607. */
  70608. name: string;
  70609. /**
  70610. * Defines the location of the file to load
  70611. */
  70612. url: string;
  70613. /**
  70614. * Gets the loaded text string
  70615. */
  70616. text: string;
  70617. /**
  70618. * Callback called when the task is successful
  70619. */
  70620. onSuccess: (task: TextFileAssetTask) => void;
  70621. /**
  70622. * Callback called when the task is successful
  70623. */
  70624. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70625. /**
  70626. * Creates a new TextFileAssetTask object
  70627. * @param name defines the name of the task
  70628. * @param url defines the location of the file to load
  70629. */
  70630. constructor(
  70631. /**
  70632. * Defines the name of the task
  70633. */
  70634. name: string,
  70635. /**
  70636. * Defines the location of the file to load
  70637. */
  70638. url: string);
  70639. /**
  70640. * Execute the current task
  70641. * @param scene defines the scene where you want your assets to be loaded
  70642. * @param onSuccess is a callback called when the task is successfully executed
  70643. * @param onError is a callback called if an error occurs
  70644. */
  70645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70646. }
  70647. /**
  70648. * Define a task used by AssetsManager to load binary data
  70649. */
  70650. export class BinaryFileAssetTask extends AbstractAssetTask {
  70651. /**
  70652. * Defines the name of the task
  70653. */
  70654. name: string;
  70655. /**
  70656. * Defines the location of the file to load
  70657. */
  70658. url: string;
  70659. /**
  70660. * Gets the lodaded data (as an array buffer)
  70661. */
  70662. data: ArrayBuffer;
  70663. /**
  70664. * Callback called when the task is successful
  70665. */
  70666. onSuccess: (task: BinaryFileAssetTask) => void;
  70667. /**
  70668. * Callback called when the task is successful
  70669. */
  70670. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70671. /**
  70672. * Creates a new BinaryFileAssetTask object
  70673. * @param name defines the name of the new task
  70674. * @param url defines the location of the file to load
  70675. */
  70676. constructor(
  70677. /**
  70678. * Defines the name of the task
  70679. */
  70680. name: string,
  70681. /**
  70682. * Defines the location of the file to load
  70683. */
  70684. url: string);
  70685. /**
  70686. * Execute the current task
  70687. * @param scene defines the scene where you want your assets to be loaded
  70688. * @param onSuccess is a callback called when the task is successfully executed
  70689. * @param onError is a callback called if an error occurs
  70690. */
  70691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70692. }
  70693. /**
  70694. * Define a task used by AssetsManager to load images
  70695. */
  70696. export class ImageAssetTask extends AbstractAssetTask {
  70697. /**
  70698. * Defines the name of the task
  70699. */
  70700. name: string;
  70701. /**
  70702. * Defines the location of the image to load
  70703. */
  70704. url: string;
  70705. /**
  70706. * Gets the loaded images
  70707. */
  70708. image: HTMLImageElement;
  70709. /**
  70710. * Callback called when the task is successful
  70711. */
  70712. onSuccess: (task: ImageAssetTask) => void;
  70713. /**
  70714. * Callback called when the task is successful
  70715. */
  70716. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70717. /**
  70718. * Creates a new ImageAssetTask
  70719. * @param name defines the name of the task
  70720. * @param url defines the location of the image to load
  70721. */
  70722. constructor(
  70723. /**
  70724. * Defines the name of the task
  70725. */
  70726. name: string,
  70727. /**
  70728. * Defines the location of the image to load
  70729. */
  70730. url: string);
  70731. /**
  70732. * Execute the current task
  70733. * @param scene defines the scene where you want your assets to be loaded
  70734. * @param onSuccess is a callback called when the task is successfully executed
  70735. * @param onError is a callback called if an error occurs
  70736. */
  70737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70738. }
  70739. /**
  70740. * Defines the interface used by texture loading tasks
  70741. */
  70742. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70743. /**
  70744. * Gets the loaded texture
  70745. */
  70746. texture: TEX;
  70747. }
  70748. /**
  70749. * Define a task used by AssetsManager to load 2D textures
  70750. */
  70751. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70752. /**
  70753. * Defines the name of the task
  70754. */
  70755. name: string;
  70756. /**
  70757. * Defines the location of the file to load
  70758. */
  70759. url: string;
  70760. /**
  70761. * Defines if mipmap should not be generated (default is false)
  70762. */
  70763. noMipmap?: boolean | undefined;
  70764. /**
  70765. * Defines if texture must be inverted on Y axis (default is true)
  70766. */
  70767. invertY: boolean;
  70768. /**
  70769. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70770. */
  70771. samplingMode: number;
  70772. /**
  70773. * Gets the loaded texture
  70774. */
  70775. texture: Texture;
  70776. /**
  70777. * Callback called when the task is successful
  70778. */
  70779. onSuccess: (task: TextureAssetTask) => void;
  70780. /**
  70781. * Callback called when the task is successful
  70782. */
  70783. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70784. /**
  70785. * Creates a new TextureAssetTask object
  70786. * @param name defines the name of the task
  70787. * @param url defines the location of the file to load
  70788. * @param noMipmap defines if mipmap should not be generated (default is false)
  70789. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70790. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70791. */
  70792. constructor(
  70793. /**
  70794. * Defines the name of the task
  70795. */
  70796. name: string,
  70797. /**
  70798. * Defines the location of the file to load
  70799. */
  70800. url: string,
  70801. /**
  70802. * Defines if mipmap should not be generated (default is false)
  70803. */
  70804. noMipmap?: boolean | undefined,
  70805. /**
  70806. * Defines if texture must be inverted on Y axis (default is true)
  70807. */
  70808. invertY?: boolean,
  70809. /**
  70810. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70811. */
  70812. samplingMode?: number);
  70813. /**
  70814. * Execute the current task
  70815. * @param scene defines the scene where you want your assets to be loaded
  70816. * @param onSuccess is a callback called when the task is successfully executed
  70817. * @param onError is a callback called if an error occurs
  70818. */
  70819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70820. }
  70821. /**
  70822. * Define a task used by AssetsManager to load cube textures
  70823. */
  70824. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70825. /**
  70826. * Defines the name of the task
  70827. */
  70828. name: string;
  70829. /**
  70830. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70831. */
  70832. url: string;
  70833. /**
  70834. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70835. */
  70836. extensions?: string[] | undefined;
  70837. /**
  70838. * Defines if mipmaps should not be generated (default is false)
  70839. */
  70840. noMipmap?: boolean | undefined;
  70841. /**
  70842. * Defines the explicit list of files (undefined by default)
  70843. */
  70844. files?: string[] | undefined;
  70845. /**
  70846. * Gets the loaded texture
  70847. */
  70848. texture: CubeTexture;
  70849. /**
  70850. * Callback called when the task is successful
  70851. */
  70852. onSuccess: (task: CubeTextureAssetTask) => void;
  70853. /**
  70854. * Callback called when the task is successful
  70855. */
  70856. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70857. /**
  70858. * Creates a new CubeTextureAssetTask
  70859. * @param name defines the name of the task
  70860. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70861. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70862. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70863. * @param files defines the explicit list of files (undefined by default)
  70864. */
  70865. constructor(
  70866. /**
  70867. * Defines the name of the task
  70868. */
  70869. name: string,
  70870. /**
  70871. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70872. */
  70873. url: string,
  70874. /**
  70875. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70876. */
  70877. extensions?: string[] | undefined,
  70878. /**
  70879. * Defines if mipmaps should not be generated (default is false)
  70880. */
  70881. noMipmap?: boolean | undefined,
  70882. /**
  70883. * Defines the explicit list of files (undefined by default)
  70884. */
  70885. files?: string[] | undefined);
  70886. /**
  70887. * Execute the current task
  70888. * @param scene defines the scene where you want your assets to be loaded
  70889. * @param onSuccess is a callback called when the task is successfully executed
  70890. * @param onError is a callback called if an error occurs
  70891. */
  70892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70893. }
  70894. /**
  70895. * Define a task used by AssetsManager to load HDR cube textures
  70896. */
  70897. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70898. /**
  70899. * Defines the name of the task
  70900. */
  70901. name: string;
  70902. /**
  70903. * Defines the location of the file to load
  70904. */
  70905. url: string;
  70906. /**
  70907. * Defines the desired size (the more it increases the longer the generation will be)
  70908. */
  70909. size: number;
  70910. /**
  70911. * Defines if mipmaps should not be generated (default is false)
  70912. */
  70913. noMipmap: boolean;
  70914. /**
  70915. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70916. */
  70917. generateHarmonics: boolean;
  70918. /**
  70919. * 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)
  70920. */
  70921. gammaSpace: boolean;
  70922. /**
  70923. * Internal Use Only
  70924. */
  70925. reserved: boolean;
  70926. /**
  70927. * Gets the loaded texture
  70928. */
  70929. texture: HDRCubeTexture;
  70930. /**
  70931. * Callback called when the task is successful
  70932. */
  70933. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70934. /**
  70935. * Callback called when the task is successful
  70936. */
  70937. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70938. /**
  70939. * Creates a new HDRCubeTextureAssetTask object
  70940. * @param name defines the name of the task
  70941. * @param url defines the location of the file to load
  70942. * @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.
  70943. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70944. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70945. * @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)
  70946. * @param reserved Internal use only
  70947. */
  70948. constructor(
  70949. /**
  70950. * Defines the name of the task
  70951. */
  70952. name: string,
  70953. /**
  70954. * Defines the location of the file to load
  70955. */
  70956. url: string,
  70957. /**
  70958. * Defines the desired size (the more it increases the longer the generation will be)
  70959. */
  70960. size: number,
  70961. /**
  70962. * Defines if mipmaps should not be generated (default is false)
  70963. */
  70964. noMipmap?: boolean,
  70965. /**
  70966. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70967. */
  70968. generateHarmonics?: boolean,
  70969. /**
  70970. * 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)
  70971. */
  70972. gammaSpace?: boolean,
  70973. /**
  70974. * Internal Use Only
  70975. */
  70976. reserved?: boolean);
  70977. /**
  70978. * Execute the current task
  70979. * @param scene defines the scene where you want your assets to be loaded
  70980. * @param onSuccess is a callback called when the task is successfully executed
  70981. * @param onError is a callback called if an error occurs
  70982. */
  70983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70984. }
  70985. /**
  70986. * Define a task used by AssetsManager to load Equirectangular cube textures
  70987. */
  70988. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70989. /**
  70990. * Defines the name of the task
  70991. */
  70992. name: string;
  70993. /**
  70994. * Defines the location of the file to load
  70995. */
  70996. url: string;
  70997. /**
  70998. * Defines the desired size (the more it increases the longer the generation will be)
  70999. */
  71000. size: number;
  71001. /**
  71002. * Defines if mipmaps should not be generated (default is false)
  71003. */
  71004. noMipmap: boolean;
  71005. /**
  71006. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71007. * but the standard material would require them in Gamma space) (default is true)
  71008. */
  71009. gammaSpace: boolean;
  71010. /**
  71011. * Gets the loaded texture
  71012. */
  71013. texture: EquiRectangularCubeTexture;
  71014. /**
  71015. * Callback called when the task is successful
  71016. */
  71017. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71018. /**
  71019. * Callback called when the task is successful
  71020. */
  71021. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71022. /**
  71023. * Creates a new EquiRectangularCubeTextureAssetTask object
  71024. * @param name defines the name of the task
  71025. * @param url defines the location of the file to load
  71026. * @param size defines the desired size (the more it increases the longer the generation will be)
  71027. * If the size is omitted this implies you are using a preprocessed cubemap.
  71028. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71029. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71030. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71031. * (default is true)
  71032. */
  71033. constructor(
  71034. /**
  71035. * Defines the name of the task
  71036. */
  71037. name: string,
  71038. /**
  71039. * Defines the location of the file to load
  71040. */
  71041. url: string,
  71042. /**
  71043. * Defines the desired size (the more it increases the longer the generation will be)
  71044. */
  71045. size: number,
  71046. /**
  71047. * Defines if mipmaps should not be generated (default is false)
  71048. */
  71049. noMipmap?: boolean,
  71050. /**
  71051. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71052. * but the standard material would require them in Gamma space) (default is true)
  71053. */
  71054. gammaSpace?: boolean);
  71055. /**
  71056. * Execute the current task
  71057. * @param scene defines the scene where you want your assets to be loaded
  71058. * @param onSuccess is a callback called when the task is successfully executed
  71059. * @param onError is a callback called if an error occurs
  71060. */
  71061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71062. }
  71063. /**
  71064. * This class can be used to easily import assets into a scene
  71065. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71066. */
  71067. export class AssetsManager {
  71068. private _scene;
  71069. private _isLoading;
  71070. protected _tasks: AbstractAssetTask[];
  71071. protected _waitingTasksCount: number;
  71072. protected _totalTasksCount: number;
  71073. /**
  71074. * Callback called when all tasks are processed
  71075. */
  71076. onFinish: (tasks: AbstractAssetTask[]) => void;
  71077. /**
  71078. * Callback called when a task is successful
  71079. */
  71080. onTaskSuccess: (task: AbstractAssetTask) => void;
  71081. /**
  71082. * Callback called when a task had an error
  71083. */
  71084. onTaskError: (task: AbstractAssetTask) => void;
  71085. /**
  71086. * Callback called when a task is done (whatever the result is)
  71087. */
  71088. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71089. /**
  71090. * Observable called when all tasks are processed
  71091. */
  71092. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71093. /**
  71094. * Observable called when a task had an error
  71095. */
  71096. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71097. /**
  71098. * Observable called when all tasks were executed
  71099. */
  71100. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71101. /**
  71102. * Observable called when a task is done (whatever the result is)
  71103. */
  71104. onProgressObservable: Observable<IAssetsProgressEvent>;
  71105. /**
  71106. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71108. */
  71109. useDefaultLoadingScreen: boolean;
  71110. /**
  71111. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71112. * when all assets have been downloaded.
  71113. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71114. */
  71115. autoHideLoadingUI: boolean;
  71116. /**
  71117. * Creates a new AssetsManager
  71118. * @param scene defines the scene to work on
  71119. */
  71120. constructor(scene: Scene);
  71121. /**
  71122. * Add a MeshAssetTask to the list of active tasks
  71123. * @param taskName defines the name of the new task
  71124. * @param meshesNames defines the name of meshes to load
  71125. * @param rootUrl defines the root url to use to locate files
  71126. * @param sceneFilename defines the filename of the scene file
  71127. * @returns a new MeshAssetTask object
  71128. */
  71129. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71130. /**
  71131. * Add a TextFileAssetTask to the list of active tasks
  71132. * @param taskName defines the name of the new task
  71133. * @param url defines the url of the file to load
  71134. * @returns a new TextFileAssetTask object
  71135. */
  71136. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71137. /**
  71138. * Add a BinaryFileAssetTask to the list of active tasks
  71139. * @param taskName defines the name of the new task
  71140. * @param url defines the url of the file to load
  71141. * @returns a new BinaryFileAssetTask object
  71142. */
  71143. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71144. /**
  71145. * Add a ImageAssetTask to the list of active tasks
  71146. * @param taskName defines the name of the new task
  71147. * @param url defines the url of the file to load
  71148. * @returns a new ImageAssetTask object
  71149. */
  71150. addImageTask(taskName: string, url: string): ImageAssetTask;
  71151. /**
  71152. * Add a TextureAssetTask to the list of active tasks
  71153. * @param taskName defines the name of the new task
  71154. * @param url defines the url of the file to load
  71155. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71156. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71157. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71158. * @returns a new TextureAssetTask object
  71159. */
  71160. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71161. /**
  71162. * Add a CubeTextureAssetTask to the list of active tasks
  71163. * @param taskName defines the name of the new task
  71164. * @param url defines the url of the file to load
  71165. * @param extensions defines the extension to use to load the cube map (can be null)
  71166. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71167. * @param files defines the list of files to load (can be null)
  71168. * @returns a new CubeTextureAssetTask object
  71169. */
  71170. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71171. /**
  71172. *
  71173. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71174. * @param taskName defines the name of the new task
  71175. * @param url defines the url of the file to load
  71176. * @param size defines the size you want for the cubemap (can be null)
  71177. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71178. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71179. * @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)
  71180. * @param reserved Internal use only
  71181. * @returns a new HDRCubeTextureAssetTask object
  71182. */
  71183. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71184. /**
  71185. *
  71186. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71187. * @param taskName defines the name of the new task
  71188. * @param url defines the url of the file to load
  71189. * @param size defines the size you want for the cubemap (can be null)
  71190. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71191. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71192. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71193. * @returns a new EquiRectangularCubeTextureAssetTask object
  71194. */
  71195. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71196. /**
  71197. * Remove a task from the assets manager.
  71198. * @param task the task to remove
  71199. */
  71200. removeTask(task: AbstractAssetTask): void;
  71201. private _decreaseWaitingTasksCount;
  71202. private _runTask;
  71203. /**
  71204. * Reset the AssetsManager and remove all tasks
  71205. * @return the current instance of the AssetsManager
  71206. */
  71207. reset(): AssetsManager;
  71208. /**
  71209. * Start the loading process
  71210. * @return the current instance of the AssetsManager
  71211. */
  71212. load(): AssetsManager;
  71213. /**
  71214. * Start the loading process as an async operation
  71215. * @return a promise returning the list of failed tasks
  71216. */
  71217. loadAsync(): Promise<void>;
  71218. }
  71219. }
  71220. declare module BABYLON {
  71221. /**
  71222. * Wrapper class for promise with external resolve and reject.
  71223. */
  71224. export class Deferred<T> {
  71225. /**
  71226. * The promise associated with this deferred object.
  71227. */
  71228. readonly promise: Promise<T>;
  71229. private _resolve;
  71230. private _reject;
  71231. /**
  71232. * The resolve method of the promise associated with this deferred object.
  71233. */
  71234. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71235. /**
  71236. * The reject method of the promise associated with this deferred object.
  71237. */
  71238. get reject(): (reason?: any) => void;
  71239. /**
  71240. * Constructor for this deferred object.
  71241. */
  71242. constructor();
  71243. }
  71244. }
  71245. declare module BABYLON {
  71246. /**
  71247. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71248. */
  71249. export class MeshExploder {
  71250. private _centerMesh;
  71251. private _meshes;
  71252. private _meshesOrigins;
  71253. private _toCenterVectors;
  71254. private _scaledDirection;
  71255. private _newPosition;
  71256. private _centerPosition;
  71257. /**
  71258. * Explodes meshes from a center mesh.
  71259. * @param meshes The meshes to explode.
  71260. * @param centerMesh The mesh to be center of explosion.
  71261. */
  71262. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71263. private _setCenterMesh;
  71264. /**
  71265. * Get class name
  71266. * @returns "MeshExploder"
  71267. */
  71268. getClassName(): string;
  71269. /**
  71270. * "Exploded meshes"
  71271. * @returns Array of meshes with the centerMesh at index 0.
  71272. */
  71273. getMeshes(): Array<Mesh>;
  71274. /**
  71275. * Explodes meshes giving a specific direction
  71276. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71277. */
  71278. explode(direction?: number): void;
  71279. }
  71280. }
  71281. declare module BABYLON {
  71282. /**
  71283. * Class used to help managing file picking and drag'n'drop
  71284. */
  71285. export class FilesInput {
  71286. /**
  71287. * List of files ready to be loaded
  71288. */
  71289. static get FilesToLoad(): {
  71290. [key: string]: File;
  71291. };
  71292. /**
  71293. * Callback called when a file is processed
  71294. */
  71295. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71296. private _engine;
  71297. private _currentScene;
  71298. private _sceneLoadedCallback;
  71299. private _progressCallback;
  71300. private _additionalRenderLoopLogicCallback;
  71301. private _textureLoadingCallback;
  71302. private _startingProcessingFilesCallback;
  71303. private _onReloadCallback;
  71304. private _errorCallback;
  71305. private _elementToMonitor;
  71306. private _sceneFileToLoad;
  71307. private _filesToLoad;
  71308. /**
  71309. * Creates a new FilesInput
  71310. * @param engine defines the rendering engine
  71311. * @param scene defines the hosting scene
  71312. * @param sceneLoadedCallback callback called when scene is loaded
  71313. * @param progressCallback callback called to track progress
  71314. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71315. * @param textureLoadingCallback callback called when a texture is loading
  71316. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71317. * @param onReloadCallback callback called when a reload is requested
  71318. * @param errorCallback callback call if an error occurs
  71319. */
  71320. 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);
  71321. private _dragEnterHandler;
  71322. private _dragOverHandler;
  71323. private _dropHandler;
  71324. /**
  71325. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71326. * @param elementToMonitor defines the DOM element to track
  71327. */
  71328. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71329. /**
  71330. * Release all associated resources
  71331. */
  71332. dispose(): void;
  71333. private renderFunction;
  71334. private drag;
  71335. private drop;
  71336. private _traverseFolder;
  71337. private _processFiles;
  71338. /**
  71339. * Load files from a drop event
  71340. * @param event defines the drop event to use as source
  71341. */
  71342. loadFiles(event: any): void;
  71343. private _processReload;
  71344. /**
  71345. * Reload the current scene from the loaded files
  71346. */
  71347. reload(): void;
  71348. }
  71349. }
  71350. declare module BABYLON {
  71351. /**
  71352. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71354. */
  71355. export class SceneOptimization {
  71356. /**
  71357. * Defines the priority of this optimization (0 by default which means first in the list)
  71358. */
  71359. priority: number;
  71360. /**
  71361. * Gets a string describing the action executed by the current optimization
  71362. * @returns description string
  71363. */
  71364. getDescription(): string;
  71365. /**
  71366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71367. * @param scene defines the current scene where to apply this optimization
  71368. * @param optimizer defines the current optimizer
  71369. * @returns true if everything that can be done was applied
  71370. */
  71371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71372. /**
  71373. * Creates the SceneOptimization object
  71374. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71375. * @param desc defines the description associated with the optimization
  71376. */
  71377. constructor(
  71378. /**
  71379. * Defines the priority of this optimization (0 by default which means first in the list)
  71380. */
  71381. priority?: number);
  71382. }
  71383. /**
  71384. * Defines an optimization used to reduce the size of render target textures
  71385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71386. */
  71387. export class TextureOptimization extends SceneOptimization {
  71388. /**
  71389. * Defines the priority of this optimization (0 by default which means first in the list)
  71390. */
  71391. priority: number;
  71392. /**
  71393. * 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
  71394. */
  71395. maximumSize: number;
  71396. /**
  71397. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71398. */
  71399. step: number;
  71400. /**
  71401. * Gets a string describing the action executed by the current optimization
  71402. * @returns description string
  71403. */
  71404. getDescription(): string;
  71405. /**
  71406. * Creates the TextureOptimization object
  71407. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71408. * @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
  71409. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71410. */
  71411. constructor(
  71412. /**
  71413. * Defines the priority of this optimization (0 by default which means first in the list)
  71414. */
  71415. priority?: number,
  71416. /**
  71417. * 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
  71418. */
  71419. maximumSize?: number,
  71420. /**
  71421. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71422. */
  71423. step?: number);
  71424. /**
  71425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71426. * @param scene defines the current scene where to apply this optimization
  71427. * @param optimizer defines the current optimizer
  71428. * @returns true if everything that can be done was applied
  71429. */
  71430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71431. }
  71432. /**
  71433. * Defines an optimization used to increase or decrease the rendering resolution
  71434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71435. */
  71436. export class HardwareScalingOptimization extends SceneOptimization {
  71437. /**
  71438. * Defines the priority of this optimization (0 by default which means first in the list)
  71439. */
  71440. priority: number;
  71441. /**
  71442. * Defines the maximum scale to use (2 by default)
  71443. */
  71444. maximumScale: number;
  71445. /**
  71446. * Defines the step to use between two passes (0.5 by default)
  71447. */
  71448. step: number;
  71449. private _currentScale;
  71450. private _directionOffset;
  71451. /**
  71452. * Gets a string describing the action executed by the current optimization
  71453. * @return description string
  71454. */
  71455. getDescription(): string;
  71456. /**
  71457. * Creates the HardwareScalingOptimization object
  71458. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71459. * @param maximumScale defines the maximum scale to use (2 by default)
  71460. * @param step defines the step to use between two passes (0.5 by default)
  71461. */
  71462. constructor(
  71463. /**
  71464. * Defines the priority of this optimization (0 by default which means first in the list)
  71465. */
  71466. priority?: number,
  71467. /**
  71468. * Defines the maximum scale to use (2 by default)
  71469. */
  71470. maximumScale?: number,
  71471. /**
  71472. * Defines the step to use between two passes (0.5 by default)
  71473. */
  71474. step?: number);
  71475. /**
  71476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71477. * @param scene defines the current scene where to apply this optimization
  71478. * @param optimizer defines the current optimizer
  71479. * @returns true if everything that can be done was applied
  71480. */
  71481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71482. }
  71483. /**
  71484. * Defines an optimization used to remove shadows
  71485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71486. */
  71487. export class ShadowsOptimization extends SceneOptimization {
  71488. /**
  71489. * Gets a string describing the action executed by the current optimization
  71490. * @return description string
  71491. */
  71492. getDescription(): string;
  71493. /**
  71494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71495. * @param scene defines the current scene where to apply this optimization
  71496. * @param optimizer defines the current optimizer
  71497. * @returns true if everything that can be done was applied
  71498. */
  71499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71500. }
  71501. /**
  71502. * Defines an optimization used to turn post-processes off
  71503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71504. */
  71505. export class PostProcessesOptimization extends SceneOptimization {
  71506. /**
  71507. * Gets a string describing the action executed by the current optimization
  71508. * @return description string
  71509. */
  71510. getDescription(): string;
  71511. /**
  71512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71513. * @param scene defines the current scene where to apply this optimization
  71514. * @param optimizer defines the current optimizer
  71515. * @returns true if everything that can be done was applied
  71516. */
  71517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71518. }
  71519. /**
  71520. * Defines an optimization used to turn lens flares off
  71521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71522. */
  71523. export class LensFlaresOptimization extends SceneOptimization {
  71524. /**
  71525. * Gets a string describing the action executed by the current optimization
  71526. * @return description string
  71527. */
  71528. getDescription(): string;
  71529. /**
  71530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71531. * @param scene defines the current scene where to apply this optimization
  71532. * @param optimizer defines the current optimizer
  71533. * @returns true if everything that can be done was applied
  71534. */
  71535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71536. }
  71537. /**
  71538. * Defines an optimization based on user defined callback.
  71539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71540. */
  71541. export class CustomOptimization extends SceneOptimization {
  71542. /**
  71543. * Callback called to apply the custom optimization.
  71544. */
  71545. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71546. /**
  71547. * Callback called to get custom description
  71548. */
  71549. onGetDescription: () => string;
  71550. /**
  71551. * Gets a string describing the action executed by the current optimization
  71552. * @returns description string
  71553. */
  71554. getDescription(): string;
  71555. /**
  71556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71557. * @param scene defines the current scene where to apply this optimization
  71558. * @param optimizer defines the current optimizer
  71559. * @returns true if everything that can be done was applied
  71560. */
  71561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71562. }
  71563. /**
  71564. * Defines an optimization used to turn particles off
  71565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71566. */
  71567. export class ParticlesOptimization extends SceneOptimization {
  71568. /**
  71569. * Gets a string describing the action executed by the current optimization
  71570. * @return description string
  71571. */
  71572. getDescription(): string;
  71573. /**
  71574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71575. * @param scene defines the current scene where to apply this optimization
  71576. * @param optimizer defines the current optimizer
  71577. * @returns true if everything that can be done was applied
  71578. */
  71579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71580. }
  71581. /**
  71582. * Defines an optimization used to turn render targets off
  71583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71584. */
  71585. export class RenderTargetsOptimization extends SceneOptimization {
  71586. /**
  71587. * Gets a string describing the action executed by the current optimization
  71588. * @return description string
  71589. */
  71590. getDescription(): string;
  71591. /**
  71592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71593. * @param scene defines the current scene where to apply this optimization
  71594. * @param optimizer defines the current optimizer
  71595. * @returns true if everything that can be done was applied
  71596. */
  71597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71598. }
  71599. /**
  71600. * Defines an optimization used to merge meshes with compatible materials
  71601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71602. */
  71603. export class MergeMeshesOptimization extends SceneOptimization {
  71604. private static _UpdateSelectionTree;
  71605. /**
  71606. * Gets or sets a boolean which defines if optimization octree has to be updated
  71607. */
  71608. static get UpdateSelectionTree(): boolean;
  71609. /**
  71610. * Gets or sets a boolean which defines if optimization octree has to be updated
  71611. */
  71612. static set UpdateSelectionTree(value: boolean);
  71613. /**
  71614. * Gets a string describing the action executed by the current optimization
  71615. * @return description string
  71616. */
  71617. getDescription(): string;
  71618. private _canBeMerged;
  71619. /**
  71620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71621. * @param scene defines the current scene where to apply this optimization
  71622. * @param optimizer defines the current optimizer
  71623. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71624. * @returns true if everything that can be done was applied
  71625. */
  71626. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71627. }
  71628. /**
  71629. * Defines a list of options used by SceneOptimizer
  71630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71631. */
  71632. export class SceneOptimizerOptions {
  71633. /**
  71634. * Defines the target frame rate to reach (60 by default)
  71635. */
  71636. targetFrameRate: number;
  71637. /**
  71638. * Defines the interval between two checkes (2000ms by default)
  71639. */
  71640. trackerDuration: number;
  71641. /**
  71642. * Gets the list of optimizations to apply
  71643. */
  71644. optimizations: SceneOptimization[];
  71645. /**
  71646. * Creates a new list of options used by SceneOptimizer
  71647. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71648. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71649. */
  71650. constructor(
  71651. /**
  71652. * Defines the target frame rate to reach (60 by default)
  71653. */
  71654. targetFrameRate?: number,
  71655. /**
  71656. * Defines the interval between two checkes (2000ms by default)
  71657. */
  71658. trackerDuration?: number);
  71659. /**
  71660. * Add a new optimization
  71661. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71662. * @returns the current SceneOptimizerOptions
  71663. */
  71664. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71665. /**
  71666. * Add a new custom optimization
  71667. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71668. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71669. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71670. * @returns the current SceneOptimizerOptions
  71671. */
  71672. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71673. /**
  71674. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71675. * @param targetFrameRate defines the target frame rate (60 by default)
  71676. * @returns a SceneOptimizerOptions object
  71677. */
  71678. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71679. /**
  71680. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71681. * @param targetFrameRate defines the target frame rate (60 by default)
  71682. * @returns a SceneOptimizerOptions object
  71683. */
  71684. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71685. /**
  71686. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71687. * @param targetFrameRate defines the target frame rate (60 by default)
  71688. * @returns a SceneOptimizerOptions object
  71689. */
  71690. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71691. }
  71692. /**
  71693. * Class used to run optimizations in order to reach a target frame rate
  71694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71695. */
  71696. export class SceneOptimizer implements IDisposable {
  71697. private _isRunning;
  71698. private _options;
  71699. private _scene;
  71700. private _currentPriorityLevel;
  71701. private _targetFrameRate;
  71702. private _trackerDuration;
  71703. private _currentFrameRate;
  71704. private _sceneDisposeObserver;
  71705. private _improvementMode;
  71706. /**
  71707. * Defines an observable called when the optimizer reaches the target frame rate
  71708. */
  71709. onSuccessObservable: Observable<SceneOptimizer>;
  71710. /**
  71711. * Defines an observable called when the optimizer enables an optimization
  71712. */
  71713. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71714. /**
  71715. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71716. */
  71717. onFailureObservable: Observable<SceneOptimizer>;
  71718. /**
  71719. * Gets a boolean indicating if the optimizer is in improvement mode
  71720. */
  71721. get isInImprovementMode(): boolean;
  71722. /**
  71723. * Gets the current priority level (0 at start)
  71724. */
  71725. get currentPriorityLevel(): number;
  71726. /**
  71727. * Gets the current frame rate checked by the SceneOptimizer
  71728. */
  71729. get currentFrameRate(): number;
  71730. /**
  71731. * Gets or sets the current target frame rate (60 by default)
  71732. */
  71733. get targetFrameRate(): number;
  71734. /**
  71735. * Gets or sets the current target frame rate (60 by default)
  71736. */
  71737. set targetFrameRate(value: number);
  71738. /**
  71739. * Gets or sets the current interval between two checks (every 2000ms by default)
  71740. */
  71741. get trackerDuration(): number;
  71742. /**
  71743. * Gets or sets the current interval between two checks (every 2000ms by default)
  71744. */
  71745. set trackerDuration(value: number);
  71746. /**
  71747. * Gets the list of active optimizations
  71748. */
  71749. get optimizations(): SceneOptimization[];
  71750. /**
  71751. * Creates a new SceneOptimizer
  71752. * @param scene defines the scene to work on
  71753. * @param options defines the options to use with the SceneOptimizer
  71754. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71755. * @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)
  71756. */
  71757. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71758. /**
  71759. * Stops the current optimizer
  71760. */
  71761. stop(): void;
  71762. /**
  71763. * Reset the optimizer to initial step (current priority level = 0)
  71764. */
  71765. reset(): void;
  71766. /**
  71767. * Start the optimizer. By default it will try to reach a specific framerate
  71768. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71769. */
  71770. start(): void;
  71771. private _checkCurrentState;
  71772. /**
  71773. * Release all resources
  71774. */
  71775. dispose(): void;
  71776. /**
  71777. * Helper function to create a SceneOptimizer with one single line of code
  71778. * @param scene defines the scene to work on
  71779. * @param options defines the options to use with the SceneOptimizer
  71780. * @param onSuccess defines a callback to call on success
  71781. * @param onFailure defines a callback to call on failure
  71782. * @returns the new SceneOptimizer object
  71783. */
  71784. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71785. }
  71786. }
  71787. declare module BABYLON {
  71788. /**
  71789. * Class used to serialize a scene into a string
  71790. */
  71791. export class SceneSerializer {
  71792. /**
  71793. * Clear cache used by a previous serialization
  71794. */
  71795. static ClearCache(): void;
  71796. /**
  71797. * Serialize a scene into a JSON compatible object
  71798. * @param scene defines the scene to serialize
  71799. * @returns a JSON compatible object
  71800. */
  71801. static Serialize(scene: Scene): any;
  71802. /**
  71803. * Serialize a mesh into a JSON compatible object
  71804. * @param toSerialize defines the mesh to serialize
  71805. * @param withParents defines if parents must be serialized as well
  71806. * @param withChildren defines if children must be serialized as well
  71807. * @returns a JSON compatible object
  71808. */
  71809. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71810. }
  71811. }
  71812. declare module BABYLON {
  71813. /**
  71814. * Class used to host texture specific utilities
  71815. */
  71816. export class TextureTools {
  71817. /**
  71818. * Uses the GPU to create a copy texture rescaled at a given size
  71819. * @param texture Texture to copy from
  71820. * @param width defines the desired width
  71821. * @param height defines the desired height
  71822. * @param useBilinearMode defines if bilinear mode has to be used
  71823. * @return the generated texture
  71824. */
  71825. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71826. }
  71827. }
  71828. declare module BABYLON {
  71829. /**
  71830. * This represents the different options available for the video capture.
  71831. */
  71832. export interface VideoRecorderOptions {
  71833. /** Defines the mime type of the video. */
  71834. mimeType: string;
  71835. /** Defines the FPS the video should be recorded at. */
  71836. fps: number;
  71837. /** Defines the chunk size for the recording data. */
  71838. recordChunckSize: number;
  71839. /** The audio tracks to attach to the recording. */
  71840. audioTracks?: MediaStreamTrack[];
  71841. }
  71842. /**
  71843. * This can help with recording videos from BabylonJS.
  71844. * This is based on the available WebRTC functionalities of the browser.
  71845. *
  71846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71847. */
  71848. export class VideoRecorder {
  71849. private static readonly _defaultOptions;
  71850. /**
  71851. * Returns whether or not the VideoRecorder is available in your browser.
  71852. * @param engine Defines the Babylon Engine.
  71853. * @returns true if supported otherwise false.
  71854. */
  71855. static IsSupported(engine: Engine): boolean;
  71856. private readonly _options;
  71857. private _canvas;
  71858. private _mediaRecorder;
  71859. private _recordedChunks;
  71860. private _fileName;
  71861. private _resolve;
  71862. private _reject;
  71863. /**
  71864. * True when a recording is already in progress.
  71865. */
  71866. get isRecording(): boolean;
  71867. /**
  71868. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71869. * @param engine Defines the BabylonJS Engine you wish to record.
  71870. * @param options Defines options that can be used to customize the capture.
  71871. */
  71872. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71873. /**
  71874. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71875. */
  71876. stopRecording(): void;
  71877. /**
  71878. * Starts recording the canvas for a max duration specified in parameters.
  71879. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71880. * If null no automatic download will start and you can rely on the promise to get the data back.
  71881. * @param maxDuration Defines the maximum recording time in seconds.
  71882. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71883. * @return A promise callback at the end of the recording with the video data in Blob.
  71884. */
  71885. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71886. /**
  71887. * Releases internal resources used during the recording.
  71888. */
  71889. dispose(): void;
  71890. private _handleDataAvailable;
  71891. private _handleError;
  71892. private _handleStop;
  71893. }
  71894. }
  71895. declare module BABYLON {
  71896. /**
  71897. * Class containing a set of static utilities functions for screenshots
  71898. */
  71899. export class ScreenshotTools {
  71900. /**
  71901. * Captures a screenshot of the current rendering
  71902. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71903. * @param engine defines the rendering engine
  71904. * @param camera defines the source camera
  71905. * @param size This parameter can be set to a single number or to an object with the
  71906. * following (optional) properties: precision, width, height. If a single number is passed,
  71907. * it will be used for both width and height. If an object is passed, the screenshot size
  71908. * will be derived from the parameters. The precision property is a multiplier allowing
  71909. * rendering at a higher or lower resolution
  71910. * @param successCallback defines the callback receives a single parameter which contains the
  71911. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71912. * src parameter of an <img> to display it
  71913. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71914. * Check your browser for supported MIME types
  71915. */
  71916. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71917. /**
  71918. * Captures a screenshot of the current rendering
  71919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71920. * @param engine defines the rendering engine
  71921. * @param camera defines the source camera
  71922. * @param size This parameter can be set to a single number or to an object with the
  71923. * following (optional) properties: precision, width, height. If a single number is passed,
  71924. * it will be used for both width and height. If an object is passed, the screenshot size
  71925. * will be derived from the parameters. The precision property is a multiplier allowing
  71926. * rendering at a higher or lower resolution
  71927. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71928. * Check your browser for supported MIME types
  71929. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71930. * to the src parameter of an <img> to display it
  71931. */
  71932. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71933. /**
  71934. * Generates an image screenshot from the specified camera.
  71935. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71936. * @param engine The engine to use for rendering
  71937. * @param camera The camera to use for rendering
  71938. * @param size This parameter can be set to a single number or to an object with the
  71939. * following (optional) properties: precision, width, height. If a single number is passed,
  71940. * it will be used for both width and height. If an object is passed, the screenshot size
  71941. * will be derived from the parameters. The precision property is a multiplier allowing
  71942. * rendering at a higher or lower resolution
  71943. * @param successCallback The callback receives a single parameter which contains the
  71944. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71945. * src parameter of an <img> to display it
  71946. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71947. * Check your browser for supported MIME types
  71948. * @param samples Texture samples (default: 1)
  71949. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71950. * @param fileName A name for for the downloaded file.
  71951. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71952. */
  71953. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71954. /**
  71955. * Generates an image screenshot from the specified camera.
  71956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71957. * @param engine The engine to use for rendering
  71958. * @param camera The camera to use for rendering
  71959. * @param size This parameter can be set to a single number or to an object with the
  71960. * following (optional) properties: precision, width, height. If a single number is passed,
  71961. * it will be used for both width and height. If an object is passed, the screenshot size
  71962. * will be derived from the parameters. The precision property is a multiplier allowing
  71963. * rendering at a higher or lower resolution
  71964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71965. * Check your browser for supported MIME types
  71966. * @param samples Texture samples (default: 1)
  71967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71968. * @param fileName A name for for the downloaded file.
  71969. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71970. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71971. * to the src parameter of an <img> to display it
  71972. */
  71973. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71974. /**
  71975. * Gets height and width for screenshot size
  71976. * @private
  71977. */
  71978. private static _getScreenshotSize;
  71979. }
  71980. }
  71981. declare module BABYLON {
  71982. /**
  71983. * Interface for a data buffer
  71984. */
  71985. export interface IDataBuffer {
  71986. /**
  71987. * Reads bytes from the data buffer.
  71988. * @param byteOffset The byte offset to read
  71989. * @param byteLength The byte length to read
  71990. * @returns A promise that resolves when the bytes are read
  71991. */
  71992. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71993. /**
  71994. * The byte length of the buffer.
  71995. */
  71996. readonly byteLength: number;
  71997. }
  71998. /**
  71999. * Utility class for reading from a data buffer
  72000. */
  72001. export class DataReader {
  72002. /**
  72003. * The data buffer associated with this data reader.
  72004. */
  72005. readonly buffer: IDataBuffer;
  72006. /**
  72007. * The current byte offset from the beginning of the data buffer.
  72008. */
  72009. byteOffset: number;
  72010. private _dataView;
  72011. private _dataByteOffset;
  72012. /**
  72013. * Constructor
  72014. * @param buffer The buffer to read
  72015. */
  72016. constructor(buffer: IDataBuffer);
  72017. /**
  72018. * Loads the given byte length.
  72019. * @param byteLength The byte length to load
  72020. * @returns A promise that resolves when the load is complete
  72021. */
  72022. loadAsync(byteLength: number): Promise<void>;
  72023. /**
  72024. * Read a unsigned 32-bit integer from the currently loaded data range.
  72025. * @returns The 32-bit integer read
  72026. */
  72027. readUint32(): number;
  72028. /**
  72029. * Read a byte array from the currently loaded data range.
  72030. * @param byteLength The byte length to read
  72031. * @returns The byte array read
  72032. */
  72033. readUint8Array(byteLength: number): Uint8Array;
  72034. /**
  72035. * Read a string from the currently loaded data range.
  72036. * @param byteLength The byte length to read
  72037. * @returns The string read
  72038. */
  72039. readString(byteLength: number): string;
  72040. /**
  72041. * Skips the given byte length the currently loaded data range.
  72042. * @param byteLength The byte length to skip
  72043. */
  72044. skipBytes(byteLength: number): void;
  72045. }
  72046. }
  72047. declare module BABYLON {
  72048. /**
  72049. * Class for storing data to local storage if available or in-memory storage otherwise
  72050. */
  72051. export class DataStorage {
  72052. private static _Storage;
  72053. private static _GetStorage;
  72054. /**
  72055. * Reads a string from the data storage
  72056. * @param key The key to read
  72057. * @param defaultValue The value if the key doesn't exist
  72058. * @returns The string value
  72059. */
  72060. static ReadString(key: string, defaultValue: string): string;
  72061. /**
  72062. * Writes a string to the data storage
  72063. * @param key The key to write
  72064. * @param value The value to write
  72065. */
  72066. static WriteString(key: string, value: string): void;
  72067. /**
  72068. * Reads a boolean from the data storage
  72069. * @param key The key to read
  72070. * @param defaultValue The value if the key doesn't exist
  72071. * @returns The boolean value
  72072. */
  72073. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72074. /**
  72075. * Writes a boolean to the data storage
  72076. * @param key The key to write
  72077. * @param value The value to write
  72078. */
  72079. static WriteBoolean(key: string, value: boolean): void;
  72080. /**
  72081. * Reads a number from the data storage
  72082. * @param key The key to read
  72083. * @param defaultValue The value if the key doesn't exist
  72084. * @returns The number value
  72085. */
  72086. static ReadNumber(key: string, defaultValue: number): number;
  72087. /**
  72088. * Writes a number to the data storage
  72089. * @param key The key to write
  72090. * @param value The value to write
  72091. */
  72092. static WriteNumber(key: string, value: number): void;
  72093. }
  72094. }
  72095. declare module BABYLON {
  72096. /**
  72097. * An interface for all Hit test features
  72098. */
  72099. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72100. /**
  72101. * Triggered when new babylon (transformed) hit test results are available
  72102. */
  72103. onHitTestResultObservable: Observable<T[]>;
  72104. }
  72105. /**
  72106. * Options used for hit testing
  72107. */
  72108. export interface IWebXRLegacyHitTestOptions {
  72109. /**
  72110. * Only test when user interacted with the scene. Default - hit test every frame
  72111. */
  72112. testOnPointerDownOnly?: boolean;
  72113. /**
  72114. * The node to use to transform the local results to world coordinates
  72115. */
  72116. worldParentNode?: TransformNode;
  72117. }
  72118. /**
  72119. * Interface defining the babylon result of raycasting/hit-test
  72120. */
  72121. export interface IWebXRLegacyHitResult {
  72122. /**
  72123. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72124. */
  72125. transformationMatrix: Matrix;
  72126. /**
  72127. * The native hit test result
  72128. */
  72129. xrHitResult: XRHitResult | XRHitTestResult;
  72130. }
  72131. /**
  72132. * The currently-working hit-test module.
  72133. * Hit test (or Ray-casting) is used to interact with the real world.
  72134. * For further information read here - https://github.com/immersive-web/hit-test
  72135. */
  72136. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72137. /**
  72138. * options to use when constructing this feature
  72139. */
  72140. readonly options: IWebXRLegacyHitTestOptions;
  72141. private _direction;
  72142. private _mat;
  72143. private _onSelectEnabled;
  72144. private _origin;
  72145. /**
  72146. * The module's name
  72147. */
  72148. static readonly Name: string;
  72149. /**
  72150. * The (Babylon) version of this module.
  72151. * This is an integer representing the implementation version.
  72152. * This number does not correspond to the WebXR specs version
  72153. */
  72154. static readonly Version: number;
  72155. /**
  72156. * Populated with the last native XR Hit Results
  72157. */
  72158. lastNativeXRHitResults: XRHitResult[];
  72159. /**
  72160. * Triggered when new babylon (transformed) hit test results are available
  72161. */
  72162. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72163. /**
  72164. * Creates a new instance of the (legacy version) hit test feature
  72165. * @param _xrSessionManager an instance of WebXRSessionManager
  72166. * @param options options to use when constructing this feature
  72167. */
  72168. constructor(_xrSessionManager: WebXRSessionManager,
  72169. /**
  72170. * options to use when constructing this feature
  72171. */
  72172. options?: IWebXRLegacyHitTestOptions);
  72173. /**
  72174. * execute a hit test with an XR Ray
  72175. *
  72176. * @param xrSession a native xrSession that will execute this hit test
  72177. * @param xrRay the ray (position and direction) to use for ray-casting
  72178. * @param referenceSpace native XR reference space to use for the hit-test
  72179. * @param filter filter function that will filter the results
  72180. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72181. */
  72182. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72183. /**
  72184. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72185. * @param event the (select) event to use to select with
  72186. * @param referenceSpace the reference space to use for this hit test
  72187. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72188. */
  72189. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72190. /**
  72191. * attach this feature
  72192. * Will usually be called by the features manager
  72193. *
  72194. * @returns true if successful.
  72195. */
  72196. attach(): boolean;
  72197. /**
  72198. * detach this feature.
  72199. * Will usually be called by the features manager
  72200. *
  72201. * @returns true if successful.
  72202. */
  72203. detach(): boolean;
  72204. /**
  72205. * Dispose this feature and all of the resources attached
  72206. */
  72207. dispose(): void;
  72208. protected _onXRFrame(frame: XRFrame): void;
  72209. private _onHitTestResults;
  72210. private _onSelect;
  72211. }
  72212. }
  72213. declare module BABYLON {
  72214. /**
  72215. * Options used for hit testing (version 2)
  72216. */
  72217. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72218. /**
  72219. * Do not create a permanent hit test. Will usually be used when only
  72220. * transient inputs are needed.
  72221. */
  72222. disablePermanentHitTest?: boolean;
  72223. /**
  72224. * Enable transient (for example touch-based) hit test inspections
  72225. */
  72226. enableTransientHitTest?: boolean;
  72227. /**
  72228. * Offset ray for the permanent hit test
  72229. */
  72230. offsetRay?: Vector3;
  72231. /**
  72232. * Offset ray for the transient hit test
  72233. */
  72234. transientOffsetRay?: Vector3;
  72235. /**
  72236. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72237. */
  72238. useReferenceSpace?: boolean;
  72239. }
  72240. /**
  72241. * Interface defining the babylon result of hit-test
  72242. */
  72243. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72244. /**
  72245. * The input source that generated this hit test (if transient)
  72246. */
  72247. inputSource?: XRInputSource;
  72248. /**
  72249. * Is this a transient hit test
  72250. */
  72251. isTransient?: boolean;
  72252. /**
  72253. * Position of the hit test result
  72254. */
  72255. position: Vector3;
  72256. /**
  72257. * Rotation of the hit test result
  72258. */
  72259. rotationQuaternion: Quaternion;
  72260. /**
  72261. * The native hit test result
  72262. */
  72263. xrHitResult: XRHitTestResult;
  72264. }
  72265. /**
  72266. * The currently-working hit-test module.
  72267. * Hit test (or Ray-casting) is used to interact with the real world.
  72268. * For further information read here - https://github.com/immersive-web/hit-test
  72269. *
  72270. * Tested on chrome (mobile) 80.
  72271. */
  72272. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72273. /**
  72274. * options to use when constructing this feature
  72275. */
  72276. readonly options: IWebXRHitTestOptions;
  72277. private _tmpMat;
  72278. private _tmpPos;
  72279. private _tmpQuat;
  72280. private _transientXrHitTestSource;
  72281. private _xrHitTestSource;
  72282. private initHitTestSource;
  72283. /**
  72284. * The module's name
  72285. */
  72286. static readonly Name: string;
  72287. /**
  72288. * The (Babylon) version of this module.
  72289. * This is an integer representing the implementation version.
  72290. * This number does not correspond to the WebXR specs version
  72291. */
  72292. static readonly Version: number;
  72293. /**
  72294. * When set to true, each hit test will have its own position/rotation objects
  72295. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72296. * the developers will clone them or copy them as they see fit.
  72297. */
  72298. autoCloneTransformation: boolean;
  72299. /**
  72300. * Triggered when new babylon (transformed) hit test results are available
  72301. */
  72302. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72303. /**
  72304. * Use this to temporarily pause hit test checks.
  72305. */
  72306. paused: boolean;
  72307. /**
  72308. * Creates a new instance of the hit test feature
  72309. * @param _xrSessionManager an instance of WebXRSessionManager
  72310. * @param options options to use when constructing this feature
  72311. */
  72312. constructor(_xrSessionManager: WebXRSessionManager,
  72313. /**
  72314. * options to use when constructing this feature
  72315. */
  72316. options?: IWebXRHitTestOptions);
  72317. /**
  72318. * attach this feature
  72319. * Will usually be called by the features manager
  72320. *
  72321. * @returns true if successful.
  72322. */
  72323. attach(): boolean;
  72324. /**
  72325. * detach this feature.
  72326. * Will usually be called by the features manager
  72327. *
  72328. * @returns true if successful.
  72329. */
  72330. detach(): boolean;
  72331. /**
  72332. * Dispose this feature and all of the resources attached
  72333. */
  72334. dispose(): void;
  72335. protected _onXRFrame(frame: XRFrame): void;
  72336. private _processWebXRHitTestResult;
  72337. }
  72338. }
  72339. declare module BABYLON {
  72340. /**
  72341. * Configuration options of the anchor system
  72342. */
  72343. export interface IWebXRAnchorSystemOptions {
  72344. /**
  72345. * a node that will be used to convert local to world coordinates
  72346. */
  72347. worldParentNode?: TransformNode;
  72348. /**
  72349. * If set to true a reference of the created anchors will be kept until the next session starts
  72350. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72351. */
  72352. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72353. }
  72354. /**
  72355. * A babylon container for an XR Anchor
  72356. */
  72357. export interface IWebXRAnchor {
  72358. /**
  72359. * A babylon-assigned ID for this anchor
  72360. */
  72361. id: number;
  72362. /**
  72363. * Transformation matrix to apply to an object attached to this anchor
  72364. */
  72365. transformationMatrix: Matrix;
  72366. /**
  72367. * The native anchor object
  72368. */
  72369. xrAnchor: XRAnchor;
  72370. /**
  72371. * if defined, this object will be constantly updated by the anchor's position and rotation
  72372. */
  72373. attachedNode?: TransformNode;
  72374. }
  72375. /**
  72376. * An implementation of the anchor system for WebXR.
  72377. * For further information see https://github.com/immersive-web/anchors/
  72378. */
  72379. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72380. private _options;
  72381. private _lastFrameDetected;
  72382. private _trackedAnchors;
  72383. private _referenceSpaceForFrameAnchors;
  72384. private _futureAnchors;
  72385. /**
  72386. * The module's name
  72387. */
  72388. static readonly Name: string;
  72389. /**
  72390. * The (Babylon) version of this module.
  72391. * This is an integer representing the implementation version.
  72392. * This number does not correspond to the WebXR specs version
  72393. */
  72394. static readonly Version: number;
  72395. /**
  72396. * Observers registered here will be executed when a new anchor was added to the session
  72397. */
  72398. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72399. /**
  72400. * Observers registered here will be executed when an anchor was removed from the session
  72401. */
  72402. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72403. /**
  72404. * Observers registered here will be executed when an existing anchor updates
  72405. * This can execute N times every frame
  72406. */
  72407. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72408. /**
  72409. * Set the reference space to use for anchor creation, when not using a hit test.
  72410. * Will default to the session's reference space if not defined
  72411. */
  72412. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72413. /**
  72414. * constructs a new anchor system
  72415. * @param _xrSessionManager an instance of WebXRSessionManager
  72416. * @param _options configuration object for this feature
  72417. */
  72418. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72419. private _tmpVector;
  72420. private _tmpQuaternion;
  72421. private _populateTmpTransformation;
  72422. /**
  72423. * Create a new anchor point using a hit test result at a specific point in the scene
  72424. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72425. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72426. *
  72427. * @param hitTestResult The hit test result to use for this anchor creation
  72428. * @param position an optional position offset for this anchor
  72429. * @param rotationQuaternion an optional rotation offset for this anchor
  72430. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72431. */
  72432. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72433. /**
  72434. * Add a new anchor at a specific position and rotation
  72435. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72436. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72437. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72438. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72439. *
  72440. * @param position the position in which to add an anchor
  72441. * @param rotationQuaternion an optional rotation for the anchor transformation
  72442. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72443. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72444. */
  72445. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72446. /**
  72447. * detach this feature.
  72448. * Will usually be called by the features manager
  72449. *
  72450. * @returns true if successful.
  72451. */
  72452. detach(): boolean;
  72453. /**
  72454. * Dispose this feature and all of the resources attached
  72455. */
  72456. dispose(): void;
  72457. protected _onXRFrame(frame: XRFrame): void;
  72458. /**
  72459. * avoiding using Array.find for global support.
  72460. * @param xrAnchor the plane to find in the array
  72461. */
  72462. private _findIndexInAnchorArray;
  72463. private _updateAnchorWithXRFrame;
  72464. private _createAnchorAtTransformation;
  72465. }
  72466. }
  72467. declare module BABYLON {
  72468. /**
  72469. * Options used in the plane detector module
  72470. */
  72471. export interface IWebXRPlaneDetectorOptions {
  72472. /**
  72473. * The node to use to transform the local results to world coordinates
  72474. */
  72475. worldParentNode?: TransformNode;
  72476. /**
  72477. * If set to true a reference of the created planes will be kept until the next session starts
  72478. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72479. */
  72480. doNotRemovePlanesOnSessionEnded?: boolean;
  72481. }
  72482. /**
  72483. * A babylon interface for a WebXR plane.
  72484. * A Plane is actually a polygon, built from N points in space
  72485. *
  72486. * Supported in chrome 79, not supported in canary 81 ATM
  72487. */
  72488. export interface IWebXRPlane {
  72489. /**
  72490. * a babylon-assigned ID for this polygon
  72491. */
  72492. id: number;
  72493. /**
  72494. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72495. */
  72496. polygonDefinition: Array<Vector3>;
  72497. /**
  72498. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72499. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72500. */
  72501. transformationMatrix: Matrix;
  72502. /**
  72503. * the native xr-plane object
  72504. */
  72505. xrPlane: XRPlane;
  72506. }
  72507. /**
  72508. * The plane detector is used to detect planes in the real world when in AR
  72509. * For more information see https://github.com/immersive-web/real-world-geometry/
  72510. */
  72511. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72512. private _options;
  72513. private _detectedPlanes;
  72514. private _enabled;
  72515. private _lastFrameDetected;
  72516. /**
  72517. * The module's name
  72518. */
  72519. static readonly Name: string;
  72520. /**
  72521. * The (Babylon) version of this module.
  72522. * This is an integer representing the implementation version.
  72523. * This number does not correspond to the WebXR specs version
  72524. */
  72525. static readonly Version: number;
  72526. /**
  72527. * Observers registered here will be executed when a new plane was added to the session
  72528. */
  72529. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72530. /**
  72531. * Observers registered here will be executed when a plane is no longer detected in the session
  72532. */
  72533. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72534. /**
  72535. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72536. * This can execute N times every frame
  72537. */
  72538. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72539. /**
  72540. * construct a new Plane Detector
  72541. * @param _xrSessionManager an instance of xr Session manager
  72542. * @param _options configuration to use when constructing this feature
  72543. */
  72544. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72545. /**
  72546. * detach this feature.
  72547. * Will usually be called by the features manager
  72548. *
  72549. * @returns true if successful.
  72550. */
  72551. detach(): boolean;
  72552. /**
  72553. * Dispose this feature and all of the resources attached
  72554. */
  72555. dispose(): void;
  72556. protected _onXRFrame(frame: XRFrame): void;
  72557. private _init;
  72558. private _updatePlaneWithXRPlane;
  72559. /**
  72560. * avoiding using Array.find for global support.
  72561. * @param xrPlane the plane to find in the array
  72562. */
  72563. private findIndexInPlaneArray;
  72564. }
  72565. }
  72566. declare module BABYLON {
  72567. /**
  72568. * Options interface for the background remover plugin
  72569. */
  72570. export interface IWebXRBackgroundRemoverOptions {
  72571. /**
  72572. * Further background meshes to disable when entering AR
  72573. */
  72574. backgroundMeshes?: AbstractMesh[];
  72575. /**
  72576. * flags to configure the removal of the environment helper.
  72577. * If not set, the entire background will be removed. If set, flags should be set as well.
  72578. */
  72579. environmentHelperRemovalFlags?: {
  72580. /**
  72581. * Should the skybox be removed (default false)
  72582. */
  72583. skyBox?: boolean;
  72584. /**
  72585. * Should the ground be removed (default false)
  72586. */
  72587. ground?: boolean;
  72588. };
  72589. /**
  72590. * don't disable the environment helper
  72591. */
  72592. ignoreEnvironmentHelper?: boolean;
  72593. }
  72594. /**
  72595. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72596. */
  72597. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72598. /**
  72599. * read-only options to be used in this module
  72600. */
  72601. readonly options: IWebXRBackgroundRemoverOptions;
  72602. /**
  72603. * The module's name
  72604. */
  72605. static readonly Name: string;
  72606. /**
  72607. * The (Babylon) version of this module.
  72608. * This is an integer representing the implementation version.
  72609. * This number does not correspond to the WebXR specs version
  72610. */
  72611. static readonly Version: number;
  72612. /**
  72613. * registered observers will be triggered when the background state changes
  72614. */
  72615. onBackgroundStateChangedObservable: Observable<boolean>;
  72616. /**
  72617. * constructs a new background remover module
  72618. * @param _xrSessionManager the session manager for this module
  72619. * @param options read-only options to be used in this module
  72620. */
  72621. constructor(_xrSessionManager: WebXRSessionManager,
  72622. /**
  72623. * read-only options to be used in this module
  72624. */
  72625. options?: IWebXRBackgroundRemoverOptions);
  72626. /**
  72627. * attach this feature
  72628. * Will usually be called by the features manager
  72629. *
  72630. * @returns true if successful.
  72631. */
  72632. attach(): boolean;
  72633. /**
  72634. * detach this feature.
  72635. * Will usually be called by the features manager
  72636. *
  72637. * @returns true if successful.
  72638. */
  72639. detach(): boolean;
  72640. /**
  72641. * Dispose this feature and all of the resources attached
  72642. */
  72643. dispose(): void;
  72644. protected _onXRFrame(_xrFrame: XRFrame): void;
  72645. private _setBackgroundState;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /**
  72650. * Options for the controller physics feature
  72651. */
  72652. export class IWebXRControllerPhysicsOptions {
  72653. /**
  72654. * Should the headset get its own impostor
  72655. */
  72656. enableHeadsetImpostor?: boolean;
  72657. /**
  72658. * Optional parameters for the headset impostor
  72659. */
  72660. headsetImpostorParams?: {
  72661. /**
  72662. * The type of impostor to create. Default is sphere
  72663. */
  72664. impostorType: number;
  72665. /**
  72666. * the size of the impostor. Defaults to 10cm
  72667. */
  72668. impostorSize?: number | {
  72669. width: number;
  72670. height: number;
  72671. depth: number;
  72672. };
  72673. /**
  72674. * Friction definitions
  72675. */
  72676. friction?: number;
  72677. /**
  72678. * Restitution
  72679. */
  72680. restitution?: number;
  72681. };
  72682. /**
  72683. * The physics properties of the future impostors
  72684. */
  72685. physicsProperties?: {
  72686. /**
  72687. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72688. * Note that this requires a physics engine that supports mesh impostors!
  72689. */
  72690. useControllerMesh?: boolean;
  72691. /**
  72692. * The type of impostor to create. Default is sphere
  72693. */
  72694. impostorType?: number;
  72695. /**
  72696. * the size of the impostor. Defaults to 10cm
  72697. */
  72698. impostorSize?: number | {
  72699. width: number;
  72700. height: number;
  72701. depth: number;
  72702. };
  72703. /**
  72704. * Friction definitions
  72705. */
  72706. friction?: number;
  72707. /**
  72708. * Restitution
  72709. */
  72710. restitution?: number;
  72711. };
  72712. /**
  72713. * the xr input to use with this pointer selection
  72714. */
  72715. xrInput: WebXRInput;
  72716. }
  72717. /**
  72718. * Add physics impostor to your webxr controllers,
  72719. * including naive calculation of their linear and angular velocity
  72720. */
  72721. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72722. private readonly _options;
  72723. private _attachController;
  72724. private _controllers;
  72725. private _debugMode;
  72726. private _delta;
  72727. private _headsetImpostor?;
  72728. private _headsetMesh?;
  72729. private _lastTimestamp;
  72730. private _tmpQuaternion;
  72731. private _tmpVector;
  72732. /**
  72733. * The module's name
  72734. */
  72735. static readonly Name: string;
  72736. /**
  72737. * The (Babylon) version of this module.
  72738. * This is an integer representing the implementation version.
  72739. * This number does not correspond to the webxr specs version
  72740. */
  72741. static readonly Version: number;
  72742. /**
  72743. * Construct a new Controller Physics Feature
  72744. * @param _xrSessionManager the corresponding xr session manager
  72745. * @param _options options to create this feature with
  72746. */
  72747. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72748. /**
  72749. * @hidden
  72750. * enable debugging - will show console outputs and the impostor mesh
  72751. */
  72752. _enablePhysicsDebug(): void;
  72753. /**
  72754. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72755. * @param xrController the controller to add
  72756. */
  72757. addController(xrController: WebXRInputSource): void;
  72758. /**
  72759. * attach this feature
  72760. * Will usually be called by the features manager
  72761. *
  72762. * @returns true if successful.
  72763. */
  72764. attach(): boolean;
  72765. /**
  72766. * detach this feature.
  72767. * Will usually be called by the features manager
  72768. *
  72769. * @returns true if successful.
  72770. */
  72771. detach(): boolean;
  72772. /**
  72773. * Get the headset impostor, if enabled
  72774. * @returns the impostor
  72775. */
  72776. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72777. /**
  72778. * Get the physics impostor of a specific controller.
  72779. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72780. * @param controller the controller or the controller id of which to get the impostor
  72781. * @returns the impostor or null
  72782. */
  72783. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72784. /**
  72785. * Update the physics properties provided in the constructor
  72786. * @param newProperties the new properties object
  72787. */
  72788. setPhysicsProperties(newProperties: {
  72789. impostorType?: number;
  72790. impostorSize?: number | {
  72791. width: number;
  72792. height: number;
  72793. depth: number;
  72794. };
  72795. friction?: number;
  72796. restitution?: number;
  72797. }): void;
  72798. protected _onXRFrame(_xrFrame: any): void;
  72799. private _detachController;
  72800. }
  72801. }
  72802. declare module BABYLON {
  72803. /**
  72804. * The motion controller class for all microsoft mixed reality controllers
  72805. */
  72806. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72807. protected readonly _mapping: {
  72808. defaultButton: {
  72809. valueNodeName: string;
  72810. unpressedNodeName: string;
  72811. pressedNodeName: string;
  72812. };
  72813. defaultAxis: {
  72814. valueNodeName: string;
  72815. minNodeName: string;
  72816. maxNodeName: string;
  72817. };
  72818. buttons: {
  72819. "xr-standard-trigger": {
  72820. rootNodeName: string;
  72821. componentProperty: string;
  72822. states: string[];
  72823. };
  72824. "xr-standard-squeeze": {
  72825. rootNodeName: string;
  72826. componentProperty: string;
  72827. states: string[];
  72828. };
  72829. "xr-standard-touchpad": {
  72830. rootNodeName: string;
  72831. labelAnchorNodeName: string;
  72832. touchPointNodeName: string;
  72833. };
  72834. "xr-standard-thumbstick": {
  72835. rootNodeName: string;
  72836. componentProperty: string;
  72837. states: string[];
  72838. };
  72839. };
  72840. axes: {
  72841. "xr-standard-touchpad": {
  72842. "x-axis": {
  72843. rootNodeName: string;
  72844. };
  72845. "y-axis": {
  72846. rootNodeName: string;
  72847. };
  72848. };
  72849. "xr-standard-thumbstick": {
  72850. "x-axis": {
  72851. rootNodeName: string;
  72852. };
  72853. "y-axis": {
  72854. rootNodeName: string;
  72855. };
  72856. };
  72857. };
  72858. };
  72859. /**
  72860. * The base url used to load the left and right controller models
  72861. */
  72862. static MODEL_BASE_URL: string;
  72863. /**
  72864. * The name of the left controller model file
  72865. */
  72866. static MODEL_LEFT_FILENAME: string;
  72867. /**
  72868. * The name of the right controller model file
  72869. */
  72870. static MODEL_RIGHT_FILENAME: string;
  72871. profileId: string;
  72872. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72873. protected _getFilenameAndPath(): {
  72874. filename: string;
  72875. path: string;
  72876. };
  72877. protected _getModelLoadingConstraints(): boolean;
  72878. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72879. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72880. protected _updateModel(): void;
  72881. }
  72882. }
  72883. declare module BABYLON {
  72884. /**
  72885. * The motion controller class for oculus touch (quest, rift).
  72886. * This class supports legacy mapping as well the standard xr mapping
  72887. */
  72888. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72889. private _forceLegacyControllers;
  72890. private _modelRootNode;
  72891. /**
  72892. * The base url used to load the left and right controller models
  72893. */
  72894. static MODEL_BASE_URL: string;
  72895. /**
  72896. * The name of the left controller model file
  72897. */
  72898. static MODEL_LEFT_FILENAME: string;
  72899. /**
  72900. * The name of the right controller model file
  72901. */
  72902. static MODEL_RIGHT_FILENAME: string;
  72903. /**
  72904. * Base Url for the Quest controller model.
  72905. */
  72906. static QUEST_MODEL_BASE_URL: string;
  72907. profileId: string;
  72908. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72909. protected _getFilenameAndPath(): {
  72910. filename: string;
  72911. path: string;
  72912. };
  72913. protected _getModelLoadingConstraints(): boolean;
  72914. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72915. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72916. protected _updateModel(): void;
  72917. /**
  72918. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72919. * between the touch and touch 2.
  72920. */
  72921. private _isQuest;
  72922. }
  72923. }
  72924. declare module BABYLON {
  72925. /**
  72926. * The motion controller class for the standard HTC-Vive controllers
  72927. */
  72928. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72929. private _modelRootNode;
  72930. /**
  72931. * The base url used to load the left and right controller models
  72932. */
  72933. static MODEL_BASE_URL: string;
  72934. /**
  72935. * File name for the controller model.
  72936. */
  72937. static MODEL_FILENAME: string;
  72938. profileId: string;
  72939. /**
  72940. * Create a new Vive motion controller object
  72941. * @param scene the scene to use to create this controller
  72942. * @param gamepadObject the corresponding gamepad object
  72943. * @param handedness the handedness of the controller
  72944. */
  72945. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72946. protected _getFilenameAndPath(): {
  72947. filename: string;
  72948. path: string;
  72949. };
  72950. protected _getModelLoadingConstraints(): boolean;
  72951. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72952. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72953. protected _updateModel(): void;
  72954. }
  72955. }
  72956. declare module BABYLON {
  72957. /**
  72958. * A cursor which tracks a point on a path
  72959. */
  72960. export class PathCursor {
  72961. private path;
  72962. /**
  72963. * Stores path cursor callbacks for when an onchange event is triggered
  72964. */
  72965. private _onchange;
  72966. /**
  72967. * The value of the path cursor
  72968. */
  72969. value: number;
  72970. /**
  72971. * The animation array of the path cursor
  72972. */
  72973. animations: Animation[];
  72974. /**
  72975. * Initializes the path cursor
  72976. * @param path The path to track
  72977. */
  72978. constructor(path: Path2);
  72979. /**
  72980. * Gets the cursor point on the path
  72981. * @returns A point on the path cursor at the cursor location
  72982. */
  72983. getPoint(): Vector3;
  72984. /**
  72985. * Moves the cursor ahead by the step amount
  72986. * @param step The amount to move the cursor forward
  72987. * @returns This path cursor
  72988. */
  72989. moveAhead(step?: number): PathCursor;
  72990. /**
  72991. * Moves the cursor behind by the step amount
  72992. * @param step The amount to move the cursor back
  72993. * @returns This path cursor
  72994. */
  72995. moveBack(step?: number): PathCursor;
  72996. /**
  72997. * Moves the cursor by the step amount
  72998. * If the step amount is greater than one, an exception is thrown
  72999. * @param step The amount to move the cursor
  73000. * @returns This path cursor
  73001. */
  73002. move(step: number): PathCursor;
  73003. /**
  73004. * Ensures that the value is limited between zero and one
  73005. * @returns This path cursor
  73006. */
  73007. private ensureLimits;
  73008. /**
  73009. * Runs onchange callbacks on change (used by the animation engine)
  73010. * @returns This path cursor
  73011. */
  73012. private raiseOnChange;
  73013. /**
  73014. * Executes a function on change
  73015. * @param f A path cursor onchange callback
  73016. * @returns This path cursor
  73017. */
  73018. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73019. }
  73020. }
  73021. declare module BABYLON {
  73022. /** @hidden */
  73023. export var blurPixelShader: {
  73024. name: string;
  73025. shader: string;
  73026. };
  73027. }
  73028. declare module BABYLON {
  73029. /** @hidden */
  73030. export var pointCloudVertexDeclaration: {
  73031. name: string;
  73032. shader: string;
  73033. };
  73034. }
  73035. // Mixins
  73036. interface Window {
  73037. mozIndexedDB: IDBFactory;
  73038. webkitIndexedDB: IDBFactory;
  73039. msIndexedDB: IDBFactory;
  73040. webkitURL: typeof URL;
  73041. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73042. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73043. WebGLRenderingContext: WebGLRenderingContext;
  73044. MSGesture: MSGesture;
  73045. CANNON: any;
  73046. AudioContext: AudioContext;
  73047. webkitAudioContext: AudioContext;
  73048. PointerEvent: any;
  73049. Math: Math;
  73050. Uint8Array: Uint8ArrayConstructor;
  73051. Float32Array: Float32ArrayConstructor;
  73052. mozURL: typeof URL;
  73053. msURL: typeof URL;
  73054. VRFrameData: any; // WebVR, from specs 1.1
  73055. DracoDecoderModule: any;
  73056. setImmediate(handler: (...args: any[]) => void): number;
  73057. }
  73058. interface HTMLCanvasElement {
  73059. requestPointerLock(): void;
  73060. msRequestPointerLock?(): void;
  73061. mozRequestPointerLock?(): void;
  73062. webkitRequestPointerLock?(): void;
  73063. /** Track wether a record is in progress */
  73064. isRecording: boolean;
  73065. /** Capture Stream method defined by some browsers */
  73066. captureStream(fps?: number): MediaStream;
  73067. }
  73068. interface CanvasRenderingContext2D {
  73069. msImageSmoothingEnabled: boolean;
  73070. }
  73071. interface MouseEvent {
  73072. mozMovementX: number;
  73073. mozMovementY: number;
  73074. webkitMovementX: number;
  73075. webkitMovementY: number;
  73076. msMovementX: number;
  73077. msMovementY: number;
  73078. }
  73079. interface Navigator {
  73080. mozGetVRDevices: (any: any) => any;
  73081. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73082. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73083. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73084. webkitGetGamepads(): Gamepad[];
  73085. msGetGamepads(): Gamepad[];
  73086. webkitGamepads(): Gamepad[];
  73087. }
  73088. interface HTMLVideoElement {
  73089. mozSrcObject: any;
  73090. }
  73091. interface Math {
  73092. fround(x: number): number;
  73093. imul(a: number, b: number): number;
  73094. }
  73095. interface WebGLRenderingContext {
  73096. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73097. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73098. vertexAttribDivisor(index: number, divisor: number): void;
  73099. createVertexArray(): any;
  73100. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73101. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73102. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73103. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73104. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73105. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73106. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73107. // Queries
  73108. createQuery(): WebGLQuery;
  73109. deleteQuery(query: WebGLQuery): void;
  73110. beginQuery(target: number, query: WebGLQuery): void;
  73111. endQuery(target: number): void;
  73112. getQueryParameter(query: WebGLQuery, pname: number): any;
  73113. getQuery(target: number, pname: number): any;
  73114. MAX_SAMPLES: number;
  73115. RGBA8: number;
  73116. READ_FRAMEBUFFER: number;
  73117. DRAW_FRAMEBUFFER: number;
  73118. UNIFORM_BUFFER: number;
  73119. HALF_FLOAT_OES: number;
  73120. RGBA16F: number;
  73121. RGBA32F: number;
  73122. R32F: number;
  73123. RG32F: number;
  73124. RGB32F: number;
  73125. R16F: number;
  73126. RG16F: number;
  73127. RGB16F: number;
  73128. RED: number;
  73129. RG: number;
  73130. R8: number;
  73131. RG8: number;
  73132. UNSIGNED_INT_24_8: number;
  73133. DEPTH24_STENCIL8: number;
  73134. MIN: number;
  73135. MAX: number;
  73136. /* Multiple Render Targets */
  73137. drawBuffers(buffers: number[]): void;
  73138. readBuffer(src: number): void;
  73139. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73140. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73141. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73142. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73143. // Occlusion Query
  73144. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73145. ANY_SAMPLES_PASSED: number;
  73146. QUERY_RESULT_AVAILABLE: number;
  73147. QUERY_RESULT: number;
  73148. }
  73149. interface WebGLProgram {
  73150. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73151. }
  73152. interface EXT_disjoint_timer_query {
  73153. QUERY_COUNTER_BITS_EXT: number;
  73154. TIME_ELAPSED_EXT: number;
  73155. TIMESTAMP_EXT: number;
  73156. GPU_DISJOINT_EXT: number;
  73157. QUERY_RESULT_EXT: number;
  73158. QUERY_RESULT_AVAILABLE_EXT: number;
  73159. queryCounterEXT(query: WebGLQuery, target: number): void;
  73160. createQueryEXT(): WebGLQuery;
  73161. beginQueryEXT(target: number, query: WebGLQuery): void;
  73162. endQueryEXT(target: number): void;
  73163. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73164. deleteQueryEXT(query: WebGLQuery): void;
  73165. }
  73166. interface WebGLUniformLocation {
  73167. _currentState: any;
  73168. }
  73169. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73170. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73171. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73172. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73173. interface WebGLRenderingContext {
  73174. readonly RASTERIZER_DISCARD: number;
  73175. readonly DEPTH_COMPONENT24: number;
  73176. readonly TEXTURE_3D: number;
  73177. readonly TEXTURE_2D_ARRAY: number;
  73178. readonly TEXTURE_COMPARE_FUNC: number;
  73179. readonly TEXTURE_COMPARE_MODE: number;
  73180. readonly COMPARE_REF_TO_TEXTURE: number;
  73181. readonly TEXTURE_WRAP_R: number;
  73182. readonly HALF_FLOAT: number;
  73183. readonly RGB8: number;
  73184. readonly RED_INTEGER: number;
  73185. readonly RG_INTEGER: number;
  73186. readonly RGB_INTEGER: number;
  73187. readonly RGBA_INTEGER: number;
  73188. readonly R8_SNORM: number;
  73189. readonly RG8_SNORM: number;
  73190. readonly RGB8_SNORM: number;
  73191. readonly RGBA8_SNORM: number;
  73192. readonly R8I: number;
  73193. readonly RG8I: number;
  73194. readonly RGB8I: number;
  73195. readonly RGBA8I: number;
  73196. readonly R8UI: number;
  73197. readonly RG8UI: number;
  73198. readonly RGB8UI: number;
  73199. readonly RGBA8UI: number;
  73200. readonly R16I: number;
  73201. readonly RG16I: number;
  73202. readonly RGB16I: number;
  73203. readonly RGBA16I: number;
  73204. readonly R16UI: number;
  73205. readonly RG16UI: number;
  73206. readonly RGB16UI: number;
  73207. readonly RGBA16UI: number;
  73208. readonly R32I: number;
  73209. readonly RG32I: number;
  73210. readonly RGB32I: number;
  73211. readonly RGBA32I: number;
  73212. readonly R32UI: number;
  73213. readonly RG32UI: number;
  73214. readonly RGB32UI: number;
  73215. readonly RGBA32UI: number;
  73216. readonly RGB10_A2UI: number;
  73217. readonly R11F_G11F_B10F: number;
  73218. readonly RGB9_E5: number;
  73219. readonly RGB10_A2: number;
  73220. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73221. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73222. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73223. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73224. readonly DEPTH_COMPONENT32F: number;
  73225. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73226. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73227. 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;
  73228. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73229. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73230. readonly TRANSFORM_FEEDBACK: number;
  73231. readonly INTERLEAVED_ATTRIBS: number;
  73232. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73233. createTransformFeedback(): WebGLTransformFeedback;
  73234. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73235. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73236. beginTransformFeedback(primitiveMode: number): void;
  73237. endTransformFeedback(): void;
  73238. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73239. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73240. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73241. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73242. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73243. }
  73244. interface ImageBitmap {
  73245. readonly width: number;
  73246. readonly height: number;
  73247. close(): void;
  73248. }
  73249. interface WebGLQuery extends WebGLObject {
  73250. }
  73251. declare var WebGLQuery: {
  73252. prototype: WebGLQuery;
  73253. new(): WebGLQuery;
  73254. };
  73255. interface WebGLSampler extends WebGLObject {
  73256. }
  73257. declare var WebGLSampler: {
  73258. prototype: WebGLSampler;
  73259. new(): WebGLSampler;
  73260. };
  73261. interface WebGLSync extends WebGLObject {
  73262. }
  73263. declare var WebGLSync: {
  73264. prototype: WebGLSync;
  73265. new(): WebGLSync;
  73266. };
  73267. interface WebGLTransformFeedback extends WebGLObject {
  73268. }
  73269. declare var WebGLTransformFeedback: {
  73270. prototype: WebGLTransformFeedback;
  73271. new(): WebGLTransformFeedback;
  73272. };
  73273. interface WebGLVertexArrayObject extends WebGLObject {
  73274. }
  73275. declare var WebGLVertexArrayObject: {
  73276. prototype: WebGLVertexArrayObject;
  73277. new(): WebGLVertexArrayObject;
  73278. };
  73279. // Type definitions for WebVR API
  73280. // Project: https://w3c.github.io/webvr/
  73281. // Definitions by: six a <https://github.com/lostfictions>
  73282. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73283. interface VRDisplay extends EventTarget {
  73284. /**
  73285. * Dictionary of capabilities describing the VRDisplay.
  73286. */
  73287. readonly capabilities: VRDisplayCapabilities;
  73288. /**
  73289. * z-depth defining the far plane of the eye view frustum
  73290. * enables mapping of values in the render target depth
  73291. * attachment to scene coordinates. Initially set to 10000.0.
  73292. */
  73293. depthFar: number;
  73294. /**
  73295. * z-depth defining the near plane of the eye view frustum
  73296. * enables mapping of values in the render target depth
  73297. * attachment to scene coordinates. Initially set to 0.01.
  73298. */
  73299. depthNear: number;
  73300. /**
  73301. * An identifier for this distinct VRDisplay. Used as an
  73302. * association point in the Gamepad API.
  73303. */
  73304. readonly displayId: number;
  73305. /**
  73306. * A display name, a user-readable name identifying it.
  73307. */
  73308. readonly displayName: string;
  73309. readonly isConnected: boolean;
  73310. readonly isPresenting: boolean;
  73311. /**
  73312. * If this VRDisplay supports room-scale experiences, the optional
  73313. * stage attribute contains details on the room-scale parameters.
  73314. */
  73315. readonly stageParameters: VRStageParameters | null;
  73316. /**
  73317. * Passing the value returned by `requestAnimationFrame` to
  73318. * `cancelAnimationFrame` will unregister the callback.
  73319. * @param handle Define the hanle of the request to cancel
  73320. */
  73321. cancelAnimationFrame(handle: number): void;
  73322. /**
  73323. * Stops presenting to the VRDisplay.
  73324. * @returns a promise to know when it stopped
  73325. */
  73326. exitPresent(): Promise<void>;
  73327. /**
  73328. * Return the current VREyeParameters for the given eye.
  73329. * @param whichEye Define the eye we want the parameter for
  73330. * @returns the eye parameters
  73331. */
  73332. getEyeParameters(whichEye: string): VREyeParameters;
  73333. /**
  73334. * Populates the passed VRFrameData with the information required to render
  73335. * the current frame.
  73336. * @param frameData Define the data structure to populate
  73337. * @returns true if ok otherwise false
  73338. */
  73339. getFrameData(frameData: VRFrameData): boolean;
  73340. /**
  73341. * Get the layers currently being presented.
  73342. * @returns the list of VR layers
  73343. */
  73344. getLayers(): VRLayer[];
  73345. /**
  73346. * Return a VRPose containing the future predicted pose of the VRDisplay
  73347. * when the current frame will be presented. The value returned will not
  73348. * change until JavaScript has returned control to the browser.
  73349. *
  73350. * The VRPose will contain the position, orientation, velocity,
  73351. * and acceleration of each of these properties.
  73352. * @returns the pose object
  73353. */
  73354. getPose(): VRPose;
  73355. /**
  73356. * Return the current instantaneous pose of the VRDisplay, with no
  73357. * prediction applied.
  73358. * @returns the current instantaneous pose
  73359. */
  73360. getImmediatePose(): VRPose;
  73361. /**
  73362. * The callback passed to `requestAnimationFrame` will be called
  73363. * any time a new frame should be rendered. When the VRDisplay is
  73364. * presenting the callback will be called at the native refresh
  73365. * rate of the HMD. When not presenting this function acts
  73366. * identically to how window.requestAnimationFrame acts. Content should
  73367. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73368. * asynchronously from other displays and at differing refresh rates.
  73369. * @param callback Define the eaction to run next frame
  73370. * @returns the request handle it
  73371. */
  73372. requestAnimationFrame(callback: FrameRequestCallback): number;
  73373. /**
  73374. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73375. * Repeat calls while already presenting will update the VRLayers being displayed.
  73376. * @param layers Define the list of layer to present
  73377. * @returns a promise to know when the request has been fulfilled
  73378. */
  73379. requestPresent(layers: VRLayer[]): Promise<void>;
  73380. /**
  73381. * Reset the pose for this display, treating its current position and
  73382. * orientation as the "origin/zero" values. VRPose.position,
  73383. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73384. * updated when calling resetPose(). This should be called in only
  73385. * sitting-space experiences.
  73386. */
  73387. resetPose(): void;
  73388. /**
  73389. * The VRLayer provided to the VRDisplay will be captured and presented
  73390. * in the HMD. Calling this function has the same effect on the source
  73391. * canvas as any other operation that uses its source image, and canvases
  73392. * created without preserveDrawingBuffer set to true will be cleared.
  73393. * @param pose Define the pose to submit
  73394. */
  73395. submitFrame(pose?: VRPose): void;
  73396. }
  73397. declare var VRDisplay: {
  73398. prototype: VRDisplay;
  73399. new(): VRDisplay;
  73400. };
  73401. interface VRLayer {
  73402. leftBounds?: number[] | Float32Array | null;
  73403. rightBounds?: number[] | Float32Array | null;
  73404. source?: HTMLCanvasElement | null;
  73405. }
  73406. interface VRDisplayCapabilities {
  73407. readonly canPresent: boolean;
  73408. readonly hasExternalDisplay: boolean;
  73409. readonly hasOrientation: boolean;
  73410. readonly hasPosition: boolean;
  73411. readonly maxLayers: number;
  73412. }
  73413. interface VREyeParameters {
  73414. /** @deprecated */
  73415. readonly fieldOfView: VRFieldOfView;
  73416. readonly offset: Float32Array;
  73417. readonly renderHeight: number;
  73418. readonly renderWidth: number;
  73419. }
  73420. interface VRFieldOfView {
  73421. readonly downDegrees: number;
  73422. readonly leftDegrees: number;
  73423. readonly rightDegrees: number;
  73424. readonly upDegrees: number;
  73425. }
  73426. interface VRFrameData {
  73427. readonly leftProjectionMatrix: Float32Array;
  73428. readonly leftViewMatrix: Float32Array;
  73429. readonly pose: VRPose;
  73430. readonly rightProjectionMatrix: Float32Array;
  73431. readonly rightViewMatrix: Float32Array;
  73432. readonly timestamp: number;
  73433. }
  73434. interface VRPose {
  73435. readonly angularAcceleration: Float32Array | null;
  73436. readonly angularVelocity: Float32Array | null;
  73437. readonly linearAcceleration: Float32Array | null;
  73438. readonly linearVelocity: Float32Array | null;
  73439. readonly orientation: Float32Array | null;
  73440. readonly position: Float32Array | null;
  73441. readonly timestamp: number;
  73442. }
  73443. interface VRStageParameters {
  73444. sittingToStandingTransform?: Float32Array;
  73445. sizeX?: number;
  73446. sizeY?: number;
  73447. }
  73448. interface Navigator {
  73449. getVRDisplays(): Promise<VRDisplay[]>;
  73450. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73451. }
  73452. interface Window {
  73453. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73454. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73455. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73456. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73457. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73458. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73459. }
  73460. interface Gamepad {
  73461. readonly displayId: number;
  73462. }
  73463. type XRSessionMode =
  73464. | "inline"
  73465. | "immersive-vr"
  73466. | "immersive-ar";
  73467. type XRReferenceSpaceType =
  73468. | "viewer"
  73469. | "local"
  73470. | "local-floor"
  73471. | "bounded-floor"
  73472. | "unbounded";
  73473. type XREnvironmentBlendMode =
  73474. | "opaque"
  73475. | "additive"
  73476. | "alpha-blend";
  73477. type XRVisibilityState =
  73478. | "visible"
  73479. | "visible-blurred"
  73480. | "hidden";
  73481. type XRHandedness =
  73482. | "none"
  73483. | "left"
  73484. | "right";
  73485. type XRTargetRayMode =
  73486. | "gaze"
  73487. | "tracked-pointer"
  73488. | "screen";
  73489. type XREye =
  73490. | "none"
  73491. | "left"
  73492. | "right";
  73493. type XREventType =
  73494. | "devicechange"
  73495. | "visibilitychange"
  73496. | "end"
  73497. | "inputsourceschange"
  73498. | "select"
  73499. | "selectstart"
  73500. | "selectend"
  73501. | "squeeze"
  73502. | "squeezestart"
  73503. | "squeezeend"
  73504. | "reset";
  73505. interface XRSpace extends EventTarget {
  73506. }
  73507. interface XRRenderState {
  73508. depthNear?: number;
  73509. depthFar?: number;
  73510. inlineVerticalFieldOfView?: number;
  73511. baseLayer?: XRWebGLLayer;
  73512. }
  73513. interface XRInputSource {
  73514. handedness: XRHandedness;
  73515. targetRayMode: XRTargetRayMode;
  73516. targetRaySpace: XRSpace;
  73517. gripSpace: XRSpace | undefined;
  73518. gamepad: Gamepad | undefined;
  73519. profiles: Array<string>;
  73520. }
  73521. interface XRSessionInit {
  73522. optionalFeatures?: string[];
  73523. requiredFeatures?: string[];
  73524. }
  73525. interface XRSession {
  73526. addEventListener: Function;
  73527. removeEventListener: Function;
  73528. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73529. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73530. requestAnimationFrame: Function;
  73531. end(): Promise<void>;
  73532. renderState: XRRenderState;
  73533. inputSources: Array<XRInputSource>;
  73534. // hit test
  73535. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73536. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73537. // legacy AR hit test
  73538. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73539. // legacy plane detection
  73540. updateWorldTrackingState(options: {
  73541. planeDetectionState?: { enabled: boolean; }
  73542. }): void;
  73543. }
  73544. interface XRReferenceSpace extends XRSpace {
  73545. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73546. onreset: any;
  73547. }
  73548. type XRPlaneSet = Set<XRPlane>;
  73549. type XRAnchorSet = Set<XRAnchor>;
  73550. interface XRFrame {
  73551. session: XRSession;
  73552. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73553. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73554. // AR
  73555. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73556. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73557. // Anchors
  73558. trackedAnchors?: XRAnchorSet;
  73559. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73560. // Planes
  73561. worldInformation: {
  73562. detectedPlanes?: XRPlaneSet;
  73563. };
  73564. }
  73565. interface XRViewerPose extends XRPose {
  73566. views: Array<XRView>;
  73567. }
  73568. interface XRPose {
  73569. transform: XRRigidTransform;
  73570. emulatedPosition: boolean;
  73571. }
  73572. interface XRWebGLLayerOptions {
  73573. antialias?: boolean;
  73574. depth?: boolean;
  73575. stencil?: boolean;
  73576. alpha?: boolean;
  73577. multiview?: boolean;
  73578. framebufferScaleFactor?: number;
  73579. }
  73580. declare var XRWebGLLayer: {
  73581. prototype: XRWebGLLayer;
  73582. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73583. };
  73584. interface XRWebGLLayer {
  73585. framebuffer: WebGLFramebuffer;
  73586. framebufferWidth: number;
  73587. framebufferHeight: number;
  73588. getViewport: Function;
  73589. }
  73590. declare class XRRigidTransform {
  73591. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73592. position: DOMPointReadOnly;
  73593. orientation: DOMPointReadOnly;
  73594. matrix: Float32Array;
  73595. inverse: XRRigidTransform;
  73596. }
  73597. interface XRView {
  73598. eye: XREye;
  73599. projectionMatrix: Float32Array;
  73600. transform: XRRigidTransform;
  73601. }
  73602. interface XRInputSourceChangeEvent {
  73603. session: XRSession;
  73604. removed: Array<XRInputSource>;
  73605. added: Array<XRInputSource>;
  73606. }
  73607. interface XRInputSourceEvent extends Event {
  73608. readonly frame: XRFrame;
  73609. readonly inputSource: XRInputSource;
  73610. }
  73611. // Experimental(er) features
  73612. declare class XRRay {
  73613. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73614. origin: DOMPointReadOnly;
  73615. direction: DOMPointReadOnly;
  73616. matrix: Float32Array;
  73617. }
  73618. declare enum XRHitTestTrackableType {
  73619. "point",
  73620. "plane"
  73621. }
  73622. interface XRHitResult {
  73623. hitMatrix: Float32Array;
  73624. }
  73625. interface XRTransientInputHitTestResult {
  73626. readonly inputSource: XRInputSource;
  73627. readonly results: Array<XRHitTestResult>;
  73628. }
  73629. interface XRHitTestResult {
  73630. getPose(baseSpace: XRSpace): XRPose | undefined;
  73631. // When anchor system is enabled
  73632. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73633. }
  73634. interface XRHitTestSource {
  73635. cancel(): void;
  73636. }
  73637. interface XRTransientInputHitTestSource {
  73638. cancel(): void;
  73639. }
  73640. interface XRHitTestOptionsInit {
  73641. space: XRSpace;
  73642. entityTypes?: Array<XRHitTestTrackableType>;
  73643. offsetRay?: XRRay;
  73644. }
  73645. interface XRTransientInputHitTestOptionsInit {
  73646. profile: string;
  73647. entityTypes?: Array<XRHitTestTrackableType>;
  73648. offsetRay?: XRRay;
  73649. }
  73650. interface XRAnchor {
  73651. anchorSpace: XRSpace;
  73652. delete(): void;
  73653. }
  73654. interface XRPlane {
  73655. orientation: "Horizontal" | "Vertical";
  73656. planeSpace: XRSpace;
  73657. polygon: Array<DOMPointReadOnly>;
  73658. lastChangedTime: number;
  73659. }
  73660. /**
  73661. * @ignore
  73662. */
  73663. declare module BABYLON.GLTF2.Exporter {
  73664. }
  73665. /**
  73666. * @ignore
  73667. */
  73668. declare module BABYLON.GLTF1 {
  73669. }
  73670. declare module BABYLON.GUI {
  73671. /**
  73672. * Class used to specific a value and its associated unit
  73673. */
  73674. export class ValueAndUnit {
  73675. /** defines the unit to store */
  73676. unit: number;
  73677. /** defines a boolean indicating if the value can be negative */
  73678. negativeValueAllowed: boolean;
  73679. private _value;
  73680. private _originalUnit;
  73681. /**
  73682. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73683. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73684. */
  73685. ignoreAdaptiveScaling: boolean;
  73686. /**
  73687. * Creates a new ValueAndUnit
  73688. * @param value defines the value to store
  73689. * @param unit defines the unit to store
  73690. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73691. */
  73692. constructor(value: number,
  73693. /** defines the unit to store */
  73694. unit?: number,
  73695. /** defines a boolean indicating if the value can be negative */
  73696. negativeValueAllowed?: boolean);
  73697. /** Gets a boolean indicating if the value is a percentage */
  73698. get isPercentage(): boolean;
  73699. /** Gets a boolean indicating if the value is store as pixel */
  73700. get isPixel(): boolean;
  73701. /** Gets direct internal value */
  73702. get internalValue(): number;
  73703. /**
  73704. * Gets value as pixel
  73705. * @param host defines the root host
  73706. * @param refValue defines the reference value for percentages
  73707. * @returns the value as pixel
  73708. */
  73709. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73710. /**
  73711. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73712. * @param value defines the value to store
  73713. * @param unit defines the unit to store
  73714. * @returns the current ValueAndUnit
  73715. */
  73716. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73717. /**
  73718. * Gets the value accordingly to its unit
  73719. * @param host defines the root host
  73720. * @returns the value
  73721. */
  73722. getValue(host: AdvancedDynamicTexture): number;
  73723. /**
  73724. * Gets a string representation of the value
  73725. * @param host defines the root host
  73726. * @param decimals defines an optional number of decimals to display
  73727. * @returns a string
  73728. */
  73729. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73730. /**
  73731. * Store a value parsed from a string
  73732. * @param source defines the source string
  73733. * @returns true if the value was successfully parsed
  73734. */
  73735. fromString(source: string | number): boolean;
  73736. private static _Regex;
  73737. private static _UNITMODE_PERCENTAGE;
  73738. private static _UNITMODE_PIXEL;
  73739. /** UNITMODE_PERCENTAGE */
  73740. static get UNITMODE_PERCENTAGE(): number;
  73741. /** UNITMODE_PIXEL */
  73742. static get UNITMODE_PIXEL(): number;
  73743. }
  73744. }
  73745. declare module BABYLON.GUI {
  73746. /**
  73747. * Define a style used by control to automatically setup properties based on a template.
  73748. * Only support font related properties so far
  73749. */
  73750. export class Style implements BABYLON.IDisposable {
  73751. private _fontFamily;
  73752. private _fontStyle;
  73753. private _fontWeight;
  73754. /** @hidden */
  73755. _host: AdvancedDynamicTexture;
  73756. /** @hidden */
  73757. _fontSize: ValueAndUnit;
  73758. /**
  73759. * BABYLON.Observable raised when the style values are changed
  73760. */
  73761. onChangedObservable: BABYLON.Observable<Style>;
  73762. /**
  73763. * Creates a new style object
  73764. * @param host defines the AdvancedDynamicTexture which hosts this style
  73765. */
  73766. constructor(host: AdvancedDynamicTexture);
  73767. /**
  73768. * Gets or sets the font size
  73769. */
  73770. get fontSize(): string | number;
  73771. set fontSize(value: string | number);
  73772. /**
  73773. * Gets or sets the font family
  73774. */
  73775. get fontFamily(): string;
  73776. set fontFamily(value: string);
  73777. /**
  73778. * Gets or sets the font style
  73779. */
  73780. get fontStyle(): string;
  73781. set fontStyle(value: string);
  73782. /** Gets or sets font weight */
  73783. get fontWeight(): string;
  73784. set fontWeight(value: string);
  73785. /** Dispose all associated resources */
  73786. dispose(): void;
  73787. }
  73788. }
  73789. declare module BABYLON.GUI {
  73790. /**
  73791. * Class used to transport BABYLON.Vector2 information for pointer events
  73792. */
  73793. export class Vector2WithInfo extends BABYLON.Vector2 {
  73794. /** defines the current mouse button index */
  73795. buttonIndex: number;
  73796. /**
  73797. * Creates a new Vector2WithInfo
  73798. * @param source defines the vector2 data to transport
  73799. * @param buttonIndex defines the current mouse button index
  73800. */
  73801. constructor(source: BABYLON.Vector2,
  73802. /** defines the current mouse button index */
  73803. buttonIndex?: number);
  73804. }
  73805. /** Class used to provide 2D matrix features */
  73806. export class Matrix2D {
  73807. /** Gets the internal array of 6 floats used to store matrix data */
  73808. m: Float32Array;
  73809. /**
  73810. * Creates a new matrix
  73811. * @param m00 defines value for (0, 0)
  73812. * @param m01 defines value for (0, 1)
  73813. * @param m10 defines value for (1, 0)
  73814. * @param m11 defines value for (1, 1)
  73815. * @param m20 defines value for (2, 0)
  73816. * @param m21 defines value for (2, 1)
  73817. */
  73818. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73819. /**
  73820. * Fills the matrix from direct values
  73821. * @param m00 defines value for (0, 0)
  73822. * @param m01 defines value for (0, 1)
  73823. * @param m10 defines value for (1, 0)
  73824. * @param m11 defines value for (1, 1)
  73825. * @param m20 defines value for (2, 0)
  73826. * @param m21 defines value for (2, 1)
  73827. * @returns the current modified matrix
  73828. */
  73829. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73830. /**
  73831. * Gets matrix determinant
  73832. * @returns the determinant
  73833. */
  73834. determinant(): number;
  73835. /**
  73836. * Inverses the matrix and stores it in a target matrix
  73837. * @param result defines the target matrix
  73838. * @returns the current matrix
  73839. */
  73840. invertToRef(result: Matrix2D): Matrix2D;
  73841. /**
  73842. * Multiplies the current matrix with another one
  73843. * @param other defines the second operand
  73844. * @param result defines the target matrix
  73845. * @returns the current matrix
  73846. */
  73847. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73848. /**
  73849. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73850. * @param x defines the x coordinate to transform
  73851. * @param y defines the x coordinate to transform
  73852. * @param result defines the target vector2
  73853. * @returns the current matrix
  73854. */
  73855. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73856. /**
  73857. * Creates an identity matrix
  73858. * @returns a new matrix
  73859. */
  73860. static Identity(): Matrix2D;
  73861. /**
  73862. * Creates a translation matrix and stores it in a target matrix
  73863. * @param x defines the x coordinate of the translation
  73864. * @param y defines the y coordinate of the translation
  73865. * @param result defines the target matrix
  73866. */
  73867. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73868. /**
  73869. * Creates a scaling matrix and stores it in a target matrix
  73870. * @param x defines the x coordinate of the scaling
  73871. * @param y defines the y coordinate of the scaling
  73872. * @param result defines the target matrix
  73873. */
  73874. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73875. /**
  73876. * Creates a rotation matrix and stores it in a target matrix
  73877. * @param angle defines the rotation angle
  73878. * @param result defines the target matrix
  73879. */
  73880. static RotationToRef(angle: number, result: Matrix2D): void;
  73881. private static _TempPreTranslationMatrix;
  73882. private static _TempPostTranslationMatrix;
  73883. private static _TempRotationMatrix;
  73884. private static _TempScalingMatrix;
  73885. private static _TempCompose0;
  73886. private static _TempCompose1;
  73887. private static _TempCompose2;
  73888. /**
  73889. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73890. * @param tx defines the x coordinate of the translation
  73891. * @param ty defines the y coordinate of the translation
  73892. * @param angle defines the rotation angle
  73893. * @param scaleX defines the x coordinate of the scaling
  73894. * @param scaleY defines the y coordinate of the scaling
  73895. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73896. * @param result defines the target matrix
  73897. */
  73898. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73899. }
  73900. }
  73901. declare module BABYLON.GUI {
  73902. /**
  73903. * Class used to store 2D control sizes
  73904. */
  73905. export class Measure {
  73906. /** defines left coordinate */
  73907. left: number;
  73908. /** defines top coordinate */
  73909. top: number;
  73910. /** defines width dimension */
  73911. width: number;
  73912. /** defines height dimension */
  73913. height: number;
  73914. /**
  73915. * Creates a new measure
  73916. * @param left defines left coordinate
  73917. * @param top defines top coordinate
  73918. * @param width defines width dimension
  73919. * @param height defines height dimension
  73920. */
  73921. constructor(
  73922. /** defines left coordinate */
  73923. left: number,
  73924. /** defines top coordinate */
  73925. top: number,
  73926. /** defines width dimension */
  73927. width: number,
  73928. /** defines height dimension */
  73929. height: number);
  73930. /**
  73931. * Copy from another measure
  73932. * @param other defines the other measure to copy from
  73933. */
  73934. copyFrom(other: Measure): void;
  73935. /**
  73936. * Copy from a group of 4 floats
  73937. * @param left defines left coordinate
  73938. * @param top defines top coordinate
  73939. * @param width defines width dimension
  73940. * @param height defines height dimension
  73941. */
  73942. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73943. /**
  73944. * Computes the axis aligned bounding box measure for two given measures
  73945. * @param a Input measure
  73946. * @param b Input measure
  73947. * @param result the resulting bounding measure
  73948. */
  73949. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73950. /**
  73951. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73952. * @param transform the matrix to transform the measure before computing the AABB
  73953. * @param result the resulting AABB
  73954. */
  73955. transformToRef(transform: Matrix2D, result: Measure): void;
  73956. /**
  73957. * Check equality between this measure and another one
  73958. * @param other defines the other measures
  73959. * @returns true if both measures are equals
  73960. */
  73961. isEqualsTo(other: Measure): boolean;
  73962. /**
  73963. * Creates an empty measure
  73964. * @returns a new measure
  73965. */
  73966. static Empty(): Measure;
  73967. }
  73968. }
  73969. declare module BABYLON.GUI {
  73970. /**
  73971. * Interface used to define a control that can receive focus
  73972. */
  73973. export interface IFocusableControl {
  73974. /**
  73975. * Function called when the control receives the focus
  73976. */
  73977. onFocus(): void;
  73978. /**
  73979. * Function called when the control loses the focus
  73980. */
  73981. onBlur(): void;
  73982. /**
  73983. * Function called to let the control handle keyboard events
  73984. * @param evt defines the current keyboard event
  73985. */
  73986. processKeyboard(evt: KeyboardEvent): void;
  73987. /**
  73988. * Function called to get the list of controls that should not steal the focus from this control
  73989. * @returns an array of controls
  73990. */
  73991. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73992. }
  73993. /**
  73994. * Class used to create texture to support 2D GUI elements
  73995. * @see http://doc.babylonjs.com/how_to/gui
  73996. */
  73997. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73998. private _isDirty;
  73999. private _renderObserver;
  74000. private _resizeObserver;
  74001. private _preKeyboardObserver;
  74002. private _pointerMoveObserver;
  74003. private _pointerObserver;
  74004. private _canvasPointerOutObserver;
  74005. private _background;
  74006. /** @hidden */
  74007. _rootContainer: Container;
  74008. /** @hidden */
  74009. _lastPickedControl: Control;
  74010. /** @hidden */
  74011. _lastControlOver: {
  74012. [pointerId: number]: Control;
  74013. };
  74014. /** @hidden */
  74015. _lastControlDown: {
  74016. [pointerId: number]: Control;
  74017. };
  74018. /** @hidden */
  74019. _capturingControl: {
  74020. [pointerId: number]: Control;
  74021. };
  74022. /** @hidden */
  74023. _shouldBlockPointer: boolean;
  74024. /** @hidden */
  74025. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74026. /** @hidden */
  74027. _linkedControls: Control[];
  74028. private _isFullscreen;
  74029. private _fullscreenViewport;
  74030. private _idealWidth;
  74031. private _idealHeight;
  74032. private _useSmallestIdeal;
  74033. private _renderAtIdealSize;
  74034. private _focusedControl;
  74035. private _blockNextFocusCheck;
  74036. private _renderScale;
  74037. private _rootElement;
  74038. private _cursorChanged;
  74039. private _defaultMousePointerId;
  74040. /** @hidden */
  74041. _numLayoutCalls: number;
  74042. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74043. get numLayoutCalls(): number;
  74044. /** @hidden */
  74045. _numRenderCalls: number;
  74046. /** Gets the number of render calls made the last time the ADT has been rendered */
  74047. get numRenderCalls(): number;
  74048. /**
  74049. * Define type to string to ensure compatibility across browsers
  74050. * Safari doesn't support DataTransfer constructor
  74051. */
  74052. private _clipboardData;
  74053. /**
  74054. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74055. */
  74056. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74057. /**
  74058. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74059. */
  74060. onControlPickedObservable: BABYLON.Observable<Control>;
  74061. /**
  74062. * BABYLON.Observable event triggered before layout is evaluated
  74063. */
  74064. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74065. /**
  74066. * BABYLON.Observable event triggered after the layout was evaluated
  74067. */
  74068. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74069. /**
  74070. * BABYLON.Observable event triggered before the texture is rendered
  74071. */
  74072. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74073. /**
  74074. * BABYLON.Observable event triggered after the texture was rendered
  74075. */
  74076. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74077. /**
  74078. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74079. */
  74080. premulAlpha: boolean;
  74081. /**
  74082. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74083. * Useful when you want more antialiasing
  74084. */
  74085. get renderScale(): number;
  74086. set renderScale(value: number);
  74087. /** Gets or sets the background color */
  74088. get background(): string;
  74089. set background(value: string);
  74090. /**
  74091. * Gets or sets the ideal width used to design controls.
  74092. * The GUI will then rescale everything accordingly
  74093. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74094. */
  74095. get idealWidth(): number;
  74096. set idealWidth(value: number);
  74097. /**
  74098. * Gets or sets the ideal height used to design controls.
  74099. * The GUI will then rescale everything accordingly
  74100. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74101. */
  74102. get idealHeight(): number;
  74103. set idealHeight(value: number);
  74104. /**
  74105. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74106. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74107. */
  74108. get useSmallestIdeal(): boolean;
  74109. set useSmallestIdeal(value: boolean);
  74110. /**
  74111. * Gets or sets a boolean indicating if adaptive scaling must be used
  74112. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74113. */
  74114. get renderAtIdealSize(): boolean;
  74115. set renderAtIdealSize(value: boolean);
  74116. /**
  74117. * Gets the ratio used when in "ideal mode"
  74118. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74119. * */
  74120. get idealRatio(): number;
  74121. /**
  74122. * Gets the underlying layer used to render the texture when in fullscreen mode
  74123. */
  74124. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74125. /**
  74126. * Gets the root container control
  74127. */
  74128. get rootContainer(): Container;
  74129. /**
  74130. * Returns an array containing the root container.
  74131. * This is mostly used to let the Inspector introspects the ADT
  74132. * @returns an array containing the rootContainer
  74133. */
  74134. getChildren(): Array<Container>;
  74135. /**
  74136. * Will return all controls that are inside this texture
  74137. * @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
  74138. * @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
  74139. * @return all child controls
  74140. */
  74141. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74142. /**
  74143. * Gets or sets the current focused control
  74144. */
  74145. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74146. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74147. /**
  74148. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74149. */
  74150. get isForeground(): boolean;
  74151. set isForeground(value: boolean);
  74152. /**
  74153. * Gets or set information about clipboardData
  74154. */
  74155. get clipboardData(): string;
  74156. set clipboardData(value: string);
  74157. /**
  74158. * Creates a new AdvancedDynamicTexture
  74159. * @param name defines the name of the texture
  74160. * @param width defines the width of the texture
  74161. * @param height defines the height of the texture
  74162. * @param scene defines the hosting scene
  74163. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74164. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74165. */
  74166. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74167. /**
  74168. * Get the current class name of the texture useful for serialization or dynamic coding.
  74169. * @returns "AdvancedDynamicTexture"
  74170. */
  74171. getClassName(): string;
  74172. /**
  74173. * Function used to execute a function on all controls
  74174. * @param func defines the function to execute
  74175. * @param container defines the container where controls belong. If null the root container will be used
  74176. */
  74177. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74178. private _useInvalidateRectOptimization;
  74179. /**
  74180. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74181. */
  74182. get useInvalidateRectOptimization(): boolean;
  74183. set useInvalidateRectOptimization(value: boolean);
  74184. private _invalidatedRectangle;
  74185. /**
  74186. * Invalidates a rectangle area on the gui texture
  74187. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74188. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74189. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74190. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74191. */
  74192. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74193. /**
  74194. * Marks the texture as dirty forcing a complete update
  74195. */
  74196. markAsDirty(): void;
  74197. /**
  74198. * Helper function used to create a new style
  74199. * @returns a new style
  74200. * @see http://doc.babylonjs.com/how_to/gui#styles
  74201. */
  74202. createStyle(): Style;
  74203. /**
  74204. * Adds a new control to the root container
  74205. * @param control defines the control to add
  74206. * @returns the current texture
  74207. */
  74208. addControl(control: Control): AdvancedDynamicTexture;
  74209. /**
  74210. * Removes a control from the root container
  74211. * @param control defines the control to remove
  74212. * @returns the current texture
  74213. */
  74214. removeControl(control: Control): AdvancedDynamicTexture;
  74215. /**
  74216. * Release all resources
  74217. */
  74218. dispose(): void;
  74219. private _onResize;
  74220. /** @hidden */
  74221. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74222. /**
  74223. * Get screen coordinates for a vector3
  74224. * @param position defines the position to project
  74225. * @param worldMatrix defines the world matrix to use
  74226. * @returns the projected position
  74227. */
  74228. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74229. private _checkUpdate;
  74230. private _clearMeasure;
  74231. private _render;
  74232. /** @hidden */
  74233. _changeCursor(cursor: string): void;
  74234. /** @hidden */
  74235. _registerLastControlDown(control: Control, pointerId: number): void;
  74236. private _doPicking;
  74237. /** @hidden */
  74238. _cleanControlAfterRemovalFromList(list: {
  74239. [pointerId: number]: Control;
  74240. }, control: Control): void;
  74241. /** @hidden */
  74242. _cleanControlAfterRemoval(control: Control): void;
  74243. /** Attach to all scene events required to support pointer events */
  74244. attach(): void;
  74245. /** @hidden */
  74246. private onClipboardCopy;
  74247. /** @hidden */
  74248. private onClipboardCut;
  74249. /** @hidden */
  74250. private onClipboardPaste;
  74251. /**
  74252. * Register the clipboard Events onto the canvas
  74253. */
  74254. registerClipboardEvents(): void;
  74255. /**
  74256. * Unregister the clipboard Events from the canvas
  74257. */
  74258. unRegisterClipboardEvents(): void;
  74259. /**
  74260. * Connect the texture to a hosting mesh to enable interactions
  74261. * @param mesh defines the mesh to attach to
  74262. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74263. */
  74264. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74265. /**
  74266. * Move the focus to a specific control
  74267. * @param control defines the control which will receive the focus
  74268. */
  74269. moveFocusToControl(control: IFocusableControl): void;
  74270. private _manageFocus;
  74271. private _attachToOnPointerOut;
  74272. /**
  74273. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74274. * @param mesh defines the mesh which will receive the texture
  74275. * @param width defines the texture width (1024 by default)
  74276. * @param height defines the texture height (1024 by default)
  74277. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74278. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74279. * @returns a new AdvancedDynamicTexture
  74280. */
  74281. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74282. /**
  74283. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74284. * In this mode the texture will rely on a layer for its rendering.
  74285. * This allows it to be treated like any other layer.
  74286. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74287. * LayerMask is set through advancedTexture.layer.layerMask
  74288. * @param name defines name for the texture
  74289. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74290. * @param scene defines the hsoting scene
  74291. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74292. * @returns a new AdvancedDynamicTexture
  74293. */
  74294. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74295. }
  74296. }
  74297. declare module BABYLON.GUI {
  74298. /**
  74299. * Root class used for all 2D controls
  74300. * @see http://doc.babylonjs.com/how_to/gui#controls
  74301. */
  74302. export class Control {
  74303. /** defines the name of the control */
  74304. name?: string | undefined;
  74305. /**
  74306. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74307. */
  74308. static AllowAlphaInheritance: boolean;
  74309. private _alpha;
  74310. private _alphaSet;
  74311. private _zIndex;
  74312. /** @hidden */
  74313. _host: AdvancedDynamicTexture;
  74314. /** Gets or sets the control parent */
  74315. parent: BABYLON.Nullable<Container>;
  74316. /** @hidden */
  74317. _currentMeasure: Measure;
  74318. private _fontFamily;
  74319. private _fontStyle;
  74320. private _fontWeight;
  74321. private _fontSize;
  74322. private _font;
  74323. /** @hidden */
  74324. _width: ValueAndUnit;
  74325. /** @hidden */
  74326. _height: ValueAndUnit;
  74327. /** @hidden */
  74328. protected _fontOffset: {
  74329. ascent: number;
  74330. height: number;
  74331. descent: number;
  74332. };
  74333. private _color;
  74334. private _style;
  74335. private _styleObserver;
  74336. /** @hidden */
  74337. protected _horizontalAlignment: number;
  74338. /** @hidden */
  74339. protected _verticalAlignment: number;
  74340. /** @hidden */
  74341. protected _isDirty: boolean;
  74342. /** @hidden */
  74343. protected _wasDirty: boolean;
  74344. /** @hidden */
  74345. _tempParentMeasure: Measure;
  74346. /** @hidden */
  74347. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74348. /** @hidden */
  74349. protected _cachedParentMeasure: Measure;
  74350. private _paddingLeft;
  74351. private _paddingRight;
  74352. private _paddingTop;
  74353. private _paddingBottom;
  74354. /** @hidden */
  74355. _left: ValueAndUnit;
  74356. /** @hidden */
  74357. _top: ValueAndUnit;
  74358. private _scaleX;
  74359. private _scaleY;
  74360. private _rotation;
  74361. private _transformCenterX;
  74362. private _transformCenterY;
  74363. /** @hidden */
  74364. _transformMatrix: Matrix2D;
  74365. /** @hidden */
  74366. protected _invertTransformMatrix: Matrix2D;
  74367. /** @hidden */
  74368. protected _transformedPosition: BABYLON.Vector2;
  74369. private _isMatrixDirty;
  74370. private _cachedOffsetX;
  74371. private _cachedOffsetY;
  74372. private _isVisible;
  74373. private _isHighlighted;
  74374. /** @hidden */
  74375. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74376. private _fontSet;
  74377. private _dummyVector2;
  74378. private _downCount;
  74379. private _enterCount;
  74380. private _doNotRender;
  74381. private _downPointerIds;
  74382. protected _isEnabled: boolean;
  74383. protected _disabledColor: string;
  74384. protected _disabledColorItem: string;
  74385. /** @hidden */
  74386. protected _rebuildLayout: boolean;
  74387. /** @hidden */
  74388. _customData: any;
  74389. /** @hidden */
  74390. _isClipped: boolean;
  74391. /** @hidden */
  74392. _automaticSize: boolean;
  74393. /** @hidden */
  74394. _tag: any;
  74395. /**
  74396. * 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
  74397. */
  74398. uniqueId: number;
  74399. /**
  74400. * Gets or sets an object used to store user defined information for the node
  74401. */
  74402. metadata: any;
  74403. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74404. isHitTestVisible: boolean;
  74405. /** Gets or sets a boolean indicating if the control can block pointer events */
  74406. isPointerBlocker: boolean;
  74407. /** Gets or sets a boolean indicating if the control can be focusable */
  74408. isFocusInvisible: boolean;
  74409. /**
  74410. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74411. * 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
  74412. */
  74413. clipChildren: boolean;
  74414. /**
  74415. * Gets or sets a boolean indicating that control content must be clipped
  74416. * 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
  74417. */
  74418. clipContent: boolean;
  74419. /**
  74420. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74421. */
  74422. useBitmapCache: boolean;
  74423. private _cacheData;
  74424. private _shadowOffsetX;
  74425. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74426. get shadowOffsetX(): number;
  74427. set shadowOffsetX(value: number);
  74428. private _shadowOffsetY;
  74429. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74430. get shadowOffsetY(): number;
  74431. set shadowOffsetY(value: number);
  74432. private _shadowBlur;
  74433. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74434. get shadowBlur(): number;
  74435. set shadowBlur(value: number);
  74436. private _shadowColor;
  74437. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74438. get shadowColor(): string;
  74439. set shadowColor(value: string);
  74440. /** Gets or sets the cursor to use when the control is hovered */
  74441. hoverCursor: string;
  74442. /** @hidden */
  74443. protected _linkOffsetX: ValueAndUnit;
  74444. /** @hidden */
  74445. protected _linkOffsetY: ValueAndUnit;
  74446. /** Gets the control type name */
  74447. get typeName(): string;
  74448. /**
  74449. * Get the current class name of the control.
  74450. * @returns current class name
  74451. */
  74452. getClassName(): string;
  74453. /**
  74454. * An event triggered when pointer wheel is scrolled
  74455. */
  74456. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74457. /**
  74458. * An event triggered when the pointer move over the control.
  74459. */
  74460. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74461. /**
  74462. * An event triggered when the pointer move out of the control.
  74463. */
  74464. onPointerOutObservable: BABYLON.Observable<Control>;
  74465. /**
  74466. * An event triggered when the pointer taps the control
  74467. */
  74468. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74469. /**
  74470. * An event triggered when pointer up
  74471. */
  74472. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74473. /**
  74474. * An event triggered when a control is clicked on
  74475. */
  74476. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74477. /**
  74478. * An event triggered when pointer enters the control
  74479. */
  74480. onPointerEnterObservable: BABYLON.Observable<Control>;
  74481. /**
  74482. * An event triggered when the control is marked as dirty
  74483. */
  74484. onDirtyObservable: BABYLON.Observable<Control>;
  74485. /**
  74486. * An event triggered before drawing the control
  74487. */
  74488. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74489. /**
  74490. * An event triggered after the control was drawn
  74491. */
  74492. onAfterDrawObservable: BABYLON.Observable<Control>;
  74493. /**
  74494. * An event triggered when the control has been disposed
  74495. */
  74496. onDisposeObservable: BABYLON.Observable<Control>;
  74497. /**
  74498. * Get the hosting AdvancedDynamicTexture
  74499. */
  74500. get host(): AdvancedDynamicTexture;
  74501. /** Gets or set information about font offsets (used to render and align text) */
  74502. get fontOffset(): {
  74503. ascent: number;
  74504. height: number;
  74505. descent: number;
  74506. };
  74507. set fontOffset(offset: {
  74508. ascent: number;
  74509. height: number;
  74510. descent: number;
  74511. });
  74512. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74513. get alpha(): number;
  74514. set alpha(value: number);
  74515. /**
  74516. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74517. */
  74518. get isHighlighted(): boolean;
  74519. set isHighlighted(value: boolean);
  74520. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74521. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74522. */
  74523. get scaleX(): number;
  74524. set scaleX(value: number);
  74525. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74526. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74527. */
  74528. get scaleY(): number;
  74529. set scaleY(value: number);
  74530. /** Gets or sets the rotation angle (0 by default)
  74531. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74532. */
  74533. get rotation(): number;
  74534. set rotation(value: number);
  74535. /** Gets or sets the transformation center on Y axis (0 by default)
  74536. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74537. */
  74538. get transformCenterY(): number;
  74539. set transformCenterY(value: number);
  74540. /** Gets or sets the transformation center on X axis (0 by default)
  74541. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74542. */
  74543. get transformCenterX(): number;
  74544. set transformCenterX(value: number);
  74545. /**
  74546. * Gets or sets the horizontal alignment
  74547. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74548. */
  74549. get horizontalAlignment(): number;
  74550. set horizontalAlignment(value: number);
  74551. /**
  74552. * Gets or sets the vertical alignment
  74553. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74554. */
  74555. get verticalAlignment(): number;
  74556. set verticalAlignment(value: number);
  74557. /**
  74558. * Gets or sets control width
  74559. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74560. */
  74561. get width(): string | number;
  74562. set width(value: string | number);
  74563. /**
  74564. * Gets or sets the control width in pixel
  74565. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74566. */
  74567. get widthInPixels(): number;
  74568. set widthInPixels(value: number);
  74569. /**
  74570. * Gets or sets control height
  74571. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74572. */
  74573. get height(): string | number;
  74574. set height(value: string | number);
  74575. /**
  74576. * Gets or sets control height in pixel
  74577. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74578. */
  74579. get heightInPixels(): number;
  74580. set heightInPixels(value: number);
  74581. /** Gets or set font family */
  74582. get fontFamily(): string;
  74583. set fontFamily(value: string);
  74584. /** Gets or sets font style */
  74585. get fontStyle(): string;
  74586. set fontStyle(value: string);
  74587. /** Gets or sets font weight */
  74588. get fontWeight(): string;
  74589. set fontWeight(value: string);
  74590. /**
  74591. * Gets or sets style
  74592. * @see http://doc.babylonjs.com/how_to/gui#styles
  74593. */
  74594. get style(): BABYLON.Nullable<Style>;
  74595. set style(value: BABYLON.Nullable<Style>);
  74596. /** @hidden */
  74597. get _isFontSizeInPercentage(): boolean;
  74598. /** Gets or sets font size in pixels */
  74599. get fontSizeInPixels(): number;
  74600. set fontSizeInPixels(value: number);
  74601. /** Gets or sets font size */
  74602. get fontSize(): string | number;
  74603. set fontSize(value: string | number);
  74604. /** Gets or sets foreground color */
  74605. get color(): string;
  74606. set color(value: string);
  74607. /** Gets or sets z index which is used to reorder controls on the z axis */
  74608. get zIndex(): number;
  74609. set zIndex(value: number);
  74610. /** Gets or sets a boolean indicating if the control can be rendered */
  74611. get notRenderable(): boolean;
  74612. set notRenderable(value: boolean);
  74613. /** Gets or sets a boolean indicating if the control is visible */
  74614. get isVisible(): boolean;
  74615. set isVisible(value: boolean);
  74616. /** Gets a boolean indicating that the control needs to update its rendering */
  74617. get isDirty(): boolean;
  74618. /**
  74619. * Gets the current linked mesh (or null if none)
  74620. */
  74621. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74622. /**
  74623. * Gets or sets a value indicating the padding to use on the left of the control
  74624. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74625. */
  74626. get paddingLeft(): string | number;
  74627. set paddingLeft(value: string | number);
  74628. /**
  74629. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74630. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74631. */
  74632. get paddingLeftInPixels(): number;
  74633. set paddingLeftInPixels(value: number);
  74634. /**
  74635. * Gets or sets a value indicating the padding to use on the right of the control
  74636. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74637. */
  74638. get paddingRight(): string | number;
  74639. set paddingRight(value: string | number);
  74640. /**
  74641. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74642. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74643. */
  74644. get paddingRightInPixels(): number;
  74645. set paddingRightInPixels(value: number);
  74646. /**
  74647. * Gets or sets a value indicating the padding to use on the top of the control
  74648. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74649. */
  74650. get paddingTop(): string | number;
  74651. set paddingTop(value: string | number);
  74652. /**
  74653. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74654. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74655. */
  74656. get paddingTopInPixels(): number;
  74657. set paddingTopInPixels(value: number);
  74658. /**
  74659. * Gets or sets a value indicating the padding to use on the bottom of the control
  74660. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74661. */
  74662. get paddingBottom(): string | number;
  74663. set paddingBottom(value: string | number);
  74664. /**
  74665. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74666. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74667. */
  74668. get paddingBottomInPixels(): number;
  74669. set paddingBottomInPixels(value: number);
  74670. /**
  74671. * Gets or sets a value indicating the left coordinate of the control
  74672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74673. */
  74674. get left(): string | number;
  74675. set left(value: string | number);
  74676. /**
  74677. * Gets or sets a value indicating the left coordinate in pixels of the control
  74678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74679. */
  74680. get leftInPixels(): number;
  74681. set leftInPixels(value: number);
  74682. /**
  74683. * Gets or sets a value indicating the top coordinate of the control
  74684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74685. */
  74686. get top(): string | number;
  74687. set top(value: string | number);
  74688. /**
  74689. * Gets or sets a value indicating the top coordinate in pixels of the control
  74690. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74691. */
  74692. get topInPixels(): number;
  74693. set topInPixels(value: number);
  74694. /**
  74695. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74696. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74697. */
  74698. get linkOffsetX(): string | number;
  74699. set linkOffsetX(value: string | number);
  74700. /**
  74701. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74702. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74703. */
  74704. get linkOffsetXInPixels(): number;
  74705. set linkOffsetXInPixels(value: number);
  74706. /**
  74707. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74708. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74709. */
  74710. get linkOffsetY(): string | number;
  74711. set linkOffsetY(value: string | number);
  74712. /**
  74713. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74714. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74715. */
  74716. get linkOffsetYInPixels(): number;
  74717. set linkOffsetYInPixels(value: number);
  74718. /** Gets the center coordinate on X axis */
  74719. get centerX(): number;
  74720. /** Gets the center coordinate on Y axis */
  74721. get centerY(): number;
  74722. /** Gets or sets if control is Enabled*/
  74723. get isEnabled(): boolean;
  74724. set isEnabled(value: boolean);
  74725. /** Gets or sets background color of control if it's disabled*/
  74726. get disabledColor(): string;
  74727. set disabledColor(value: string);
  74728. /** Gets or sets front color of control if it's disabled*/
  74729. get disabledColorItem(): string;
  74730. set disabledColorItem(value: string);
  74731. /**
  74732. * Creates a new control
  74733. * @param name defines the name of the control
  74734. */
  74735. constructor(
  74736. /** defines the name of the control */
  74737. name?: string | undefined);
  74738. /** @hidden */
  74739. protected _getTypeName(): string;
  74740. /**
  74741. * Gets the first ascendant in the hierarchy of the given type
  74742. * @param className defines the required type
  74743. * @returns the ascendant or null if not found
  74744. */
  74745. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74746. /** @hidden */
  74747. _resetFontCache(): void;
  74748. /**
  74749. * Determines if a container is an ascendant of the current control
  74750. * @param container defines the container to look for
  74751. * @returns true if the container is one of the ascendant of the control
  74752. */
  74753. isAscendant(container: Control): boolean;
  74754. /**
  74755. * Gets coordinates in local control space
  74756. * @param globalCoordinates defines the coordinates to transform
  74757. * @returns the new coordinates in local space
  74758. */
  74759. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74760. /**
  74761. * Gets coordinates in local control space
  74762. * @param globalCoordinates defines the coordinates to transform
  74763. * @param result defines the target vector2 where to store the result
  74764. * @returns the current control
  74765. */
  74766. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74767. /**
  74768. * Gets coordinates in parent local control space
  74769. * @param globalCoordinates defines the coordinates to transform
  74770. * @returns the new coordinates in parent local space
  74771. */
  74772. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74773. /**
  74774. * Move the current control to a vector3 position projected onto the screen.
  74775. * @param position defines the target position
  74776. * @param scene defines the hosting scene
  74777. */
  74778. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74779. /**
  74780. * Will store all controls that have this control as ascendant in a given array
  74781. * @param results defines the array where to store the descendants
  74782. * @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
  74783. * @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
  74784. */
  74785. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74786. /**
  74787. * Will return all controls that have this control as ascendant
  74788. * @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
  74789. * @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
  74790. * @return all child controls
  74791. */
  74792. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74793. /**
  74794. * Link current control with a target mesh
  74795. * @param mesh defines the mesh to link with
  74796. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74797. */
  74798. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74799. /** @hidden */
  74800. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74801. /** @hidden */
  74802. _offsetLeft(offset: number): void;
  74803. /** @hidden */
  74804. _offsetTop(offset: number): void;
  74805. /** @hidden */
  74806. _markMatrixAsDirty(): void;
  74807. /** @hidden */
  74808. _flagDescendantsAsMatrixDirty(): void;
  74809. /** @hidden */
  74810. _intersectsRect(rect: Measure): boolean;
  74811. /** @hidden */
  74812. protected invalidateRect(): void;
  74813. /** @hidden */
  74814. _markAsDirty(force?: boolean): void;
  74815. /** @hidden */
  74816. _markAllAsDirty(): void;
  74817. /** @hidden */
  74818. _link(host: AdvancedDynamicTexture): void;
  74819. /** @hidden */
  74820. protected _transform(context?: CanvasRenderingContext2D): void;
  74821. /** @hidden */
  74822. _renderHighlight(context: CanvasRenderingContext2D): void;
  74823. /** @hidden */
  74824. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74825. /** @hidden */
  74826. protected _applyStates(context: CanvasRenderingContext2D): void;
  74827. /** @hidden */
  74828. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74829. /** @hidden */
  74830. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74831. protected _evaluateClippingState(parentMeasure: Measure): void;
  74832. /** @hidden */
  74833. _measure(): void;
  74834. /** @hidden */
  74835. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74836. /** @hidden */
  74837. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74838. /** @hidden */
  74839. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74840. /** @hidden */
  74841. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74842. private static _ClipMeasure;
  74843. private _tmpMeasureA;
  74844. private _clip;
  74845. /** @hidden */
  74846. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74847. /** @hidden */
  74848. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74849. /**
  74850. * Tests if a given coordinates belong to the current control
  74851. * @param x defines x coordinate to test
  74852. * @param y defines y coordinate to test
  74853. * @returns true if the coordinates are inside the control
  74854. */
  74855. contains(x: number, y: number): boolean;
  74856. /** @hidden */
  74857. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74858. /** @hidden */
  74859. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74860. /** @hidden */
  74861. _onPointerEnter(target: Control): boolean;
  74862. /** @hidden */
  74863. _onPointerOut(target: Control, force?: boolean): void;
  74864. /** @hidden */
  74865. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74866. /** @hidden */
  74867. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74868. /** @hidden */
  74869. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74870. /** @hidden */
  74871. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74872. /** @hidden */
  74873. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74874. private _prepareFont;
  74875. /** Releases associated resources */
  74876. dispose(): void;
  74877. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74878. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74879. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74880. private static _VERTICAL_ALIGNMENT_TOP;
  74881. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74882. private static _VERTICAL_ALIGNMENT_CENTER;
  74883. /** HORIZONTAL_ALIGNMENT_LEFT */
  74884. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74885. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74886. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74887. /** HORIZONTAL_ALIGNMENT_CENTER */
  74888. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74889. /** VERTICAL_ALIGNMENT_TOP */
  74890. static get VERTICAL_ALIGNMENT_TOP(): number;
  74891. /** VERTICAL_ALIGNMENT_BOTTOM */
  74892. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74893. /** VERTICAL_ALIGNMENT_CENTER */
  74894. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74895. private static _FontHeightSizes;
  74896. /** @hidden */
  74897. static _GetFontOffset(font: string): {
  74898. ascent: number;
  74899. height: number;
  74900. descent: number;
  74901. };
  74902. /**
  74903. * Creates a stack panel that can be used to render headers
  74904. * @param control defines the control to associate with the header
  74905. * @param text defines the text of the header
  74906. * @param size defines the size of the header
  74907. * @param options defines options used to configure the header
  74908. * @returns a new StackPanel
  74909. * @ignore
  74910. * @hidden
  74911. */
  74912. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74913. isHorizontal: boolean;
  74914. controlFirst: boolean;
  74915. }) => any;
  74916. /** @hidden */
  74917. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74918. }
  74919. }
  74920. declare module BABYLON.GUI {
  74921. /**
  74922. * Root class for 2D containers
  74923. * @see http://doc.babylonjs.com/how_to/gui#containers
  74924. */
  74925. export class Container extends Control {
  74926. name?: string | undefined;
  74927. /** @hidden */
  74928. _children: Control[];
  74929. /** @hidden */
  74930. protected _measureForChildren: Measure;
  74931. /** @hidden */
  74932. protected _background: string;
  74933. /** @hidden */
  74934. protected _adaptWidthToChildren: boolean;
  74935. /** @hidden */
  74936. protected _adaptHeightToChildren: boolean;
  74937. /**
  74938. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74939. */
  74940. logLayoutCycleErrors: boolean;
  74941. /**
  74942. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74943. */
  74944. maxLayoutCycle: number;
  74945. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74946. get adaptHeightToChildren(): boolean;
  74947. set adaptHeightToChildren(value: boolean);
  74948. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74949. get adaptWidthToChildren(): boolean;
  74950. set adaptWidthToChildren(value: boolean);
  74951. /** Gets or sets background color */
  74952. get background(): string;
  74953. set background(value: string);
  74954. /** Gets the list of children */
  74955. get children(): Control[];
  74956. /**
  74957. * Creates a new Container
  74958. * @param name defines the name of the container
  74959. */
  74960. constructor(name?: string | undefined);
  74961. protected _getTypeName(): string;
  74962. _flagDescendantsAsMatrixDirty(): void;
  74963. /**
  74964. * Gets a child using its name
  74965. * @param name defines the child name to look for
  74966. * @returns the child control if found
  74967. */
  74968. getChildByName(name: string): BABYLON.Nullable<Control>;
  74969. /**
  74970. * Gets a child using its type and its name
  74971. * @param name defines the child name to look for
  74972. * @param type defines the child type to look for
  74973. * @returns the child control if found
  74974. */
  74975. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74976. /**
  74977. * Search for a specific control in children
  74978. * @param control defines the control to look for
  74979. * @returns true if the control is in child list
  74980. */
  74981. containsControl(control: Control): boolean;
  74982. /**
  74983. * Adds a new control to the current container
  74984. * @param control defines the control to add
  74985. * @returns the current container
  74986. */
  74987. addControl(control: BABYLON.Nullable<Control>): Container;
  74988. /**
  74989. * Removes all controls from the current container
  74990. * @returns the current container
  74991. */
  74992. clearControls(): Container;
  74993. /**
  74994. * Removes a control from the current container
  74995. * @param control defines the control to remove
  74996. * @returns the current container
  74997. */
  74998. removeControl(control: Control): Container;
  74999. /** @hidden */
  75000. _reOrderControl(control: Control): void;
  75001. /** @hidden */
  75002. _offsetLeft(offset: number): void;
  75003. /** @hidden */
  75004. _offsetTop(offset: number): void;
  75005. /** @hidden */
  75006. _markAllAsDirty(): void;
  75007. /** @hidden */
  75008. protected _localDraw(context: CanvasRenderingContext2D): void;
  75009. /** @hidden */
  75010. _link(host: AdvancedDynamicTexture): void;
  75011. /** @hidden */
  75012. protected _beforeLayout(): void;
  75013. /** @hidden */
  75014. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75015. /** @hidden */
  75016. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75017. protected _postMeasure(): void;
  75018. /** @hidden */
  75019. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75020. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75021. /** @hidden */
  75022. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75023. /** @hidden */
  75024. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75025. /** Releases associated resources */
  75026. dispose(): void;
  75027. }
  75028. }
  75029. declare module BABYLON.GUI {
  75030. /** Class used to create rectangle container */
  75031. export class Rectangle extends Container {
  75032. name?: string | undefined;
  75033. private _thickness;
  75034. private _cornerRadius;
  75035. /** Gets or sets border thickness */
  75036. get thickness(): number;
  75037. set thickness(value: number);
  75038. /** Gets or sets the corner radius angle */
  75039. get cornerRadius(): number;
  75040. set cornerRadius(value: number);
  75041. /**
  75042. * Creates a new Rectangle
  75043. * @param name defines the control name
  75044. */
  75045. constructor(name?: string | undefined);
  75046. protected _getTypeName(): string;
  75047. protected _localDraw(context: CanvasRenderingContext2D): void;
  75048. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75049. private _drawRoundedRect;
  75050. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75051. }
  75052. }
  75053. declare module BABYLON.GUI {
  75054. /**
  75055. * Enum that determines the text-wrapping mode to use.
  75056. */
  75057. export enum TextWrapping {
  75058. /**
  75059. * Clip the text when it's larger than Control.width; this is the default mode.
  75060. */
  75061. Clip = 0,
  75062. /**
  75063. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75064. */
  75065. WordWrap = 1,
  75066. /**
  75067. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75068. */
  75069. Ellipsis = 2
  75070. }
  75071. /**
  75072. * Class used to create text block control
  75073. */
  75074. export class TextBlock extends Control {
  75075. /**
  75076. * Defines the name of the control
  75077. */
  75078. name?: string | undefined;
  75079. private _text;
  75080. private _textWrapping;
  75081. private _textHorizontalAlignment;
  75082. private _textVerticalAlignment;
  75083. private _lines;
  75084. private _resizeToFit;
  75085. private _lineSpacing;
  75086. private _outlineWidth;
  75087. private _outlineColor;
  75088. /**
  75089. * An event triggered after the text is changed
  75090. */
  75091. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75092. /**
  75093. * An event triggered after the text was broken up into lines
  75094. */
  75095. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75096. /**
  75097. * Function used to split a string into words. By default, a string is split at each space character found
  75098. */
  75099. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75100. /**
  75101. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75102. */
  75103. get lines(): any[];
  75104. /**
  75105. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75106. */
  75107. get resizeToFit(): boolean;
  75108. /**
  75109. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75110. */
  75111. set resizeToFit(value: boolean);
  75112. /**
  75113. * Gets or sets a boolean indicating if text must be wrapped
  75114. */
  75115. get textWrapping(): TextWrapping | boolean;
  75116. /**
  75117. * Gets or sets a boolean indicating if text must be wrapped
  75118. */
  75119. set textWrapping(value: TextWrapping | boolean);
  75120. /**
  75121. * Gets or sets text to display
  75122. */
  75123. get text(): string;
  75124. /**
  75125. * Gets or sets text to display
  75126. */
  75127. set text(value: string);
  75128. /**
  75129. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75130. */
  75131. get textHorizontalAlignment(): number;
  75132. /**
  75133. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75134. */
  75135. set textHorizontalAlignment(value: number);
  75136. /**
  75137. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75138. */
  75139. get textVerticalAlignment(): number;
  75140. /**
  75141. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75142. */
  75143. set textVerticalAlignment(value: number);
  75144. /**
  75145. * Gets or sets line spacing value
  75146. */
  75147. set lineSpacing(value: string | number);
  75148. /**
  75149. * Gets or sets line spacing value
  75150. */
  75151. get lineSpacing(): string | number;
  75152. /**
  75153. * Gets or sets outlineWidth of the text to display
  75154. */
  75155. get outlineWidth(): number;
  75156. /**
  75157. * Gets or sets outlineWidth of the text to display
  75158. */
  75159. set outlineWidth(value: number);
  75160. /**
  75161. * Gets or sets outlineColor of the text to display
  75162. */
  75163. get outlineColor(): string;
  75164. /**
  75165. * Gets or sets outlineColor of the text to display
  75166. */
  75167. set outlineColor(value: string);
  75168. /**
  75169. * Creates a new TextBlock object
  75170. * @param name defines the name of the control
  75171. * @param text defines the text to display (emptry string by default)
  75172. */
  75173. constructor(
  75174. /**
  75175. * Defines the name of the control
  75176. */
  75177. name?: string | undefined, text?: string);
  75178. protected _getTypeName(): string;
  75179. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75180. private _drawText;
  75181. /** @hidden */
  75182. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75183. protected _applyStates(context: CanvasRenderingContext2D): void;
  75184. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75185. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75186. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75187. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75188. protected _renderLines(context: CanvasRenderingContext2D): void;
  75189. /**
  75190. * Given a width constraint applied on the text block, find the expected height
  75191. * @returns expected height
  75192. */
  75193. computeExpectedHeight(): number;
  75194. dispose(): void;
  75195. }
  75196. }
  75197. declare module BABYLON.GUI {
  75198. /**
  75199. * Class used to create 2D images
  75200. */
  75201. export class Image extends Control {
  75202. name?: string | undefined;
  75203. private _workingCanvas;
  75204. private _domImage;
  75205. private _imageWidth;
  75206. private _imageHeight;
  75207. private _loaded;
  75208. private _stretch;
  75209. private _source;
  75210. private _autoScale;
  75211. private _sourceLeft;
  75212. private _sourceTop;
  75213. private _sourceWidth;
  75214. private _sourceHeight;
  75215. private _svgAttributesComputationCompleted;
  75216. private _isSVG;
  75217. private _cellWidth;
  75218. private _cellHeight;
  75219. private _cellId;
  75220. private _populateNinePatchSlicesFromImage;
  75221. private _sliceLeft;
  75222. private _sliceRight;
  75223. private _sliceTop;
  75224. private _sliceBottom;
  75225. private _detectPointerOnOpaqueOnly;
  75226. /**
  75227. * BABYLON.Observable notified when the content is loaded
  75228. */
  75229. onImageLoadedObservable: BABYLON.Observable<Image>;
  75230. /**
  75231. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75232. */
  75233. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75234. /**
  75235. * Gets a boolean indicating that the content is loaded
  75236. */
  75237. get isLoaded(): boolean;
  75238. /**
  75239. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75240. */
  75241. get populateNinePatchSlicesFromImage(): boolean;
  75242. set populateNinePatchSlicesFromImage(value: boolean);
  75243. /**
  75244. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75245. * Beware using this as this will comsume more memory as the image has to be stored twice
  75246. */
  75247. get detectPointerOnOpaqueOnly(): boolean;
  75248. set detectPointerOnOpaqueOnly(value: boolean);
  75249. /**
  75250. * Gets or sets the left value for slicing (9-patch)
  75251. */
  75252. get sliceLeft(): number;
  75253. set sliceLeft(value: number);
  75254. /**
  75255. * Gets or sets the right value for slicing (9-patch)
  75256. */
  75257. get sliceRight(): number;
  75258. set sliceRight(value: number);
  75259. /**
  75260. * Gets or sets the top value for slicing (9-patch)
  75261. */
  75262. get sliceTop(): number;
  75263. set sliceTop(value: number);
  75264. /**
  75265. * Gets or sets the bottom value for slicing (9-patch)
  75266. */
  75267. get sliceBottom(): number;
  75268. set sliceBottom(value: number);
  75269. /**
  75270. * Gets or sets the left coordinate in the source image
  75271. */
  75272. get sourceLeft(): number;
  75273. set sourceLeft(value: number);
  75274. /**
  75275. * Gets or sets the top coordinate in the source image
  75276. */
  75277. get sourceTop(): number;
  75278. set sourceTop(value: number);
  75279. /**
  75280. * Gets or sets the width to capture in the source image
  75281. */
  75282. get sourceWidth(): number;
  75283. set sourceWidth(value: number);
  75284. /**
  75285. * Gets or sets the height to capture in the source image
  75286. */
  75287. get sourceHeight(): number;
  75288. set sourceHeight(value: number);
  75289. /** Indicates if the format of the image is SVG */
  75290. get isSVG(): boolean;
  75291. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75292. get svgAttributesComputationCompleted(): boolean;
  75293. /**
  75294. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75295. * @see http://doc.babylonjs.com/how_to/gui#image
  75296. */
  75297. get autoScale(): boolean;
  75298. set autoScale(value: boolean);
  75299. /** Gets or sets the streching mode used by the image */
  75300. get stretch(): number;
  75301. set stretch(value: number);
  75302. /** @hidden */
  75303. _rotate90(n: number, preserveProperties?: boolean): Image;
  75304. private _handleRotationForSVGImage;
  75305. private _rotate90SourceProperties;
  75306. /**
  75307. * Gets or sets the internal DOM image used to render the control
  75308. */
  75309. set domImage(value: HTMLImageElement);
  75310. get domImage(): HTMLImageElement;
  75311. private _onImageLoaded;
  75312. private _extractNinePatchSliceDataFromImage;
  75313. /**
  75314. * Gets or sets image source url
  75315. */
  75316. set source(value: BABYLON.Nullable<string>);
  75317. /**
  75318. * Checks for svg document with icon id present
  75319. */
  75320. private _svgCheck;
  75321. /**
  75322. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75323. * given external svg file and icon id
  75324. */
  75325. private _getSVGAttribs;
  75326. /**
  75327. * Gets or sets the cell width to use when animation sheet is enabled
  75328. * @see http://doc.babylonjs.com/how_to/gui#image
  75329. */
  75330. get cellWidth(): number;
  75331. set cellWidth(value: number);
  75332. /**
  75333. * Gets or sets the cell height to use when animation sheet is enabled
  75334. * @see http://doc.babylonjs.com/how_to/gui#image
  75335. */
  75336. get cellHeight(): number;
  75337. set cellHeight(value: number);
  75338. /**
  75339. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75340. * @see http://doc.babylonjs.com/how_to/gui#image
  75341. */
  75342. get cellId(): number;
  75343. set cellId(value: number);
  75344. /**
  75345. * Creates a new Image
  75346. * @param name defines the control name
  75347. * @param url defines the image url
  75348. */
  75349. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75350. /**
  75351. * Tests if a given coordinates belong to the current control
  75352. * @param x defines x coordinate to test
  75353. * @param y defines y coordinate to test
  75354. * @returns true if the coordinates are inside the control
  75355. */
  75356. contains(x: number, y: number): boolean;
  75357. protected _getTypeName(): string;
  75358. /** Force the control to synchronize with its content */
  75359. synchronizeSizeWithContent(): void;
  75360. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75361. private _prepareWorkingCanvasForOpaqueDetection;
  75362. private _drawImage;
  75363. _draw(context: CanvasRenderingContext2D): void;
  75364. private _renderCornerPatch;
  75365. private _renderNinePatch;
  75366. dispose(): void;
  75367. /** STRETCH_NONE */
  75368. static readonly STRETCH_NONE: number;
  75369. /** STRETCH_FILL */
  75370. static readonly STRETCH_FILL: number;
  75371. /** STRETCH_UNIFORM */
  75372. static readonly STRETCH_UNIFORM: number;
  75373. /** STRETCH_EXTEND */
  75374. static readonly STRETCH_EXTEND: number;
  75375. /** NINE_PATCH */
  75376. static readonly STRETCH_NINE_PATCH: number;
  75377. }
  75378. }
  75379. declare module BABYLON.GUI {
  75380. /**
  75381. * Class used to create 2D buttons
  75382. */
  75383. export class Button extends Rectangle {
  75384. name?: string | undefined;
  75385. /**
  75386. * Function called to generate a pointer enter animation
  75387. */
  75388. pointerEnterAnimation: () => void;
  75389. /**
  75390. * Function called to generate a pointer out animation
  75391. */
  75392. pointerOutAnimation: () => void;
  75393. /**
  75394. * Function called to generate a pointer down animation
  75395. */
  75396. pointerDownAnimation: () => void;
  75397. /**
  75398. * Function called to generate a pointer up animation
  75399. */
  75400. pointerUpAnimation: () => void;
  75401. /**
  75402. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75403. */
  75404. delegatePickingToChildren: boolean;
  75405. private _image;
  75406. /**
  75407. * Returns the image part of the button (if any)
  75408. */
  75409. get image(): BABYLON.Nullable<Image>;
  75410. private _textBlock;
  75411. /**
  75412. * Returns the image part of the button (if any)
  75413. */
  75414. get textBlock(): BABYLON.Nullable<TextBlock>;
  75415. /**
  75416. * Creates a new Button
  75417. * @param name defines the name of the button
  75418. */
  75419. constructor(name?: string | undefined);
  75420. protected _getTypeName(): string;
  75421. /** @hidden */
  75422. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75423. /** @hidden */
  75424. _onPointerEnter(target: Control): boolean;
  75425. /** @hidden */
  75426. _onPointerOut(target: Control, force?: boolean): void;
  75427. /** @hidden */
  75428. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75429. /** @hidden */
  75430. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75431. /**
  75432. * Creates a new button made with an image and a text
  75433. * @param name defines the name of the button
  75434. * @param text defines the text of the button
  75435. * @param imageUrl defines the url of the image
  75436. * @returns a new Button
  75437. */
  75438. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75439. /**
  75440. * Creates a new button made with an image
  75441. * @param name defines the name of the button
  75442. * @param imageUrl defines the url of the image
  75443. * @returns a new Button
  75444. */
  75445. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75446. /**
  75447. * Creates a new button made with a text
  75448. * @param name defines the name of the button
  75449. * @param text defines the text of the button
  75450. * @returns a new Button
  75451. */
  75452. static CreateSimpleButton(name: string, text: string): Button;
  75453. /**
  75454. * Creates a new button made with an image and a centered text
  75455. * @param name defines the name of the button
  75456. * @param text defines the text of the button
  75457. * @param imageUrl defines the url of the image
  75458. * @returns a new Button
  75459. */
  75460. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75461. }
  75462. }
  75463. declare module BABYLON.GUI {
  75464. /**
  75465. * Class used to create a 2D stack panel container
  75466. */
  75467. export class StackPanel extends Container {
  75468. name?: string | undefined;
  75469. private _isVertical;
  75470. private _manualWidth;
  75471. private _manualHeight;
  75472. private _doNotTrackManualChanges;
  75473. /**
  75474. * Gets or sets a boolean indicating that layou warnings should be ignored
  75475. */
  75476. ignoreLayoutWarnings: boolean;
  75477. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75478. get isVertical(): boolean;
  75479. set isVertical(value: boolean);
  75480. /**
  75481. * Gets or sets panel width.
  75482. * This value should not be set when in horizontal mode as it will be computed automatically
  75483. */
  75484. set width(value: string | number);
  75485. get width(): string | number;
  75486. /**
  75487. * Gets or sets panel height.
  75488. * This value should not be set when in vertical mode as it will be computed automatically
  75489. */
  75490. set height(value: string | number);
  75491. get height(): string | number;
  75492. /**
  75493. * Creates a new StackPanel
  75494. * @param name defines control name
  75495. */
  75496. constructor(name?: string | undefined);
  75497. protected _getTypeName(): string;
  75498. /** @hidden */
  75499. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75500. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75501. protected _postMeasure(): void;
  75502. }
  75503. }
  75504. declare module BABYLON.GUI {
  75505. /**
  75506. * Class used to represent a 2D checkbox
  75507. */
  75508. export class Checkbox extends Control {
  75509. name?: string | undefined;
  75510. private _isChecked;
  75511. private _background;
  75512. private _checkSizeRatio;
  75513. private _thickness;
  75514. /** Gets or sets border thickness */
  75515. get thickness(): number;
  75516. set thickness(value: number);
  75517. /**
  75518. * BABYLON.Observable raised when isChecked property changes
  75519. */
  75520. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75521. /** Gets or sets a value indicating the ratio between overall size and check size */
  75522. get checkSizeRatio(): number;
  75523. set checkSizeRatio(value: number);
  75524. /** Gets or sets background color */
  75525. get background(): string;
  75526. set background(value: string);
  75527. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75528. get isChecked(): boolean;
  75529. set isChecked(value: boolean);
  75530. /**
  75531. * Creates a new CheckBox
  75532. * @param name defines the control name
  75533. */
  75534. constructor(name?: string | undefined);
  75535. protected _getTypeName(): string;
  75536. /** @hidden */
  75537. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75538. /** @hidden */
  75539. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75540. /**
  75541. * Utility function to easily create a checkbox with a header
  75542. * @param title defines the label to use for the header
  75543. * @param onValueChanged defines the callback to call when value changes
  75544. * @returns a StackPanel containing the checkbox and a textBlock
  75545. */
  75546. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75547. }
  75548. }
  75549. declare module BABYLON.GUI {
  75550. /**
  75551. * Class used to store key control properties
  75552. */
  75553. export class KeyPropertySet {
  75554. /** Width */
  75555. width?: string;
  75556. /** Height */
  75557. height?: string;
  75558. /** Left padding */
  75559. paddingLeft?: string;
  75560. /** Right padding */
  75561. paddingRight?: string;
  75562. /** Top padding */
  75563. paddingTop?: string;
  75564. /** Bottom padding */
  75565. paddingBottom?: string;
  75566. /** Foreground color */
  75567. color?: string;
  75568. /** Background color */
  75569. background?: string;
  75570. }
  75571. /**
  75572. * Class used to create virtual keyboard
  75573. */
  75574. export class VirtualKeyboard extends StackPanel {
  75575. /** BABYLON.Observable raised when a key is pressed */
  75576. onKeyPressObservable: BABYLON.Observable<string>;
  75577. /** Gets or sets default key button width */
  75578. defaultButtonWidth: string;
  75579. /** Gets or sets default key button height */
  75580. defaultButtonHeight: string;
  75581. /** Gets or sets default key button left padding */
  75582. defaultButtonPaddingLeft: string;
  75583. /** Gets or sets default key button right padding */
  75584. defaultButtonPaddingRight: string;
  75585. /** Gets or sets default key button top padding */
  75586. defaultButtonPaddingTop: string;
  75587. /** Gets or sets default key button bottom padding */
  75588. defaultButtonPaddingBottom: string;
  75589. /** Gets or sets default key button foreground color */
  75590. defaultButtonColor: string;
  75591. /** Gets or sets default key button background color */
  75592. defaultButtonBackground: string;
  75593. /** Gets or sets shift button foreground color */
  75594. shiftButtonColor: string;
  75595. /** Gets or sets shift button thickness*/
  75596. selectedShiftThickness: number;
  75597. /** Gets shift key state */
  75598. shiftState: number;
  75599. protected _getTypeName(): string;
  75600. private _createKey;
  75601. /**
  75602. * Adds a new row of keys
  75603. * @param keys defines the list of keys to add
  75604. * @param propertySets defines the associated property sets
  75605. */
  75606. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75607. /**
  75608. * Set the shift key to a specific state
  75609. * @param shiftState defines the new shift state
  75610. */
  75611. applyShiftState(shiftState: number): void;
  75612. private _currentlyConnectedInputText;
  75613. private _connectedInputTexts;
  75614. private _onKeyPressObserver;
  75615. /** Gets the input text control currently attached to the keyboard */
  75616. get connectedInputText(): BABYLON.Nullable<InputText>;
  75617. /**
  75618. * Connects the keyboard with an input text control
  75619. *
  75620. * @param input defines the target control
  75621. */
  75622. connect(input: InputText): void;
  75623. /**
  75624. * Disconnects the keyboard from connected InputText controls
  75625. *
  75626. * @param input optionally defines a target control, otherwise all are disconnected
  75627. */
  75628. disconnect(input?: InputText): void;
  75629. private _removeConnectedInputObservables;
  75630. /**
  75631. * Release all resources
  75632. */
  75633. dispose(): void;
  75634. /**
  75635. * Creates a new keyboard using a default layout
  75636. *
  75637. * @param name defines control name
  75638. * @returns a new VirtualKeyboard
  75639. */
  75640. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75641. }
  75642. }
  75643. declare module BABYLON.GUI {
  75644. /**
  75645. * Class used to create input text control
  75646. */
  75647. export class InputText extends Control implements IFocusableControl {
  75648. name?: string | undefined;
  75649. private _text;
  75650. private _placeholderText;
  75651. private _background;
  75652. private _focusedBackground;
  75653. private _focusedColor;
  75654. private _placeholderColor;
  75655. private _thickness;
  75656. private _margin;
  75657. private _autoStretchWidth;
  75658. private _maxWidth;
  75659. private _isFocused;
  75660. private _blinkTimeout;
  75661. private _blinkIsEven;
  75662. private _cursorOffset;
  75663. private _scrollLeft;
  75664. private _textWidth;
  75665. private _clickedCoordinate;
  75666. private _deadKey;
  75667. private _addKey;
  75668. private _currentKey;
  75669. private _isTextHighlightOn;
  75670. private _textHighlightColor;
  75671. private _highligherOpacity;
  75672. private _highlightedText;
  75673. private _startHighlightIndex;
  75674. private _endHighlightIndex;
  75675. private _cursorIndex;
  75676. private _onFocusSelectAll;
  75677. private _isPointerDown;
  75678. private _onClipboardObserver;
  75679. private _onPointerDblTapObserver;
  75680. /** @hidden */
  75681. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75682. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75683. promptMessage: string;
  75684. /** Force disable prompt on mobile device */
  75685. disableMobilePrompt: boolean;
  75686. /** BABYLON.Observable raised when the text changes */
  75687. onTextChangedObservable: BABYLON.Observable<InputText>;
  75688. /** BABYLON.Observable raised just before an entered character is to be added */
  75689. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75690. /** BABYLON.Observable raised when the control gets the focus */
  75691. onFocusObservable: BABYLON.Observable<InputText>;
  75692. /** BABYLON.Observable raised when the control loses the focus */
  75693. onBlurObservable: BABYLON.Observable<InputText>;
  75694. /**Observable raised when the text is highlighted */
  75695. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75696. /**Observable raised when copy event is triggered */
  75697. onTextCopyObservable: BABYLON.Observable<InputText>;
  75698. /** BABYLON.Observable raised when cut event is triggered */
  75699. onTextCutObservable: BABYLON.Observable<InputText>;
  75700. /** BABYLON.Observable raised when paste event is triggered */
  75701. onTextPasteObservable: BABYLON.Observable<InputText>;
  75702. /** BABYLON.Observable raised when a key event was processed */
  75703. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75704. /** Gets or sets the maximum width allowed by the control */
  75705. get maxWidth(): string | number;
  75706. /** Gets the maximum width allowed by the control in pixels */
  75707. get maxWidthInPixels(): number;
  75708. set maxWidth(value: string | number);
  75709. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75710. get highligherOpacity(): number;
  75711. set highligherOpacity(value: number);
  75712. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75713. get onFocusSelectAll(): boolean;
  75714. set onFocusSelectAll(value: boolean);
  75715. /** Gets or sets the text hightlight color */
  75716. get textHighlightColor(): string;
  75717. set textHighlightColor(value: string);
  75718. /** Gets or sets control margin */
  75719. get margin(): string;
  75720. /** Gets control margin in pixels */
  75721. get marginInPixels(): number;
  75722. set margin(value: string);
  75723. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75724. get autoStretchWidth(): boolean;
  75725. set autoStretchWidth(value: boolean);
  75726. /** Gets or sets border thickness */
  75727. get thickness(): number;
  75728. set thickness(value: number);
  75729. /** Gets or sets the background color when focused */
  75730. get focusedBackground(): string;
  75731. set focusedBackground(value: string);
  75732. /** Gets or sets the background color when focused */
  75733. get focusedColor(): string;
  75734. set focusedColor(value: string);
  75735. /** Gets or sets the background color */
  75736. get background(): string;
  75737. set background(value: string);
  75738. /** Gets or sets the placeholder color */
  75739. get placeholderColor(): string;
  75740. set placeholderColor(value: string);
  75741. /** Gets or sets the text displayed when the control is empty */
  75742. get placeholderText(): string;
  75743. set placeholderText(value: string);
  75744. /** Gets or sets the dead key flag */
  75745. get deadKey(): boolean;
  75746. set deadKey(flag: boolean);
  75747. /** Gets or sets the highlight text */
  75748. get highlightedText(): string;
  75749. set highlightedText(text: string);
  75750. /** Gets or sets if the current key should be added */
  75751. get addKey(): boolean;
  75752. set addKey(flag: boolean);
  75753. /** Gets or sets the value of the current key being entered */
  75754. get currentKey(): string;
  75755. set currentKey(key: string);
  75756. /** Gets or sets the text displayed in the control */
  75757. get text(): string;
  75758. set text(value: string);
  75759. /** Gets or sets control width */
  75760. get width(): string | number;
  75761. set width(value: string | number);
  75762. /**
  75763. * Creates a new InputText
  75764. * @param name defines the control name
  75765. * @param text defines the text of the control
  75766. */
  75767. constructor(name?: string | undefined, text?: string);
  75768. /** @hidden */
  75769. onBlur(): void;
  75770. /** @hidden */
  75771. onFocus(): void;
  75772. protected _getTypeName(): string;
  75773. /**
  75774. * Function called to get the list of controls that should not steal the focus from this control
  75775. * @returns an array of controls
  75776. */
  75777. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75778. /** @hidden */
  75779. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75780. /** @hidden */
  75781. private _updateValueFromCursorIndex;
  75782. /** @hidden */
  75783. private _processDblClick;
  75784. /** @hidden */
  75785. private _selectAllText;
  75786. /**
  75787. * Handles the keyboard event
  75788. * @param evt Defines the KeyboardEvent
  75789. */
  75790. processKeyboard(evt: KeyboardEvent): void;
  75791. /** @hidden */
  75792. private _onCopyText;
  75793. /** @hidden */
  75794. private _onCutText;
  75795. /** @hidden */
  75796. private _onPasteText;
  75797. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75798. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75799. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75800. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75801. protected _beforeRenderText(text: string): string;
  75802. dispose(): void;
  75803. }
  75804. }
  75805. declare module BABYLON.GUI {
  75806. /**
  75807. * Class used to create a 2D grid container
  75808. */
  75809. export class Grid extends Container {
  75810. name?: string | undefined;
  75811. private _rowDefinitions;
  75812. private _columnDefinitions;
  75813. private _cells;
  75814. private _childControls;
  75815. /**
  75816. * Gets the number of columns
  75817. */
  75818. get columnCount(): number;
  75819. /**
  75820. * Gets the number of rows
  75821. */
  75822. get rowCount(): number;
  75823. /** Gets the list of children */
  75824. get children(): Control[];
  75825. /** Gets the list of cells (e.g. the containers) */
  75826. get cells(): {
  75827. [key: string]: Container;
  75828. };
  75829. /**
  75830. * Gets the definition of a specific row
  75831. * @param index defines the index of the row
  75832. * @returns the row definition
  75833. */
  75834. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75835. /**
  75836. * Gets the definition of a specific column
  75837. * @param index defines the index of the column
  75838. * @returns the column definition
  75839. */
  75840. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75841. /**
  75842. * Adds a new row to the grid
  75843. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75844. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75845. * @returns the current grid
  75846. */
  75847. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75848. /**
  75849. * Adds a new column to the grid
  75850. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75851. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75852. * @returns the current grid
  75853. */
  75854. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75855. /**
  75856. * Update a row definition
  75857. * @param index defines the index of the row to update
  75858. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75859. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75860. * @returns the current grid
  75861. */
  75862. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75863. /**
  75864. * Update a column definition
  75865. * @param index defines the index of the column to update
  75866. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75867. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75868. * @returns the current grid
  75869. */
  75870. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75871. /**
  75872. * Gets the list of children stored in a specific cell
  75873. * @param row defines the row to check
  75874. * @param column defines the column to check
  75875. * @returns the list of controls
  75876. */
  75877. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75878. /**
  75879. * Gets a string representing the child cell info (row x column)
  75880. * @param child defines the control to get info from
  75881. * @returns a string containing the child cell info (row x column)
  75882. */
  75883. getChildCellInfo(child: Control): string;
  75884. private _removeCell;
  75885. private _offsetCell;
  75886. /**
  75887. * Remove a column definition at specified index
  75888. * @param index defines the index of the column to remove
  75889. * @returns the current grid
  75890. */
  75891. removeColumnDefinition(index: number): Grid;
  75892. /**
  75893. * Remove a row definition at specified index
  75894. * @param index defines the index of the row to remove
  75895. * @returns the current grid
  75896. */
  75897. removeRowDefinition(index: number): Grid;
  75898. /**
  75899. * Adds a new control to the current grid
  75900. * @param control defines the control to add
  75901. * @param row defines the row where to add the control (0 by default)
  75902. * @param column defines the column where to add the control (0 by default)
  75903. * @returns the current grid
  75904. */
  75905. addControl(control: Control, row?: number, column?: number): Grid;
  75906. /**
  75907. * Removes a control from the current container
  75908. * @param control defines the control to remove
  75909. * @returns the current container
  75910. */
  75911. removeControl(control: Control): Container;
  75912. /**
  75913. * Creates a new Grid
  75914. * @param name defines control name
  75915. */
  75916. constructor(name?: string | undefined);
  75917. protected _getTypeName(): string;
  75918. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75919. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75920. _flagDescendantsAsMatrixDirty(): void;
  75921. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75922. /** Releases associated resources */
  75923. dispose(): void;
  75924. }
  75925. }
  75926. declare module BABYLON.GUI {
  75927. /** Class used to create color pickers */
  75928. export class ColorPicker extends Control {
  75929. name?: string | undefined;
  75930. private static _Epsilon;
  75931. private _colorWheelCanvas;
  75932. private _value;
  75933. private _tmpColor;
  75934. private _pointerStartedOnSquare;
  75935. private _pointerStartedOnWheel;
  75936. private _squareLeft;
  75937. private _squareTop;
  75938. private _squareSize;
  75939. private _h;
  75940. private _s;
  75941. private _v;
  75942. private _lastPointerDownID;
  75943. /**
  75944. * BABYLON.Observable raised when the value changes
  75945. */
  75946. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75947. /** Gets or sets the color of the color picker */
  75948. get value(): BABYLON.Color3;
  75949. set value(value: BABYLON.Color3);
  75950. /**
  75951. * Gets or sets control width
  75952. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75953. */
  75954. get width(): string | number;
  75955. set width(value: string | number);
  75956. /**
  75957. * Gets or sets control height
  75958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75959. */
  75960. get height(): string | number;
  75961. /** Gets or sets control height */
  75962. set height(value: string | number);
  75963. /** Gets or sets control size */
  75964. get size(): string | number;
  75965. set size(value: string | number);
  75966. /**
  75967. * Creates a new ColorPicker
  75968. * @param name defines the control name
  75969. */
  75970. constructor(name?: string | undefined);
  75971. protected _getTypeName(): string;
  75972. /** @hidden */
  75973. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75974. private _updateSquareProps;
  75975. private _drawGradientSquare;
  75976. private _drawCircle;
  75977. private _createColorWheelCanvas;
  75978. /** @hidden */
  75979. _draw(context: CanvasRenderingContext2D): void;
  75980. private _pointerIsDown;
  75981. private _updateValueFromPointer;
  75982. private _isPointOnSquare;
  75983. private _isPointOnWheel;
  75984. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75985. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75986. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75987. /**
  75988. * This function expands the color picker by creating a color picker dialog with manual
  75989. * color value input and the ability to save colors into an array to be used later in
  75990. * subsequent launches of the dialogue.
  75991. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75992. * @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.
  75993. * @returns picked color as a hex string and the saved colors array as hex strings.
  75994. */
  75995. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75996. pickerWidth?: string;
  75997. pickerHeight?: string;
  75998. headerHeight?: string;
  75999. lastColor?: string;
  76000. swatchLimit?: number;
  76001. numSwatchesPerLine?: number;
  76002. savedColors?: Array<string>;
  76003. }): Promise<{
  76004. savedColors?: string[];
  76005. pickedColor: string;
  76006. }>;
  76007. }
  76008. }
  76009. declare module BABYLON.GUI {
  76010. /** Class used to create 2D ellipse containers */
  76011. export class Ellipse extends Container {
  76012. name?: string | undefined;
  76013. private _thickness;
  76014. /** Gets or sets border thickness */
  76015. get thickness(): number;
  76016. set thickness(value: number);
  76017. /**
  76018. * Creates a new Ellipse
  76019. * @param name defines the control name
  76020. */
  76021. constructor(name?: string | undefined);
  76022. protected _getTypeName(): string;
  76023. protected _localDraw(context: CanvasRenderingContext2D): void;
  76024. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76025. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76026. }
  76027. }
  76028. declare module BABYLON.GUI {
  76029. /**
  76030. * Class used to create a password control
  76031. */
  76032. export class InputPassword extends InputText {
  76033. protected _beforeRenderText(text: string): string;
  76034. }
  76035. }
  76036. declare module BABYLON.GUI {
  76037. /** Class used to render 2D lines */
  76038. export class Line extends Control {
  76039. name?: string | undefined;
  76040. private _lineWidth;
  76041. private _x1;
  76042. private _y1;
  76043. private _x2;
  76044. private _y2;
  76045. private _dash;
  76046. private _connectedControl;
  76047. private _connectedControlDirtyObserver;
  76048. /** Gets or sets the dash pattern */
  76049. get dash(): Array<number>;
  76050. set dash(value: Array<number>);
  76051. /** Gets or sets the control connected with the line end */
  76052. get connectedControl(): Control;
  76053. set connectedControl(value: Control);
  76054. /** Gets or sets start coordinates on X axis */
  76055. get x1(): string | number;
  76056. set x1(value: string | number);
  76057. /** Gets or sets start coordinates on Y axis */
  76058. get y1(): string | number;
  76059. set y1(value: string | number);
  76060. /** Gets or sets end coordinates on X axis */
  76061. get x2(): string | number;
  76062. set x2(value: string | number);
  76063. /** Gets or sets end coordinates on Y axis */
  76064. get y2(): string | number;
  76065. set y2(value: string | number);
  76066. /** Gets or sets line width */
  76067. get lineWidth(): number;
  76068. set lineWidth(value: number);
  76069. /** Gets or sets horizontal alignment */
  76070. set horizontalAlignment(value: number);
  76071. /** Gets or sets vertical alignment */
  76072. set verticalAlignment(value: number);
  76073. private get _effectiveX2();
  76074. private get _effectiveY2();
  76075. /**
  76076. * Creates a new Line
  76077. * @param name defines the control name
  76078. */
  76079. constructor(name?: string | undefined);
  76080. protected _getTypeName(): string;
  76081. _draw(context: CanvasRenderingContext2D): void;
  76082. _measure(): void;
  76083. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76084. /**
  76085. * Move one end of the line given 3D cartesian coordinates.
  76086. * @param position Targeted world position
  76087. * @param scene BABYLON.Scene
  76088. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76089. */
  76090. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76091. /**
  76092. * Move one end of the line to a position in screen absolute space.
  76093. * @param projectedPosition Position in screen absolute space (X, Y)
  76094. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76095. */
  76096. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76097. }
  76098. }
  76099. declare module BABYLON.GUI {
  76100. /**
  76101. * Class used to store a point for a MultiLine object.
  76102. * The point can be pure 2D coordinates, a mesh or a control
  76103. */
  76104. export class MultiLinePoint {
  76105. private _multiLine;
  76106. private _x;
  76107. private _y;
  76108. private _control;
  76109. private _mesh;
  76110. private _controlObserver;
  76111. private _meshObserver;
  76112. /** @hidden */
  76113. _point: BABYLON.Vector2;
  76114. /**
  76115. * Creates a new MultiLinePoint
  76116. * @param multiLine defines the source MultiLine object
  76117. */
  76118. constructor(multiLine: MultiLine);
  76119. /** Gets or sets x coordinate */
  76120. get x(): string | number;
  76121. set x(value: string | number);
  76122. /** Gets or sets y coordinate */
  76123. get y(): string | number;
  76124. set y(value: string | number);
  76125. /** Gets or sets the control associated with this point */
  76126. get control(): BABYLON.Nullable<Control>;
  76127. set control(value: BABYLON.Nullable<Control>);
  76128. /** Gets or sets the mesh associated with this point */
  76129. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76130. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76131. /** Resets links */
  76132. resetLinks(): void;
  76133. /**
  76134. * Gets a translation vector
  76135. * @returns the translation vector
  76136. */
  76137. translate(): BABYLON.Vector2;
  76138. private _translatePoint;
  76139. /** Release associated resources */
  76140. dispose(): void;
  76141. }
  76142. }
  76143. declare module BABYLON.GUI {
  76144. /**
  76145. * Class used to create multi line control
  76146. */
  76147. export class MultiLine extends Control {
  76148. name?: string | undefined;
  76149. private _lineWidth;
  76150. private _dash;
  76151. private _points;
  76152. private _minX;
  76153. private _minY;
  76154. private _maxX;
  76155. private _maxY;
  76156. /**
  76157. * Creates a new MultiLine
  76158. * @param name defines the control name
  76159. */
  76160. constructor(name?: string | undefined);
  76161. /** Gets or sets dash pattern */
  76162. get dash(): Array<number>;
  76163. set dash(value: Array<number>);
  76164. /**
  76165. * Gets point stored at specified index
  76166. * @param index defines the index to look for
  76167. * @returns the requested point if found
  76168. */
  76169. getAt(index: number): MultiLinePoint;
  76170. /** Function called when a point is updated */
  76171. onPointUpdate: () => void;
  76172. /**
  76173. * Adds new points to the point collection
  76174. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76175. * @returns the list of created MultiLinePoint
  76176. */
  76177. add(...items: (AbstractMesh | Control | {
  76178. x: string | number;
  76179. y: string | number;
  76180. })[]): MultiLinePoint[];
  76181. /**
  76182. * Adds a new point to the point collection
  76183. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76184. * @returns the created MultiLinePoint
  76185. */
  76186. push(item?: (AbstractMesh | Control | {
  76187. x: string | number;
  76188. y: string | number;
  76189. })): MultiLinePoint;
  76190. /**
  76191. * Remove a specific value or point from the active point collection
  76192. * @param value defines the value or point to remove
  76193. */
  76194. remove(value: number | MultiLinePoint): void;
  76195. /**
  76196. * Resets this object to initial state (no point)
  76197. */
  76198. reset(): void;
  76199. /**
  76200. * Resets all links
  76201. */
  76202. resetLinks(): void;
  76203. /** Gets or sets line width */
  76204. get lineWidth(): number;
  76205. set lineWidth(value: number);
  76206. set horizontalAlignment(value: number);
  76207. set verticalAlignment(value: number);
  76208. protected _getTypeName(): string;
  76209. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76210. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76211. _measure(): void;
  76212. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76213. dispose(): void;
  76214. }
  76215. }
  76216. declare module BABYLON.GUI {
  76217. /**
  76218. * Class used to create radio button controls
  76219. */
  76220. export class RadioButton extends Control {
  76221. name?: string | undefined;
  76222. private _isChecked;
  76223. private _background;
  76224. private _checkSizeRatio;
  76225. private _thickness;
  76226. /** Gets or sets border thickness */
  76227. get thickness(): number;
  76228. set thickness(value: number);
  76229. /** Gets or sets group name */
  76230. group: string;
  76231. /** BABYLON.Observable raised when isChecked is changed */
  76232. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76233. /** Gets or sets a value indicating the ratio between overall size and check size */
  76234. get checkSizeRatio(): number;
  76235. set checkSizeRatio(value: number);
  76236. /** Gets or sets background color */
  76237. get background(): string;
  76238. set background(value: string);
  76239. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76240. get isChecked(): boolean;
  76241. set isChecked(value: boolean);
  76242. /**
  76243. * Creates a new RadioButton
  76244. * @param name defines the control name
  76245. */
  76246. constructor(name?: string | undefined);
  76247. protected _getTypeName(): string;
  76248. _draw(context: CanvasRenderingContext2D): void;
  76249. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76250. /**
  76251. * Utility function to easily create a radio button with a header
  76252. * @param title defines the label to use for the header
  76253. * @param group defines the group to use for the radio button
  76254. * @param isChecked defines the initial state of the radio button
  76255. * @param onValueChanged defines the callback to call when value changes
  76256. * @returns a StackPanel containing the radio button and a textBlock
  76257. */
  76258. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76259. }
  76260. }
  76261. declare module BABYLON.GUI {
  76262. /**
  76263. * Class used to create slider controls
  76264. */
  76265. export class BaseSlider extends Control {
  76266. name?: string | undefined;
  76267. protected _thumbWidth: ValueAndUnit;
  76268. private _minimum;
  76269. private _maximum;
  76270. private _value;
  76271. private _isVertical;
  76272. protected _barOffset: ValueAndUnit;
  76273. private _isThumbClamped;
  76274. protected _displayThumb: boolean;
  76275. private _step;
  76276. private _lastPointerDownID;
  76277. protected _effectiveBarOffset: number;
  76278. protected _renderLeft: number;
  76279. protected _renderTop: number;
  76280. protected _renderWidth: number;
  76281. protected _renderHeight: number;
  76282. protected _backgroundBoxLength: number;
  76283. protected _backgroundBoxThickness: number;
  76284. protected _effectiveThumbThickness: number;
  76285. /** BABYLON.Observable raised when the sldier value changes */
  76286. onValueChangedObservable: BABYLON.Observable<number>;
  76287. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76288. get displayThumb(): boolean;
  76289. set displayThumb(value: boolean);
  76290. /** Gets or sets a step to apply to values (0 by default) */
  76291. get step(): number;
  76292. set step(value: number);
  76293. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76294. get barOffset(): string | number;
  76295. /** Gets main bar offset in pixels*/
  76296. get barOffsetInPixels(): number;
  76297. set barOffset(value: string | number);
  76298. /** Gets or sets thumb width */
  76299. get thumbWidth(): string | number;
  76300. /** Gets thumb width in pixels */
  76301. get thumbWidthInPixels(): number;
  76302. set thumbWidth(value: string | number);
  76303. /** Gets or sets minimum value */
  76304. get minimum(): number;
  76305. set minimum(value: number);
  76306. /** Gets or sets maximum value */
  76307. get maximum(): number;
  76308. set maximum(value: number);
  76309. /** Gets or sets current value */
  76310. get value(): number;
  76311. set value(value: number);
  76312. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76313. get isVertical(): boolean;
  76314. set isVertical(value: boolean);
  76315. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76316. get isThumbClamped(): boolean;
  76317. set isThumbClamped(value: boolean);
  76318. /**
  76319. * Creates a new BaseSlider
  76320. * @param name defines the control name
  76321. */
  76322. constructor(name?: string | undefined);
  76323. protected _getTypeName(): string;
  76324. protected _getThumbPosition(): number;
  76325. protected _getThumbThickness(type: string): number;
  76326. protected _prepareRenderingData(type: string): void;
  76327. private _pointerIsDown;
  76328. /** @hidden */
  76329. protected _updateValueFromPointer(x: number, y: number): void;
  76330. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76331. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76332. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76333. }
  76334. }
  76335. declare module BABYLON.GUI {
  76336. /**
  76337. * Class used to create slider controls
  76338. */
  76339. export class Slider extends BaseSlider {
  76340. name?: string | undefined;
  76341. private _background;
  76342. private _borderColor;
  76343. private _isThumbCircle;
  76344. protected _displayValueBar: boolean;
  76345. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76346. get displayValueBar(): boolean;
  76347. set displayValueBar(value: boolean);
  76348. /** Gets or sets border color */
  76349. get borderColor(): string;
  76350. set borderColor(value: string);
  76351. /** Gets or sets background color */
  76352. get background(): string;
  76353. set background(value: string);
  76354. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76355. get isThumbCircle(): boolean;
  76356. set isThumbCircle(value: boolean);
  76357. /**
  76358. * Creates a new Slider
  76359. * @param name defines the control name
  76360. */
  76361. constructor(name?: string | undefined);
  76362. protected _getTypeName(): string;
  76363. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76364. }
  76365. }
  76366. declare module BABYLON.GUI {
  76367. /** Class used to create a RadioGroup
  76368. * which contains groups of radio buttons
  76369. */
  76370. export class SelectorGroup {
  76371. /** name of SelectorGroup */
  76372. name: string;
  76373. private _groupPanel;
  76374. private _selectors;
  76375. private _groupHeader;
  76376. /**
  76377. * Creates a new SelectorGroup
  76378. * @param name of group, used as a group heading
  76379. */
  76380. constructor(
  76381. /** name of SelectorGroup */
  76382. name: string);
  76383. /** Gets the groupPanel of the SelectorGroup */
  76384. get groupPanel(): StackPanel;
  76385. /** Gets the selectors array */
  76386. get selectors(): StackPanel[];
  76387. /** Gets and sets the group header */
  76388. get header(): string;
  76389. set header(label: string);
  76390. /** @hidden */
  76391. private _addGroupHeader;
  76392. /** @hidden*/
  76393. _getSelector(selectorNb: number): StackPanel | undefined;
  76394. /** Removes the selector at the given position
  76395. * @param selectorNb the position of the selector within the group
  76396. */
  76397. removeSelector(selectorNb: number): void;
  76398. }
  76399. /** Class used to create a CheckboxGroup
  76400. * which contains groups of checkbox buttons
  76401. */
  76402. export class CheckboxGroup extends SelectorGroup {
  76403. /** Adds a checkbox as a control
  76404. * @param text is the label for the selector
  76405. * @param func is the function called when the Selector is checked
  76406. * @param checked is true when Selector is checked
  76407. */
  76408. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76409. /** @hidden */
  76410. _setSelectorLabel(selectorNb: number, label: string): void;
  76411. /** @hidden */
  76412. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76413. /** @hidden */
  76414. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76415. /** @hidden */
  76416. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76417. }
  76418. /** Class used to create a RadioGroup
  76419. * which contains groups of radio buttons
  76420. */
  76421. export class RadioGroup extends SelectorGroup {
  76422. private _selectNb;
  76423. /** Adds a radio button as a control
  76424. * @param label is the label for the selector
  76425. * @param func is the function called when the Selector is checked
  76426. * @param checked is true when Selector is checked
  76427. */
  76428. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76429. /** @hidden */
  76430. _setSelectorLabel(selectorNb: number, label: string): void;
  76431. /** @hidden */
  76432. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76433. /** @hidden */
  76434. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76435. /** @hidden */
  76436. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76437. }
  76438. /** Class used to create a SliderGroup
  76439. * which contains groups of slider buttons
  76440. */
  76441. export class SliderGroup extends SelectorGroup {
  76442. /**
  76443. * Adds a slider to the SelectorGroup
  76444. * @param label is the label for the SliderBar
  76445. * @param func is the function called when the Slider moves
  76446. * @param unit is a string describing the units used, eg degrees or metres
  76447. * @param min is the minimum value for the Slider
  76448. * @param max is the maximum value for the Slider
  76449. * @param value is the start value for the Slider between min and max
  76450. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76451. */
  76452. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76453. /** @hidden */
  76454. _setSelectorLabel(selectorNb: number, label: string): void;
  76455. /** @hidden */
  76456. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76457. /** @hidden */
  76458. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76459. /** @hidden */
  76460. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76461. }
  76462. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76463. * @see http://doc.babylonjs.com/how_to/selector
  76464. */
  76465. export class SelectionPanel extends Rectangle {
  76466. /** name of SelectionPanel */
  76467. name: string;
  76468. /** an array of SelectionGroups */
  76469. groups: SelectorGroup[];
  76470. private _panel;
  76471. private _buttonColor;
  76472. private _buttonBackground;
  76473. private _headerColor;
  76474. private _barColor;
  76475. private _barHeight;
  76476. private _spacerHeight;
  76477. private _labelColor;
  76478. private _groups;
  76479. private _bars;
  76480. /**
  76481. * Creates a new SelectionPanel
  76482. * @param name of SelectionPanel
  76483. * @param groups is an array of SelectionGroups
  76484. */
  76485. constructor(
  76486. /** name of SelectionPanel */
  76487. name: string,
  76488. /** an array of SelectionGroups */
  76489. groups?: SelectorGroup[]);
  76490. protected _getTypeName(): string;
  76491. /** Gets or sets the headerColor */
  76492. get headerColor(): string;
  76493. set headerColor(color: string);
  76494. private _setHeaderColor;
  76495. /** Gets or sets the button color */
  76496. get buttonColor(): string;
  76497. set buttonColor(color: string);
  76498. private _setbuttonColor;
  76499. /** Gets or sets the label color */
  76500. get labelColor(): string;
  76501. set labelColor(color: string);
  76502. private _setLabelColor;
  76503. /** Gets or sets the button background */
  76504. get buttonBackground(): string;
  76505. set buttonBackground(color: string);
  76506. private _setButtonBackground;
  76507. /** Gets or sets the color of separator bar */
  76508. get barColor(): string;
  76509. set barColor(color: string);
  76510. private _setBarColor;
  76511. /** Gets or sets the height of separator bar */
  76512. get barHeight(): string;
  76513. set barHeight(value: string);
  76514. private _setBarHeight;
  76515. /** Gets or sets the height of spacers*/
  76516. get spacerHeight(): string;
  76517. set spacerHeight(value: string);
  76518. private _setSpacerHeight;
  76519. /** Adds a bar between groups */
  76520. private _addSpacer;
  76521. /** Add a group to the selection panel
  76522. * @param group is the selector group to add
  76523. */
  76524. addGroup(group: SelectorGroup): void;
  76525. /** Remove the group from the given position
  76526. * @param groupNb is the position of the group in the list
  76527. */
  76528. removeGroup(groupNb: number): void;
  76529. /** Change a group header label
  76530. * @param label is the new group header label
  76531. * @param groupNb is the number of the group to relabel
  76532. * */
  76533. setHeaderName(label: string, groupNb: number): void;
  76534. /** Change selector label to the one given
  76535. * @param label is the new selector label
  76536. * @param groupNb is the number of the groupcontaining the selector
  76537. * @param selectorNb is the number of the selector within a group to relabel
  76538. * */
  76539. relabel(label: string, groupNb: number, selectorNb: number): void;
  76540. /** For a given group position remove the selector at the given position
  76541. * @param groupNb is the number of the group to remove the selector from
  76542. * @param selectorNb is the number of the selector within the group
  76543. */
  76544. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76545. /** For a given group position of correct type add a checkbox button
  76546. * @param groupNb is the number of the group to remove the selector from
  76547. * @param label is the label for the selector
  76548. * @param func is the function called when the Selector is checked
  76549. * @param checked is true when Selector is checked
  76550. */
  76551. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76552. /** For a given group position of correct type add a radio button
  76553. * @param groupNb is the number of the group to remove the selector from
  76554. * @param label is the label for the selector
  76555. * @param func is the function called when the Selector is checked
  76556. * @param checked is true when Selector is checked
  76557. */
  76558. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76559. /**
  76560. * For a given slider group add a slider
  76561. * @param groupNb is the number of the group to add the slider to
  76562. * @param label is the label for the Slider
  76563. * @param func is the function called when the Slider moves
  76564. * @param unit is a string describing the units used, eg degrees or metres
  76565. * @param min is the minimum value for the Slider
  76566. * @param max is the maximum value for the Slider
  76567. * @param value is the start value for the Slider between min and max
  76568. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76569. */
  76570. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76571. }
  76572. }
  76573. declare module BABYLON.GUI {
  76574. /**
  76575. * Class used to hold a the container for ScrollViewer
  76576. * @hidden
  76577. */
  76578. export class _ScrollViewerWindow extends Container {
  76579. parentClientWidth: number;
  76580. parentClientHeight: number;
  76581. private _freezeControls;
  76582. private _parentMeasure;
  76583. private _oldLeft;
  76584. private _oldTop;
  76585. get freezeControls(): boolean;
  76586. set freezeControls(value: boolean);
  76587. private _bucketWidth;
  76588. private _bucketHeight;
  76589. private _buckets;
  76590. private _bucketLen;
  76591. get bucketWidth(): number;
  76592. get bucketHeight(): number;
  76593. setBucketSizes(width: number, height: number): void;
  76594. private _useBuckets;
  76595. private _makeBuckets;
  76596. private _dispatchInBuckets;
  76597. private _updateMeasures;
  76598. private _updateChildrenMeasures;
  76599. private _restoreMeasures;
  76600. /**
  76601. * Creates a new ScrollViewerWindow
  76602. * @param name of ScrollViewerWindow
  76603. */
  76604. constructor(name?: string);
  76605. protected _getTypeName(): string;
  76606. /** @hidden */
  76607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76608. /** @hidden */
  76609. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76610. private _scrollChildren;
  76611. private _scrollChildrenWithBuckets;
  76612. /** @hidden */
  76613. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76614. protected _postMeasure(): void;
  76615. }
  76616. }
  76617. declare module BABYLON.GUI {
  76618. /**
  76619. * Class used to create slider controls
  76620. */
  76621. export class ScrollBar extends BaseSlider {
  76622. name?: string | undefined;
  76623. private _background;
  76624. private _borderColor;
  76625. private _tempMeasure;
  76626. /** Gets or sets border color */
  76627. get borderColor(): string;
  76628. set borderColor(value: string);
  76629. /** Gets or sets background color */
  76630. get background(): string;
  76631. set background(value: string);
  76632. /**
  76633. * Creates a new Slider
  76634. * @param name defines the control name
  76635. */
  76636. constructor(name?: string | undefined);
  76637. protected _getTypeName(): string;
  76638. protected _getThumbThickness(): number;
  76639. _draw(context: CanvasRenderingContext2D): void;
  76640. private _first;
  76641. private _originX;
  76642. private _originY;
  76643. /** @hidden */
  76644. protected _updateValueFromPointer(x: number, y: number): void;
  76645. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76646. }
  76647. }
  76648. declare module BABYLON.GUI {
  76649. /**
  76650. * Class used to create slider controls
  76651. */
  76652. export class ImageScrollBar extends BaseSlider {
  76653. name?: string | undefined;
  76654. private _backgroundBaseImage;
  76655. private _backgroundImage;
  76656. private _thumbImage;
  76657. private _thumbBaseImage;
  76658. private _thumbLength;
  76659. private _thumbHeight;
  76660. private _barImageHeight;
  76661. private _tempMeasure;
  76662. /** Number of 90° rotation to apply on the images when in vertical mode */
  76663. num90RotationInVerticalMode: number;
  76664. /**
  76665. * Gets or sets the image used to render the background for horizontal bar
  76666. */
  76667. get backgroundImage(): Image;
  76668. set backgroundImage(value: Image);
  76669. /**
  76670. * Gets or sets the image used to render the thumb
  76671. */
  76672. get thumbImage(): Image;
  76673. set thumbImage(value: Image);
  76674. /**
  76675. * Gets or sets the length of the thumb
  76676. */
  76677. get thumbLength(): number;
  76678. set thumbLength(value: number);
  76679. /**
  76680. * Gets or sets the height of the thumb
  76681. */
  76682. get thumbHeight(): number;
  76683. set thumbHeight(value: number);
  76684. /**
  76685. * Gets or sets the height of the bar image
  76686. */
  76687. get barImageHeight(): number;
  76688. set barImageHeight(value: number);
  76689. /**
  76690. * Creates a new ImageScrollBar
  76691. * @param name defines the control name
  76692. */
  76693. constructor(name?: string | undefined);
  76694. protected _getTypeName(): string;
  76695. protected _getThumbThickness(): number;
  76696. _draw(context: CanvasRenderingContext2D): void;
  76697. private _first;
  76698. private _originX;
  76699. private _originY;
  76700. /** @hidden */
  76701. protected _updateValueFromPointer(x: number, y: number): void;
  76702. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76703. }
  76704. }
  76705. declare module BABYLON.GUI {
  76706. /**
  76707. * Class used to hold a viewer window and sliders in a grid
  76708. */
  76709. export class ScrollViewer extends Rectangle {
  76710. private _grid;
  76711. private _horizontalBarSpace;
  76712. private _verticalBarSpace;
  76713. private _dragSpace;
  76714. private _horizontalBar;
  76715. private _verticalBar;
  76716. private _barColor;
  76717. private _barBackground;
  76718. private _barImage;
  76719. private _horizontalBarImage;
  76720. private _verticalBarImage;
  76721. private _barBackgroundImage;
  76722. private _horizontalBarBackgroundImage;
  76723. private _verticalBarBackgroundImage;
  76724. private _barSize;
  76725. private _window;
  76726. private _pointerIsOver;
  76727. private _wheelPrecision;
  76728. private _onWheelObserver;
  76729. private _clientWidth;
  76730. private _clientHeight;
  76731. private _useImageBar;
  76732. private _thumbLength;
  76733. private _thumbHeight;
  76734. private _barImageHeight;
  76735. private _horizontalBarImageHeight;
  76736. private _verticalBarImageHeight;
  76737. private _oldWindowContentsWidth;
  76738. private _oldWindowContentsHeight;
  76739. /**
  76740. * Gets the horizontal scrollbar
  76741. */
  76742. get horizontalBar(): ScrollBar | ImageScrollBar;
  76743. /**
  76744. * Gets the vertical scrollbar
  76745. */
  76746. get verticalBar(): ScrollBar | ImageScrollBar;
  76747. /**
  76748. * Adds a new control to the current container
  76749. * @param control defines the control to add
  76750. * @returns the current container
  76751. */
  76752. addControl(control: BABYLON.Nullable<Control>): Container;
  76753. /**
  76754. * Removes a control from the current container
  76755. * @param control defines the control to remove
  76756. * @returns the current container
  76757. */
  76758. removeControl(control: Control): Container;
  76759. /** Gets the list of children */
  76760. get children(): Control[];
  76761. _flagDescendantsAsMatrixDirty(): void;
  76762. /**
  76763. * Freezes or unfreezes the controls in the window.
  76764. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76765. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76766. */
  76767. get freezeControls(): boolean;
  76768. set freezeControls(value: boolean);
  76769. /** Gets the bucket width */
  76770. get bucketWidth(): number;
  76771. /** Gets the bucket height */
  76772. get bucketHeight(): number;
  76773. /**
  76774. * Sets the bucket sizes.
  76775. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76776. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76777. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76778. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76779. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76780. * used), that's why it is not enabled by default.
  76781. * @param width width of the bucket
  76782. * @param height height of the bucket
  76783. */
  76784. setBucketSizes(width: number, height: number): void;
  76785. private _forceHorizontalBar;
  76786. private _forceVerticalBar;
  76787. /**
  76788. * Forces the horizontal scroll bar to be displayed
  76789. */
  76790. get forceHorizontalBar(): boolean;
  76791. set forceHorizontalBar(value: boolean);
  76792. /**
  76793. * Forces the vertical scroll bar to be displayed
  76794. */
  76795. get forceVerticalBar(): boolean;
  76796. set forceVerticalBar(value: boolean);
  76797. /**
  76798. * Creates a new ScrollViewer
  76799. * @param name of ScrollViewer
  76800. */
  76801. constructor(name?: string, isImageBased?: boolean);
  76802. /** Reset the scroll viewer window to initial size */
  76803. resetWindow(): void;
  76804. protected _getTypeName(): string;
  76805. private _buildClientSizes;
  76806. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76807. protected _postMeasure(): void;
  76808. /**
  76809. * Gets or sets the mouse wheel precision
  76810. * from 0 to 1 with a default value of 0.05
  76811. * */
  76812. get wheelPrecision(): number;
  76813. set wheelPrecision(value: number);
  76814. /** Gets or sets the scroll bar container background color */
  76815. get scrollBackground(): string;
  76816. set scrollBackground(color: string);
  76817. /** Gets or sets the bar color */
  76818. get barColor(): string;
  76819. set barColor(color: string);
  76820. /** Gets or sets the bar image */
  76821. get thumbImage(): Image;
  76822. set thumbImage(value: Image);
  76823. /** Gets or sets the horizontal bar image */
  76824. get horizontalThumbImage(): Image;
  76825. set horizontalThumbImage(value: Image);
  76826. /** Gets or sets the vertical bar image */
  76827. get verticalThumbImage(): Image;
  76828. set verticalThumbImage(value: Image);
  76829. /** Gets or sets the size of the bar */
  76830. get barSize(): number;
  76831. set barSize(value: number);
  76832. /** Gets or sets the length of the thumb */
  76833. get thumbLength(): number;
  76834. set thumbLength(value: number);
  76835. /** Gets or sets the height of the thumb */
  76836. get thumbHeight(): number;
  76837. set thumbHeight(value: number);
  76838. /** Gets or sets the height of the bar image */
  76839. get barImageHeight(): number;
  76840. set barImageHeight(value: number);
  76841. /** Gets or sets the height of the horizontal bar image */
  76842. get horizontalBarImageHeight(): number;
  76843. set horizontalBarImageHeight(value: number);
  76844. /** Gets or sets the height of the vertical bar image */
  76845. get verticalBarImageHeight(): number;
  76846. set verticalBarImageHeight(value: number);
  76847. /** Gets or sets the bar background */
  76848. get barBackground(): string;
  76849. set barBackground(color: string);
  76850. /** Gets or sets the bar background image */
  76851. get barImage(): Image;
  76852. set barImage(value: Image);
  76853. /** Gets or sets the horizontal bar background image */
  76854. get horizontalBarImage(): Image;
  76855. set horizontalBarImage(value: Image);
  76856. /** Gets or sets the vertical bar background image */
  76857. get verticalBarImage(): Image;
  76858. set verticalBarImage(value: Image);
  76859. private _setWindowPosition;
  76860. /** @hidden */
  76861. private _updateScroller;
  76862. _link(host: AdvancedDynamicTexture): void;
  76863. /** @hidden */
  76864. private _addBar;
  76865. /** @hidden */
  76866. private _attachWheel;
  76867. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76868. /** Releases associated resources */
  76869. dispose(): void;
  76870. }
  76871. }
  76872. declare module BABYLON.GUI {
  76873. /** Class used to render a grid */
  76874. export class DisplayGrid extends Control {
  76875. name?: string | undefined;
  76876. private _cellWidth;
  76877. private _cellHeight;
  76878. private _minorLineTickness;
  76879. private _minorLineColor;
  76880. private _majorLineTickness;
  76881. private _majorLineColor;
  76882. private _majorLineFrequency;
  76883. private _background;
  76884. private _displayMajorLines;
  76885. private _displayMinorLines;
  76886. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76887. get displayMinorLines(): boolean;
  76888. set displayMinorLines(value: boolean);
  76889. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76890. get displayMajorLines(): boolean;
  76891. set displayMajorLines(value: boolean);
  76892. /** Gets or sets background color (Black by default) */
  76893. get background(): string;
  76894. set background(value: string);
  76895. /** Gets or sets the width of each cell (20 by default) */
  76896. get cellWidth(): number;
  76897. set cellWidth(value: number);
  76898. /** Gets or sets the height of each cell (20 by default) */
  76899. get cellHeight(): number;
  76900. set cellHeight(value: number);
  76901. /** Gets or sets the tickness of minor lines (1 by default) */
  76902. get minorLineTickness(): number;
  76903. set minorLineTickness(value: number);
  76904. /** Gets or sets the color of minor lines (DarkGray by default) */
  76905. get minorLineColor(): string;
  76906. set minorLineColor(value: string);
  76907. /** Gets or sets the tickness of major lines (2 by default) */
  76908. get majorLineTickness(): number;
  76909. set majorLineTickness(value: number);
  76910. /** Gets or sets the color of major lines (White by default) */
  76911. get majorLineColor(): string;
  76912. set majorLineColor(value: string);
  76913. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76914. get majorLineFrequency(): number;
  76915. set majorLineFrequency(value: number);
  76916. /**
  76917. * Creates a new GridDisplayRectangle
  76918. * @param name defines the control name
  76919. */
  76920. constructor(name?: string | undefined);
  76921. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76922. protected _getTypeName(): string;
  76923. }
  76924. }
  76925. declare module BABYLON.GUI {
  76926. /**
  76927. * Class used to create slider controls based on images
  76928. */
  76929. export class ImageBasedSlider extends BaseSlider {
  76930. name?: string | undefined;
  76931. private _backgroundImage;
  76932. private _thumbImage;
  76933. private _valueBarImage;
  76934. private _tempMeasure;
  76935. get displayThumb(): boolean;
  76936. set displayThumb(value: boolean);
  76937. /**
  76938. * Gets or sets the image used to render the background
  76939. */
  76940. get backgroundImage(): Image;
  76941. set backgroundImage(value: Image);
  76942. /**
  76943. * Gets or sets the image used to render the value bar
  76944. */
  76945. get valueBarImage(): Image;
  76946. set valueBarImage(value: Image);
  76947. /**
  76948. * Gets or sets the image used to render the thumb
  76949. */
  76950. get thumbImage(): Image;
  76951. set thumbImage(value: Image);
  76952. /**
  76953. * Creates a new ImageBasedSlider
  76954. * @param name defines the control name
  76955. */
  76956. constructor(name?: string | undefined);
  76957. protected _getTypeName(): string;
  76958. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76959. }
  76960. }
  76961. declare module BABYLON.GUI {
  76962. /**
  76963. * Forcing an export so that this code will execute
  76964. * @hidden
  76965. */
  76966. const name = "Statics";
  76967. }
  76968. declare module BABYLON.GUI {
  76969. /**
  76970. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76971. */
  76972. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76973. /**
  76974. * Define the instrumented AdvancedDynamicTexture.
  76975. */
  76976. texture: AdvancedDynamicTexture;
  76977. private _captureRenderTime;
  76978. private _renderTime;
  76979. private _captureLayoutTime;
  76980. private _layoutTime;
  76981. private _onBeginRenderObserver;
  76982. private _onEndRenderObserver;
  76983. private _onBeginLayoutObserver;
  76984. private _onEndLayoutObserver;
  76985. /**
  76986. * Gets the perf counter used to capture render time
  76987. */
  76988. get renderTimeCounter(): BABYLON.PerfCounter;
  76989. /**
  76990. * Gets the perf counter used to capture layout time
  76991. */
  76992. get layoutTimeCounter(): BABYLON.PerfCounter;
  76993. /**
  76994. * Enable or disable the render time capture
  76995. */
  76996. get captureRenderTime(): boolean;
  76997. set captureRenderTime(value: boolean);
  76998. /**
  76999. * Enable or disable the layout time capture
  77000. */
  77001. get captureLayoutTime(): boolean;
  77002. set captureLayoutTime(value: boolean);
  77003. /**
  77004. * Instantiates a new advanced dynamic texture instrumentation.
  77005. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77006. * @param texture Defines the AdvancedDynamicTexture to instrument
  77007. */
  77008. constructor(
  77009. /**
  77010. * Define the instrumented AdvancedDynamicTexture.
  77011. */
  77012. texture: AdvancedDynamicTexture);
  77013. /**
  77014. * Dispose and release associated resources.
  77015. */
  77016. dispose(): void;
  77017. }
  77018. }
  77019. declare module BABYLON.GUI {
  77020. /**
  77021. * Class used to load GUI via XML.
  77022. */
  77023. export class XmlLoader {
  77024. private _nodes;
  77025. private _nodeTypes;
  77026. private _isLoaded;
  77027. private _objectAttributes;
  77028. private _parentClass;
  77029. /**
  77030. * Create a new xml loader
  77031. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77032. */
  77033. constructor(parentClass?: null);
  77034. private _getChainElement;
  77035. private _getClassAttribute;
  77036. private _createGuiElement;
  77037. private _parseGrid;
  77038. private _parseElement;
  77039. private _prepareSourceElement;
  77040. private _parseElementsFromSource;
  77041. private _parseXml;
  77042. /**
  77043. * Gets if the loading has finished.
  77044. * @returns whether the loading has finished or not
  77045. */
  77046. isLoaded(): boolean;
  77047. /**
  77048. * Gets a loaded node / control by id.
  77049. * @param id the Controls id set in the xml
  77050. * @returns element of type Control
  77051. */
  77052. getNodeById(id: string): any;
  77053. /**
  77054. * Gets all loaded nodes / controls
  77055. * @returns Array of controls
  77056. */
  77057. getNodes(): any;
  77058. /**
  77059. * Initiates the xml layout loading
  77060. * @param xmlFile defines the xml layout to load
  77061. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77062. * @param callback defines the callback called on layout load.
  77063. */
  77064. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77065. }
  77066. }
  77067. declare module BABYLON.GUI {
  77068. /**
  77069. * Class used to create containers for controls
  77070. */
  77071. export class Container3D extends Control3D {
  77072. private _blockLayout;
  77073. /**
  77074. * Gets the list of child controls
  77075. */
  77076. protected _children: Control3D[];
  77077. /**
  77078. * Gets the list of child controls
  77079. */
  77080. get children(): Array<Control3D>;
  77081. /**
  77082. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77083. * This is helpful to optimize layout operation when adding multiple children in a row
  77084. */
  77085. get blockLayout(): boolean;
  77086. set blockLayout(value: boolean);
  77087. /**
  77088. * Creates a new container
  77089. * @param name defines the container name
  77090. */
  77091. constructor(name?: string);
  77092. /**
  77093. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77094. * @returns the current container
  77095. */
  77096. updateLayout(): Container3D;
  77097. /**
  77098. * Gets a boolean indicating if the given control is in the children of this control
  77099. * @param control defines the control to check
  77100. * @returns true if the control is in the child list
  77101. */
  77102. containsControl(control: Control3D): boolean;
  77103. /**
  77104. * Adds a control to the children of this control
  77105. * @param control defines the control to add
  77106. * @returns the current container
  77107. */
  77108. addControl(control: Control3D): Container3D;
  77109. /**
  77110. * This function will be called everytime a new control is added
  77111. */
  77112. protected _arrangeChildren(): void;
  77113. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77114. /**
  77115. * Removes a control from the children of this control
  77116. * @param control defines the control to remove
  77117. * @returns the current container
  77118. */
  77119. removeControl(control: Control3D): Container3D;
  77120. protected _getTypeName(): string;
  77121. /**
  77122. * Releases all associated resources
  77123. */
  77124. dispose(): void;
  77125. /** Control rotation will remain unchanged */
  77126. static readonly UNSET_ORIENTATION: number;
  77127. /** Control will rotate to make it look at sphere central axis */
  77128. static readonly FACEORIGIN_ORIENTATION: number;
  77129. /** Control will rotate to make it look back at sphere central axis */
  77130. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77131. /** Control will rotate to look at z axis (0, 0, 1) */
  77132. static readonly FACEFORWARD_ORIENTATION: number;
  77133. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77134. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77135. }
  77136. }
  77137. declare module BABYLON.GUI {
  77138. /**
  77139. * Class used to manage 3D user interface
  77140. * @see http://doc.babylonjs.com/how_to/gui3d
  77141. */
  77142. export class GUI3DManager implements BABYLON.IDisposable {
  77143. private _scene;
  77144. private _sceneDisposeObserver;
  77145. private _utilityLayer;
  77146. private _rootContainer;
  77147. private _pointerObserver;
  77148. private _pointerOutObserver;
  77149. /** @hidden */
  77150. _lastPickedControl: Control3D;
  77151. /** @hidden */
  77152. _lastControlOver: {
  77153. [pointerId: number]: Control3D;
  77154. };
  77155. /** @hidden */
  77156. _lastControlDown: {
  77157. [pointerId: number]: Control3D;
  77158. };
  77159. /**
  77160. * BABYLON.Observable raised when the point picked by the pointer events changed
  77161. */
  77162. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77163. /** @hidden */
  77164. _sharedMaterials: {
  77165. [key: string]: BABYLON.Material;
  77166. };
  77167. /** Gets the hosting scene */
  77168. get scene(): BABYLON.Scene;
  77169. /** Gets associated utility layer */
  77170. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77171. /**
  77172. * Creates a new GUI3DManager
  77173. * @param scene
  77174. */
  77175. constructor(scene?: BABYLON.Scene);
  77176. private _handlePointerOut;
  77177. private _doPicking;
  77178. /**
  77179. * Gets the root container
  77180. */
  77181. get rootContainer(): Container3D;
  77182. /**
  77183. * Gets a boolean indicating if the given control is in the root child list
  77184. * @param control defines the control to check
  77185. * @returns true if the control is in the root child list
  77186. */
  77187. containsControl(control: Control3D): boolean;
  77188. /**
  77189. * Adds a control to the root child list
  77190. * @param control defines the control to add
  77191. * @returns the current manager
  77192. */
  77193. addControl(control: Control3D): GUI3DManager;
  77194. /**
  77195. * Removes a control from the root child list
  77196. * @param control defines the control to remove
  77197. * @returns the current container
  77198. */
  77199. removeControl(control: Control3D): GUI3DManager;
  77200. /**
  77201. * Releases all associated resources
  77202. */
  77203. dispose(): void;
  77204. }
  77205. }
  77206. declare module BABYLON.GUI {
  77207. /**
  77208. * Class used to transport BABYLON.Vector3 information for pointer events
  77209. */
  77210. export class Vector3WithInfo extends BABYLON.Vector3 {
  77211. /** defines the current mouse button index */
  77212. buttonIndex: number;
  77213. /**
  77214. * Creates a new Vector3WithInfo
  77215. * @param source defines the vector3 data to transport
  77216. * @param buttonIndex defines the current mouse button index
  77217. */
  77218. constructor(source: BABYLON.Vector3,
  77219. /** defines the current mouse button index */
  77220. buttonIndex?: number);
  77221. }
  77222. }
  77223. declare module BABYLON.GUI {
  77224. /**
  77225. * Class used as base class for controls
  77226. */
  77227. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77228. /** Defines the control name */
  77229. name?: string | undefined;
  77230. /** @hidden */
  77231. _host: GUI3DManager;
  77232. private _node;
  77233. private _downCount;
  77234. private _enterCount;
  77235. private _downPointerIds;
  77236. private _isVisible;
  77237. /** Gets or sets the control position in world space */
  77238. get position(): BABYLON.Vector3;
  77239. set position(value: BABYLON.Vector3);
  77240. /** Gets or sets the control scaling in world space */
  77241. get scaling(): BABYLON.Vector3;
  77242. set scaling(value: BABYLON.Vector3);
  77243. /** Callback used to start pointer enter animation */
  77244. pointerEnterAnimation: () => void;
  77245. /** Callback used to start pointer out animation */
  77246. pointerOutAnimation: () => void;
  77247. /** Callback used to start pointer down animation */
  77248. pointerDownAnimation: () => void;
  77249. /** Callback used to start pointer up animation */
  77250. pointerUpAnimation: () => void;
  77251. /**
  77252. * An event triggered when the pointer move over the control
  77253. */
  77254. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77255. /**
  77256. * An event triggered when the pointer move out of the control
  77257. */
  77258. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77259. /**
  77260. * An event triggered when the pointer taps the control
  77261. */
  77262. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77263. /**
  77264. * An event triggered when pointer is up
  77265. */
  77266. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77267. /**
  77268. * An event triggered when a control is clicked on (with a mouse)
  77269. */
  77270. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77271. /**
  77272. * An event triggered when pointer enters the control
  77273. */
  77274. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77275. /**
  77276. * Gets or sets the parent container
  77277. */
  77278. parent: BABYLON.Nullable<Container3D>;
  77279. private _behaviors;
  77280. /**
  77281. * Gets the list of attached behaviors
  77282. * @see http://doc.babylonjs.com/features/behaviour
  77283. */
  77284. get behaviors(): BABYLON.Behavior<Control3D>[];
  77285. /**
  77286. * Attach a behavior to the control
  77287. * @see http://doc.babylonjs.com/features/behaviour
  77288. * @param behavior defines the behavior to attach
  77289. * @returns the current control
  77290. */
  77291. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77292. /**
  77293. * Remove an attached behavior
  77294. * @see http://doc.babylonjs.com/features/behaviour
  77295. * @param behavior defines the behavior to attach
  77296. * @returns the current control
  77297. */
  77298. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77299. /**
  77300. * Gets an attached behavior by name
  77301. * @param name defines the name of the behavior to look for
  77302. * @see http://doc.babylonjs.com/features/behaviour
  77303. * @returns null if behavior was not found else the requested behavior
  77304. */
  77305. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77306. /** Gets or sets a boolean indicating if the control is visible */
  77307. get isVisible(): boolean;
  77308. set isVisible(value: boolean);
  77309. /**
  77310. * Creates a new control
  77311. * @param name defines the control name
  77312. */
  77313. constructor(
  77314. /** Defines the control name */
  77315. name?: string | undefined);
  77316. /**
  77317. * Gets a string representing the class name
  77318. */
  77319. get typeName(): string;
  77320. /**
  77321. * Get the current class name of the control.
  77322. * @returns current class name
  77323. */
  77324. getClassName(): string;
  77325. protected _getTypeName(): string;
  77326. /**
  77327. * Gets the transform node used by this control
  77328. */
  77329. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77330. /**
  77331. * Gets the mesh used to render this control
  77332. */
  77333. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77334. /**
  77335. * Link the control as child of the given node
  77336. * @param node defines the node to link to. Use null to unlink the control
  77337. * @returns the current control
  77338. */
  77339. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77340. /** @hidden **/
  77341. _prepareNode(scene: BABYLON.Scene): void;
  77342. /**
  77343. * Node creation.
  77344. * Can be overriden by children
  77345. * @param scene defines the scene where the node must be attached
  77346. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77347. */
  77348. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77349. /**
  77350. * Affect a material to the given mesh
  77351. * @param mesh defines the mesh which will represent the control
  77352. */
  77353. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77354. /** @hidden */
  77355. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77356. /** @hidden */
  77357. _onPointerEnter(target: Control3D): boolean;
  77358. /** @hidden */
  77359. _onPointerOut(target: Control3D): void;
  77360. /** @hidden */
  77361. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77362. /** @hidden */
  77363. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77364. /** @hidden */
  77365. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77366. /** @hidden */
  77367. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77368. /** @hidden */
  77369. _disposeNode(): void;
  77370. /**
  77371. * Releases all associated resources
  77372. */
  77373. dispose(): void;
  77374. }
  77375. }
  77376. declare module BABYLON.GUI {
  77377. /**
  77378. * Class used as a root to all buttons
  77379. */
  77380. export class AbstractButton3D extends Control3D {
  77381. /**
  77382. * Creates a new button
  77383. * @param name defines the control name
  77384. */
  77385. constructor(name?: string);
  77386. protected _getTypeName(): string;
  77387. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77388. }
  77389. }
  77390. declare module BABYLON.GUI {
  77391. /**
  77392. * Class used to create a button in 3D
  77393. */
  77394. export class Button3D extends AbstractButton3D {
  77395. /** @hidden */
  77396. protected _currentMaterial: BABYLON.Material;
  77397. private _facadeTexture;
  77398. private _content;
  77399. private _contentResolution;
  77400. private _contentScaleRatio;
  77401. /**
  77402. * Gets or sets the texture resolution used to render content (512 by default)
  77403. */
  77404. get contentResolution(): BABYLON.int;
  77405. set contentResolution(value: BABYLON.int);
  77406. /**
  77407. * Gets or sets the texture scale ratio used to render content (2 by default)
  77408. */
  77409. get contentScaleRatio(): number;
  77410. set contentScaleRatio(value: number);
  77411. protected _disposeFacadeTexture(): void;
  77412. protected _resetContent(): void;
  77413. /**
  77414. * Creates a new button
  77415. * @param name defines the control name
  77416. */
  77417. constructor(name?: string);
  77418. /**
  77419. * Gets or sets the GUI 2D content used to display the button's facade
  77420. */
  77421. get content(): Control;
  77422. set content(value: Control);
  77423. /**
  77424. * Apply the facade texture (created from the content property).
  77425. * This function can be overloaded by child classes
  77426. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77427. */
  77428. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77429. protected _getTypeName(): string;
  77430. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77431. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77432. /**
  77433. * Releases all associated resources
  77434. */
  77435. dispose(): void;
  77436. }
  77437. }
  77438. declare module BABYLON.GUI {
  77439. /**
  77440. * Abstract class used to create a container panel deployed on the surface of a volume
  77441. */
  77442. export abstract class VolumeBasedPanel extends Container3D {
  77443. private _columns;
  77444. private _rows;
  77445. private _rowThenColum;
  77446. private _orientation;
  77447. protected _cellWidth: number;
  77448. protected _cellHeight: number;
  77449. /**
  77450. * Gets or sets the distance between elements
  77451. */
  77452. margin: number;
  77453. /**
  77454. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77455. * | Value | Type | Description |
  77456. * | ----- | ----------------------------------- | ----------- |
  77457. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77458. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77459. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77460. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77461. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77462. */
  77463. get orientation(): number;
  77464. set orientation(value: number);
  77465. /**
  77466. * Gets or sets the number of columns requested (10 by default).
  77467. * The panel will automatically compute the number of rows based on number of child controls.
  77468. */
  77469. get columns(): BABYLON.int;
  77470. set columns(value: BABYLON.int);
  77471. /**
  77472. * Gets or sets a the number of rows requested.
  77473. * The panel will automatically compute the number of columns based on number of child controls.
  77474. */
  77475. get rows(): BABYLON.int;
  77476. set rows(value: BABYLON.int);
  77477. /**
  77478. * Creates new VolumeBasedPanel
  77479. */
  77480. constructor();
  77481. protected _arrangeChildren(): void;
  77482. /** Child classes must implement this function to provide correct control positioning */
  77483. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77484. /** Child classes can implement this function to provide additional processing */
  77485. protected _finalProcessing(): void;
  77486. }
  77487. }
  77488. declare module BABYLON.GUI {
  77489. /**
  77490. * Class used to create a container panel deployed on the surface of a cylinder
  77491. */
  77492. export class CylinderPanel extends VolumeBasedPanel {
  77493. private _radius;
  77494. /**
  77495. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77496. */
  77497. get radius(): BABYLON.float;
  77498. set radius(value: BABYLON.float);
  77499. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77500. private _cylindricalMapping;
  77501. }
  77502. }
  77503. declare module BABYLON.GUI {
  77504. /** @hidden */
  77505. export var fluentVertexShader: {
  77506. name: string;
  77507. shader: string;
  77508. };
  77509. }
  77510. declare module BABYLON.GUI {
  77511. /** @hidden */
  77512. export var fluentPixelShader: {
  77513. name: string;
  77514. shader: string;
  77515. };
  77516. }
  77517. declare module BABYLON.GUI {
  77518. /** @hidden */
  77519. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77520. INNERGLOW: boolean;
  77521. BORDER: boolean;
  77522. HOVERLIGHT: boolean;
  77523. TEXTURE: boolean;
  77524. constructor();
  77525. }
  77526. /**
  77527. * Class used to render controls with fluent desgin
  77528. */
  77529. export class FluentMaterial extends BABYLON.PushMaterial {
  77530. /**
  77531. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77532. */
  77533. innerGlowColorIntensity: number;
  77534. /**
  77535. * Gets or sets the inner glow color (white by default)
  77536. */
  77537. innerGlowColor: BABYLON.Color3;
  77538. /**
  77539. * Gets or sets alpha value (default is 1.0)
  77540. */
  77541. alpha: number;
  77542. /**
  77543. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77544. */
  77545. albedoColor: BABYLON.Color3;
  77546. /**
  77547. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77548. */
  77549. renderBorders: boolean;
  77550. /**
  77551. * Gets or sets border width (default is 0.5)
  77552. */
  77553. borderWidth: number;
  77554. /**
  77555. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77556. */
  77557. edgeSmoothingValue: number;
  77558. /**
  77559. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77560. */
  77561. borderMinValue: number;
  77562. /**
  77563. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77564. */
  77565. renderHoverLight: boolean;
  77566. /**
  77567. * Gets or sets the radius used to render the hover light (default is 1.0)
  77568. */
  77569. hoverRadius: number;
  77570. /**
  77571. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77572. */
  77573. hoverColor: BABYLON.Color4;
  77574. /**
  77575. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77576. */
  77577. hoverPosition: BABYLON.Vector3;
  77578. private _albedoTexture;
  77579. /** Gets or sets the texture to use for albedo color */
  77580. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77581. /**
  77582. * Creates a new Fluent material
  77583. * @param name defines the name of the material
  77584. * @param scene defines the hosting scene
  77585. */
  77586. constructor(name: string, scene: BABYLON.Scene);
  77587. needAlphaBlending(): boolean;
  77588. needAlphaTesting(): boolean;
  77589. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77590. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77591. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77592. getActiveTextures(): BABYLON.BaseTexture[];
  77593. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77594. dispose(forceDisposeEffect?: boolean): void;
  77595. clone(name: string): FluentMaterial;
  77596. serialize(): any;
  77597. getClassName(): string;
  77598. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77599. }
  77600. }
  77601. declare module BABYLON.GUI {
  77602. /**
  77603. * Class used to create a holographic button in 3D
  77604. */
  77605. export class HolographicButton extends Button3D {
  77606. private _backPlate;
  77607. private _textPlate;
  77608. private _frontPlate;
  77609. private _text;
  77610. private _imageUrl;
  77611. private _shareMaterials;
  77612. private _frontMaterial;
  77613. private _backMaterial;
  77614. private _plateMaterial;
  77615. private _pickedPointObserver;
  77616. private _tooltipFade;
  77617. private _tooltipTextBlock;
  77618. private _tooltipTexture;
  77619. private _tooltipMesh;
  77620. private _tooltipHoverObserver;
  77621. private _tooltipOutObserver;
  77622. private _disposeTooltip;
  77623. /**
  77624. * Rendering ground id of all the mesh in the button
  77625. */
  77626. set renderingGroupId(id: number);
  77627. get renderingGroupId(): number;
  77628. /**
  77629. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77630. */
  77631. set tooltipText(text: BABYLON.Nullable<string>);
  77632. get tooltipText(): BABYLON.Nullable<string>;
  77633. /**
  77634. * Gets or sets text for the button
  77635. */
  77636. get text(): string;
  77637. set text(value: string);
  77638. /**
  77639. * Gets or sets the image url for the button
  77640. */
  77641. get imageUrl(): string;
  77642. set imageUrl(value: string);
  77643. /**
  77644. * Gets the back material used by this button
  77645. */
  77646. get backMaterial(): FluentMaterial;
  77647. /**
  77648. * Gets the front material used by this button
  77649. */
  77650. get frontMaterial(): FluentMaterial;
  77651. /**
  77652. * Gets the plate material used by this button
  77653. */
  77654. get plateMaterial(): BABYLON.StandardMaterial;
  77655. /**
  77656. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77657. */
  77658. get shareMaterials(): boolean;
  77659. /**
  77660. * Creates a new button
  77661. * @param name defines the control name
  77662. */
  77663. constructor(name?: string, shareMaterials?: boolean);
  77664. protected _getTypeName(): string;
  77665. private _rebuildContent;
  77666. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77667. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77668. private _createBackMaterial;
  77669. private _createFrontMaterial;
  77670. private _createPlateMaterial;
  77671. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77672. /**
  77673. * Releases all associated resources
  77674. */
  77675. dispose(): void;
  77676. }
  77677. }
  77678. declare module BABYLON.GUI {
  77679. /**
  77680. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77681. */
  77682. export class MeshButton3D extends Button3D {
  77683. /** @hidden */
  77684. protected _currentMesh: BABYLON.Mesh;
  77685. /**
  77686. * Creates a new 3D button based on a mesh
  77687. * @param mesh mesh to become a 3D button
  77688. * @param name defines the control name
  77689. */
  77690. constructor(mesh: BABYLON.Mesh, name?: string);
  77691. protected _getTypeName(): string;
  77692. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77693. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77694. }
  77695. }
  77696. declare module BABYLON.GUI {
  77697. /**
  77698. * Class used to create a container panel deployed on the surface of a plane
  77699. */
  77700. export class PlanePanel extends VolumeBasedPanel {
  77701. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77702. }
  77703. }
  77704. declare module BABYLON.GUI {
  77705. /**
  77706. * Class used to create a container panel where items get randomized planar mapping
  77707. */
  77708. export class ScatterPanel extends VolumeBasedPanel {
  77709. private _iteration;
  77710. /**
  77711. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77712. */
  77713. get iteration(): BABYLON.float;
  77714. set iteration(value: BABYLON.float);
  77715. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77716. private _scatterMapping;
  77717. protected _finalProcessing(): void;
  77718. }
  77719. }
  77720. declare module BABYLON.GUI {
  77721. /**
  77722. * Class used to create a container panel deployed on the surface of a sphere
  77723. */
  77724. export class SpherePanel extends VolumeBasedPanel {
  77725. private _radius;
  77726. /**
  77727. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77728. */
  77729. get radius(): BABYLON.float;
  77730. set radius(value: BABYLON.float);
  77731. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77732. private _sphericalMapping;
  77733. }
  77734. }
  77735. declare module BABYLON.GUI {
  77736. /**
  77737. * Class used to create a stack panel in 3D on XY plane
  77738. */
  77739. export class StackPanel3D extends Container3D {
  77740. private _isVertical;
  77741. /**
  77742. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77743. */
  77744. get isVertical(): boolean;
  77745. set isVertical(value: boolean);
  77746. /**
  77747. * Gets or sets the distance between elements
  77748. */
  77749. margin: number;
  77750. /**
  77751. * Creates new StackPanel
  77752. * @param isVertical
  77753. */
  77754. constructor(isVertical?: boolean);
  77755. protected _arrangeChildren(): void;
  77756. }
  77757. }
  77758. declare module BABYLON {
  77759. /**
  77760. * Configuration for glTF validation
  77761. */
  77762. export interface IGLTFValidationConfiguration {
  77763. /**
  77764. * The url of the glTF validator.
  77765. */
  77766. url: string;
  77767. }
  77768. /**
  77769. * glTF validation
  77770. */
  77771. export class GLTFValidation {
  77772. /**
  77773. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77774. */
  77775. static Configuration: IGLTFValidationConfiguration;
  77776. private static _LoadScriptPromise;
  77777. /**
  77778. * Validate a glTF asset using the glTF-Validator.
  77779. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77780. * @param rootUrl The root url for the glTF
  77781. * @param fileName The file name for the glTF
  77782. * @param getExternalResource The callback to get external resources for the glTF validator
  77783. * @returns A promise that resolves with the glTF validation results once complete
  77784. */
  77785. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77786. }
  77787. }
  77788. declare module BABYLON {
  77789. /**
  77790. * Mode that determines the coordinate system to use.
  77791. */
  77792. export enum GLTFLoaderCoordinateSystemMode {
  77793. /**
  77794. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77795. */
  77796. AUTO = 0,
  77797. /**
  77798. * Sets the useRightHandedSystem flag on the scene.
  77799. */
  77800. FORCE_RIGHT_HANDED = 1
  77801. }
  77802. /**
  77803. * Mode that determines what animations will start.
  77804. */
  77805. export enum GLTFLoaderAnimationStartMode {
  77806. /**
  77807. * No animation will start.
  77808. */
  77809. NONE = 0,
  77810. /**
  77811. * The first animation will start.
  77812. */
  77813. FIRST = 1,
  77814. /**
  77815. * All animations will start.
  77816. */
  77817. ALL = 2
  77818. }
  77819. /**
  77820. * Interface that contains the data for the glTF asset.
  77821. */
  77822. export interface IGLTFLoaderData {
  77823. /**
  77824. * The object that represents the glTF JSON.
  77825. */
  77826. json: Object;
  77827. /**
  77828. * The BIN chunk of a binary glTF.
  77829. */
  77830. bin: Nullable<IDataBuffer>;
  77831. }
  77832. /**
  77833. * Interface for extending the loader.
  77834. */
  77835. export interface IGLTFLoaderExtension {
  77836. /**
  77837. * The name of this extension.
  77838. */
  77839. readonly name: string;
  77840. /**
  77841. * Defines whether this extension is enabled.
  77842. */
  77843. enabled: boolean;
  77844. /**
  77845. * Defines the order of this extension.
  77846. * The loader sorts the extensions using these values when loading.
  77847. */
  77848. order?: number;
  77849. }
  77850. /**
  77851. * Loader state.
  77852. */
  77853. export enum GLTFLoaderState {
  77854. /**
  77855. * The asset is loading.
  77856. */
  77857. LOADING = 0,
  77858. /**
  77859. * The asset is ready for rendering.
  77860. */
  77861. READY = 1,
  77862. /**
  77863. * The asset is completely loaded.
  77864. */
  77865. COMPLETE = 2
  77866. }
  77867. /** @hidden */
  77868. export interface IImportMeshAsyncOutput {
  77869. meshes: AbstractMesh[];
  77870. particleSystems: IParticleSystem[];
  77871. skeletons: Skeleton[];
  77872. animationGroups: AnimationGroup[];
  77873. lights: Light[];
  77874. transformNodes: TransformNode[];
  77875. }
  77876. /** @hidden */
  77877. export interface IGLTFLoader extends IDisposable {
  77878. readonly state: Nullable<GLTFLoaderState>;
  77879. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77880. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77881. }
  77882. /**
  77883. * File loader for loading glTF files into a scene.
  77884. */
  77885. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77886. /** @hidden */
  77887. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77888. /** @hidden */
  77889. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77890. /**
  77891. * Raised when the asset has been parsed
  77892. */
  77893. onParsedObservable: Observable<IGLTFLoaderData>;
  77894. private _onParsedObserver;
  77895. /**
  77896. * Raised when the asset has been parsed
  77897. */
  77898. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77899. /**
  77900. * 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.
  77901. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77902. * Defaults to true.
  77903. * @hidden
  77904. */
  77905. static IncrementalLoading: boolean;
  77906. /**
  77907. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77908. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77909. * @hidden
  77910. */
  77911. static HomogeneousCoordinates: boolean;
  77912. /**
  77913. * The coordinate system mode. Defaults to AUTO.
  77914. */
  77915. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77916. /**
  77917. * The animation start mode. Defaults to FIRST.
  77918. */
  77919. animationStartMode: GLTFLoaderAnimationStartMode;
  77920. /**
  77921. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77922. */
  77923. compileMaterials: boolean;
  77924. /**
  77925. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77926. */
  77927. useClipPlane: boolean;
  77928. /**
  77929. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77930. */
  77931. compileShadowGenerators: boolean;
  77932. /**
  77933. * Defines if the Alpha blended materials are only applied as coverage.
  77934. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77935. * If true, no extra effects are applied to transparent pixels.
  77936. */
  77937. transparencyAsCoverage: boolean;
  77938. /**
  77939. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77940. * Enabling will disable offline support and glTF validator.
  77941. * Defaults to false.
  77942. */
  77943. useRangeRequests: boolean;
  77944. /**
  77945. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77946. */
  77947. createInstances: boolean;
  77948. /**
  77949. * Function called before loading a url referenced by the asset.
  77950. */
  77951. preprocessUrlAsync: (url: string) => Promise<string>;
  77952. /**
  77953. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77954. */
  77955. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77956. private _onMeshLoadedObserver;
  77957. /**
  77958. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77959. */
  77960. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77961. /**
  77962. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77963. */
  77964. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77965. private _onTextureLoadedObserver;
  77966. /**
  77967. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77968. */
  77969. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77970. /**
  77971. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77972. */
  77973. readonly onMaterialLoadedObservable: Observable<Material>;
  77974. private _onMaterialLoadedObserver;
  77975. /**
  77976. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77977. */
  77978. set onMaterialLoaded(callback: (material: Material) => void);
  77979. /**
  77980. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77981. */
  77982. readonly onCameraLoadedObservable: Observable<Camera>;
  77983. private _onCameraLoadedObserver;
  77984. /**
  77985. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77986. */
  77987. set onCameraLoaded(callback: (camera: Camera) => void);
  77988. /**
  77989. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77990. * For assets with LODs, raised when all of the LODs are complete.
  77991. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77992. */
  77993. readonly onCompleteObservable: Observable<void>;
  77994. private _onCompleteObserver;
  77995. /**
  77996. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77997. * For assets with LODs, raised when all of the LODs are complete.
  77998. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77999. */
  78000. set onComplete(callback: () => void);
  78001. /**
  78002. * Observable raised when an error occurs.
  78003. */
  78004. readonly onErrorObservable: Observable<any>;
  78005. private _onErrorObserver;
  78006. /**
  78007. * Callback raised when an error occurs.
  78008. */
  78009. set onError(callback: (reason: any) => void);
  78010. /**
  78011. * Observable raised after the loader is disposed.
  78012. */
  78013. readonly onDisposeObservable: Observable<void>;
  78014. private _onDisposeObserver;
  78015. /**
  78016. * Callback raised after the loader is disposed.
  78017. */
  78018. set onDispose(callback: () => void);
  78019. /**
  78020. * Observable raised after a loader extension is created.
  78021. * Set additional options for a loader extension in this event.
  78022. */
  78023. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78024. private _onExtensionLoadedObserver;
  78025. /**
  78026. * Callback raised after a loader extension is created.
  78027. */
  78028. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78029. /**
  78030. * Defines if the loader logging is enabled.
  78031. */
  78032. get loggingEnabled(): boolean;
  78033. set loggingEnabled(value: boolean);
  78034. /**
  78035. * Defines if the loader should capture performance counters.
  78036. */
  78037. get capturePerformanceCounters(): boolean;
  78038. set capturePerformanceCounters(value: boolean);
  78039. /**
  78040. * Defines if the loader should validate the asset.
  78041. */
  78042. validate: boolean;
  78043. /**
  78044. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78045. */
  78046. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78047. private _onValidatedObserver;
  78048. /**
  78049. * Callback raised after a loader extension is created.
  78050. */
  78051. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78052. private _loader;
  78053. /**
  78054. * Name of the loader ("gltf")
  78055. */
  78056. name: string;
  78057. /** @hidden */
  78058. extensions: ISceneLoaderPluginExtensions;
  78059. /**
  78060. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78061. */
  78062. dispose(): void;
  78063. /** @hidden */
  78064. _clear(): void;
  78065. /** @hidden */
  78066. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78067. /** @hidden */
  78068. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78069. /** @hidden */
  78070. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78071. meshes: AbstractMesh[];
  78072. particleSystems: IParticleSystem[];
  78073. skeletons: Skeleton[];
  78074. animationGroups: AnimationGroup[];
  78075. }>;
  78076. /** @hidden */
  78077. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78078. /** @hidden */
  78079. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78080. /** @hidden */
  78081. canDirectLoad(data: string): boolean;
  78082. /** @hidden */
  78083. directLoad(scene: Scene, data: string): any;
  78084. /**
  78085. * The callback that allows custom handling of the root url based on the response url.
  78086. * @param rootUrl the original root url
  78087. * @param responseURL the response url if available
  78088. * @returns the new root url
  78089. */
  78090. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78091. /** @hidden */
  78092. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78093. /**
  78094. * The loader state or null if the loader is not active.
  78095. */
  78096. get loaderState(): Nullable<GLTFLoaderState>;
  78097. /**
  78098. * Returns a promise that resolves when the asset is completely loaded.
  78099. * @returns a promise that resolves when the asset is completely loaded.
  78100. */
  78101. whenCompleteAsync(): Promise<void>;
  78102. private _validate;
  78103. private _getLoader;
  78104. private _parseJson;
  78105. private _unpackBinaryAsync;
  78106. private _unpackBinaryV1Async;
  78107. private _unpackBinaryV2Async;
  78108. private static _parseVersion;
  78109. private static _compareVersion;
  78110. private static readonly _logSpaces;
  78111. private _logIndentLevel;
  78112. private _loggingEnabled;
  78113. /** @hidden */
  78114. _log: (message: string) => void;
  78115. /** @hidden */
  78116. _logOpen(message: string): void;
  78117. /** @hidden */
  78118. _logClose(): void;
  78119. private _logEnabled;
  78120. private _logDisabled;
  78121. private _capturePerformanceCounters;
  78122. /** @hidden */
  78123. _startPerformanceCounter: (counterName: string) => void;
  78124. /** @hidden */
  78125. _endPerformanceCounter: (counterName: string) => void;
  78126. private _startPerformanceCounterEnabled;
  78127. private _startPerformanceCounterDisabled;
  78128. private _endPerformanceCounterEnabled;
  78129. private _endPerformanceCounterDisabled;
  78130. }
  78131. }
  78132. declare module BABYLON.GLTF1 {
  78133. /**
  78134. * Enums
  78135. * @hidden
  78136. */
  78137. export enum EComponentType {
  78138. BYTE = 5120,
  78139. UNSIGNED_BYTE = 5121,
  78140. SHORT = 5122,
  78141. UNSIGNED_SHORT = 5123,
  78142. FLOAT = 5126
  78143. }
  78144. /** @hidden */
  78145. export enum EShaderType {
  78146. FRAGMENT = 35632,
  78147. VERTEX = 35633
  78148. }
  78149. /** @hidden */
  78150. export enum EParameterType {
  78151. BYTE = 5120,
  78152. UNSIGNED_BYTE = 5121,
  78153. SHORT = 5122,
  78154. UNSIGNED_SHORT = 5123,
  78155. INT = 5124,
  78156. UNSIGNED_INT = 5125,
  78157. FLOAT = 5126,
  78158. FLOAT_VEC2 = 35664,
  78159. FLOAT_VEC3 = 35665,
  78160. FLOAT_VEC4 = 35666,
  78161. INT_VEC2 = 35667,
  78162. INT_VEC3 = 35668,
  78163. INT_VEC4 = 35669,
  78164. BOOL = 35670,
  78165. BOOL_VEC2 = 35671,
  78166. BOOL_VEC3 = 35672,
  78167. BOOL_VEC4 = 35673,
  78168. FLOAT_MAT2 = 35674,
  78169. FLOAT_MAT3 = 35675,
  78170. FLOAT_MAT4 = 35676,
  78171. SAMPLER_2D = 35678
  78172. }
  78173. /** @hidden */
  78174. export enum ETextureWrapMode {
  78175. CLAMP_TO_EDGE = 33071,
  78176. MIRRORED_REPEAT = 33648,
  78177. REPEAT = 10497
  78178. }
  78179. /** @hidden */
  78180. export enum ETextureFilterType {
  78181. NEAREST = 9728,
  78182. LINEAR = 9728,
  78183. NEAREST_MIPMAP_NEAREST = 9984,
  78184. LINEAR_MIPMAP_NEAREST = 9985,
  78185. NEAREST_MIPMAP_LINEAR = 9986,
  78186. LINEAR_MIPMAP_LINEAR = 9987
  78187. }
  78188. /** @hidden */
  78189. export enum ETextureFormat {
  78190. ALPHA = 6406,
  78191. RGB = 6407,
  78192. RGBA = 6408,
  78193. LUMINANCE = 6409,
  78194. LUMINANCE_ALPHA = 6410
  78195. }
  78196. /** @hidden */
  78197. export enum ECullingType {
  78198. FRONT = 1028,
  78199. BACK = 1029,
  78200. FRONT_AND_BACK = 1032
  78201. }
  78202. /** @hidden */
  78203. export enum EBlendingFunction {
  78204. ZERO = 0,
  78205. ONE = 1,
  78206. SRC_COLOR = 768,
  78207. ONE_MINUS_SRC_COLOR = 769,
  78208. DST_COLOR = 774,
  78209. ONE_MINUS_DST_COLOR = 775,
  78210. SRC_ALPHA = 770,
  78211. ONE_MINUS_SRC_ALPHA = 771,
  78212. DST_ALPHA = 772,
  78213. ONE_MINUS_DST_ALPHA = 773,
  78214. CONSTANT_COLOR = 32769,
  78215. ONE_MINUS_CONSTANT_COLOR = 32770,
  78216. CONSTANT_ALPHA = 32771,
  78217. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78218. SRC_ALPHA_SATURATE = 776
  78219. }
  78220. /** @hidden */
  78221. export interface IGLTFProperty {
  78222. extensions?: {
  78223. [key: string]: any;
  78224. };
  78225. extras?: Object;
  78226. }
  78227. /** @hidden */
  78228. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78229. name?: string;
  78230. }
  78231. /** @hidden */
  78232. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78233. bufferView: string;
  78234. byteOffset: number;
  78235. byteStride: number;
  78236. count: number;
  78237. type: string;
  78238. componentType: EComponentType;
  78239. max?: number[];
  78240. min?: number[];
  78241. name?: string;
  78242. }
  78243. /** @hidden */
  78244. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78245. buffer: string;
  78246. byteOffset: number;
  78247. byteLength: number;
  78248. byteStride: number;
  78249. target?: number;
  78250. }
  78251. /** @hidden */
  78252. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78253. uri: string;
  78254. byteLength?: number;
  78255. type?: string;
  78256. }
  78257. /** @hidden */
  78258. export interface IGLTFShader extends IGLTFChildRootProperty {
  78259. uri: string;
  78260. type: EShaderType;
  78261. }
  78262. /** @hidden */
  78263. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78264. attributes: string[];
  78265. fragmentShader: string;
  78266. vertexShader: string;
  78267. }
  78268. /** @hidden */
  78269. export interface IGLTFTechniqueParameter {
  78270. type: number;
  78271. count?: number;
  78272. semantic?: string;
  78273. node?: string;
  78274. value?: number | boolean | string | Array<any>;
  78275. source?: string;
  78276. babylonValue?: any;
  78277. }
  78278. /** @hidden */
  78279. export interface IGLTFTechniqueCommonProfile {
  78280. lightingModel: string;
  78281. texcoordBindings: Object;
  78282. parameters?: Array<any>;
  78283. }
  78284. /** @hidden */
  78285. export interface IGLTFTechniqueStatesFunctions {
  78286. blendColor?: number[];
  78287. blendEquationSeparate?: number[];
  78288. blendFuncSeparate?: number[];
  78289. colorMask: boolean[];
  78290. cullFace: number[];
  78291. }
  78292. /** @hidden */
  78293. export interface IGLTFTechniqueStates {
  78294. enable: number[];
  78295. functions: IGLTFTechniqueStatesFunctions;
  78296. }
  78297. /** @hidden */
  78298. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78299. parameters: {
  78300. [key: string]: IGLTFTechniqueParameter;
  78301. };
  78302. program: string;
  78303. attributes: {
  78304. [key: string]: string;
  78305. };
  78306. uniforms: {
  78307. [key: string]: string;
  78308. };
  78309. states: IGLTFTechniqueStates;
  78310. }
  78311. /** @hidden */
  78312. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78313. technique?: string;
  78314. values: string[];
  78315. }
  78316. /** @hidden */
  78317. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78318. attributes: {
  78319. [key: string]: string;
  78320. };
  78321. indices: string;
  78322. material: string;
  78323. mode?: number;
  78324. }
  78325. /** @hidden */
  78326. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78327. primitives: IGLTFMeshPrimitive[];
  78328. }
  78329. /** @hidden */
  78330. export interface IGLTFImage extends IGLTFChildRootProperty {
  78331. uri: string;
  78332. }
  78333. /** @hidden */
  78334. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78335. magFilter?: number;
  78336. minFilter?: number;
  78337. wrapS?: number;
  78338. wrapT?: number;
  78339. }
  78340. /** @hidden */
  78341. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78342. sampler: string;
  78343. source: string;
  78344. format?: ETextureFormat;
  78345. internalFormat?: ETextureFormat;
  78346. target?: number;
  78347. type?: number;
  78348. babylonTexture?: Texture;
  78349. }
  78350. /** @hidden */
  78351. export interface IGLTFAmbienLight {
  78352. color?: number[];
  78353. }
  78354. /** @hidden */
  78355. export interface IGLTFDirectionalLight {
  78356. color?: number[];
  78357. }
  78358. /** @hidden */
  78359. export interface IGLTFPointLight {
  78360. color?: number[];
  78361. constantAttenuation?: number;
  78362. linearAttenuation?: number;
  78363. quadraticAttenuation?: number;
  78364. }
  78365. /** @hidden */
  78366. export interface IGLTFSpotLight {
  78367. color?: number[];
  78368. constantAttenuation?: number;
  78369. fallOfAngle?: number;
  78370. fallOffExponent?: number;
  78371. linearAttenuation?: number;
  78372. quadraticAttenuation?: number;
  78373. }
  78374. /** @hidden */
  78375. export interface IGLTFLight extends IGLTFChildRootProperty {
  78376. type: string;
  78377. }
  78378. /** @hidden */
  78379. export interface IGLTFCameraOrthographic {
  78380. xmag: number;
  78381. ymag: number;
  78382. zfar: number;
  78383. znear: number;
  78384. }
  78385. /** @hidden */
  78386. export interface IGLTFCameraPerspective {
  78387. aspectRatio: number;
  78388. yfov: number;
  78389. zfar: number;
  78390. znear: number;
  78391. }
  78392. /** @hidden */
  78393. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78394. type: string;
  78395. }
  78396. /** @hidden */
  78397. export interface IGLTFAnimationChannelTarget {
  78398. id: string;
  78399. path: string;
  78400. }
  78401. /** @hidden */
  78402. export interface IGLTFAnimationChannel {
  78403. sampler: string;
  78404. target: IGLTFAnimationChannelTarget;
  78405. }
  78406. /** @hidden */
  78407. export interface IGLTFAnimationSampler {
  78408. input: string;
  78409. output: string;
  78410. interpolation?: string;
  78411. }
  78412. /** @hidden */
  78413. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78414. channels?: IGLTFAnimationChannel[];
  78415. parameters?: {
  78416. [key: string]: string;
  78417. };
  78418. samplers?: {
  78419. [key: string]: IGLTFAnimationSampler;
  78420. };
  78421. }
  78422. /** @hidden */
  78423. export interface IGLTFNodeInstanceSkin {
  78424. skeletons: string[];
  78425. skin: string;
  78426. meshes: string[];
  78427. }
  78428. /** @hidden */
  78429. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78430. bindShapeMatrix: number[];
  78431. inverseBindMatrices: string;
  78432. jointNames: string[];
  78433. babylonSkeleton?: Skeleton;
  78434. }
  78435. /** @hidden */
  78436. export interface IGLTFNode extends IGLTFChildRootProperty {
  78437. camera?: string;
  78438. children: string[];
  78439. skin?: string;
  78440. jointName?: string;
  78441. light?: string;
  78442. matrix: number[];
  78443. mesh?: string;
  78444. meshes?: string[];
  78445. rotation?: number[];
  78446. scale?: number[];
  78447. translation?: number[];
  78448. babylonNode?: Node;
  78449. }
  78450. /** @hidden */
  78451. export interface IGLTFScene extends IGLTFChildRootProperty {
  78452. nodes: string[];
  78453. }
  78454. /** @hidden */
  78455. export interface IGLTFRuntime {
  78456. extensions: {
  78457. [key: string]: any;
  78458. };
  78459. accessors: {
  78460. [key: string]: IGLTFAccessor;
  78461. };
  78462. buffers: {
  78463. [key: string]: IGLTFBuffer;
  78464. };
  78465. bufferViews: {
  78466. [key: string]: IGLTFBufferView;
  78467. };
  78468. meshes: {
  78469. [key: string]: IGLTFMesh;
  78470. };
  78471. lights: {
  78472. [key: string]: IGLTFLight;
  78473. };
  78474. cameras: {
  78475. [key: string]: IGLTFCamera;
  78476. };
  78477. nodes: {
  78478. [key: string]: IGLTFNode;
  78479. };
  78480. images: {
  78481. [key: string]: IGLTFImage;
  78482. };
  78483. textures: {
  78484. [key: string]: IGLTFTexture;
  78485. };
  78486. shaders: {
  78487. [key: string]: IGLTFShader;
  78488. };
  78489. programs: {
  78490. [key: string]: IGLTFProgram;
  78491. };
  78492. samplers: {
  78493. [key: string]: IGLTFSampler;
  78494. };
  78495. techniques: {
  78496. [key: string]: IGLTFTechnique;
  78497. };
  78498. materials: {
  78499. [key: string]: IGLTFMaterial;
  78500. };
  78501. animations: {
  78502. [key: string]: IGLTFAnimation;
  78503. };
  78504. skins: {
  78505. [key: string]: IGLTFSkins;
  78506. };
  78507. currentScene?: Object;
  78508. scenes: {
  78509. [key: string]: IGLTFScene;
  78510. };
  78511. extensionsUsed: string[];
  78512. extensionsRequired?: string[];
  78513. buffersCount: number;
  78514. shaderscount: number;
  78515. scene: Scene;
  78516. rootUrl: string;
  78517. loadedBufferCount: number;
  78518. loadedBufferViews: {
  78519. [name: string]: ArrayBufferView;
  78520. };
  78521. loadedShaderCount: number;
  78522. importOnlyMeshes: boolean;
  78523. importMeshesNames?: string[];
  78524. dummyNodes: Node[];
  78525. forAssetContainer: boolean;
  78526. }
  78527. /** @hidden */
  78528. export interface INodeToRoot {
  78529. bone: Bone;
  78530. node: IGLTFNode;
  78531. id: string;
  78532. }
  78533. /** @hidden */
  78534. export interface IJointNode {
  78535. node: IGLTFNode;
  78536. id: string;
  78537. }
  78538. }
  78539. declare module BABYLON.GLTF1 {
  78540. /**
  78541. * Utils functions for GLTF
  78542. * @hidden
  78543. */
  78544. export class GLTFUtils {
  78545. /**
  78546. * Sets the given "parameter" matrix
  78547. * @param scene: the Scene object
  78548. * @param source: the source node where to pick the matrix
  78549. * @param parameter: the GLTF technique parameter
  78550. * @param uniformName: the name of the shader's uniform
  78551. * @param shaderMaterial: the shader material
  78552. */
  78553. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78554. /**
  78555. * Sets the given "parameter" matrix
  78556. * @param shaderMaterial: the shader material
  78557. * @param uniform: the name of the shader's uniform
  78558. * @param value: the value of the uniform
  78559. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78560. */
  78561. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78562. /**
  78563. * Returns the wrap mode of the texture
  78564. * @param mode: the mode value
  78565. */
  78566. static GetWrapMode(mode: number): number;
  78567. /**
  78568. * Returns the byte stride giving an accessor
  78569. * @param accessor: the GLTF accessor objet
  78570. */
  78571. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78572. /**
  78573. * Returns the texture filter mode giving a mode value
  78574. * @param mode: the filter mode value
  78575. */
  78576. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78577. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78578. /**
  78579. * Returns a buffer from its accessor
  78580. * @param gltfRuntime: the GLTF runtime
  78581. * @param accessor: the GLTF accessor
  78582. */
  78583. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78584. /**
  78585. * Decodes a buffer view into a string
  78586. * @param view: the buffer view
  78587. */
  78588. static DecodeBufferToText(view: ArrayBufferView): string;
  78589. /**
  78590. * Returns the default material of gltf. Related to
  78591. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78592. * @param scene: the Babylon.js scene
  78593. */
  78594. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78595. private static _DefaultMaterial;
  78596. }
  78597. }
  78598. declare module BABYLON.GLTF1 {
  78599. /**
  78600. * Implementation of the base glTF spec
  78601. * @hidden
  78602. */
  78603. export class GLTFLoaderBase {
  78604. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78605. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78606. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78607. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78608. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78609. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78610. }
  78611. /**
  78612. * glTF V1 Loader
  78613. * @hidden
  78614. */
  78615. export class GLTFLoader implements IGLTFLoader {
  78616. static Extensions: {
  78617. [name: string]: GLTFLoaderExtension;
  78618. };
  78619. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78620. state: Nullable<GLTFLoaderState>;
  78621. dispose(): void;
  78622. private _importMeshAsync;
  78623. /**
  78624. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78625. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78626. * @param scene the scene the meshes should be added to
  78627. * @param forAssetContainer defines if the entities must be stored in the scene
  78628. * @param data gltf data containing information of the meshes in a loaded file
  78629. * @param rootUrl root url to load from
  78630. * @param onProgress event that fires when loading progress has occured
  78631. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78632. */
  78633. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78634. private _loadAsync;
  78635. /**
  78636. * Imports all objects from a loaded gltf file and adds them to the scene
  78637. * @param scene the scene the objects should be added to
  78638. * @param data gltf data containing information of the meshes in a loaded file
  78639. * @param rootUrl root url to load from
  78640. * @param onProgress event that fires when loading progress has occured
  78641. * @returns a promise which completes when objects have been loaded to the scene
  78642. */
  78643. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78644. private _loadShadersAsync;
  78645. private _loadBuffersAsync;
  78646. private _createNodes;
  78647. }
  78648. /** @hidden */
  78649. export abstract class GLTFLoaderExtension {
  78650. private _name;
  78651. constructor(name: string);
  78652. get name(): string;
  78653. /**
  78654. * Defines an override for loading the runtime
  78655. * Return true to stop further extensions from loading the runtime
  78656. */
  78657. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78658. /**
  78659. * Defines an onverride for creating gltf runtime
  78660. * Return true to stop further extensions from creating the runtime
  78661. */
  78662. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78663. /**
  78664. * Defines an override for loading buffers
  78665. * Return true to stop further extensions from loading this buffer
  78666. */
  78667. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78668. /**
  78669. * Defines an override for loading texture buffers
  78670. * Return true to stop further extensions from loading this texture data
  78671. */
  78672. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78673. /**
  78674. * Defines an override for creating textures
  78675. * Return true to stop further extensions from loading this texture
  78676. */
  78677. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78678. /**
  78679. * Defines an override for loading shader strings
  78680. * Return true to stop further extensions from loading this shader data
  78681. */
  78682. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78683. /**
  78684. * Defines an override for loading materials
  78685. * Return true to stop further extensions from loading this material
  78686. */
  78687. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78688. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78689. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78690. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78691. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78692. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78693. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78694. private static LoadTextureBufferAsync;
  78695. private static CreateTextureAsync;
  78696. private static ApplyExtensions;
  78697. }
  78698. }
  78699. declare module BABYLON.GLTF1 {
  78700. /** @hidden */
  78701. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78702. private _bin;
  78703. constructor();
  78704. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78705. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78706. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78707. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78708. }
  78709. }
  78710. declare module BABYLON.GLTF1 {
  78711. /** @hidden */
  78712. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78713. constructor();
  78714. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78715. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78716. private _loadTexture;
  78717. }
  78718. }
  78719. declare module BABYLON.GLTF2.Loader {
  78720. /**
  78721. * Loader interface with an index field.
  78722. */
  78723. export interface IArrayItem {
  78724. /**
  78725. * The index of this item in the array.
  78726. */
  78727. index: number;
  78728. }
  78729. /**
  78730. * Loader interface with additional members.
  78731. */
  78732. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78733. /** @hidden */
  78734. _data?: Promise<ArrayBufferView>;
  78735. /** @hidden */
  78736. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78737. }
  78738. /**
  78739. * Loader interface with additional members.
  78740. */
  78741. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78742. }
  78743. /** @hidden */
  78744. export interface _IAnimationSamplerData {
  78745. input: Float32Array;
  78746. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78747. output: Float32Array;
  78748. }
  78749. /**
  78750. * Loader interface with additional members.
  78751. */
  78752. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78753. /** @hidden */
  78754. _data?: Promise<_IAnimationSamplerData>;
  78755. }
  78756. /**
  78757. * Loader interface with additional members.
  78758. */
  78759. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78760. channels: IAnimationChannel[];
  78761. samplers: IAnimationSampler[];
  78762. /** @hidden */
  78763. _babylonAnimationGroup?: AnimationGroup;
  78764. }
  78765. /**
  78766. * Loader interface with additional members.
  78767. */
  78768. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78769. /** @hidden */
  78770. _data?: Promise<ArrayBufferView>;
  78771. }
  78772. /**
  78773. * Loader interface with additional members.
  78774. */
  78775. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78776. /** @hidden */
  78777. _data?: Promise<ArrayBufferView>;
  78778. /** @hidden */
  78779. _babylonBuffer?: Promise<Buffer>;
  78780. }
  78781. /**
  78782. * Loader interface with additional members.
  78783. */
  78784. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78785. }
  78786. /**
  78787. * Loader interface with additional members.
  78788. */
  78789. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78790. /** @hidden */
  78791. _data?: Promise<ArrayBufferView>;
  78792. }
  78793. /**
  78794. * Loader interface with additional members.
  78795. */
  78796. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78797. }
  78798. /**
  78799. * Loader interface with additional members.
  78800. */
  78801. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78802. }
  78803. /**
  78804. * Loader interface with additional members.
  78805. */
  78806. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78807. baseColorTexture?: ITextureInfo;
  78808. metallicRoughnessTexture?: ITextureInfo;
  78809. }
  78810. /**
  78811. * Loader interface with additional members.
  78812. */
  78813. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78814. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78815. normalTexture?: IMaterialNormalTextureInfo;
  78816. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78817. emissiveTexture?: ITextureInfo;
  78818. /** @hidden */
  78819. _data?: {
  78820. [babylonDrawMode: number]: {
  78821. babylonMaterial: Material;
  78822. babylonMeshes: AbstractMesh[];
  78823. promise: Promise<void>;
  78824. };
  78825. };
  78826. }
  78827. /**
  78828. * Loader interface with additional members.
  78829. */
  78830. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78831. primitives: IMeshPrimitive[];
  78832. }
  78833. /**
  78834. * Loader interface with additional members.
  78835. */
  78836. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78837. /** @hidden */
  78838. _instanceData?: {
  78839. babylonSourceMesh: Mesh;
  78840. promise: Promise<any>;
  78841. };
  78842. }
  78843. /**
  78844. * Loader interface with additional members.
  78845. */
  78846. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78847. /**
  78848. * The parent glTF node.
  78849. */
  78850. parent?: INode;
  78851. /** @hidden */
  78852. _babylonTransformNode?: TransformNode;
  78853. /** @hidden */
  78854. _primitiveBabylonMeshes?: AbstractMesh[];
  78855. /** @hidden */
  78856. _babylonBones?: Bone[];
  78857. /** @hidden */
  78858. _numMorphTargets?: number;
  78859. }
  78860. /** @hidden */
  78861. export interface _ISamplerData {
  78862. noMipMaps: boolean;
  78863. samplingMode: number;
  78864. wrapU: number;
  78865. wrapV: number;
  78866. }
  78867. /**
  78868. * Loader interface with additional members.
  78869. */
  78870. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78871. /** @hidden */
  78872. _data?: _ISamplerData;
  78873. }
  78874. /**
  78875. * Loader interface with additional members.
  78876. */
  78877. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78878. }
  78879. /**
  78880. * Loader interface with additional members.
  78881. */
  78882. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78883. /** @hidden */
  78884. _data?: {
  78885. babylonSkeleton: Skeleton;
  78886. promise: Promise<void>;
  78887. };
  78888. }
  78889. /**
  78890. * Loader interface with additional members.
  78891. */
  78892. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78893. }
  78894. /**
  78895. * Loader interface with additional members.
  78896. */
  78897. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78898. }
  78899. /**
  78900. * Loader interface with additional members.
  78901. */
  78902. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78903. accessors?: IAccessor[];
  78904. animations?: IAnimation[];
  78905. buffers?: IBuffer[];
  78906. bufferViews?: IBufferView[];
  78907. cameras?: ICamera[];
  78908. images?: IImage[];
  78909. materials?: IMaterial[];
  78910. meshes?: IMesh[];
  78911. nodes?: INode[];
  78912. samplers?: ISampler[];
  78913. scenes?: IScene[];
  78914. skins?: ISkin[];
  78915. textures?: ITexture[];
  78916. }
  78917. }
  78918. declare module BABYLON.GLTF2 {
  78919. /**
  78920. * Interface for a glTF loader extension.
  78921. */
  78922. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78923. /**
  78924. * Called after the loader state changes to LOADING.
  78925. */
  78926. onLoading?(): void;
  78927. /**
  78928. * Called after the loader state changes to READY.
  78929. */
  78930. onReady?(): void;
  78931. /**
  78932. * Define this method to modify the default behavior when loading scenes.
  78933. * @param context The context when loading the asset
  78934. * @param scene The glTF scene property
  78935. * @returns A promise that resolves when the load is complete or null if not handled
  78936. */
  78937. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78938. /**
  78939. * Define this method to modify the default behavior when loading nodes.
  78940. * @param context The context when loading the asset
  78941. * @param node The glTF node property
  78942. * @param assign A function called synchronously after parsing the glTF properties
  78943. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78944. */
  78945. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78946. /**
  78947. * Define this method to modify the default behavior when loading cameras.
  78948. * @param context The context when loading the asset
  78949. * @param camera The glTF camera property
  78950. * @param assign A function called synchronously after parsing the glTF properties
  78951. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78952. */
  78953. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78954. /**
  78955. * @hidden
  78956. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78957. * @param context The context when loading the asset
  78958. * @param primitive The glTF mesh primitive property
  78959. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78960. */
  78961. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78962. /**
  78963. * @hidden
  78964. * Define this method to modify the default behavior when loading data for mesh primitives.
  78965. * @param context The context when loading the asset
  78966. * @param name The mesh name when loading the asset
  78967. * @param node The glTF node when loading the asset
  78968. * @param mesh The glTF mesh when loading the asset
  78969. * @param primitive The glTF mesh primitive property
  78970. * @param assign A function called synchronously after parsing the glTF properties
  78971. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78972. */
  78973. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78974. /**
  78975. * @hidden
  78976. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78977. * @param context The context when loading the asset
  78978. * @param material The glTF material property
  78979. * @param assign A function called synchronously after parsing the glTF properties
  78980. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78981. */
  78982. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78983. /**
  78984. * Define this method to modify the default behavior when creating materials.
  78985. * @param context The context when loading the asset
  78986. * @param material The glTF material property
  78987. * @param babylonDrawMode The draw mode for the Babylon material
  78988. * @returns The Babylon material or null if not handled
  78989. */
  78990. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78991. /**
  78992. * Define this method to modify the default behavior when loading material properties.
  78993. * @param context The context when loading the asset
  78994. * @param material The glTF material property
  78995. * @param babylonMaterial The Babylon material
  78996. * @returns A promise that resolves when the load is complete or null if not handled
  78997. */
  78998. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78999. /**
  79000. * Define this method to modify the default behavior when loading texture infos.
  79001. * @param context The context when loading the asset
  79002. * @param textureInfo The glTF texture info property
  79003. * @param assign A function called synchronously after parsing the glTF properties
  79004. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79005. */
  79006. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79007. /**
  79008. * @hidden
  79009. * Define this method to modify the default behavior when loading textures.
  79010. * @param context The context when loading the asset
  79011. * @param texture The glTF texture property
  79012. * @param assign A function called synchronously after parsing the glTF properties
  79013. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79014. */
  79015. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79016. /**
  79017. * Define this method to modify the default behavior when loading animations.
  79018. * @param context The context when loading the asset
  79019. * @param animation The glTF animation property
  79020. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79021. */
  79022. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79023. /**
  79024. * @hidden
  79025. * Define this method to modify the default behavior when loading skins.
  79026. * @param context The context when loading the asset
  79027. * @param node The glTF node property
  79028. * @param skin The glTF skin property
  79029. * @returns A promise that resolves when the load is complete or null if not handled
  79030. */
  79031. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79032. /**
  79033. * @hidden
  79034. * Define this method to modify the default behavior when loading uris.
  79035. * @param context The context when loading the asset
  79036. * @param property The glTF property associated with the uri
  79037. * @param uri The uri to load
  79038. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79039. */
  79040. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79041. /**
  79042. * Define this method to modify the default behavior when loading buffer views.
  79043. * @param context The context when loading the asset
  79044. * @param bufferView The glTF buffer view property
  79045. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79046. */
  79047. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79048. /**
  79049. * Define this method to modify the default behavior when loading buffers.
  79050. * @param context The context when loading the asset
  79051. * @param buffer The glTF buffer property
  79052. * @param byteOffset The byte offset to load
  79053. * @param byteLength The byte length to load
  79054. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79055. */
  79056. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79057. }
  79058. }
  79059. declare module BABYLON.GLTF2 {
  79060. /**
  79061. * Helper class for working with arrays when loading the glTF asset
  79062. */
  79063. export class ArrayItem {
  79064. /**
  79065. * Gets an item from the given array.
  79066. * @param context The context when loading the asset
  79067. * @param array The array to get the item from
  79068. * @param index The index to the array
  79069. * @returns The array item
  79070. */
  79071. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79072. /**
  79073. * Assign an `index` field to each item of the given array.
  79074. * @param array The array of items
  79075. */
  79076. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79077. }
  79078. /**
  79079. * The glTF 2.0 loader
  79080. */
  79081. export class GLTFLoader implements IGLTFLoader {
  79082. /** @hidden */
  79083. _completePromises: Promise<any>[];
  79084. /** @hidden */
  79085. _forAssetContainer: boolean;
  79086. /** Storage */
  79087. _babylonLights: Light[];
  79088. /** @hidden */
  79089. _disableInstancedMesh: number;
  79090. private _disposed;
  79091. private _parent;
  79092. private _state;
  79093. private _extensions;
  79094. private _rootUrl;
  79095. private _fileName;
  79096. private _uniqueRootUrl;
  79097. private _gltf;
  79098. private _bin;
  79099. private _babylonScene;
  79100. private _rootBabylonMesh;
  79101. private _defaultBabylonMaterialData;
  79102. private _progressCallback?;
  79103. private _requests;
  79104. private static _RegisteredExtensions;
  79105. /**
  79106. * The default glTF sampler.
  79107. */
  79108. static readonly DefaultSampler: ISampler;
  79109. /**
  79110. * Registers a loader extension.
  79111. * @param name The name of the loader extension.
  79112. * @param factory The factory function that creates the loader extension.
  79113. */
  79114. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79115. /**
  79116. * Unregisters a loader extension.
  79117. * @param name The name of the loader extension.
  79118. * @returns A boolean indicating whether the extension has been unregistered
  79119. */
  79120. static UnregisterExtension(name: string): boolean;
  79121. /**
  79122. * The loader state.
  79123. */
  79124. get state(): Nullable<GLTFLoaderState>;
  79125. /**
  79126. * The object that represents the glTF JSON.
  79127. */
  79128. get gltf(): IGLTF;
  79129. /**
  79130. * The BIN chunk of a binary glTF.
  79131. */
  79132. get bin(): Nullable<IDataBuffer>;
  79133. /**
  79134. * The parent file loader.
  79135. */
  79136. get parent(): GLTFFileLoader;
  79137. /**
  79138. * The Babylon scene when loading the asset.
  79139. */
  79140. get babylonScene(): Scene;
  79141. /**
  79142. * The root Babylon mesh when loading the asset.
  79143. */
  79144. get rootBabylonMesh(): Mesh;
  79145. /** @hidden */
  79146. constructor(parent: GLTFFileLoader);
  79147. /** @hidden */
  79148. dispose(): void;
  79149. /** @hidden */
  79150. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79151. /** @hidden */
  79152. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79153. private _loadAsync;
  79154. private _loadData;
  79155. private _setupData;
  79156. private _loadExtensions;
  79157. private _checkExtensions;
  79158. private _setState;
  79159. private _createRootNode;
  79160. /**
  79161. * Loads a glTF scene.
  79162. * @param context The context when loading the asset
  79163. * @param scene The glTF scene property
  79164. * @returns A promise that resolves when the load is complete
  79165. */
  79166. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79167. private _forEachPrimitive;
  79168. private _getMeshes;
  79169. private _getTransformNodes;
  79170. private _getSkeletons;
  79171. private _getAnimationGroups;
  79172. private _startAnimations;
  79173. /**
  79174. * Loads a glTF node.
  79175. * @param context The context when loading the asset
  79176. * @param node The glTF node property
  79177. * @param assign A function called synchronously after parsing the glTF properties
  79178. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79179. */
  79180. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79181. private _loadMeshAsync;
  79182. /**
  79183. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79184. * @param context The context when loading the asset
  79185. * @param name The mesh name when loading the asset
  79186. * @param node The glTF node when loading the asset
  79187. * @param mesh The glTF mesh when loading the asset
  79188. * @param primitive The glTF mesh primitive property
  79189. * @param assign A function called synchronously after parsing the glTF properties
  79190. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79191. */
  79192. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79193. private _loadVertexDataAsync;
  79194. private _createMorphTargets;
  79195. private _loadMorphTargetsAsync;
  79196. private _loadMorphTargetVertexDataAsync;
  79197. private static _LoadTransform;
  79198. private _loadSkinAsync;
  79199. private _loadBones;
  79200. private _loadBone;
  79201. private _loadSkinInverseBindMatricesDataAsync;
  79202. private _updateBoneMatrices;
  79203. private _getNodeMatrix;
  79204. /**
  79205. * Loads a glTF camera.
  79206. * @param context The context when loading the asset
  79207. * @param camera The glTF camera property
  79208. * @param assign A function called synchronously after parsing the glTF properties
  79209. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79210. */
  79211. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79212. private _loadAnimationsAsync;
  79213. /**
  79214. * Loads a glTF animation.
  79215. * @param context The context when loading the asset
  79216. * @param animation The glTF animation property
  79217. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79218. */
  79219. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79220. /**
  79221. * @hidden Loads a glTF animation channel.
  79222. * @param context The context when loading the asset
  79223. * @param animationContext The context of the animation when loading the asset
  79224. * @param animation The glTF animation property
  79225. * @param channel The glTF animation channel property
  79226. * @param babylonAnimationGroup The babylon animation group property
  79227. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79228. * @returns A void promise when the channel load is complete
  79229. */
  79230. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79231. private _loadAnimationSamplerAsync;
  79232. private _loadBufferAsync;
  79233. /**
  79234. * Loads a glTF buffer view.
  79235. * @param context The context when loading the asset
  79236. * @param bufferView The glTF buffer view property
  79237. * @returns A promise that resolves with the loaded data when the load is complete
  79238. */
  79239. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79240. private _loadAccessorAsync;
  79241. /** @hidden */
  79242. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79243. private _loadIndicesAccessorAsync;
  79244. private _loadVertexBufferViewAsync;
  79245. private _loadVertexAccessorAsync;
  79246. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79247. /** @hidden */
  79248. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79249. private _createDefaultMaterial;
  79250. /**
  79251. * Creates a Babylon material from a glTF material.
  79252. * @param context The context when loading the asset
  79253. * @param material The glTF material property
  79254. * @param babylonDrawMode The draw mode for the Babylon material
  79255. * @returns The Babylon material
  79256. */
  79257. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79258. /**
  79259. * Loads properties from a glTF material into a Babylon material.
  79260. * @param context The context when loading the asset
  79261. * @param material The glTF material property
  79262. * @param babylonMaterial The Babylon material
  79263. * @returns A promise that resolves when the load is complete
  79264. */
  79265. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79266. /**
  79267. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79268. * @param context The context when loading the asset
  79269. * @param material The glTF material property
  79270. * @param babylonMaterial The Babylon material
  79271. * @returns A promise that resolves when the load is complete
  79272. */
  79273. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79274. /**
  79275. * Loads the alpha properties from a glTF material into a Babylon material.
  79276. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79277. * @param context The context when loading the asset
  79278. * @param material The glTF material property
  79279. * @param babylonMaterial The Babylon material
  79280. */
  79281. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79282. /**
  79283. * Loads a glTF texture info.
  79284. * @param context The context when loading the asset
  79285. * @param textureInfo The glTF texture info property
  79286. * @param assign A function called synchronously after parsing the glTF properties
  79287. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79288. */
  79289. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79290. /** @hidden */
  79291. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79292. /** @hidden */
  79293. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79294. private _loadSampler;
  79295. /**
  79296. * Loads a glTF image.
  79297. * @param context The context when loading the asset
  79298. * @param image The glTF image property
  79299. * @returns A promise that resolves with the loaded data when the load is complete
  79300. */
  79301. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79302. /**
  79303. * Loads a glTF uri.
  79304. * @param context The context when loading the asset
  79305. * @param property The glTF property associated with the uri
  79306. * @param uri The base64 or relative uri
  79307. * @returns A promise that resolves with the loaded data when the load is complete
  79308. */
  79309. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79310. private _onProgress;
  79311. /**
  79312. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79313. * @param babylonObject the Babylon object with metadata
  79314. * @param pointer the JSON pointer
  79315. */
  79316. static AddPointerMetadata(babylonObject: {
  79317. metadata: any;
  79318. }, pointer: string): void;
  79319. private static _GetTextureWrapMode;
  79320. private static _GetTextureSamplingMode;
  79321. private static _GetTypedArrayConstructor;
  79322. private static _GetTypedArray;
  79323. private static _GetNumComponents;
  79324. private static _ValidateUri;
  79325. private static _GetDrawMode;
  79326. private _compileMaterialsAsync;
  79327. private _compileShadowGeneratorsAsync;
  79328. private _forEachExtensions;
  79329. private _applyExtensions;
  79330. private _extensionsOnLoading;
  79331. private _extensionsOnReady;
  79332. private _extensionsLoadSceneAsync;
  79333. private _extensionsLoadNodeAsync;
  79334. private _extensionsLoadCameraAsync;
  79335. private _extensionsLoadVertexDataAsync;
  79336. private _extensionsLoadMeshPrimitiveAsync;
  79337. private _extensionsLoadMaterialAsync;
  79338. private _extensionsCreateMaterial;
  79339. private _extensionsLoadMaterialPropertiesAsync;
  79340. private _extensionsLoadTextureInfoAsync;
  79341. private _extensionsLoadTextureAsync;
  79342. private _extensionsLoadAnimationAsync;
  79343. private _extensionsLoadSkinAsync;
  79344. private _extensionsLoadUriAsync;
  79345. private _extensionsLoadBufferViewAsync;
  79346. private _extensionsLoadBufferAsync;
  79347. /**
  79348. * Helper method called by a loader extension to load an glTF extension.
  79349. * @param context The context when loading the asset
  79350. * @param property The glTF property to load the extension from
  79351. * @param extensionName The name of the extension to load
  79352. * @param actionAsync The action to run
  79353. * @returns The promise returned by actionAsync or null if the extension does not exist
  79354. */
  79355. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79356. /**
  79357. * Helper method called by a loader extension to load a glTF extra.
  79358. * @param context The context when loading the asset
  79359. * @param property The glTF property to load the extra from
  79360. * @param extensionName The name of the extension to load
  79361. * @param actionAsync The action to run
  79362. * @returns The promise returned by actionAsync or null if the extra does not exist
  79363. */
  79364. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79365. /**
  79366. * Checks for presence of an extension.
  79367. * @param name The name of the extension to check
  79368. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79369. */
  79370. isExtensionUsed(name: string): boolean;
  79371. /**
  79372. * Increments the indentation level and logs a message.
  79373. * @param message The message to log
  79374. */
  79375. logOpen(message: string): void;
  79376. /**
  79377. * Decrements the indentation level.
  79378. */
  79379. logClose(): void;
  79380. /**
  79381. * Logs a message
  79382. * @param message The message to log
  79383. */
  79384. log(message: string): void;
  79385. /**
  79386. * Starts a performance counter.
  79387. * @param counterName The name of the performance counter
  79388. */
  79389. startPerformanceCounter(counterName: string): void;
  79390. /**
  79391. * Ends a performance counter.
  79392. * @param counterName The name of the performance counter
  79393. */
  79394. endPerformanceCounter(counterName: string): void;
  79395. }
  79396. }
  79397. declare module BABYLON.GLTF2.Loader.Extensions {
  79398. /**
  79399. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79400. */
  79401. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79402. /**
  79403. * The name of this extension.
  79404. */
  79405. readonly name: string;
  79406. /**
  79407. * Defines whether this extension is enabled.
  79408. */
  79409. enabled: boolean;
  79410. private _loader;
  79411. private _lights?;
  79412. /** @hidden */
  79413. constructor(loader: GLTFLoader);
  79414. /** @hidden */
  79415. dispose(): void;
  79416. /** @hidden */
  79417. onLoading(): void;
  79418. /** @hidden */
  79419. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79420. private _loadLightAsync;
  79421. }
  79422. }
  79423. declare module BABYLON.GLTF2.Loader.Extensions {
  79424. /**
  79425. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79426. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79427. * !!! Experimental Extension Subject to Changes !!!
  79428. */
  79429. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79430. /**
  79431. * The name of this extension.
  79432. */
  79433. readonly name: string;
  79434. /**
  79435. * Defines whether this extension is enabled.
  79436. */
  79437. enabled: boolean;
  79438. private _loader;
  79439. /** @hidden */
  79440. constructor(loader: GLTFLoader);
  79441. /** @hidden */
  79442. dispose(): void;
  79443. /** @hidden */
  79444. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79445. }
  79446. }
  79447. declare module BABYLON.GLTF2.Loader.Extensions {
  79448. /**
  79449. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79450. */
  79451. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79452. /**
  79453. * The name of this extension.
  79454. */
  79455. readonly name: string;
  79456. /**
  79457. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79458. */
  79459. dracoCompression?: DracoCompression;
  79460. /**
  79461. * Defines whether this extension is enabled.
  79462. */
  79463. enabled: boolean;
  79464. private _loader;
  79465. /** @hidden */
  79466. constructor(loader: GLTFLoader);
  79467. /** @hidden */
  79468. dispose(): void;
  79469. /** @hidden */
  79470. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79471. }
  79472. }
  79473. declare module BABYLON.GLTF2.Loader.Extensions {
  79474. /**
  79475. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79476. */
  79477. export class KHR_lights 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. private _loader;
  79487. private _lights?;
  79488. /** @hidden */
  79489. constructor(loader: GLTFLoader);
  79490. /** @hidden */
  79491. dispose(): void;
  79492. /** @hidden */
  79493. onLoading(): void;
  79494. /** @hidden */
  79495. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79496. }
  79497. }
  79498. declare module BABYLON.GLTF2.Loader.Extensions {
  79499. /**
  79500. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79501. */
  79502. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79503. /**
  79504. * The name of this extension.
  79505. */
  79506. readonly name: string;
  79507. /**
  79508. * Defines whether this extension is enabled.
  79509. */
  79510. enabled: boolean;
  79511. /**
  79512. * Defines a number that determines the order the extensions are applied.
  79513. */
  79514. order: number;
  79515. private _loader;
  79516. /** @hidden */
  79517. constructor(loader: GLTFLoader);
  79518. /** @hidden */
  79519. dispose(): void;
  79520. /** @hidden */
  79521. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79522. private _loadSpecularGlossinessPropertiesAsync;
  79523. }
  79524. }
  79525. declare module BABYLON.GLTF2.Loader.Extensions {
  79526. /**
  79527. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79528. */
  79529. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79530. /**
  79531. * The name of this extension.
  79532. */
  79533. readonly name: string;
  79534. /**
  79535. * Defines whether this extension is enabled.
  79536. */
  79537. enabled: boolean;
  79538. /**
  79539. * Defines a number that determines the order the extensions are applied.
  79540. */
  79541. order: number;
  79542. private _loader;
  79543. /** @hidden */
  79544. constructor(loader: GLTFLoader);
  79545. /** @hidden */
  79546. dispose(): void;
  79547. /** @hidden */
  79548. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79549. private _loadUnlitPropertiesAsync;
  79550. }
  79551. }
  79552. declare module BABYLON.GLTF2.Loader.Extensions {
  79553. /**
  79554. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79555. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79556. * !!! Experimental Extension Subject to Changes !!!
  79557. */
  79558. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79559. /**
  79560. * The name of this extension.
  79561. */
  79562. readonly name: string;
  79563. /**
  79564. * Defines whether this extension is enabled.
  79565. */
  79566. enabled: boolean;
  79567. /**
  79568. * Defines a number that determines the order the extensions are applied.
  79569. */
  79570. order: number;
  79571. private _loader;
  79572. /** @hidden */
  79573. constructor(loader: GLTFLoader);
  79574. /** @hidden */
  79575. dispose(): void;
  79576. /** @hidden */
  79577. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79578. private _loadClearCoatPropertiesAsync;
  79579. }
  79580. }
  79581. declare module BABYLON.GLTF2.Loader.Extensions {
  79582. /**
  79583. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79584. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79585. * !!! Experimental Extension Subject to Changes !!!
  79586. */
  79587. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79588. /**
  79589. * The name of this extension.
  79590. */
  79591. readonly name: string;
  79592. /**
  79593. * Defines whether this extension is enabled.
  79594. */
  79595. enabled: boolean;
  79596. /**
  79597. * Defines a number that determines the order the extensions are applied.
  79598. */
  79599. order: number;
  79600. private _loader;
  79601. /** @hidden */
  79602. constructor(loader: GLTFLoader);
  79603. /** @hidden */
  79604. dispose(): void;
  79605. /** @hidden */
  79606. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79607. private _loadSheenPropertiesAsync;
  79608. }
  79609. }
  79610. declare module BABYLON.GLTF2.Loader.Extensions {
  79611. /**
  79612. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79613. * !!! Experimental Extension Subject to Changes !!!
  79614. */
  79615. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79616. /**
  79617. * The name of this extension.
  79618. */
  79619. readonly name: string;
  79620. /**
  79621. * Defines whether this extension is enabled.
  79622. */
  79623. enabled: boolean;
  79624. /**
  79625. * Defines a number that determines the order the extensions are applied.
  79626. */
  79627. order: number;
  79628. private _loader;
  79629. /** @hidden */
  79630. constructor(loader: GLTFLoader);
  79631. /** @hidden */
  79632. dispose(): void;
  79633. /** @hidden */
  79634. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79635. private _loadSpecularPropertiesAsync;
  79636. }
  79637. }
  79638. declare module BABYLON.GLTF2.Loader.Extensions {
  79639. /**
  79640. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79641. * !!! Experimental Extension Subject to Changes !!!
  79642. */
  79643. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79644. /**
  79645. * Default ior Value from the spec.
  79646. */
  79647. private static readonly _DEFAULT_IOR;
  79648. /**
  79649. * The name of this extension.
  79650. */
  79651. readonly name: string;
  79652. /**
  79653. * Defines whether this extension is enabled.
  79654. */
  79655. enabled: boolean;
  79656. /**
  79657. * Defines a number that determines the order the extensions are applied.
  79658. */
  79659. order: number;
  79660. private _loader;
  79661. /** @hidden */
  79662. constructor(loader: GLTFLoader);
  79663. /** @hidden */
  79664. dispose(): void;
  79665. /** @hidden */
  79666. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79667. private _loadIorPropertiesAsync;
  79668. }
  79669. }
  79670. declare module BABYLON.GLTF2.Loader.Extensions {
  79671. /**
  79672. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79673. */
  79674. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79675. /**
  79676. * The name of this extension.
  79677. */
  79678. readonly name: string;
  79679. /**
  79680. * Defines whether this extension is enabled.
  79681. */
  79682. enabled: boolean;
  79683. /** @hidden */
  79684. constructor(loader: GLTFLoader);
  79685. /** @hidden */
  79686. dispose(): void;
  79687. }
  79688. }
  79689. declare module BABYLON.GLTF2.Loader.Extensions {
  79690. /**
  79691. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79692. * !!! Experimental Extension Subject to Changes !!!
  79693. */
  79694. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79695. /** The name of this extension. */
  79696. readonly name: string;
  79697. /** Defines whether this extension is enabled. */
  79698. enabled: boolean;
  79699. private _loader;
  79700. /** @hidden */
  79701. constructor(loader: GLTFLoader);
  79702. /** @hidden */
  79703. dispose(): void;
  79704. /** @hidden */
  79705. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79706. }
  79707. }
  79708. declare module BABYLON.GLTF2.Loader.Extensions {
  79709. /**
  79710. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79711. */
  79712. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79713. /**
  79714. * The name of this extension.
  79715. */
  79716. readonly name: string;
  79717. /**
  79718. * Defines whether this extension is enabled.
  79719. */
  79720. enabled: boolean;
  79721. private _loader;
  79722. /** @hidden */
  79723. constructor(loader: GLTFLoader);
  79724. /** @hidden */
  79725. dispose(): void;
  79726. /** @hidden */
  79727. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79728. }
  79729. }
  79730. declare module BABYLON.GLTF2.Loader.Extensions {
  79731. /**
  79732. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  79733. * !!! Experimental Extension Subject to Changes !!!
  79734. */
  79735. export class KHR_xmp implements IGLTFLoaderExtension {
  79736. /**
  79737. * The name of this extension.
  79738. */
  79739. readonly name: string;
  79740. /**
  79741. * Defines whether this extension is enabled.
  79742. */
  79743. enabled: boolean;
  79744. /**
  79745. * Defines a number that determines the order the extensions are applied.
  79746. */
  79747. order: number;
  79748. private _loader;
  79749. /** @hidden */
  79750. constructor(loader: GLTFLoader);
  79751. /** @hidden */
  79752. dispose(): void;
  79753. /**
  79754. * Called after the loader state changes to LOADING.
  79755. */
  79756. onLoading(): void;
  79757. }
  79758. }
  79759. declare module BABYLON.GLTF2.Loader.Extensions {
  79760. /**
  79761. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79762. */
  79763. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79764. /**
  79765. * The name of this extension.
  79766. */
  79767. readonly name: string;
  79768. /**
  79769. * Defines whether this extension is enabled.
  79770. */
  79771. enabled: boolean;
  79772. private _loader;
  79773. private _clips;
  79774. private _emitters;
  79775. /** @hidden */
  79776. constructor(loader: GLTFLoader);
  79777. /** @hidden */
  79778. dispose(): void;
  79779. /** @hidden */
  79780. onLoading(): void;
  79781. /** @hidden */
  79782. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79783. /** @hidden */
  79784. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79785. /** @hidden */
  79786. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79787. private _loadClipAsync;
  79788. private _loadEmitterAsync;
  79789. private _getEventAction;
  79790. private _loadAnimationEventAsync;
  79791. }
  79792. }
  79793. declare module BABYLON.GLTF2.Loader.Extensions {
  79794. /**
  79795. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79796. */
  79797. export class MSFT_lod implements IGLTFLoaderExtension {
  79798. /**
  79799. * The name of this extension.
  79800. */
  79801. readonly name: string;
  79802. /**
  79803. * Defines whether this extension is enabled.
  79804. */
  79805. enabled: boolean;
  79806. /**
  79807. * Defines a number that determines the order the extensions are applied.
  79808. */
  79809. order: number;
  79810. /**
  79811. * Maximum number of LODs to load, starting from the lowest LOD.
  79812. */
  79813. maxLODsToLoad: number;
  79814. /**
  79815. * Observable raised when all node LODs of one level are loaded.
  79816. * The event data is the index of the loaded LOD starting from zero.
  79817. * Dispose the loader to cancel the loading of the next level of LODs.
  79818. */
  79819. onNodeLODsLoadedObservable: Observable<number>;
  79820. /**
  79821. * Observable raised when all material LODs of one level are loaded.
  79822. * The event data is the index of the loaded LOD starting from zero.
  79823. * Dispose the loader to cancel the loading of the next level of LODs.
  79824. */
  79825. onMaterialLODsLoadedObservable: Observable<number>;
  79826. private _loader;
  79827. private _nodeIndexLOD;
  79828. private _nodeSignalLODs;
  79829. private _nodePromiseLODs;
  79830. private _materialIndexLOD;
  79831. private _materialSignalLODs;
  79832. private _materialPromiseLODs;
  79833. private _indexLOD;
  79834. private _bufferLODs;
  79835. /** @hidden */
  79836. constructor(loader: GLTFLoader);
  79837. /** @hidden */
  79838. dispose(): void;
  79839. /** @hidden */
  79840. onReady(): void;
  79841. /** @hidden */
  79842. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79843. /** @hidden */
  79844. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79845. /** @hidden */
  79846. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79847. /** @hidden */
  79848. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79849. /** @hidden */
  79850. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79851. private _loadBufferLOD;
  79852. /**
  79853. * Gets an array of LOD properties from lowest to highest.
  79854. */
  79855. private _getLODs;
  79856. private _disposeTransformNode;
  79857. private _disposeMaterials;
  79858. }
  79859. }
  79860. declare module BABYLON.GLTF2.Loader.Extensions {
  79861. /** @hidden */
  79862. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79863. readonly name: string;
  79864. enabled: boolean;
  79865. private _loader;
  79866. constructor(loader: GLTFLoader);
  79867. dispose(): void;
  79868. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79869. }
  79870. }
  79871. declare module BABYLON.GLTF2.Loader.Extensions {
  79872. /** @hidden */
  79873. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79874. readonly name: string;
  79875. enabled: boolean;
  79876. private _loader;
  79877. constructor(loader: GLTFLoader);
  79878. dispose(): void;
  79879. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79880. }
  79881. }
  79882. declare module BABYLON.GLTF2.Loader.Extensions {
  79883. /**
  79884. * Store glTF extras (if present) in BJS objects' metadata
  79885. */
  79886. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79887. /**
  79888. * The name of this extension.
  79889. */
  79890. readonly name: string;
  79891. /**
  79892. * Defines whether this extension is enabled.
  79893. */
  79894. enabled: boolean;
  79895. private _loader;
  79896. private _assignExtras;
  79897. /** @hidden */
  79898. constructor(loader: GLTFLoader);
  79899. /** @hidden */
  79900. dispose(): void;
  79901. /** @hidden */
  79902. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79903. /** @hidden */
  79904. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79905. /** @hidden */
  79906. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Class reading and parsing the MTL file bundled with the obj file.
  79912. */
  79913. export class MTLFileLoader {
  79914. /**
  79915. * Invert Y-Axis of referenced textures on load
  79916. */
  79917. static INVERT_TEXTURE_Y: boolean;
  79918. /**
  79919. * All material loaded from the mtl will be set here
  79920. */
  79921. materials: StandardMaterial[];
  79922. /**
  79923. * This function will read the mtl file and create each material described inside
  79924. * This function could be improve by adding :
  79925. * -some component missing (Ni, Tf...)
  79926. * -including the specific options available
  79927. *
  79928. * @param scene defines the scene the material will be created in
  79929. * @param data defines the mtl data to parse
  79930. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79931. * @param forAssetContainer defines if the material should be registered in the scene
  79932. */
  79933. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79934. /**
  79935. * Gets the texture for the material.
  79936. *
  79937. * If the material is imported from input file,
  79938. * We sanitize the url to ensure it takes the textre from aside the material.
  79939. *
  79940. * @param rootUrl The root url to load from
  79941. * @param value The value stored in the mtl
  79942. * @return The Texture
  79943. */
  79944. private static _getTexture;
  79945. }
  79946. }
  79947. declare module BABYLON {
  79948. /**
  79949. * Options for loading OBJ/MTL files
  79950. */
  79951. type MeshLoadOptions = {
  79952. /**
  79953. * Defines if UVs are optimized by default during load.
  79954. */
  79955. OptimizeWithUV: boolean;
  79956. /**
  79957. * Defines custom scaling of UV coordinates of loaded meshes.
  79958. */
  79959. UVScaling: Vector2;
  79960. /**
  79961. * Invert model on y-axis (does a model scaling inversion)
  79962. */
  79963. InvertY: boolean;
  79964. /**
  79965. * Invert Y-Axis of referenced textures on load
  79966. */
  79967. InvertTextureY: boolean;
  79968. /**
  79969. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79970. */
  79971. ImportVertexColors: boolean;
  79972. /**
  79973. * Compute the normals for the model, even if normals are present in the file.
  79974. */
  79975. ComputeNormals: boolean;
  79976. /**
  79977. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79978. */
  79979. SkipMaterials: boolean;
  79980. /**
  79981. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79982. */
  79983. MaterialLoadingFailsSilently: boolean;
  79984. };
  79985. /**
  79986. * OBJ file type loader.
  79987. * This is a babylon scene loader plugin.
  79988. */
  79989. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79990. /**
  79991. * Defines if UVs are optimized by default during load.
  79992. */
  79993. static OPTIMIZE_WITH_UV: boolean;
  79994. /**
  79995. * Invert model on y-axis (does a model scaling inversion)
  79996. */
  79997. static INVERT_Y: boolean;
  79998. /**
  79999. * Invert Y-Axis of referenced textures on load
  80000. */
  80001. static get INVERT_TEXTURE_Y(): boolean;
  80002. static set INVERT_TEXTURE_Y(value: boolean);
  80003. /**
  80004. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80005. */
  80006. static IMPORT_VERTEX_COLORS: boolean;
  80007. /**
  80008. * Compute the normals for the model, even if normals are present in the file.
  80009. */
  80010. static COMPUTE_NORMALS: boolean;
  80011. /**
  80012. * Defines custom scaling of UV coordinates of loaded meshes.
  80013. */
  80014. static UV_SCALING: Vector2;
  80015. /**
  80016. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80017. */
  80018. static SKIP_MATERIALS: boolean;
  80019. /**
  80020. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80021. *
  80022. * Defaults to true for backwards compatibility.
  80023. */
  80024. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80025. /**
  80026. * Defines the name of the plugin.
  80027. */
  80028. name: string;
  80029. /**
  80030. * Defines the extension the plugin is able to load.
  80031. */
  80032. extensions: string;
  80033. /** @hidden */
  80034. obj: RegExp;
  80035. /** @hidden */
  80036. group: RegExp;
  80037. /** @hidden */
  80038. mtllib: RegExp;
  80039. /** @hidden */
  80040. usemtl: RegExp;
  80041. /** @hidden */
  80042. smooth: RegExp;
  80043. /** @hidden */
  80044. vertexPattern: RegExp;
  80045. /** @hidden */
  80046. normalPattern: RegExp;
  80047. /** @hidden */
  80048. uvPattern: RegExp;
  80049. /** @hidden */
  80050. facePattern1: RegExp;
  80051. /** @hidden */
  80052. facePattern2: RegExp;
  80053. /** @hidden */
  80054. facePattern3: RegExp;
  80055. /** @hidden */
  80056. facePattern4: RegExp;
  80057. /** @hidden */
  80058. facePattern5: RegExp;
  80059. private _forAssetContainer;
  80060. private _meshLoadOptions;
  80061. /**
  80062. * Creates loader for .OBJ files
  80063. *
  80064. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80065. */
  80066. constructor(meshLoadOptions?: MeshLoadOptions);
  80067. private static get currentMeshLoadOptions();
  80068. /**
  80069. * Calls synchronously the MTL file attached to this obj.
  80070. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80071. * Without this function materials are not displayed in the first frame (but displayed after).
  80072. * In consequence it is impossible to get material information in your HTML file
  80073. *
  80074. * @param url The URL of the MTL file
  80075. * @param rootUrl
  80076. * @param onSuccess Callback function to be called when the MTL file is loaded
  80077. * @private
  80078. */
  80079. private _loadMTL;
  80080. /**
  80081. * Instantiates a OBJ file loader plugin.
  80082. * @returns the created plugin
  80083. */
  80084. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80085. /**
  80086. * If the data string can be loaded directly.
  80087. *
  80088. * @param data string containing the file data
  80089. * @returns if the data can be loaded directly
  80090. */
  80091. canDirectLoad(data: string): boolean;
  80092. /**
  80093. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80094. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80095. * @param scene the scene the meshes should be added to
  80096. * @param data the OBJ data to load
  80097. * @param rootUrl root url to load from
  80098. * @param onProgress event that fires when loading progress has occured
  80099. * @param fileName Defines the name of the file to load
  80100. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80101. */
  80102. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80103. meshes: AbstractMesh[];
  80104. particleSystems: IParticleSystem[];
  80105. skeletons: Skeleton[];
  80106. animationGroups: AnimationGroup[];
  80107. }>;
  80108. /**
  80109. * Imports all objects from the loaded OBJ data and adds them to the scene
  80110. * @param scene the scene the objects should be added to
  80111. * @param data the OBJ data to load
  80112. * @param rootUrl root url to load from
  80113. * @param onProgress event that fires when loading progress has occured
  80114. * @param fileName Defines the name of the file to load
  80115. * @returns a promise which completes when objects have been loaded to the scene
  80116. */
  80117. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80118. /**
  80119. * Load into an asset container.
  80120. * @param scene The scene to load into
  80121. * @param data The data to import
  80122. * @param rootUrl The root url for scene and resources
  80123. * @param onProgress The callback when the load progresses
  80124. * @param fileName Defines the name of the file to load
  80125. * @returns The loaded asset container
  80126. */
  80127. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80128. /**
  80129. * Read the OBJ file and create an Array of meshes.
  80130. * Each mesh contains all information given by the OBJ and the MTL file.
  80131. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80132. *
  80133. * @param meshesNames
  80134. * @param scene Scene The scene where are displayed the data
  80135. * @param data String The content of the obj file
  80136. * @param rootUrl String The path to the folder
  80137. * @returns Array<AbstractMesh>
  80138. * @private
  80139. */
  80140. private _parseSolid;
  80141. }
  80142. }
  80143. declare module BABYLON {
  80144. /**
  80145. * STL file type loader.
  80146. * This is a babylon scene loader plugin.
  80147. */
  80148. export class STLFileLoader implements ISceneLoaderPlugin {
  80149. /** @hidden */
  80150. solidPattern: RegExp;
  80151. /** @hidden */
  80152. facetsPattern: RegExp;
  80153. /** @hidden */
  80154. normalPattern: RegExp;
  80155. /** @hidden */
  80156. vertexPattern: RegExp;
  80157. /**
  80158. * Defines the name of the plugin.
  80159. */
  80160. name: string;
  80161. /**
  80162. * Defines the extensions the stl loader is able to load.
  80163. * force data to come in as an ArrayBuffer
  80164. * we'll convert to string if it looks like it's an ASCII .stl
  80165. */
  80166. extensions: ISceneLoaderPluginExtensions;
  80167. /**
  80168. * Import meshes into a scene.
  80169. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80170. * @param scene The scene to import into
  80171. * @param data The data to import
  80172. * @param rootUrl The root url for scene and resources
  80173. * @param meshes The meshes array to import into
  80174. * @param particleSystems The particle systems array to import into
  80175. * @param skeletons The skeletons array to import into
  80176. * @param onError The callback when import fails
  80177. * @returns True if successful or false otherwise
  80178. */
  80179. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80180. /**
  80181. * Load into a scene.
  80182. * @param scene The scene to load into
  80183. * @param data The data to import
  80184. * @param rootUrl The root url for scene and resources
  80185. * @param onError The callback when import fails
  80186. * @returns true if successful or false otherwise
  80187. */
  80188. load(scene: Scene, data: any, rootUrl: string): boolean;
  80189. /**
  80190. * Load into an asset container.
  80191. * @param scene The scene to load into
  80192. * @param data The data to import
  80193. * @param rootUrl The root url for scene and resources
  80194. * @param onError The callback when import fails
  80195. * @returns The loaded asset container
  80196. */
  80197. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80198. private _isBinary;
  80199. private _parseBinary;
  80200. private _parseASCII;
  80201. }
  80202. }
  80203. declare module BABYLON {
  80204. /**
  80205. * Class for generating OBJ data from a Babylon scene.
  80206. */
  80207. export class OBJExport {
  80208. /**
  80209. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80210. * @param mesh defines the list of meshes to serialize
  80211. * @param materials defines if materials should be exported
  80212. * @param matlibname defines the name of the associated mtl file
  80213. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80214. * @returns the OBJ content
  80215. */
  80216. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80217. /**
  80218. * Exports the material(s) of a mesh in .MTL file format (text)
  80219. * @param mesh defines the mesh to extract the material from
  80220. * @returns the mtl content
  80221. */
  80222. static MTL(mesh: Mesh): string;
  80223. }
  80224. }
  80225. declare module BABYLON {
  80226. /** @hidden */
  80227. export var __IGLTFExporterExtension: number;
  80228. /**
  80229. * Interface for extending the exporter
  80230. * @hidden
  80231. */
  80232. export interface IGLTFExporterExtension {
  80233. /**
  80234. * The name of this extension
  80235. */
  80236. readonly name: string;
  80237. /**
  80238. * Defines whether this extension is enabled
  80239. */
  80240. enabled: boolean;
  80241. /**
  80242. * Defines whether this extension is required
  80243. */
  80244. required: boolean;
  80245. }
  80246. }
  80247. declare module BABYLON.GLTF2.Exporter {
  80248. /** @hidden */
  80249. export var __IGLTFExporterExtensionV2: number;
  80250. /**
  80251. * Interface for a glTF exporter extension
  80252. * @hidden
  80253. */
  80254. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80255. /**
  80256. * Define this method to modify the default behavior before exporting a texture
  80257. * @param context The context when loading the asset
  80258. * @param babylonTexture The Babylon.js texture
  80259. * @param mimeType The mime-type of the generated image
  80260. * @returns A promise that resolves with the exported texture
  80261. */
  80262. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80263. /**
  80264. * Define this method to get notified when a texture info is created
  80265. * @param context The context when loading the asset
  80266. * @param textureInfo The glTF texture info
  80267. * @param babylonTexture The Babylon.js texture
  80268. */
  80269. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80270. /**
  80271. * Define this method to modify the default behavior when exporting texture info
  80272. * @param context The context when loading the asset
  80273. * @param meshPrimitive glTF mesh primitive
  80274. * @param babylonSubMesh Babylon submesh
  80275. * @param binaryWriter glTF serializer binary writer instance
  80276. * @returns nullable IMeshPrimitive promise
  80277. */
  80278. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80279. /**
  80280. * Define this method to modify the default behavior when exporting a node
  80281. * @param context The context when exporting the node
  80282. * @param node glTF node
  80283. * @param babylonNode BabylonJS node
  80284. * @returns nullable INode promise
  80285. */
  80286. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80287. [key: number]: number;
  80288. }): Promise<Nullable<INode>>;
  80289. /**
  80290. * Define this method to modify the default behavior when exporting a material
  80291. * @param material glTF material
  80292. * @param babylonMaterial BabylonJS material
  80293. * @returns nullable IMaterial promise
  80294. */
  80295. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80296. /**
  80297. * Define this method to return additional textures to export from a material
  80298. * @param material glTF material
  80299. * @param babylonMaterial BabylonJS material
  80300. * @returns List of textures
  80301. */
  80302. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80303. /** Gets a boolean indicating that this extension was used */
  80304. wasUsed: boolean;
  80305. /** Gets a boolean indicating that this extension is required for the file to work */
  80306. required: boolean;
  80307. /**
  80308. * Called after the exporter state changes to EXPORTING
  80309. */
  80310. onExporting?(): void;
  80311. }
  80312. }
  80313. declare module BABYLON.GLTF2.Exporter {
  80314. /**
  80315. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80316. * @hidden
  80317. */
  80318. export class _GLTFMaterialExporter {
  80319. /**
  80320. * Represents the dielectric specular values for R, G and B
  80321. */
  80322. private static readonly _DielectricSpecular;
  80323. /**
  80324. * Allows the maximum specular power to be defined for material calculations
  80325. */
  80326. private static readonly _MaxSpecularPower;
  80327. /**
  80328. * Mapping to store textures
  80329. */
  80330. private _textureMap;
  80331. /**
  80332. * Numeric tolerance value
  80333. */
  80334. private static readonly _Epsilon;
  80335. /**
  80336. * Reference to the glTF Exporter
  80337. */
  80338. private _exporter;
  80339. constructor(exporter: _Exporter);
  80340. /**
  80341. * Specifies if two colors are approximately equal in value
  80342. * @param color1 first color to compare to
  80343. * @param color2 second color to compare to
  80344. * @param epsilon threshold value
  80345. */
  80346. private static FuzzyEquals;
  80347. /**
  80348. * Gets the materials from a Babylon scene and converts them to glTF materials
  80349. * @param scene babylonjs scene
  80350. * @param mimeType texture mime type
  80351. * @param images array of images
  80352. * @param textures array of textures
  80353. * @param materials array of materials
  80354. * @param imageData mapping of texture names to base64 textures
  80355. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80356. */
  80357. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80358. /**
  80359. * Makes a copy of the glTF material without the texture parameters
  80360. * @param originalMaterial original glTF material
  80361. * @returns glTF material without texture parameters
  80362. */
  80363. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80364. /**
  80365. * Specifies if the material has any texture parameters present
  80366. * @param material glTF Material
  80367. * @returns boolean specifying if texture parameters are present
  80368. */
  80369. _hasTexturesPresent(material: IMaterial): boolean;
  80370. /**
  80371. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80372. * @param babylonStandardMaterial
  80373. * @returns glTF Metallic Roughness Material representation
  80374. */
  80375. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80376. /**
  80377. * Computes the metallic factor
  80378. * @param diffuse diffused value
  80379. * @param specular specular value
  80380. * @param oneMinusSpecularStrength one minus the specular strength
  80381. * @returns metallic value
  80382. */
  80383. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80384. /**
  80385. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80386. * @param glTFMaterial glTF material
  80387. * @param babylonMaterial Babylon material
  80388. */
  80389. private static _SetAlphaMode;
  80390. /**
  80391. * Converts a Babylon Standard Material to a glTF Material
  80392. * @param babylonStandardMaterial BJS Standard Material
  80393. * @param mimeType mime type to use for the textures
  80394. * @param images array of glTF image interfaces
  80395. * @param textures array of glTF texture interfaces
  80396. * @param materials array of glTF material interfaces
  80397. * @param imageData map of image file name to data
  80398. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80399. */
  80400. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80401. private _finishMaterial;
  80402. /**
  80403. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80404. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80405. * @param mimeType mime type to use for the textures
  80406. * @param images array of glTF image interfaces
  80407. * @param textures array of glTF texture interfaces
  80408. * @param materials array of glTF material interfaces
  80409. * @param imageData map of image file name to data
  80410. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80411. */
  80412. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80413. /**
  80414. * Converts an image typed array buffer to a base64 image
  80415. * @param buffer typed array buffer
  80416. * @param width width of the image
  80417. * @param height height of the image
  80418. * @param mimeType mimetype of the image
  80419. * @returns base64 image string
  80420. */
  80421. private _createBase64FromCanvasAsync;
  80422. /**
  80423. * Generates a white texture based on the specified width and height
  80424. * @param width width of the texture in pixels
  80425. * @param height height of the texture in pixels
  80426. * @param scene babylonjs scene
  80427. * @returns white texture
  80428. */
  80429. private _createWhiteTexture;
  80430. /**
  80431. * 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
  80432. * @param texture1 first texture to resize
  80433. * @param texture2 second texture to resize
  80434. * @param scene babylonjs scene
  80435. * @returns resized textures or null
  80436. */
  80437. private _resizeTexturesToSameDimensions;
  80438. /**
  80439. * Converts an array of pixels to a Float32Array
  80440. * Throws an error if the pixel format is not supported
  80441. * @param pixels - array buffer containing pixel values
  80442. * @returns Float32 of pixels
  80443. */
  80444. private _convertPixelArrayToFloat32;
  80445. /**
  80446. * Convert Specular Glossiness Textures to Metallic Roughness
  80447. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80448. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80449. * @param diffuseTexture texture used to store diffuse information
  80450. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80451. * @param factors specular glossiness material factors
  80452. * @param mimeType the mime type to use for the texture
  80453. * @returns pbr metallic roughness interface or null
  80454. */
  80455. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80456. /**
  80457. * Converts specular glossiness material properties to metallic roughness
  80458. * @param specularGlossiness interface with specular glossiness material properties
  80459. * @returns interface with metallic roughness material properties
  80460. */
  80461. private _convertSpecularGlossinessToMetallicRoughness;
  80462. /**
  80463. * Calculates the surface reflectance, independent of lighting conditions
  80464. * @param color Color source to calculate brightness from
  80465. * @returns number representing the perceived brightness, or zero if color is undefined
  80466. */
  80467. private _getPerceivedBrightness;
  80468. /**
  80469. * Returns the maximum color component value
  80470. * @param color
  80471. * @returns maximum color component value, or zero if color is null or undefined
  80472. */
  80473. private _getMaxComponent;
  80474. /**
  80475. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80476. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80477. * @param mimeType mime type to use for the textures
  80478. * @param images array of glTF image interfaces
  80479. * @param textures array of glTF texture interfaces
  80480. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80481. * @param imageData map of image file name to data
  80482. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80483. * @returns glTF PBR Metallic Roughness factors
  80484. */
  80485. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80486. private _getGLTFTextureSampler;
  80487. private _getGLTFTextureWrapMode;
  80488. private _getGLTFTextureWrapModesSampler;
  80489. /**
  80490. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80491. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80492. * @param mimeType mime type to use for the textures
  80493. * @param images array of glTF image interfaces
  80494. * @param textures array of glTF texture interfaces
  80495. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80496. * @param imageData map of image file name to data
  80497. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80498. * @returns glTF PBR Metallic Roughness factors
  80499. */
  80500. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80501. /**
  80502. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80503. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80504. * @param mimeType mime type to use for the textures
  80505. * @param images array of glTF image interfaces
  80506. * @param textures array of glTF texture interfaces
  80507. * @param materials array of glTF material interfaces
  80508. * @param imageData map of image file name to data
  80509. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80510. */
  80511. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80512. private setMetallicRoughnessPbrMaterial;
  80513. private getPixelsFromTexture;
  80514. /**
  80515. * Extracts a texture from a Babylon texture into file data and glTF data
  80516. * @param babylonTexture Babylon texture to extract
  80517. * @param mimeType Mime Type of the babylonTexture
  80518. * @return glTF texture info, or null if the texture format is not supported
  80519. */
  80520. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80521. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80522. /**
  80523. * Builds a texture from base64 string
  80524. * @param base64Texture base64 texture string
  80525. * @param baseTextureName Name to use for the texture
  80526. * @param mimeType image mime type for the texture
  80527. * @param images array of images
  80528. * @param textures array of textures
  80529. * @param imageData map of image data
  80530. * @returns glTF texture info, or null if the texture format is not supported
  80531. */
  80532. private _getTextureInfoFromBase64;
  80533. }
  80534. }
  80535. declare module BABYLON {
  80536. /**
  80537. * Class for holding and downloading glTF file data
  80538. */
  80539. export class GLTFData {
  80540. /**
  80541. * Object which contains the file name as the key and its data as the value
  80542. */
  80543. glTFFiles: {
  80544. [fileName: string]: string | Blob;
  80545. };
  80546. /**
  80547. * Initializes the glTF file object
  80548. */
  80549. constructor();
  80550. /**
  80551. * Downloads the glTF data as files based on their names and data
  80552. */
  80553. downloadFiles(): void;
  80554. }
  80555. }
  80556. declare module BABYLON {
  80557. /**
  80558. * Holds a collection of exporter options and parameters
  80559. */
  80560. export interface IExportOptions {
  80561. /**
  80562. * Function which indicates whether a babylon node should be exported or not
  80563. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80564. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80565. */
  80566. shouldExportNode?(node: Node): boolean;
  80567. /**
  80568. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80569. * @param metadata source metadata to read from
  80570. * @returns the data to store to glTF node extras
  80571. */
  80572. metadataSelector?(metadata: any): any;
  80573. /**
  80574. * The sample rate to bake animation curves
  80575. */
  80576. animationSampleRate?: number;
  80577. /**
  80578. * Begin serialization without waiting for the scene to be ready
  80579. */
  80580. exportWithoutWaitingForScene?: boolean;
  80581. /**
  80582. * Indicates if coordinate system swapping root nodes should be included in export
  80583. */
  80584. includeCoordinateSystemConversionNodes?: boolean;
  80585. }
  80586. /**
  80587. * Class for generating glTF data from a Babylon scene.
  80588. */
  80589. export class GLTF2Export {
  80590. /**
  80591. * Exports the geometry of the scene to .gltf file format asynchronously
  80592. * @param scene Babylon scene with scene hierarchy information
  80593. * @param filePrefix File prefix to use when generating the glTF file
  80594. * @param options Exporter options
  80595. * @returns Returns an object with a .gltf file and associates texture names
  80596. * as keys and their data and paths as values
  80597. */
  80598. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80599. private static _PreExportAsync;
  80600. private static _PostExportAsync;
  80601. /**
  80602. * Exports the geometry of the scene to .glb file format asychronously
  80603. * @param scene Babylon scene with scene hierarchy information
  80604. * @param filePrefix File prefix to use when generating glb file
  80605. * @param options Exporter options
  80606. * @returns Returns an object with a .glb filename as key and data as value
  80607. */
  80608. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80609. }
  80610. }
  80611. declare module BABYLON.GLTF2.Exporter {
  80612. /**
  80613. * @hidden
  80614. */
  80615. export class _GLTFUtilities {
  80616. /**
  80617. * Creates a buffer view based on the supplied arguments
  80618. * @param bufferIndex index value of the specified buffer
  80619. * @param byteOffset byte offset value
  80620. * @param byteLength byte length of the bufferView
  80621. * @param byteStride byte distance between conequential elements
  80622. * @param name name of the buffer view
  80623. * @returns bufferView for glTF
  80624. */
  80625. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80626. /**
  80627. * Creates an accessor based on the supplied arguments
  80628. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80629. * @param name The name of the accessor
  80630. * @param type The type of the accessor
  80631. * @param componentType The datatype of components in the attribute
  80632. * @param count The number of attributes referenced by this accessor
  80633. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80634. * @param min Minimum value of each component in this attribute
  80635. * @param max Maximum value of each component in this attribute
  80636. * @returns accessor for glTF
  80637. */
  80638. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80639. /**
  80640. * Calculates the minimum and maximum values of an array of position floats
  80641. * @param positions Positions array of a mesh
  80642. * @param vertexStart Starting vertex offset to calculate min and max values
  80643. * @param vertexCount Number of vertices to check for min and max values
  80644. * @returns min number array and max number array
  80645. */
  80646. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80647. min: number[];
  80648. max: number[];
  80649. };
  80650. /**
  80651. * Converts a new right-handed Vector3
  80652. * @param vector vector3 array
  80653. * @returns right-handed Vector3
  80654. */
  80655. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80656. /**
  80657. * Converts a Vector3 to right-handed
  80658. * @param vector Vector3 to convert to right-handed
  80659. */
  80660. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80661. /**
  80662. * Converts a three element number array to right-handed
  80663. * @param vector number array to convert to right-handed
  80664. */
  80665. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80666. /**
  80667. * Converts a new right-handed Vector3
  80668. * @param vector vector3 array
  80669. * @returns right-handed Vector3
  80670. */
  80671. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80672. /**
  80673. * Converts a Vector3 to right-handed
  80674. * @param vector Vector3 to convert to right-handed
  80675. */
  80676. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80677. /**
  80678. * Converts a three element number array to right-handed
  80679. * @param vector number array to convert to right-handed
  80680. */
  80681. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80682. /**
  80683. * Converts a Vector4 to right-handed
  80684. * @param vector Vector4 to convert to right-handed
  80685. */
  80686. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80687. /**
  80688. * Converts a Vector4 to right-handed
  80689. * @param vector Vector4 to convert to right-handed
  80690. */
  80691. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80692. /**
  80693. * Converts a Quaternion to right-handed
  80694. * @param quaternion Source quaternion to convert to right-handed
  80695. */
  80696. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80697. /**
  80698. * Converts a Quaternion to right-handed
  80699. * @param quaternion Source quaternion to convert to right-handed
  80700. */
  80701. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80702. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80703. }
  80704. }
  80705. declare module BABYLON.GLTF2.Exporter {
  80706. /**
  80707. * Converts Babylon Scene into glTF 2.0.
  80708. * @hidden
  80709. */
  80710. export class _Exporter {
  80711. /**
  80712. * Stores the glTF to export
  80713. */
  80714. _glTF: IGLTF;
  80715. /**
  80716. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80717. */
  80718. _bufferViews: IBufferView[];
  80719. /**
  80720. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80721. */
  80722. _accessors: IAccessor[];
  80723. /**
  80724. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80725. */
  80726. _nodes: INode[];
  80727. /**
  80728. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80729. */
  80730. private _scenes;
  80731. /**
  80732. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80733. */
  80734. private _meshes;
  80735. /**
  80736. * Stores all the generated material information, which represents the appearance of each primitive
  80737. */
  80738. _materials: IMaterial[];
  80739. _materialMap: {
  80740. [materialID: number]: number;
  80741. };
  80742. /**
  80743. * Stores all the generated texture information, which is referenced by glTF materials
  80744. */
  80745. _textures: ITexture[];
  80746. /**
  80747. * Stores all the generated image information, which is referenced by glTF textures
  80748. */
  80749. _images: IImage[];
  80750. /**
  80751. * Stores all the texture samplers
  80752. */
  80753. _samplers: ISampler[];
  80754. /**
  80755. * Stores all the generated animation samplers, which is referenced by glTF animations
  80756. */
  80757. /**
  80758. * Stores the animations for glTF models
  80759. */
  80760. private _animations;
  80761. /**
  80762. * Stores the total amount of bytes stored in the glTF buffer
  80763. */
  80764. private _totalByteLength;
  80765. /**
  80766. * Stores a reference to the Babylon scene containing the source geometry and material information
  80767. */
  80768. _babylonScene: Scene;
  80769. /**
  80770. * Stores a map of the image data, where the key is the file name and the value
  80771. * is the image data
  80772. */
  80773. _imageData: {
  80774. [fileName: string]: {
  80775. data: Uint8Array;
  80776. mimeType: ImageMimeType;
  80777. };
  80778. };
  80779. /**
  80780. * Stores a map of the unique id of a node to its index in the node array
  80781. */
  80782. _nodeMap: {
  80783. [key: number]: number;
  80784. };
  80785. /**
  80786. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80787. */
  80788. _convertToRightHandedSystem: boolean;
  80789. /**
  80790. * Specifies if a Babylon node should be converted to right-handed on export
  80791. */
  80792. _convertToRightHandedSystemMap: {
  80793. [nodeId: number]: boolean;
  80794. };
  80795. _includeCoordinateSystemConversionNodes: boolean;
  80796. /**
  80797. * Baked animation sample rate
  80798. */
  80799. private _animationSampleRate;
  80800. private _options;
  80801. private _localEngine;
  80802. _glTFMaterialExporter: _GLTFMaterialExporter;
  80803. private _extensions;
  80804. private static _ExtensionNames;
  80805. private static _ExtensionFactories;
  80806. private _applyExtension;
  80807. private _applyExtensions;
  80808. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80809. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80810. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80811. [key: number]: number;
  80812. }): Promise<Nullable<INode>>;
  80813. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80814. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80815. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80816. private _forEachExtensions;
  80817. private _extensionsOnExporting;
  80818. /**
  80819. * Load glTF serializer extensions
  80820. */
  80821. private _loadExtensions;
  80822. /**
  80823. * Creates a glTF Exporter instance, which can accept optional exporter options
  80824. * @param babylonScene Babylon scene object
  80825. * @param options Options to modify the behavior of the exporter
  80826. */
  80827. constructor(babylonScene: Scene, options?: IExportOptions);
  80828. dispose(): void;
  80829. /**
  80830. * Registers a glTF exporter extension
  80831. * @param name Name of the extension to export
  80832. * @param factory The factory function that creates the exporter extension
  80833. */
  80834. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80835. /**
  80836. * Un-registers an exporter extension
  80837. * @param name The name fo the exporter extension
  80838. * @returns A boolean indicating whether the extension has been un-registered
  80839. */
  80840. static UnregisterExtension(name: string): boolean;
  80841. /**
  80842. * Lazy load a local engine
  80843. */
  80844. _getLocalEngine(): Engine;
  80845. private reorderIndicesBasedOnPrimitiveMode;
  80846. /**
  80847. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80848. * clock-wise during export to glTF
  80849. * @param submesh BabylonJS submesh
  80850. * @param primitiveMode Primitive mode of the mesh
  80851. * @param sideOrientation the winding order of the submesh
  80852. * @param vertexBufferKind The type of vertex attribute
  80853. * @param meshAttributeArray The vertex attribute data
  80854. * @param byteOffset The offset to the binary data
  80855. * @param binaryWriter The binary data for the glTF file
  80856. * @param convertToRightHandedSystem Converts the values to right-handed
  80857. */
  80858. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80859. /**
  80860. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80861. * clock-wise during export to glTF
  80862. * @param submesh BabylonJS submesh
  80863. * @param primitiveMode Primitive mode of the mesh
  80864. * @param sideOrientation the winding order of the submesh
  80865. * @param vertexBufferKind The type of vertex attribute
  80866. * @param meshAttributeArray The vertex attribute data
  80867. * @param byteOffset The offset to the binary data
  80868. * @param binaryWriter The binary data for the glTF file
  80869. * @param convertToRightHandedSystem Converts the values to right-handed
  80870. */
  80871. private reorderTriangleFillMode;
  80872. /**
  80873. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80874. * clock-wise during export to glTF
  80875. * @param submesh BabylonJS submesh
  80876. * @param primitiveMode Primitive mode of the mesh
  80877. * @param sideOrientation the winding order of the submesh
  80878. * @param vertexBufferKind The type of vertex attribute
  80879. * @param meshAttributeArray The vertex attribute data
  80880. * @param byteOffset The offset to the binary data
  80881. * @param binaryWriter The binary data for the glTF file
  80882. * @param convertToRightHandedSystem Converts the values to right-handed
  80883. */
  80884. private reorderTriangleStripDrawMode;
  80885. /**
  80886. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80887. * clock-wise during export to glTF
  80888. * @param submesh BabylonJS submesh
  80889. * @param primitiveMode Primitive mode of the mesh
  80890. * @param sideOrientation the winding order of the submesh
  80891. * @param vertexBufferKind The type of vertex attribute
  80892. * @param meshAttributeArray The vertex attribute data
  80893. * @param byteOffset The offset to the binary data
  80894. * @param binaryWriter The binary data for the glTF file
  80895. * @param convertToRightHandedSystem Converts the values to right-handed
  80896. */
  80897. private reorderTriangleFanMode;
  80898. /**
  80899. * Writes the vertex attribute data to binary
  80900. * @param vertices The vertices to write to the binary writer
  80901. * @param byteOffset The offset into the binary writer to overwrite binary data
  80902. * @param vertexAttributeKind The vertex attribute type
  80903. * @param meshAttributeArray The vertex attribute data
  80904. * @param binaryWriter The writer containing the binary data
  80905. * @param convertToRightHandedSystem Converts the values to right-handed
  80906. */
  80907. private writeVertexAttributeData;
  80908. /**
  80909. * Writes mesh attribute data to a data buffer
  80910. * Returns the bytelength of the data
  80911. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80912. * @param meshAttributeArray Array containing the attribute data
  80913. * @param binaryWriter The buffer to write the binary data to
  80914. * @param indices Used to specify the order of the vertex data
  80915. * @param convertToRightHandedSystem Converts the values to right-handed
  80916. */
  80917. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80918. /**
  80919. * Generates glTF json data
  80920. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80921. * @param glTFPrefix Text to use when prefixing a glTF file
  80922. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80923. * @returns json data as string
  80924. */
  80925. private generateJSON;
  80926. /**
  80927. * Generates data for .gltf and .bin files based on the glTF prefix string
  80928. * @param glTFPrefix Text to use when prefixing a glTF file
  80929. * @param dispose Dispose the exporter
  80930. * @returns GLTFData with glTF file data
  80931. */
  80932. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80933. /**
  80934. * Creates a binary buffer for glTF
  80935. * @returns array buffer for binary data
  80936. */
  80937. private _generateBinaryAsync;
  80938. /**
  80939. * Pads the number to a multiple of 4
  80940. * @param num number to pad
  80941. * @returns padded number
  80942. */
  80943. private _getPadding;
  80944. /**
  80945. * @hidden
  80946. */
  80947. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80948. /**
  80949. * Sets the TRS for each node
  80950. * @param node glTF Node for storing the transformation data
  80951. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80952. * @param convertToRightHandedSystem Converts the values to right-handed
  80953. */
  80954. private setNodeTransformation;
  80955. private getVertexBufferFromMesh;
  80956. /**
  80957. * Creates a bufferview based on the vertices type for the Babylon mesh
  80958. * @param kind Indicates the type of vertices data
  80959. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80960. * @param binaryWriter The buffer to write the bufferview data to
  80961. * @param convertToRightHandedSystem Converts the values to right-handed
  80962. */
  80963. private createBufferViewKind;
  80964. /**
  80965. * The primitive mode of the Babylon mesh
  80966. * @param babylonMesh The BabylonJS mesh
  80967. */
  80968. private getMeshPrimitiveMode;
  80969. /**
  80970. * Sets the primitive mode of the glTF mesh primitive
  80971. * @param meshPrimitive glTF mesh primitive
  80972. * @param primitiveMode The primitive mode
  80973. */
  80974. private setPrimitiveMode;
  80975. /**
  80976. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80977. * @param meshPrimitive glTF mesh primitive
  80978. * @param attributeKind vertex attribute
  80979. * @returns boolean specifying if uv coordinates are present
  80980. */
  80981. private setAttributeKind;
  80982. /**
  80983. * Sets data for the primitive attributes of each submesh
  80984. * @param mesh glTF Mesh object to store the primitive attribute information
  80985. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80986. * @param binaryWriter Buffer to write the attribute data to
  80987. * @param convertToRightHandedSystem Converts the values to right-handed
  80988. */
  80989. private setPrimitiveAttributesAsync;
  80990. /**
  80991. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80992. * @param node The node to check
  80993. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80994. */
  80995. private isBabylonCoordinateSystemConvertingNode;
  80996. /**
  80997. * Creates a glTF scene based on the array of meshes
  80998. * Returns the the total byte offset
  80999. * @param babylonScene Babylon scene to get the mesh data from
  81000. * @param binaryWriter Buffer to write binary data to
  81001. */
  81002. private createSceneAsync;
  81003. /**
  81004. * Creates a mapping of Node unique id to node index and handles animations
  81005. * @param babylonScene Babylon Scene
  81006. * @param nodes Babylon transform nodes
  81007. * @param binaryWriter Buffer to write binary data to
  81008. * @returns Node mapping of unique id to index
  81009. */
  81010. private createNodeMapAndAnimationsAsync;
  81011. /**
  81012. * Creates a glTF node from a Babylon mesh
  81013. * @param babylonMesh Source Babylon mesh
  81014. * @param binaryWriter Buffer for storing geometry data
  81015. * @param convertToRightHandedSystem Converts the values to right-handed
  81016. * @param nodeMap Node mapping of unique id to glTF node index
  81017. * @returns glTF node
  81018. */
  81019. private createNodeAsync;
  81020. }
  81021. /**
  81022. * @hidden
  81023. *
  81024. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81025. */
  81026. export class _BinaryWriter {
  81027. /**
  81028. * Array buffer which stores all binary data
  81029. */
  81030. private _arrayBuffer;
  81031. /**
  81032. * View of the array buffer
  81033. */
  81034. private _dataView;
  81035. /**
  81036. * byte offset of data in array buffer
  81037. */
  81038. private _byteOffset;
  81039. /**
  81040. * Initialize binary writer with an initial byte length
  81041. * @param byteLength Initial byte length of the array buffer
  81042. */
  81043. constructor(byteLength: number);
  81044. /**
  81045. * Resize the array buffer to the specified byte length
  81046. * @param byteLength
  81047. */
  81048. private resizeBuffer;
  81049. /**
  81050. * Get an array buffer with the length of the byte offset
  81051. * @returns ArrayBuffer resized to the byte offset
  81052. */
  81053. getArrayBuffer(): ArrayBuffer;
  81054. /**
  81055. * Get the byte offset of the array buffer
  81056. * @returns byte offset
  81057. */
  81058. getByteOffset(): number;
  81059. /**
  81060. * Stores an UInt8 in the array buffer
  81061. * @param entry
  81062. * @param byteOffset If defined, specifies where to set the value as an offset.
  81063. */
  81064. setUInt8(entry: number, byteOffset?: number): void;
  81065. /**
  81066. * Gets an UInt32 in the array buffer
  81067. * @param entry
  81068. * @param byteOffset If defined, specifies where to set the value as an offset.
  81069. */
  81070. getUInt32(byteOffset: number): number;
  81071. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81072. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81073. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81074. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81075. /**
  81076. * Stores a Float32 in the array buffer
  81077. * @param entry
  81078. */
  81079. setFloat32(entry: number, byteOffset?: number): void;
  81080. /**
  81081. * Stores an UInt32 in the array buffer
  81082. * @param entry
  81083. * @param byteOffset If defined, specifies where to set the value as an offset.
  81084. */
  81085. setUInt32(entry: number, byteOffset?: number): void;
  81086. }
  81087. }
  81088. declare module BABYLON.GLTF2.Exporter {
  81089. /**
  81090. * @hidden
  81091. * Interface to store animation data.
  81092. */
  81093. export interface _IAnimationData {
  81094. /**
  81095. * Keyframe data.
  81096. */
  81097. inputs: number[];
  81098. /**
  81099. * Value data.
  81100. */
  81101. outputs: number[][];
  81102. /**
  81103. * Animation interpolation data.
  81104. */
  81105. samplerInterpolation: AnimationSamplerInterpolation;
  81106. /**
  81107. * Minimum keyframe value.
  81108. */
  81109. inputsMin: number;
  81110. /**
  81111. * Maximum keyframe value.
  81112. */
  81113. inputsMax: number;
  81114. }
  81115. /**
  81116. * @hidden
  81117. */
  81118. export interface _IAnimationInfo {
  81119. /**
  81120. * The target channel for the animation
  81121. */
  81122. animationChannelTargetPath: AnimationChannelTargetPath;
  81123. /**
  81124. * The glTF accessor type for the data.
  81125. */
  81126. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81127. /**
  81128. * Specifies if quaternions should be used.
  81129. */
  81130. useQuaternion: boolean;
  81131. }
  81132. /**
  81133. * @hidden
  81134. * Utility class for generating glTF animation data from BabylonJS.
  81135. */
  81136. export class _GLTFAnimation {
  81137. /**
  81138. * @ignore
  81139. *
  81140. * Creates glTF channel animation from BabylonJS animation.
  81141. * @param babylonTransformNode - BabylonJS mesh.
  81142. * @param animation - animation.
  81143. * @param animationChannelTargetPath - The target animation channel.
  81144. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81145. * @param useQuaternion - Specifies if quaternions are used.
  81146. * @returns nullable IAnimationData
  81147. */
  81148. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81149. private static _DeduceAnimationInfo;
  81150. /**
  81151. * @ignore
  81152. * Create node animations from the transform node animations
  81153. * @param babylonNode
  81154. * @param runtimeGLTFAnimation
  81155. * @param idleGLTFAnimations
  81156. * @param nodeMap
  81157. * @param nodes
  81158. * @param binaryWriter
  81159. * @param bufferViews
  81160. * @param accessors
  81161. * @param convertToRightHandedSystem
  81162. * @param animationSampleRate
  81163. */
  81164. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81165. [key: number]: number;
  81166. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81167. /**
  81168. * @ignore
  81169. * Create node animations from the animation groups
  81170. * @param babylonScene
  81171. * @param glTFAnimations
  81172. * @param nodeMap
  81173. * @param nodes
  81174. * @param binaryWriter
  81175. * @param bufferViews
  81176. * @param accessors
  81177. * @param convertToRightHandedSystemMap
  81178. * @param animationSampleRate
  81179. */
  81180. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81181. [key: number]: number;
  81182. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81183. [nodeId: number]: boolean;
  81184. }, animationSampleRate: number): void;
  81185. private static AddAnimation;
  81186. /**
  81187. * Create a baked animation
  81188. * @param babylonTransformNode BabylonJS mesh
  81189. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81190. * @param animationChannelTargetPath animation target channel
  81191. * @param minFrame minimum animation frame
  81192. * @param maxFrame maximum animation frame
  81193. * @param fps frames per second of the animation
  81194. * @param inputs input key frames of the animation
  81195. * @param outputs output key frame data of the animation
  81196. * @param convertToRightHandedSystem converts the values to right-handed
  81197. * @param useQuaternion specifies if quaternions should be used
  81198. */
  81199. private static _CreateBakedAnimation;
  81200. private static _ConvertFactorToVector3OrQuaternion;
  81201. private static _SetInterpolatedValue;
  81202. /**
  81203. * Creates linear animation from the animation key frames
  81204. * @param babylonTransformNode BabylonJS mesh
  81205. * @param animation BabylonJS animation
  81206. * @param animationChannelTargetPath The target animation channel
  81207. * @param frameDelta The difference between the last and first frame of the animation
  81208. * @param inputs Array to store the key frame times
  81209. * @param outputs Array to store the key frame data
  81210. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81211. * @param useQuaternion Specifies if quaternions are used in the animation
  81212. */
  81213. private static _CreateLinearOrStepAnimation;
  81214. /**
  81215. * Creates cubic spline animation from the animation key frames
  81216. * @param babylonTransformNode BabylonJS mesh
  81217. * @param animation BabylonJS animation
  81218. * @param animationChannelTargetPath The target animation channel
  81219. * @param frameDelta The difference between the last and first frame of the animation
  81220. * @param inputs Array to store the key frame times
  81221. * @param outputs Array to store the key frame data
  81222. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81223. * @param useQuaternion Specifies if quaternions are used in the animation
  81224. */
  81225. private static _CreateCubicSplineAnimation;
  81226. private static _GetBasePositionRotationOrScale;
  81227. /**
  81228. * Adds a key frame value
  81229. * @param keyFrame
  81230. * @param animation
  81231. * @param outputs
  81232. * @param animationChannelTargetPath
  81233. * @param basePositionRotationOrScale
  81234. * @param convertToRightHandedSystem
  81235. * @param useQuaternion
  81236. */
  81237. private static _AddKeyframeValue;
  81238. /**
  81239. * Determine the interpolation based on the key frames
  81240. * @param keyFrames
  81241. * @param animationChannelTargetPath
  81242. * @param useQuaternion
  81243. */
  81244. private static _DeduceInterpolation;
  81245. /**
  81246. * Adds an input tangent or output tangent to the output data
  81247. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81248. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81249. * @param outputs The animation data by keyframe
  81250. * @param animationChannelTargetPath The target animation channel
  81251. * @param interpolation The interpolation type
  81252. * @param keyFrame The key frame with the animation data
  81253. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81254. * @param useQuaternion Specifies if quaternions are used
  81255. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81256. */
  81257. private static AddSplineTangent;
  81258. /**
  81259. * Get the minimum and maximum key frames' frame values
  81260. * @param keyFrames animation key frames
  81261. * @returns the minimum and maximum key frame value
  81262. */
  81263. private static calculateMinMaxKeyFrames;
  81264. }
  81265. }
  81266. declare module BABYLON.GLTF2.Exporter {
  81267. /** @hidden */
  81268. export var textureTransformPixelShader: {
  81269. name: string;
  81270. shader: string;
  81271. };
  81272. }
  81273. declare module BABYLON.GLTF2.Exporter.Extensions {
  81274. /**
  81275. * @hidden
  81276. */
  81277. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81278. private _recordedTextures;
  81279. /** Name of this extension */
  81280. readonly name: string;
  81281. /** Defines whether this extension is enabled */
  81282. enabled: boolean;
  81283. /** Defines whether this extension is required */
  81284. required: boolean;
  81285. /** Reference to the glTF exporter */
  81286. private _wasUsed;
  81287. constructor(exporter: _Exporter);
  81288. dispose(): void;
  81289. /** @hidden */
  81290. get wasUsed(): boolean;
  81291. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81292. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81293. /**
  81294. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81295. * @param babylonTexture
  81296. * @param offset
  81297. * @param rotation
  81298. * @param scale
  81299. * @param scene
  81300. */
  81301. private _textureTransformTextureAsync;
  81302. }
  81303. }
  81304. declare module BABYLON.GLTF2.Exporter.Extensions {
  81305. /**
  81306. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81307. */
  81308. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81309. /** The name of this extension. */
  81310. readonly name: string;
  81311. /** Defines whether this extension is enabled. */
  81312. enabled: boolean;
  81313. /** Defines whether this extension is required */
  81314. required: boolean;
  81315. /** Reference to the glTF exporter */
  81316. private _exporter;
  81317. private _lights;
  81318. /** @hidden */
  81319. constructor(exporter: _Exporter);
  81320. /** @hidden */
  81321. dispose(): void;
  81322. /** @hidden */
  81323. get wasUsed(): boolean;
  81324. /** @hidden */
  81325. onExporting(): void;
  81326. /**
  81327. * Define this method to modify the default behavior when exporting a node
  81328. * @param context The context when exporting the node
  81329. * @param node glTF node
  81330. * @param babylonNode BabylonJS node
  81331. * @param nodeMap Node mapping of unique id to glTF node index
  81332. * @returns nullable INode promise
  81333. */
  81334. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81335. [key: number]: number;
  81336. }): Promise<Nullable<INode>>;
  81337. }
  81338. }
  81339. declare module BABYLON.GLTF2.Exporter.Extensions {
  81340. /**
  81341. * @hidden
  81342. */
  81343. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81344. /** Name of this extension */
  81345. readonly name: string;
  81346. /** Defines whether this extension is enabled */
  81347. enabled: boolean;
  81348. /** Defines whether this extension is required */
  81349. required: boolean;
  81350. /** Reference to the glTF exporter */
  81351. private _textureInfos;
  81352. private _exportedTextures;
  81353. private _wasUsed;
  81354. constructor(exporter: _Exporter);
  81355. dispose(): void;
  81356. /** @hidden */
  81357. get wasUsed(): boolean;
  81358. private _getTextureIndex;
  81359. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81360. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81361. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81362. }
  81363. }
  81364. declare module BABYLON {
  81365. /**
  81366. * Class for generating STL data from a Babylon scene.
  81367. */
  81368. export class STLExport {
  81369. /**
  81370. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81371. * @param meshes list defines the mesh to serialize
  81372. * @param download triggers the automatic download of the file.
  81373. * @param fileName changes the downloads fileName.
  81374. * @param binary changes the STL to a binary type.
  81375. * @param isLittleEndian toggle for binary type exporter.
  81376. * @returns the STL as UTF8 string
  81377. */
  81378. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81379. }
  81380. }
  81381. declare module "babylonjs-gltf2interface" {
  81382. export = BABYLON.GLTF2;
  81383. }
  81384. /**
  81385. * Module for glTF 2.0 Interface
  81386. */
  81387. declare module BABYLON.GLTF2 {
  81388. /**
  81389. * The datatype of the components in the attribute
  81390. */
  81391. const enum AccessorComponentType {
  81392. /**
  81393. * Byte
  81394. */
  81395. BYTE = 5120,
  81396. /**
  81397. * Unsigned Byte
  81398. */
  81399. UNSIGNED_BYTE = 5121,
  81400. /**
  81401. * Short
  81402. */
  81403. SHORT = 5122,
  81404. /**
  81405. * Unsigned Short
  81406. */
  81407. UNSIGNED_SHORT = 5123,
  81408. /**
  81409. * Unsigned Int
  81410. */
  81411. UNSIGNED_INT = 5125,
  81412. /**
  81413. * Float
  81414. */
  81415. FLOAT = 5126,
  81416. }
  81417. /**
  81418. * Specifies if the attirbute is a scalar, vector, or matrix
  81419. */
  81420. const enum AccessorType {
  81421. /**
  81422. * Scalar
  81423. */
  81424. SCALAR = "SCALAR",
  81425. /**
  81426. * Vector2
  81427. */
  81428. VEC2 = "VEC2",
  81429. /**
  81430. * Vector3
  81431. */
  81432. VEC3 = "VEC3",
  81433. /**
  81434. * Vector4
  81435. */
  81436. VEC4 = "VEC4",
  81437. /**
  81438. * Matrix2x2
  81439. */
  81440. MAT2 = "MAT2",
  81441. /**
  81442. * Matrix3x3
  81443. */
  81444. MAT3 = "MAT3",
  81445. /**
  81446. * Matrix4x4
  81447. */
  81448. MAT4 = "MAT4",
  81449. }
  81450. /**
  81451. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81452. */
  81453. const enum AnimationChannelTargetPath {
  81454. /**
  81455. * Translation
  81456. */
  81457. TRANSLATION = "translation",
  81458. /**
  81459. * Rotation
  81460. */
  81461. ROTATION = "rotation",
  81462. /**
  81463. * Scale
  81464. */
  81465. SCALE = "scale",
  81466. /**
  81467. * Weights
  81468. */
  81469. WEIGHTS = "weights",
  81470. }
  81471. /**
  81472. * Interpolation algorithm
  81473. */
  81474. const enum AnimationSamplerInterpolation {
  81475. /**
  81476. * The animated values are linearly interpolated between keyframes
  81477. */
  81478. LINEAR = "LINEAR",
  81479. /**
  81480. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81481. */
  81482. STEP = "STEP",
  81483. /**
  81484. * The animation's interpolation is computed using a cubic spline with specified tangents
  81485. */
  81486. CUBICSPLINE = "CUBICSPLINE",
  81487. }
  81488. /**
  81489. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81490. */
  81491. const enum CameraType {
  81492. /**
  81493. * A perspective camera containing properties to create a perspective projection matrix
  81494. */
  81495. PERSPECTIVE = "perspective",
  81496. /**
  81497. * An orthographic camera containing properties to create an orthographic projection matrix
  81498. */
  81499. ORTHOGRAPHIC = "orthographic",
  81500. }
  81501. /**
  81502. * The mime-type of the image
  81503. */
  81504. const enum ImageMimeType {
  81505. /**
  81506. * JPEG Mime-type
  81507. */
  81508. JPEG = "image/jpeg",
  81509. /**
  81510. * PNG Mime-type
  81511. */
  81512. PNG = "image/png",
  81513. }
  81514. /**
  81515. * The alpha rendering mode of the material
  81516. */
  81517. const enum MaterialAlphaMode {
  81518. /**
  81519. * The alpha value is ignored and the rendered output is fully opaque
  81520. */
  81521. OPAQUE = "OPAQUE",
  81522. /**
  81523. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81524. */
  81525. MASK = "MASK",
  81526. /**
  81527. * 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)
  81528. */
  81529. BLEND = "BLEND",
  81530. }
  81531. /**
  81532. * The type of the primitives to render
  81533. */
  81534. const enum MeshPrimitiveMode {
  81535. /**
  81536. * Points
  81537. */
  81538. POINTS = 0,
  81539. /**
  81540. * Lines
  81541. */
  81542. LINES = 1,
  81543. /**
  81544. * Line Loop
  81545. */
  81546. LINE_LOOP = 2,
  81547. /**
  81548. * Line Strip
  81549. */
  81550. LINE_STRIP = 3,
  81551. /**
  81552. * Triangles
  81553. */
  81554. TRIANGLES = 4,
  81555. /**
  81556. * Triangle Strip
  81557. */
  81558. TRIANGLE_STRIP = 5,
  81559. /**
  81560. * Triangle Fan
  81561. */
  81562. TRIANGLE_FAN = 6,
  81563. }
  81564. /**
  81565. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81566. */
  81567. const enum TextureMagFilter {
  81568. /**
  81569. * Nearest
  81570. */
  81571. NEAREST = 9728,
  81572. /**
  81573. * Linear
  81574. */
  81575. LINEAR = 9729,
  81576. }
  81577. /**
  81578. * Minification filter. All valid values correspond to WebGL enums
  81579. */
  81580. const enum TextureMinFilter {
  81581. /**
  81582. * Nearest
  81583. */
  81584. NEAREST = 9728,
  81585. /**
  81586. * Linear
  81587. */
  81588. LINEAR = 9729,
  81589. /**
  81590. * Nearest Mip-Map Nearest
  81591. */
  81592. NEAREST_MIPMAP_NEAREST = 9984,
  81593. /**
  81594. * Linear Mipmap Nearest
  81595. */
  81596. LINEAR_MIPMAP_NEAREST = 9985,
  81597. /**
  81598. * Nearest Mipmap Linear
  81599. */
  81600. NEAREST_MIPMAP_LINEAR = 9986,
  81601. /**
  81602. * Linear Mipmap Linear
  81603. */
  81604. LINEAR_MIPMAP_LINEAR = 9987,
  81605. }
  81606. /**
  81607. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81608. */
  81609. const enum TextureWrapMode {
  81610. /**
  81611. * Clamp to Edge
  81612. */
  81613. CLAMP_TO_EDGE = 33071,
  81614. /**
  81615. * Mirrored Repeat
  81616. */
  81617. MIRRORED_REPEAT = 33648,
  81618. /**
  81619. * Repeat
  81620. */
  81621. REPEAT = 10497,
  81622. }
  81623. /**
  81624. * glTF Property
  81625. */
  81626. interface IProperty {
  81627. /**
  81628. * Dictionary object with extension-specific objects
  81629. */
  81630. extensions?: {
  81631. [key: string]: any;
  81632. };
  81633. /**
  81634. * Application-Specific data
  81635. */
  81636. extras?: any;
  81637. }
  81638. /**
  81639. * glTF Child of Root Property
  81640. */
  81641. interface IChildRootProperty extends IProperty {
  81642. /**
  81643. * The user-defined name of this object
  81644. */
  81645. name?: string;
  81646. }
  81647. /**
  81648. * Indices of those attributes that deviate from their initialization value
  81649. */
  81650. interface IAccessorSparseIndices extends IProperty {
  81651. /**
  81652. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81653. */
  81654. bufferView: number;
  81655. /**
  81656. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81657. */
  81658. byteOffset?: number;
  81659. /**
  81660. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81661. */
  81662. componentType: AccessorComponentType;
  81663. }
  81664. /**
  81665. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81666. */
  81667. interface IAccessorSparseValues extends IProperty {
  81668. /**
  81669. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81670. */
  81671. bufferView: number;
  81672. /**
  81673. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81674. */
  81675. byteOffset?: number;
  81676. }
  81677. /**
  81678. * Sparse storage of attributes that deviate from their initialization value
  81679. */
  81680. interface IAccessorSparse extends IProperty {
  81681. /**
  81682. * The number of attributes encoded in this sparse accessor
  81683. */
  81684. count: number;
  81685. /**
  81686. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81687. */
  81688. indices: IAccessorSparseIndices;
  81689. /**
  81690. * 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
  81691. */
  81692. values: IAccessorSparseValues;
  81693. }
  81694. /**
  81695. * 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
  81696. */
  81697. interface IAccessor extends IChildRootProperty {
  81698. /**
  81699. * The index of the bufferview
  81700. */
  81701. bufferView?: number;
  81702. /**
  81703. * The offset relative to the start of the bufferView in bytes
  81704. */
  81705. byteOffset?: number;
  81706. /**
  81707. * The datatype of components in the attribute
  81708. */
  81709. componentType: AccessorComponentType;
  81710. /**
  81711. * Specifies whether integer data values should be normalized
  81712. */
  81713. normalized?: boolean;
  81714. /**
  81715. * The number of attributes referenced by this accessor
  81716. */
  81717. count: number;
  81718. /**
  81719. * Specifies if the attribute is a scalar, vector, or matrix
  81720. */
  81721. type: AccessorType;
  81722. /**
  81723. * Maximum value of each component in this attribute
  81724. */
  81725. max?: number[];
  81726. /**
  81727. * Minimum value of each component in this attribute
  81728. */
  81729. min?: number[];
  81730. /**
  81731. * Sparse storage of attributes that deviate from their initialization value
  81732. */
  81733. sparse?: IAccessorSparse;
  81734. }
  81735. /**
  81736. * Targets an animation's sampler at a node's property
  81737. */
  81738. interface IAnimationChannel extends IProperty {
  81739. /**
  81740. * The index of a sampler in this animation used to compute the value for the target
  81741. */
  81742. sampler: number;
  81743. /**
  81744. * The index of the node and TRS property to target
  81745. */
  81746. target: IAnimationChannelTarget;
  81747. }
  81748. /**
  81749. * The index of the node and TRS property that an animation channel targets
  81750. */
  81751. interface IAnimationChannelTarget extends IProperty {
  81752. /**
  81753. * The index of the node to target
  81754. */
  81755. node: number;
  81756. /**
  81757. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81758. */
  81759. path: AnimationChannelTargetPath;
  81760. }
  81761. /**
  81762. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81763. */
  81764. interface IAnimationSampler extends IProperty {
  81765. /**
  81766. * The index of an accessor containing keyframe input values, e.g., time
  81767. */
  81768. input: number;
  81769. /**
  81770. * Interpolation algorithm
  81771. */
  81772. interpolation?: AnimationSamplerInterpolation;
  81773. /**
  81774. * The index of an accessor, containing keyframe output values
  81775. */
  81776. output: number;
  81777. }
  81778. /**
  81779. * A keyframe animation
  81780. */
  81781. interface IAnimation extends IChildRootProperty {
  81782. /**
  81783. * An array of channels, each of which targets an animation's sampler at a node's property
  81784. */
  81785. channels: IAnimationChannel[];
  81786. /**
  81787. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81788. */
  81789. samplers: IAnimationSampler[];
  81790. }
  81791. /**
  81792. * Metadata about the glTF asset
  81793. */
  81794. interface IAsset extends IChildRootProperty {
  81795. /**
  81796. * A copyright message suitable for display to credit the content creator
  81797. */
  81798. copyright?: string;
  81799. /**
  81800. * Tool that generated this glTF model. Useful for debugging
  81801. */
  81802. generator?: string;
  81803. /**
  81804. * The glTF version that this asset targets
  81805. */
  81806. version: string;
  81807. /**
  81808. * The minimum glTF version that this asset targets
  81809. */
  81810. minVersion?: string;
  81811. }
  81812. /**
  81813. * A buffer points to binary geometry, animation, or skins
  81814. */
  81815. interface IBuffer extends IChildRootProperty {
  81816. /**
  81817. * 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
  81818. */
  81819. uri?: string;
  81820. /**
  81821. * The length of the buffer in bytes
  81822. */
  81823. byteLength: number;
  81824. }
  81825. /**
  81826. * A view into a buffer generally representing a subset of the buffer
  81827. */
  81828. interface IBufferView extends IChildRootProperty {
  81829. /**
  81830. * The index of the buffer
  81831. */
  81832. buffer: number;
  81833. /**
  81834. * The offset into the buffer in bytes
  81835. */
  81836. byteOffset?: number;
  81837. /**
  81838. * The lenth of the bufferView in bytes
  81839. */
  81840. byteLength: number;
  81841. /**
  81842. * The stride, in bytes
  81843. */
  81844. byteStride?: number;
  81845. }
  81846. /**
  81847. * An orthographic camera containing properties to create an orthographic projection matrix
  81848. */
  81849. interface ICameraOrthographic extends IProperty {
  81850. /**
  81851. * The floating-point horizontal magnification of the view. Must not be zero
  81852. */
  81853. xmag: number;
  81854. /**
  81855. * The floating-point vertical magnification of the view. Must not be zero
  81856. */
  81857. ymag: number;
  81858. /**
  81859. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81860. */
  81861. zfar: number;
  81862. /**
  81863. * The floating-point distance to the near clipping plane
  81864. */
  81865. znear: number;
  81866. }
  81867. /**
  81868. * A perspective camera containing properties to create a perspective projection matrix
  81869. */
  81870. interface ICameraPerspective extends IProperty {
  81871. /**
  81872. * The floating-point aspect ratio of the field of view
  81873. */
  81874. aspectRatio?: number;
  81875. /**
  81876. * The floating-point vertical field of view in radians
  81877. */
  81878. yfov: number;
  81879. /**
  81880. * The floating-point distance to the far clipping plane
  81881. */
  81882. zfar?: number;
  81883. /**
  81884. * The floating-point distance to the near clipping plane
  81885. */
  81886. znear: number;
  81887. }
  81888. /**
  81889. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81890. */
  81891. interface ICamera extends IChildRootProperty {
  81892. /**
  81893. * An orthographic camera containing properties to create an orthographic projection matrix
  81894. */
  81895. orthographic?: ICameraOrthographic;
  81896. /**
  81897. * A perspective camera containing properties to create a perspective projection matrix
  81898. */
  81899. perspective?: ICameraPerspective;
  81900. /**
  81901. * Specifies if the camera uses a perspective or orthographic projection
  81902. */
  81903. type: CameraType;
  81904. }
  81905. /**
  81906. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81907. */
  81908. interface IImage extends IChildRootProperty {
  81909. /**
  81910. * 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
  81911. */
  81912. uri?: string;
  81913. /**
  81914. * The image's MIME type
  81915. */
  81916. mimeType?: ImageMimeType;
  81917. /**
  81918. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81919. */
  81920. bufferView?: number;
  81921. }
  81922. /**
  81923. * Material Normal Texture Info
  81924. */
  81925. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81926. /**
  81927. * The scalar multiplier applied to each normal vector of the normal texture
  81928. */
  81929. scale?: number;
  81930. }
  81931. /**
  81932. * Material Occlusion Texture Info
  81933. */
  81934. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81935. /**
  81936. * A scalar multiplier controlling the amount of occlusion applied
  81937. */
  81938. strength?: number;
  81939. }
  81940. /**
  81941. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81942. */
  81943. interface IMaterialPbrMetallicRoughness {
  81944. /**
  81945. * The material's base color factor
  81946. */
  81947. baseColorFactor?: number[];
  81948. /**
  81949. * The base color texture
  81950. */
  81951. baseColorTexture?: ITextureInfo;
  81952. /**
  81953. * The metalness of the material
  81954. */
  81955. metallicFactor?: number;
  81956. /**
  81957. * The roughness of the material
  81958. */
  81959. roughnessFactor?: number;
  81960. /**
  81961. * The metallic-roughness texture
  81962. */
  81963. metallicRoughnessTexture?: ITextureInfo;
  81964. }
  81965. /**
  81966. * The material appearance of a primitive
  81967. */
  81968. interface IMaterial extends IChildRootProperty {
  81969. /**
  81970. * 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
  81971. */
  81972. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81973. /**
  81974. * The normal map texture
  81975. */
  81976. normalTexture?: IMaterialNormalTextureInfo;
  81977. /**
  81978. * The occlusion map texture
  81979. */
  81980. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81981. /**
  81982. * The emissive map texture
  81983. */
  81984. emissiveTexture?: ITextureInfo;
  81985. /**
  81986. * 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
  81987. */
  81988. emissiveFactor?: number[];
  81989. /**
  81990. * The alpha rendering mode of the material
  81991. */
  81992. alphaMode?: MaterialAlphaMode;
  81993. /**
  81994. * The alpha cutoff value of the material
  81995. */
  81996. alphaCutoff?: number;
  81997. /**
  81998. * Specifies whether the material is double sided
  81999. */
  82000. doubleSided?: boolean;
  82001. }
  82002. /**
  82003. * Geometry to be rendered with the given material
  82004. */
  82005. interface IMeshPrimitive extends IProperty {
  82006. /**
  82007. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82008. */
  82009. attributes: {
  82010. [name: string]: number;
  82011. };
  82012. /**
  82013. * The index of the accessor that contains the indices
  82014. */
  82015. indices?: number;
  82016. /**
  82017. * The index of the material to apply to this primitive when rendering
  82018. */
  82019. material?: number;
  82020. /**
  82021. * The type of primitives to render. All valid values correspond to WebGL enums
  82022. */
  82023. mode?: MeshPrimitiveMode;
  82024. /**
  82025. * 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
  82026. */
  82027. targets?: {
  82028. [name: string]: number;
  82029. }[];
  82030. }
  82031. /**
  82032. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82033. */
  82034. interface IMesh extends IChildRootProperty {
  82035. /**
  82036. * An array of primitives, each defining geometry to be rendered with a material
  82037. */
  82038. primitives: IMeshPrimitive[];
  82039. /**
  82040. * Array of weights to be applied to the Morph Targets
  82041. */
  82042. weights?: number[];
  82043. }
  82044. /**
  82045. * A node in the node hierarchy
  82046. */
  82047. interface INode extends IChildRootProperty {
  82048. /**
  82049. * The index of the camera referenced by this node
  82050. */
  82051. camera?: number;
  82052. /**
  82053. * The indices of this node's children
  82054. */
  82055. children?: number[];
  82056. /**
  82057. * The index of the skin referenced by this node
  82058. */
  82059. skin?: number;
  82060. /**
  82061. * A floating-point 4x4 transformation matrix stored in column-major order
  82062. */
  82063. matrix?: number[];
  82064. /**
  82065. * The index of the mesh in this node
  82066. */
  82067. mesh?: number;
  82068. /**
  82069. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82070. */
  82071. rotation?: number[];
  82072. /**
  82073. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82074. */
  82075. scale?: number[];
  82076. /**
  82077. * The node's translation along the x, y, and z axes
  82078. */
  82079. translation?: number[];
  82080. /**
  82081. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82082. */
  82083. weights?: number[];
  82084. }
  82085. /**
  82086. * Texture sampler properties for filtering and wrapping modes
  82087. */
  82088. interface ISampler extends IChildRootProperty {
  82089. /**
  82090. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82091. */
  82092. magFilter?: TextureMagFilter;
  82093. /**
  82094. * Minification filter. All valid values correspond to WebGL enums
  82095. */
  82096. minFilter?: TextureMinFilter;
  82097. /**
  82098. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82099. */
  82100. wrapS?: TextureWrapMode;
  82101. /**
  82102. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82103. */
  82104. wrapT?: TextureWrapMode;
  82105. }
  82106. /**
  82107. * The root nodes of a scene
  82108. */
  82109. interface IScene extends IChildRootProperty {
  82110. /**
  82111. * The indices of each root node
  82112. */
  82113. nodes: number[];
  82114. }
  82115. /**
  82116. * Joints and matrices defining a skin
  82117. */
  82118. interface ISkin extends IChildRootProperty {
  82119. /**
  82120. * 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
  82121. */
  82122. inverseBindMatrices?: number;
  82123. /**
  82124. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82125. */
  82126. skeleton?: number;
  82127. /**
  82128. * 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)
  82129. */
  82130. joints: number[];
  82131. }
  82132. /**
  82133. * A texture and its sampler
  82134. */
  82135. interface ITexture extends IChildRootProperty {
  82136. /**
  82137. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82138. */
  82139. sampler?: number;
  82140. /**
  82141. * The index of the image used by this texture
  82142. */
  82143. source: number;
  82144. }
  82145. /**
  82146. * Reference to a texture
  82147. */
  82148. interface ITextureInfo extends IProperty {
  82149. /**
  82150. * The index of the texture
  82151. */
  82152. index: number;
  82153. /**
  82154. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82155. */
  82156. texCoord?: number;
  82157. }
  82158. /**
  82159. * The root object for a glTF asset
  82160. */
  82161. interface IGLTF extends IProperty {
  82162. /**
  82163. * An array of accessors. An accessor is a typed view into a bufferView
  82164. */
  82165. accessors?: IAccessor[];
  82166. /**
  82167. * An array of keyframe animations
  82168. */
  82169. animations?: IAnimation[];
  82170. /**
  82171. * Metadata about the glTF asset
  82172. */
  82173. asset: IAsset;
  82174. /**
  82175. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82176. */
  82177. buffers?: IBuffer[];
  82178. /**
  82179. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82180. */
  82181. bufferViews?: IBufferView[];
  82182. /**
  82183. * An array of cameras
  82184. */
  82185. cameras?: ICamera[];
  82186. /**
  82187. * Names of glTF extensions used somewhere in this asset
  82188. */
  82189. extensionsUsed?: string[];
  82190. /**
  82191. * Names of glTF extensions required to properly load this asset
  82192. */
  82193. extensionsRequired?: string[];
  82194. /**
  82195. * An array of images. An image defines data used to create a texture
  82196. */
  82197. images?: IImage[];
  82198. /**
  82199. * An array of materials. A material defines the appearance of a primitive
  82200. */
  82201. materials?: IMaterial[];
  82202. /**
  82203. * An array of meshes. A mesh is a set of primitives to be rendered
  82204. */
  82205. meshes?: IMesh[];
  82206. /**
  82207. * An array of nodes
  82208. */
  82209. nodes?: INode[];
  82210. /**
  82211. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82212. */
  82213. samplers?: ISampler[];
  82214. /**
  82215. * The index of the default scene
  82216. */
  82217. scene?: number;
  82218. /**
  82219. * An array of scenes
  82220. */
  82221. scenes?: IScene[];
  82222. /**
  82223. * An array of skins. A skin is defined by joints and matrices
  82224. */
  82225. skins?: ISkin[];
  82226. /**
  82227. * An array of textures
  82228. */
  82229. textures?: ITexture[];
  82230. }
  82231. /**
  82232. * The glTF validation results
  82233. * @ignore
  82234. */
  82235. interface IGLTFValidationResults {
  82236. info: {
  82237. generator: string;
  82238. hasAnimations: boolean;
  82239. hasDefaultScene: boolean;
  82240. hasMaterials: boolean;
  82241. hasMorphTargets: boolean;
  82242. hasSkins: boolean;
  82243. hasTextures: boolean;
  82244. maxAttributesUsed: number;
  82245. primitivesCount: number
  82246. };
  82247. issues: {
  82248. messages: Array<string>;
  82249. numErrors: number;
  82250. numHints: number;
  82251. numInfos: number;
  82252. numWarnings: number;
  82253. truncated: boolean
  82254. };
  82255. mimeType: string;
  82256. uri: string;
  82257. validatedAt: string;
  82258. validatorVersion: string;
  82259. }
  82260. /**
  82261. * The glTF validation options
  82262. */
  82263. interface IGLTFValidationOptions {
  82264. /** Uri to use */
  82265. uri?: string;
  82266. /** Function used to load external resources */
  82267. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82268. /** Boolean indicating that we need to validate accessor data */
  82269. validateAccessorData?: boolean;
  82270. /** max number of issues allowed */
  82271. maxIssues?: number;
  82272. /** Ignored issues */
  82273. ignoredIssues?: Array<string>;
  82274. /** Value to override severy settings */
  82275. severityOverrides?: Object;
  82276. }
  82277. /**
  82278. * The glTF validator object
  82279. * @ignore
  82280. */
  82281. interface IGLTFValidator {
  82282. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82283. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82284. }
  82285. }
  82286. declare module BABYLON {
  82287. /** @hidden */
  82288. export var cellPixelShader: {
  82289. name: string;
  82290. shader: string;
  82291. };
  82292. }
  82293. declare module BABYLON {
  82294. /** @hidden */
  82295. export var cellVertexShader: {
  82296. name: string;
  82297. shader: string;
  82298. };
  82299. }
  82300. declare module BABYLON {
  82301. export class CellMaterial extends BABYLON.PushMaterial {
  82302. private _diffuseTexture;
  82303. diffuseTexture: BABYLON.BaseTexture;
  82304. diffuseColor: BABYLON.Color3;
  82305. _computeHighLevel: boolean;
  82306. computeHighLevel: boolean;
  82307. private _disableLighting;
  82308. disableLighting: boolean;
  82309. private _maxSimultaneousLights;
  82310. maxSimultaneousLights: number;
  82311. constructor(name: string, scene: BABYLON.Scene);
  82312. needAlphaBlending(): boolean;
  82313. needAlphaTesting(): boolean;
  82314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82315. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82317. getAnimatables(): BABYLON.IAnimatable[];
  82318. getActiveTextures(): BABYLON.BaseTexture[];
  82319. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82320. dispose(forceDisposeEffect?: boolean): void;
  82321. getClassName(): string;
  82322. clone(name: string): CellMaterial;
  82323. serialize(): any;
  82324. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82325. }
  82326. }
  82327. declare module BABYLON {
  82328. export class CustomShaderStructure {
  82329. FragmentStore: string;
  82330. VertexStore: string;
  82331. constructor();
  82332. }
  82333. export class ShaderSpecialParts {
  82334. constructor();
  82335. Fragment_Begin: string;
  82336. Fragment_Definitions: string;
  82337. Fragment_MainBegin: string;
  82338. Fragment_Custom_Diffuse: string;
  82339. Fragment_Before_Lights: string;
  82340. Fragment_Before_Fog: string;
  82341. Fragment_Custom_Alpha: string;
  82342. Fragment_Before_FragColor: string;
  82343. Vertex_Begin: string;
  82344. Vertex_Definitions: string;
  82345. Vertex_MainBegin: string;
  82346. Vertex_Before_PositionUpdated: string;
  82347. Vertex_Before_NormalUpdated: string;
  82348. Vertex_After_WorldPosComputed: string;
  82349. Vertex_MainEnd: string;
  82350. }
  82351. export class CustomMaterial extends BABYLON.StandardMaterial {
  82352. static ShaderIndexer: number;
  82353. CustomParts: ShaderSpecialParts;
  82354. _isCreatedShader: boolean;
  82355. _createdShaderName: string;
  82356. _customUniform: string[];
  82357. _newUniforms: string[];
  82358. _newUniformInstances: {
  82359. [name: string]: any;
  82360. };
  82361. _newSamplerInstances: {
  82362. [name: string]: BABYLON.Texture;
  82363. };
  82364. _customAttributes: string[];
  82365. FragmentShader: string;
  82366. VertexShader: string;
  82367. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82368. ReviewUniform(name: string, arr: string[]): string[];
  82369. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82370. constructor(name: string, scene: BABYLON.Scene);
  82371. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82372. AddAttribute(name: string): CustomMaterial;
  82373. Fragment_Begin(shaderPart: string): CustomMaterial;
  82374. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82375. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82376. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82377. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82378. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82379. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82380. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82381. Vertex_Begin(shaderPart: string): CustomMaterial;
  82382. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82383. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82384. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82385. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82386. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82387. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82388. }
  82389. }
  82390. declare module BABYLON {
  82391. export class ShaderAlebdoParts {
  82392. constructor();
  82393. Fragment_Begin: string;
  82394. Fragment_Definitions: string;
  82395. Fragment_MainBegin: string;
  82396. Fragment_Custom_Albedo: string;
  82397. Fragment_Before_Lights: string;
  82398. Fragment_Custom_MetallicRoughness: string;
  82399. Fragment_Custom_MicroSurface: string;
  82400. Fragment_Before_Fog: string;
  82401. Fragment_Custom_Alpha: string;
  82402. Fragment_Before_FragColor: string;
  82403. Vertex_Begin: string;
  82404. Vertex_Definitions: string;
  82405. Vertex_MainBegin: string;
  82406. Vertex_Before_PositionUpdated: string;
  82407. Vertex_Before_NormalUpdated: string;
  82408. Vertex_After_WorldPosComputed: string;
  82409. Vertex_MainEnd: string;
  82410. }
  82411. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82412. static ShaderIndexer: number;
  82413. CustomParts: ShaderAlebdoParts;
  82414. _isCreatedShader: boolean;
  82415. _createdShaderName: string;
  82416. _customUniform: string[];
  82417. _newUniforms: string[];
  82418. _newUniformInstances: {
  82419. [name: string]: any;
  82420. };
  82421. _newSamplerInstances: {
  82422. [name: string]: BABYLON.Texture;
  82423. };
  82424. _customAttributes: string[];
  82425. FragmentShader: string;
  82426. VertexShader: string;
  82427. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82428. ReviewUniform(name: string, arr: string[]): string[];
  82429. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82430. constructor(name: string, scene: BABYLON.Scene);
  82431. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82432. AddAttribute(name: string): PBRCustomMaterial;
  82433. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82434. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82435. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82436. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82437. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82438. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82439. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82440. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82441. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82442. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82443. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82444. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82445. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82446. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82447. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82448. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82449. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82450. }
  82451. }
  82452. declare module BABYLON {
  82453. /** @hidden */
  82454. export var firePixelShader: {
  82455. name: string;
  82456. shader: string;
  82457. };
  82458. }
  82459. declare module BABYLON {
  82460. /** @hidden */
  82461. export var fireVertexShader: {
  82462. name: string;
  82463. shader: string;
  82464. };
  82465. }
  82466. declare module BABYLON {
  82467. export class FireMaterial extends BABYLON.PushMaterial {
  82468. private _diffuseTexture;
  82469. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82470. private _distortionTexture;
  82471. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82472. private _opacityTexture;
  82473. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82474. diffuseColor: BABYLON.Color3;
  82475. speed: number;
  82476. private _scaledDiffuse;
  82477. private _lastTime;
  82478. constructor(name: string, scene: BABYLON.Scene);
  82479. needAlphaBlending(): boolean;
  82480. needAlphaTesting(): boolean;
  82481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82484. getAnimatables(): BABYLON.IAnimatable[];
  82485. getActiveTextures(): BABYLON.BaseTexture[];
  82486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82487. getClassName(): string;
  82488. dispose(forceDisposeEffect?: boolean): void;
  82489. clone(name: string): FireMaterial;
  82490. serialize(): any;
  82491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82492. }
  82493. }
  82494. declare module BABYLON {
  82495. /** @hidden */
  82496. export var furPixelShader: {
  82497. name: string;
  82498. shader: string;
  82499. };
  82500. }
  82501. declare module BABYLON {
  82502. /** @hidden */
  82503. export var furVertexShader: {
  82504. name: string;
  82505. shader: string;
  82506. };
  82507. }
  82508. declare module BABYLON {
  82509. export class FurMaterial extends BABYLON.PushMaterial {
  82510. private _diffuseTexture;
  82511. diffuseTexture: BABYLON.BaseTexture;
  82512. private _heightTexture;
  82513. heightTexture: BABYLON.BaseTexture;
  82514. diffuseColor: BABYLON.Color3;
  82515. furLength: number;
  82516. furAngle: number;
  82517. furColor: BABYLON.Color3;
  82518. furOffset: number;
  82519. furSpacing: number;
  82520. furGravity: BABYLON.Vector3;
  82521. furSpeed: number;
  82522. furDensity: number;
  82523. furOcclusion: number;
  82524. furTexture: BABYLON.DynamicTexture;
  82525. private _disableLighting;
  82526. disableLighting: boolean;
  82527. private _maxSimultaneousLights;
  82528. maxSimultaneousLights: number;
  82529. highLevelFur: boolean;
  82530. _meshes: BABYLON.AbstractMesh[];
  82531. private _furTime;
  82532. constructor(name: string, scene: BABYLON.Scene);
  82533. get furTime(): number;
  82534. set furTime(furTime: number);
  82535. needAlphaBlending(): boolean;
  82536. needAlphaTesting(): boolean;
  82537. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82538. updateFur(): void;
  82539. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82540. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82541. getAnimatables(): BABYLON.IAnimatable[];
  82542. getActiveTextures(): BABYLON.BaseTexture[];
  82543. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82544. dispose(forceDisposeEffect?: boolean): void;
  82545. clone(name: string): FurMaterial;
  82546. serialize(): any;
  82547. getClassName(): string;
  82548. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82549. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82550. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82551. }
  82552. }
  82553. declare module BABYLON {
  82554. /** @hidden */
  82555. export var gradientPixelShader: {
  82556. name: string;
  82557. shader: string;
  82558. };
  82559. }
  82560. declare module BABYLON {
  82561. /** @hidden */
  82562. export var gradientVertexShader: {
  82563. name: string;
  82564. shader: string;
  82565. };
  82566. }
  82567. declare module BABYLON {
  82568. export class GradientMaterial extends BABYLON.PushMaterial {
  82569. private _maxSimultaneousLights;
  82570. maxSimultaneousLights: number;
  82571. topColor: BABYLON.Color3;
  82572. topColorAlpha: number;
  82573. bottomColor: BABYLON.Color3;
  82574. bottomColorAlpha: number;
  82575. offset: number;
  82576. scale: number;
  82577. smoothness: number;
  82578. private _disableLighting;
  82579. disableLighting: boolean;
  82580. constructor(name: string, scene: BABYLON.Scene);
  82581. needAlphaBlending(): boolean;
  82582. needAlphaTesting(): boolean;
  82583. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82584. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82585. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82586. getAnimatables(): BABYLON.IAnimatable[];
  82587. dispose(forceDisposeEffect?: boolean): void;
  82588. clone(name: string): GradientMaterial;
  82589. serialize(): any;
  82590. getClassName(): string;
  82591. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82592. }
  82593. }
  82594. declare module BABYLON {
  82595. /** @hidden */
  82596. export var gridPixelShader: {
  82597. name: string;
  82598. shader: string;
  82599. };
  82600. }
  82601. declare module BABYLON {
  82602. /** @hidden */
  82603. export var gridVertexShader: {
  82604. name: string;
  82605. shader: string;
  82606. };
  82607. }
  82608. declare module BABYLON {
  82609. /**
  82610. * The grid materials allows you to wrap any shape with a grid.
  82611. * Colors are customizable.
  82612. */
  82613. export class GridMaterial extends BABYLON.PushMaterial {
  82614. /**
  82615. * Main color of the grid (e.g. between lines)
  82616. */
  82617. mainColor: BABYLON.Color3;
  82618. /**
  82619. * Color of the grid lines.
  82620. */
  82621. lineColor: BABYLON.Color3;
  82622. /**
  82623. * The scale of the grid compared to unit.
  82624. */
  82625. gridRatio: number;
  82626. /**
  82627. * Allows setting an offset for the grid lines.
  82628. */
  82629. gridOffset: BABYLON.Vector3;
  82630. /**
  82631. * The frequency of thicker lines.
  82632. */
  82633. majorUnitFrequency: number;
  82634. /**
  82635. * The visibility of minor units in the grid.
  82636. */
  82637. minorUnitVisibility: number;
  82638. /**
  82639. * The grid opacity outside of the lines.
  82640. */
  82641. opacity: number;
  82642. /**
  82643. * Determine RBG output is premultiplied by alpha value.
  82644. */
  82645. preMultiplyAlpha: boolean;
  82646. private _opacityTexture;
  82647. opacityTexture: BABYLON.BaseTexture;
  82648. private _gridControl;
  82649. /**
  82650. * constructor
  82651. * @param name The name given to the material in order to identify it afterwards.
  82652. * @param scene The scene the material is used in.
  82653. */
  82654. constructor(name: string, scene: BABYLON.Scene);
  82655. /**
  82656. * Returns wehter or not the grid requires alpha blending.
  82657. */
  82658. needAlphaBlending(): boolean;
  82659. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82660. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82661. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82662. /**
  82663. * Dispose the material and its associated resources.
  82664. * @param forceDisposeEffect will also dispose the used effect when true
  82665. */
  82666. dispose(forceDisposeEffect?: boolean): void;
  82667. clone(name: string): GridMaterial;
  82668. serialize(): any;
  82669. getClassName(): string;
  82670. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82671. }
  82672. }
  82673. declare module BABYLON {
  82674. /** @hidden */
  82675. export var lavaPixelShader: {
  82676. name: string;
  82677. shader: string;
  82678. };
  82679. }
  82680. declare module BABYLON {
  82681. /** @hidden */
  82682. export var lavaVertexShader: {
  82683. name: string;
  82684. shader: string;
  82685. };
  82686. }
  82687. declare module BABYLON {
  82688. export class LavaMaterial extends BABYLON.PushMaterial {
  82689. private _diffuseTexture;
  82690. diffuseTexture: BABYLON.BaseTexture;
  82691. noiseTexture: BABYLON.BaseTexture;
  82692. fogColor: BABYLON.Color3;
  82693. speed: number;
  82694. movingSpeed: number;
  82695. lowFrequencySpeed: number;
  82696. fogDensity: number;
  82697. private _lastTime;
  82698. diffuseColor: BABYLON.Color3;
  82699. private _disableLighting;
  82700. disableLighting: boolean;
  82701. private _unlit;
  82702. unlit: boolean;
  82703. private _maxSimultaneousLights;
  82704. maxSimultaneousLights: number;
  82705. private _scaledDiffuse;
  82706. constructor(name: string, scene: BABYLON.Scene);
  82707. needAlphaBlending(): boolean;
  82708. needAlphaTesting(): boolean;
  82709. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82710. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82711. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82712. getAnimatables(): BABYLON.IAnimatable[];
  82713. getActiveTextures(): BABYLON.BaseTexture[];
  82714. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82715. dispose(forceDisposeEffect?: boolean): void;
  82716. clone(name: string): LavaMaterial;
  82717. serialize(): any;
  82718. getClassName(): string;
  82719. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82720. }
  82721. }
  82722. declare module BABYLON {
  82723. /** @hidden */
  82724. export var mixPixelShader: {
  82725. name: string;
  82726. shader: string;
  82727. };
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export var mixVertexShader: {
  82732. name: string;
  82733. shader: string;
  82734. };
  82735. }
  82736. declare module BABYLON {
  82737. export class MixMaterial extends BABYLON.PushMaterial {
  82738. /**
  82739. * Mix textures
  82740. */
  82741. private _mixTexture1;
  82742. mixTexture1: BABYLON.BaseTexture;
  82743. private _mixTexture2;
  82744. mixTexture2: BABYLON.BaseTexture;
  82745. /**
  82746. * Diffuse textures
  82747. */
  82748. private _diffuseTexture1;
  82749. diffuseTexture1: BABYLON.Texture;
  82750. private _diffuseTexture2;
  82751. diffuseTexture2: BABYLON.Texture;
  82752. private _diffuseTexture3;
  82753. diffuseTexture3: BABYLON.Texture;
  82754. private _diffuseTexture4;
  82755. diffuseTexture4: BABYLON.Texture;
  82756. private _diffuseTexture5;
  82757. diffuseTexture5: BABYLON.Texture;
  82758. private _diffuseTexture6;
  82759. diffuseTexture6: BABYLON.Texture;
  82760. private _diffuseTexture7;
  82761. diffuseTexture7: BABYLON.Texture;
  82762. private _diffuseTexture8;
  82763. diffuseTexture8: BABYLON.Texture;
  82764. /**
  82765. * Uniforms
  82766. */
  82767. diffuseColor: BABYLON.Color3;
  82768. specularColor: BABYLON.Color3;
  82769. specularPower: number;
  82770. private _disableLighting;
  82771. disableLighting: boolean;
  82772. private _maxSimultaneousLights;
  82773. maxSimultaneousLights: number;
  82774. constructor(name: string, scene: BABYLON.Scene);
  82775. needAlphaBlending(): boolean;
  82776. needAlphaTesting(): boolean;
  82777. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82778. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82779. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82780. getAnimatables(): BABYLON.IAnimatable[];
  82781. getActiveTextures(): BABYLON.BaseTexture[];
  82782. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82783. dispose(forceDisposeEffect?: boolean): void;
  82784. clone(name: string): MixMaterial;
  82785. serialize(): any;
  82786. getClassName(): string;
  82787. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82788. }
  82789. }
  82790. declare module BABYLON {
  82791. /** @hidden */
  82792. export var normalPixelShader: {
  82793. name: string;
  82794. shader: string;
  82795. };
  82796. }
  82797. declare module BABYLON {
  82798. /** @hidden */
  82799. export var normalVertexShader: {
  82800. name: string;
  82801. shader: string;
  82802. };
  82803. }
  82804. declare module BABYLON {
  82805. export class NormalMaterial extends BABYLON.PushMaterial {
  82806. private _diffuseTexture;
  82807. diffuseTexture: BABYLON.BaseTexture;
  82808. diffuseColor: BABYLON.Color3;
  82809. private _disableLighting;
  82810. disableLighting: boolean;
  82811. private _maxSimultaneousLights;
  82812. maxSimultaneousLights: number;
  82813. constructor(name: string, scene: BABYLON.Scene);
  82814. needAlphaBlending(): boolean;
  82815. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82816. needAlphaTesting(): boolean;
  82817. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82818. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82819. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82820. getAnimatables(): BABYLON.IAnimatable[];
  82821. getActiveTextures(): BABYLON.BaseTexture[];
  82822. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82823. dispose(forceDisposeEffect?: boolean): void;
  82824. clone(name: string): NormalMaterial;
  82825. serialize(): any;
  82826. getClassName(): string;
  82827. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82828. }
  82829. }
  82830. declare module BABYLON {
  82831. /** @hidden */
  82832. export var shadowOnlyPixelShader: {
  82833. name: string;
  82834. shader: string;
  82835. };
  82836. }
  82837. declare module BABYLON {
  82838. /** @hidden */
  82839. export var shadowOnlyVertexShader: {
  82840. name: string;
  82841. shader: string;
  82842. };
  82843. }
  82844. declare module BABYLON {
  82845. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82846. private _activeLight;
  82847. private _needAlphaBlending;
  82848. constructor(name: string, scene: BABYLON.Scene);
  82849. shadowColor: BABYLON.Color3;
  82850. needAlphaBlending(): boolean;
  82851. needAlphaTesting(): boolean;
  82852. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82853. get activeLight(): BABYLON.IShadowLight;
  82854. set activeLight(light: BABYLON.IShadowLight);
  82855. private _getFirstShadowLightForMesh;
  82856. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82857. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82858. clone(name: string): ShadowOnlyMaterial;
  82859. serialize(): any;
  82860. getClassName(): string;
  82861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82862. }
  82863. }
  82864. declare module BABYLON {
  82865. /** @hidden */
  82866. export var simplePixelShader: {
  82867. name: string;
  82868. shader: string;
  82869. };
  82870. }
  82871. declare module BABYLON {
  82872. /** @hidden */
  82873. export var simpleVertexShader: {
  82874. name: string;
  82875. shader: string;
  82876. };
  82877. }
  82878. declare module BABYLON {
  82879. export class SimpleMaterial extends BABYLON.PushMaterial {
  82880. private _diffuseTexture;
  82881. diffuseTexture: BABYLON.BaseTexture;
  82882. diffuseColor: BABYLON.Color3;
  82883. private _disableLighting;
  82884. disableLighting: boolean;
  82885. private _maxSimultaneousLights;
  82886. maxSimultaneousLights: number;
  82887. constructor(name: string, scene: BABYLON.Scene);
  82888. needAlphaBlending(): boolean;
  82889. needAlphaTesting(): boolean;
  82890. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82893. getAnimatables(): BABYLON.IAnimatable[];
  82894. getActiveTextures(): BABYLON.BaseTexture[];
  82895. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82896. dispose(forceDisposeEffect?: boolean): void;
  82897. clone(name: string): SimpleMaterial;
  82898. serialize(): any;
  82899. getClassName(): string;
  82900. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82901. }
  82902. }
  82903. declare module BABYLON {
  82904. /** @hidden */
  82905. export var skyPixelShader: {
  82906. name: string;
  82907. shader: string;
  82908. };
  82909. }
  82910. declare module BABYLON {
  82911. /** @hidden */
  82912. export var skyVertexShader: {
  82913. name: string;
  82914. shader: string;
  82915. };
  82916. }
  82917. declare module BABYLON {
  82918. /**
  82919. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82920. * @see https://doc.babylonjs.com/extensions/sky
  82921. */
  82922. export class SkyMaterial extends BABYLON.PushMaterial {
  82923. /**
  82924. * Defines the overall luminance of sky in interval ]0, 1[.
  82925. */
  82926. luminance: number;
  82927. /**
  82928. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82929. */
  82930. turbidity: number;
  82931. /**
  82932. * Defines the sky appearance (light intensity).
  82933. */
  82934. rayleigh: number;
  82935. /**
  82936. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82937. */
  82938. mieCoefficient: number;
  82939. /**
  82940. * Defines the amount of haze particles following the Mie scattering theory.
  82941. */
  82942. mieDirectionalG: number;
  82943. /**
  82944. * Defines the distance of the sun according to the active scene camera.
  82945. */
  82946. distance: number;
  82947. /**
  82948. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82949. * "inclined".
  82950. */
  82951. inclination: number;
  82952. /**
  82953. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82954. * an object direction and a reference direction.
  82955. */
  82956. azimuth: number;
  82957. /**
  82958. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82959. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82960. */
  82961. sunPosition: BABYLON.Vector3;
  82962. /**
  82963. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82964. * .sunPosition property.
  82965. */
  82966. useSunPosition: boolean;
  82967. /**
  82968. * Defines an offset vector used to get a horizon offset.
  82969. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82970. */
  82971. cameraOffset: BABYLON.Vector3;
  82972. private _cameraPosition;
  82973. /**
  82974. * Instantiates a new sky material.
  82975. * This material allows to create dynamic and texture free
  82976. * effects for skyboxes by taking care of the atmosphere state.
  82977. * @see https://doc.babylonjs.com/extensions/sky
  82978. * @param name Define the name of the material in the scene
  82979. * @param scene Define the scene the material belong to
  82980. */
  82981. constructor(name: string, scene: BABYLON.Scene);
  82982. /**
  82983. * Specifies if the material will require alpha blending
  82984. * @returns a boolean specifying if alpha blending is needed
  82985. */
  82986. needAlphaBlending(): boolean;
  82987. /**
  82988. * Specifies if this material should be rendered in alpha test mode
  82989. * @returns false as the sky material doesn't need alpha testing.
  82990. */
  82991. needAlphaTesting(): boolean;
  82992. /**
  82993. * Get the texture used for alpha test purpose.
  82994. * @returns null as the sky material has no texture.
  82995. */
  82996. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82997. /**
  82998. * Get if the submesh is ready to be used and all its information available.
  82999. * Child classes can use it to update shaders
  83000. * @param mesh defines the mesh to check
  83001. * @param subMesh defines which submesh to check
  83002. * @param useInstances specifies that instances should be used
  83003. * @returns a boolean indicating that the submesh is ready or not
  83004. */
  83005. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83006. /**
  83007. * Binds the submesh to this material by preparing the effect and shader to draw
  83008. * @param world defines the world transformation matrix
  83009. * @param mesh defines the mesh containing the submesh
  83010. * @param subMesh defines the submesh to bind the material to
  83011. */
  83012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83013. /**
  83014. * Get the list of animatables in the material.
  83015. * @returns the list of animatables object used in the material
  83016. */
  83017. getAnimatables(): BABYLON.IAnimatable[];
  83018. /**
  83019. * Disposes the material
  83020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83021. */
  83022. dispose(forceDisposeEffect?: boolean): void;
  83023. /**
  83024. * Makes a duplicate of the material, and gives it a new name
  83025. * @param name defines the new name for the duplicated material
  83026. * @returns the cloned material
  83027. */
  83028. clone(name: string): SkyMaterial;
  83029. /**
  83030. * Serializes this material in a JSON representation
  83031. * @returns the serialized material object
  83032. */
  83033. serialize(): any;
  83034. /**
  83035. * Gets the current class name of the material e.g. "SkyMaterial"
  83036. * Mainly use in serialization.
  83037. * @returns the class name
  83038. */
  83039. getClassName(): string;
  83040. /**
  83041. * Creates a sky material from parsed material data
  83042. * @param source defines the JSON representation of the material
  83043. * @param scene defines the hosting scene
  83044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83045. * @returns a new sky material
  83046. */
  83047. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83048. }
  83049. }
  83050. declare module BABYLON {
  83051. /** @hidden */
  83052. export var terrainPixelShader: {
  83053. name: string;
  83054. shader: string;
  83055. };
  83056. }
  83057. declare module BABYLON {
  83058. /** @hidden */
  83059. export var terrainVertexShader: {
  83060. name: string;
  83061. shader: string;
  83062. };
  83063. }
  83064. declare module BABYLON {
  83065. export class TerrainMaterial extends BABYLON.PushMaterial {
  83066. private _mixTexture;
  83067. mixTexture: BABYLON.BaseTexture;
  83068. private _diffuseTexture1;
  83069. diffuseTexture1: BABYLON.Texture;
  83070. private _diffuseTexture2;
  83071. diffuseTexture2: BABYLON.Texture;
  83072. private _diffuseTexture3;
  83073. diffuseTexture3: BABYLON.Texture;
  83074. private _bumpTexture1;
  83075. bumpTexture1: BABYLON.Texture;
  83076. private _bumpTexture2;
  83077. bumpTexture2: BABYLON.Texture;
  83078. private _bumpTexture3;
  83079. bumpTexture3: BABYLON.Texture;
  83080. diffuseColor: BABYLON.Color3;
  83081. specularColor: BABYLON.Color3;
  83082. specularPower: number;
  83083. private _disableLighting;
  83084. disableLighting: boolean;
  83085. private _maxSimultaneousLights;
  83086. maxSimultaneousLights: number;
  83087. constructor(name: string, scene: BABYLON.Scene);
  83088. needAlphaBlending(): boolean;
  83089. needAlphaTesting(): boolean;
  83090. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83093. getAnimatables(): BABYLON.IAnimatable[];
  83094. getActiveTextures(): BABYLON.BaseTexture[];
  83095. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83096. dispose(forceDisposeEffect?: boolean): void;
  83097. clone(name: string): TerrainMaterial;
  83098. serialize(): any;
  83099. getClassName(): string;
  83100. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83101. }
  83102. }
  83103. declare module BABYLON {
  83104. /** @hidden */
  83105. export var triplanarPixelShader: {
  83106. name: string;
  83107. shader: string;
  83108. };
  83109. }
  83110. declare module BABYLON {
  83111. /** @hidden */
  83112. export var triplanarVertexShader: {
  83113. name: string;
  83114. shader: string;
  83115. };
  83116. }
  83117. declare module BABYLON {
  83118. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83119. mixTexture: BABYLON.BaseTexture;
  83120. private _diffuseTextureX;
  83121. diffuseTextureX: BABYLON.BaseTexture;
  83122. private _diffuseTextureY;
  83123. diffuseTextureY: BABYLON.BaseTexture;
  83124. private _diffuseTextureZ;
  83125. diffuseTextureZ: BABYLON.BaseTexture;
  83126. private _normalTextureX;
  83127. normalTextureX: BABYLON.BaseTexture;
  83128. private _normalTextureY;
  83129. normalTextureY: BABYLON.BaseTexture;
  83130. private _normalTextureZ;
  83131. normalTextureZ: BABYLON.BaseTexture;
  83132. tileSize: number;
  83133. diffuseColor: BABYLON.Color3;
  83134. specularColor: BABYLON.Color3;
  83135. specularPower: number;
  83136. private _disableLighting;
  83137. disableLighting: boolean;
  83138. private _maxSimultaneousLights;
  83139. maxSimultaneousLights: number;
  83140. constructor(name: string, scene: BABYLON.Scene);
  83141. needAlphaBlending(): boolean;
  83142. needAlphaTesting(): boolean;
  83143. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83146. getAnimatables(): BABYLON.IAnimatable[];
  83147. getActiveTextures(): BABYLON.BaseTexture[];
  83148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83149. dispose(forceDisposeEffect?: boolean): void;
  83150. clone(name: string): TriPlanarMaterial;
  83151. serialize(): any;
  83152. getClassName(): string;
  83153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83154. }
  83155. }
  83156. declare module BABYLON {
  83157. /** @hidden */
  83158. export var waterPixelShader: {
  83159. name: string;
  83160. shader: string;
  83161. };
  83162. }
  83163. declare module BABYLON {
  83164. /** @hidden */
  83165. export var waterVertexShader: {
  83166. name: string;
  83167. shader: string;
  83168. };
  83169. }
  83170. declare module BABYLON {
  83171. export class WaterMaterial extends BABYLON.PushMaterial {
  83172. renderTargetSize: BABYLON.Vector2;
  83173. private _bumpTexture;
  83174. bumpTexture: BABYLON.BaseTexture;
  83175. diffuseColor: BABYLON.Color3;
  83176. specularColor: BABYLON.Color3;
  83177. specularPower: number;
  83178. private _disableLighting;
  83179. disableLighting: boolean;
  83180. private _maxSimultaneousLights;
  83181. maxSimultaneousLights: number;
  83182. /**
  83183. * @param {number}: Represents the wind force
  83184. */
  83185. windForce: number;
  83186. /**
  83187. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83188. */
  83189. windDirection: BABYLON.Vector2;
  83190. /**
  83191. * @param {number}: Wave height, represents the height of the waves
  83192. */
  83193. waveHeight: number;
  83194. /**
  83195. * @param {number}: Bump height, represents the bump height related to the bump map
  83196. */
  83197. bumpHeight: number;
  83198. /**
  83199. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83200. */
  83201. private _bumpSuperimpose;
  83202. bumpSuperimpose: boolean;
  83203. /**
  83204. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83205. */
  83206. private _fresnelSeparate;
  83207. fresnelSeparate: boolean;
  83208. /**
  83209. * @param {boolean}: bump Waves modify the reflection.
  83210. */
  83211. private _bumpAffectsReflection;
  83212. bumpAffectsReflection: boolean;
  83213. /**
  83214. * @param {number}: The water color blended with the refraction (near)
  83215. */
  83216. waterColor: BABYLON.Color3;
  83217. /**
  83218. * @param {number}: The blend factor related to the water color
  83219. */
  83220. colorBlendFactor: number;
  83221. /**
  83222. * @param {number}: The water color blended with the reflection (far)
  83223. */
  83224. waterColor2: BABYLON.Color3;
  83225. /**
  83226. * @param {number}: The blend factor related to the water color (reflection, far)
  83227. */
  83228. colorBlendFactor2: number;
  83229. /**
  83230. * @param {number}: Represents the maximum length of a wave
  83231. */
  83232. waveLength: number;
  83233. /**
  83234. * @param {number}: Defines the waves speed
  83235. */
  83236. waveSpeed: number;
  83237. /**
  83238. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83239. * will avoid calculating useless pixels in the pixel shader of the water material.
  83240. */
  83241. disableClipPlane: boolean;
  83242. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83243. private _mesh;
  83244. private _refractionRTT;
  83245. private _reflectionRTT;
  83246. private _reflectionTransform;
  83247. private _lastTime;
  83248. private _lastDeltaTime;
  83249. private _useLogarithmicDepth;
  83250. private _waitingRenderList;
  83251. private _imageProcessingConfiguration;
  83252. private _imageProcessingObserver;
  83253. /**
  83254. * Gets a boolean indicating that current material needs to register RTT
  83255. */
  83256. get hasRenderTargetTextures(): boolean;
  83257. /**
  83258. * Constructor
  83259. */
  83260. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83261. get useLogarithmicDepth(): boolean;
  83262. set useLogarithmicDepth(value: boolean);
  83263. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83264. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83265. addToRenderList(node: any): void;
  83266. enableRenderTargets(enable: boolean): void;
  83267. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83268. get renderTargetsEnabled(): boolean;
  83269. needAlphaBlending(): boolean;
  83270. needAlphaTesting(): boolean;
  83271. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83272. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83273. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83274. private _createRenderTargets;
  83275. getAnimatables(): BABYLON.IAnimatable[];
  83276. getActiveTextures(): BABYLON.BaseTexture[];
  83277. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83278. dispose(forceDisposeEffect?: boolean): void;
  83279. clone(name: string): WaterMaterial;
  83280. serialize(): any;
  83281. getClassName(): string;
  83282. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83283. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83284. }
  83285. }
  83286. declare module BABYLON {
  83287. /** @hidden */
  83288. export var asciiartPixelShader: {
  83289. name: string;
  83290. shader: string;
  83291. };
  83292. }
  83293. declare module BABYLON {
  83294. /**
  83295. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83296. *
  83297. * It basically takes care rendering the font front the given font size to a texture.
  83298. * This is used later on in the postprocess.
  83299. */
  83300. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83301. private _font;
  83302. private _text;
  83303. private _charSize;
  83304. /**
  83305. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83306. */
  83307. get charSize(): number;
  83308. /**
  83309. * Create a new instance of the Ascii Art FontTexture class
  83310. * @param name the name of the texture
  83311. * @param font the font to use, use the W3C CSS notation
  83312. * @param text the caracter set to use in the rendering.
  83313. * @param scene the scene that owns the texture
  83314. */
  83315. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83316. /**
  83317. * Gets the max char width of a font.
  83318. * @param font the font to use, use the W3C CSS notation
  83319. * @return the max char width
  83320. */
  83321. private getFontWidth;
  83322. /**
  83323. * Gets the max char height of a font.
  83324. * @param font the font to use, use the W3C CSS notation
  83325. * @return the max char height
  83326. */
  83327. private getFontHeight;
  83328. /**
  83329. * Clones the current AsciiArtTexture.
  83330. * @return the clone of the texture.
  83331. */
  83332. clone(): AsciiArtFontTexture;
  83333. /**
  83334. * Parses a json object representing the texture and returns an instance of it.
  83335. * @param source the source JSON representation
  83336. * @param scene the scene to create the texture for
  83337. * @return the parsed texture
  83338. */
  83339. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83340. }
  83341. /**
  83342. * Option available in the Ascii Art Post Process.
  83343. */
  83344. export interface IAsciiArtPostProcessOptions {
  83345. /**
  83346. * The font to use following the w3c font definition.
  83347. */
  83348. font?: string;
  83349. /**
  83350. * The character set to use in the postprocess.
  83351. */
  83352. characterSet?: string;
  83353. /**
  83354. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83355. * This number is defined between 0 and 1;
  83356. */
  83357. mixToTile?: number;
  83358. /**
  83359. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83360. * This number is defined between 0 and 1;
  83361. */
  83362. mixToNormal?: number;
  83363. }
  83364. /**
  83365. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83366. *
  83367. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83368. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83369. */
  83370. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83371. /**
  83372. * The font texture used to render the char in the post process.
  83373. */
  83374. private _asciiArtFontTexture;
  83375. /**
  83376. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83377. * This number is defined between 0 and 1;
  83378. */
  83379. mixToTile: number;
  83380. /**
  83381. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83382. * This number is defined between 0 and 1;
  83383. */
  83384. mixToNormal: number;
  83385. /**
  83386. * Instantiates a new Ascii Art Post Process.
  83387. * @param name the name to give to the postprocess
  83388. * @camera the camera to apply the post process to.
  83389. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83390. */
  83391. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83392. }
  83393. }
  83394. declare module BABYLON {
  83395. /** @hidden */
  83396. export var digitalrainPixelShader: {
  83397. name: string;
  83398. shader: string;
  83399. };
  83400. }
  83401. declare module BABYLON {
  83402. /**
  83403. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83404. *
  83405. * It basically takes care rendering the font front the given font size to a texture.
  83406. * This is used later on in the postprocess.
  83407. */
  83408. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83409. private _font;
  83410. private _text;
  83411. private _charSize;
  83412. /**
  83413. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83414. */
  83415. get charSize(): number;
  83416. /**
  83417. * Create a new instance of the Digital Rain FontTexture class
  83418. * @param name the name of the texture
  83419. * @param font the font to use, use the W3C CSS notation
  83420. * @param text the caracter set to use in the rendering.
  83421. * @param scene the scene that owns the texture
  83422. */
  83423. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83424. /**
  83425. * Gets the max char width of a font.
  83426. * @param font the font to use, use the W3C CSS notation
  83427. * @return the max char width
  83428. */
  83429. private getFontWidth;
  83430. /**
  83431. * Gets the max char height of a font.
  83432. * @param font the font to use, use the W3C CSS notation
  83433. * @return the max char height
  83434. */
  83435. private getFontHeight;
  83436. /**
  83437. * Clones the current DigitalRainFontTexture.
  83438. * @return the clone of the texture.
  83439. */
  83440. clone(): DigitalRainFontTexture;
  83441. /**
  83442. * Parses a json object representing the texture and returns an instance of it.
  83443. * @param source the source JSON representation
  83444. * @param scene the scene to create the texture for
  83445. * @return the parsed texture
  83446. */
  83447. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83448. }
  83449. /**
  83450. * Option available in the Digital Rain Post Process.
  83451. */
  83452. export interface IDigitalRainPostProcessOptions {
  83453. /**
  83454. * The font to use following the w3c font definition.
  83455. */
  83456. font?: string;
  83457. /**
  83458. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83459. * This number is defined between 0 and 1;
  83460. */
  83461. mixToTile?: number;
  83462. /**
  83463. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83464. * This number is defined between 0 and 1;
  83465. */
  83466. mixToNormal?: number;
  83467. }
  83468. /**
  83469. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83470. *
  83471. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83472. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83473. */
  83474. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83475. /**
  83476. * The font texture used to render the char in the post process.
  83477. */
  83478. private _digitalRainFontTexture;
  83479. /**
  83480. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83481. * This number is defined between 0 and 1;
  83482. */
  83483. mixToTile: number;
  83484. /**
  83485. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83486. * This number is defined between 0 and 1;
  83487. */
  83488. mixToNormal: number;
  83489. /**
  83490. * Instantiates a new Digital Rain Post Process.
  83491. * @param name the name to give to the postprocess
  83492. * @camera the camera to apply the post process to.
  83493. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83494. */
  83495. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83496. }
  83497. }
  83498. declare module BABYLON {
  83499. /** @hidden */
  83500. export var brickProceduralTexturePixelShader: {
  83501. name: string;
  83502. shader: string;
  83503. };
  83504. }
  83505. declare module BABYLON {
  83506. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83507. private _numberOfBricksHeight;
  83508. private _numberOfBricksWidth;
  83509. private _jointColor;
  83510. private _brickColor;
  83511. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83512. updateShaderUniforms(): void;
  83513. get numberOfBricksHeight(): number;
  83514. set numberOfBricksHeight(value: number);
  83515. get numberOfBricksWidth(): number;
  83516. set numberOfBricksWidth(value: number);
  83517. get jointColor(): BABYLON.Color3;
  83518. set jointColor(value: BABYLON.Color3);
  83519. get brickColor(): BABYLON.Color3;
  83520. set brickColor(value: BABYLON.Color3);
  83521. /**
  83522. * Serializes this brick procedural texture
  83523. * @returns a serialized brick procedural texture object
  83524. */
  83525. serialize(): any;
  83526. /**
  83527. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83528. * @param parsedTexture defines parsed texture data
  83529. * @param scene defines the current scene
  83530. * @param rootUrl defines the root URL containing brick procedural texture information
  83531. * @returns a parsed Brick Procedural BABYLON.Texture
  83532. */
  83533. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83534. }
  83535. }
  83536. declare module BABYLON {
  83537. /** @hidden */
  83538. export var cloudProceduralTexturePixelShader: {
  83539. name: string;
  83540. shader: string;
  83541. };
  83542. }
  83543. declare module BABYLON {
  83544. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83545. private _skyColor;
  83546. private _cloudColor;
  83547. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83548. updateShaderUniforms(): void;
  83549. get skyColor(): BABYLON.Color4;
  83550. set skyColor(value: BABYLON.Color4);
  83551. get cloudColor(): BABYLON.Color4;
  83552. set cloudColor(value: BABYLON.Color4);
  83553. /**
  83554. * Serializes this cloud procedural texture
  83555. * @returns a serialized cloud procedural texture object
  83556. */
  83557. serialize(): any;
  83558. /**
  83559. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83560. * @param parsedTexture defines parsed texture data
  83561. * @param scene defines the current scene
  83562. * @param rootUrl defines the root URL containing cloud procedural texture information
  83563. * @returns a parsed Cloud Procedural BABYLON.Texture
  83564. */
  83565. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /** @hidden */
  83570. export var fireProceduralTexturePixelShader: {
  83571. name: string;
  83572. shader: string;
  83573. };
  83574. }
  83575. declare module BABYLON {
  83576. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83577. private _time;
  83578. private _speed;
  83579. private _autoGenerateTime;
  83580. private _fireColors;
  83581. private _alphaThreshold;
  83582. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83583. updateShaderUniforms(): void;
  83584. render(useCameraPostProcess?: boolean): void;
  83585. static get PurpleFireColors(): BABYLON.Color3[];
  83586. static get GreenFireColors(): BABYLON.Color3[];
  83587. static get RedFireColors(): BABYLON.Color3[];
  83588. static get BlueFireColors(): BABYLON.Color3[];
  83589. get autoGenerateTime(): boolean;
  83590. set autoGenerateTime(value: boolean);
  83591. get fireColors(): BABYLON.Color3[];
  83592. set fireColors(value: BABYLON.Color3[]);
  83593. get time(): number;
  83594. set time(value: number);
  83595. get speed(): BABYLON.Vector2;
  83596. set speed(value: BABYLON.Vector2);
  83597. get alphaThreshold(): number;
  83598. set alphaThreshold(value: number);
  83599. /**
  83600. * Serializes this fire procedural texture
  83601. * @returns a serialized fire procedural texture object
  83602. */
  83603. serialize(): any;
  83604. /**
  83605. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83606. * @param parsedTexture defines parsed texture data
  83607. * @param scene defines the current scene
  83608. * @param rootUrl defines the root URL containing fire procedural texture information
  83609. * @returns a parsed Fire Procedural BABYLON.Texture
  83610. */
  83611. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83612. }
  83613. }
  83614. declare module BABYLON {
  83615. /** @hidden */
  83616. export var grassProceduralTexturePixelShader: {
  83617. name: string;
  83618. shader: string;
  83619. };
  83620. }
  83621. declare module BABYLON {
  83622. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83623. private _grassColors;
  83624. private _groundColor;
  83625. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83626. updateShaderUniforms(): void;
  83627. get grassColors(): BABYLON.Color3[];
  83628. set grassColors(value: BABYLON.Color3[]);
  83629. get groundColor(): BABYLON.Color3;
  83630. set groundColor(value: BABYLON.Color3);
  83631. /**
  83632. * Serializes this grass procedural texture
  83633. * @returns a serialized grass procedural texture object
  83634. */
  83635. serialize(): any;
  83636. /**
  83637. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83638. * @param parsedTexture defines parsed texture data
  83639. * @param scene defines the current scene
  83640. * @param rootUrl defines the root URL containing grass procedural texture information
  83641. * @returns a parsed Grass Procedural BABYLON.Texture
  83642. */
  83643. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83644. }
  83645. }
  83646. declare module BABYLON {
  83647. /** @hidden */
  83648. export var marbleProceduralTexturePixelShader: {
  83649. name: string;
  83650. shader: string;
  83651. };
  83652. }
  83653. declare module BABYLON {
  83654. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83655. private _numberOfTilesHeight;
  83656. private _numberOfTilesWidth;
  83657. private _amplitude;
  83658. private _jointColor;
  83659. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83660. updateShaderUniforms(): void;
  83661. get numberOfTilesHeight(): number;
  83662. set numberOfTilesHeight(value: number);
  83663. get amplitude(): number;
  83664. set amplitude(value: number);
  83665. get numberOfTilesWidth(): number;
  83666. set numberOfTilesWidth(value: number);
  83667. get jointColor(): BABYLON.Color3;
  83668. set jointColor(value: BABYLON.Color3);
  83669. /**
  83670. * Serializes this marble procedural texture
  83671. * @returns a serialized marble procedural texture object
  83672. */
  83673. serialize(): any;
  83674. /**
  83675. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83676. * @param parsedTexture defines parsed texture data
  83677. * @param scene defines the current scene
  83678. * @param rootUrl defines the root URL containing marble procedural texture information
  83679. * @returns a parsed Marble Procedural BABYLON.Texture
  83680. */
  83681. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83682. }
  83683. }
  83684. declare module BABYLON {
  83685. /** @hidden */
  83686. export var normalMapProceduralTexturePixelShader: {
  83687. name: string;
  83688. shader: string;
  83689. };
  83690. }
  83691. declare module BABYLON {
  83692. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83693. private _baseTexture;
  83694. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83695. updateShaderUniforms(): void;
  83696. render(useCameraPostProcess?: boolean): void;
  83697. resize(size: any, generateMipMaps: any): void;
  83698. get baseTexture(): BABYLON.Texture;
  83699. set baseTexture(texture: BABYLON.Texture);
  83700. /**
  83701. * Serializes this normal map procedural texture
  83702. * @returns a serialized normal map procedural texture object
  83703. */
  83704. serialize(): any;
  83705. /**
  83706. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83707. * @param parsedTexture defines parsed texture data
  83708. * @param scene defines the current scene
  83709. * @param rootUrl defines the root URL containing normal map procedural texture information
  83710. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83711. */
  83712. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83713. }
  83714. }
  83715. declare module BABYLON {
  83716. /** @hidden */
  83717. export var perlinNoiseProceduralTexturePixelShader: {
  83718. name: string;
  83719. shader: string;
  83720. };
  83721. }
  83722. declare module BABYLON {
  83723. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83724. time: number;
  83725. timeScale: number;
  83726. translationSpeed: number;
  83727. private _currentTranslation;
  83728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83729. updateShaderUniforms(): void;
  83730. render(useCameraPostProcess?: boolean): void;
  83731. resize(size: any, generateMipMaps: any): void;
  83732. /**
  83733. * Serializes this perlin noise procedural texture
  83734. * @returns a serialized perlin noise procedural texture object
  83735. */
  83736. serialize(): any;
  83737. /**
  83738. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83739. * @param parsedTexture defines parsed texture data
  83740. * @param scene defines the current scene
  83741. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83742. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83743. */
  83744. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83745. }
  83746. }
  83747. declare module BABYLON {
  83748. /** @hidden */
  83749. export var roadProceduralTexturePixelShader: {
  83750. name: string;
  83751. shader: string;
  83752. };
  83753. }
  83754. declare module BABYLON {
  83755. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83756. private _roadColor;
  83757. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83758. updateShaderUniforms(): void;
  83759. get roadColor(): BABYLON.Color3;
  83760. set roadColor(value: BABYLON.Color3);
  83761. /**
  83762. * Serializes this road procedural texture
  83763. * @returns a serialized road procedural texture object
  83764. */
  83765. serialize(): any;
  83766. /**
  83767. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83768. * @param parsedTexture defines parsed texture data
  83769. * @param scene defines the current scene
  83770. * @param rootUrl defines the root URL containing road procedural texture information
  83771. * @returns a parsed Road Procedural BABYLON.Texture
  83772. */
  83773. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83774. }
  83775. }
  83776. declare module BABYLON {
  83777. /** @hidden */
  83778. export var starfieldProceduralTexturePixelShader: {
  83779. name: string;
  83780. shader: string;
  83781. };
  83782. }
  83783. declare module BABYLON {
  83784. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83785. private _time;
  83786. private _alpha;
  83787. private _beta;
  83788. private _zoom;
  83789. private _formuparam;
  83790. private _stepsize;
  83791. private _tile;
  83792. private _brightness;
  83793. private _darkmatter;
  83794. private _distfading;
  83795. private _saturation;
  83796. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83797. updateShaderUniforms(): void;
  83798. get time(): number;
  83799. set time(value: number);
  83800. get alpha(): number;
  83801. set alpha(value: number);
  83802. get beta(): number;
  83803. set beta(value: number);
  83804. get formuparam(): number;
  83805. set formuparam(value: number);
  83806. get stepsize(): number;
  83807. set stepsize(value: number);
  83808. get zoom(): number;
  83809. set zoom(value: number);
  83810. get tile(): number;
  83811. set tile(value: number);
  83812. get brightness(): number;
  83813. set brightness(value: number);
  83814. get darkmatter(): number;
  83815. set darkmatter(value: number);
  83816. get distfading(): number;
  83817. set distfading(value: number);
  83818. get saturation(): number;
  83819. set saturation(value: number);
  83820. /**
  83821. * Serializes this starfield procedural texture
  83822. * @returns a serialized starfield procedural texture object
  83823. */
  83824. serialize(): any;
  83825. /**
  83826. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83827. * @param parsedTexture defines parsed texture data
  83828. * @param scene defines the current scene
  83829. * @param rootUrl defines the root URL containing startfield procedural texture information
  83830. * @returns a parsed Starfield Procedural BABYLON.Texture
  83831. */
  83832. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83833. }
  83834. }
  83835. declare module BABYLON {
  83836. /** @hidden */
  83837. export var woodProceduralTexturePixelShader: {
  83838. name: string;
  83839. shader: string;
  83840. };
  83841. }
  83842. declare module BABYLON {
  83843. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83844. private _ampScale;
  83845. private _woodColor;
  83846. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83847. updateShaderUniforms(): void;
  83848. get ampScale(): number;
  83849. set ampScale(value: number);
  83850. get woodColor(): BABYLON.Color3;
  83851. set woodColor(value: BABYLON.Color3);
  83852. /**
  83853. * Serializes this wood procedural texture
  83854. * @returns a serialized wood procedural texture object
  83855. */
  83856. serialize(): any;
  83857. /**
  83858. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83859. * @param parsedTexture defines parsed texture data
  83860. * @param scene defines the current scene
  83861. * @param rootUrl defines the root URL containing wood procedural texture information
  83862. * @returns a parsed Wood Procedural BABYLON.Texture
  83863. */
  83864. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83865. }
  83866. }