documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396
  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. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10307. subMeshFaceId: number;
  10308. /** Id of the the submesh that was picked */
  10309. subMeshId: number;
  10310. /** If a sprite was picked, this will be the sprite the pick collided with */
  10311. pickedSprite: Nullable<Sprite>;
  10312. /**
  10313. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10314. */
  10315. originMesh: Nullable<AbstractMesh>;
  10316. /**
  10317. * The ray that was used to perform the picking.
  10318. */
  10319. ray: Nullable<Ray>;
  10320. /**
  10321. * Gets the normal correspodning to the face the pick collided with
  10322. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10323. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10324. * @returns The normal correspodning to the face the pick collided with
  10325. */
  10326. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10327. /**
  10328. * Gets the texture coordinates of where the pick occured
  10329. * @returns the vector containing the coordnates of the texture
  10330. */
  10331. getTextureCoordinates(): Nullable<Vector2>;
  10332. }
  10333. }
  10334. declare module BABYLON {
  10335. /**
  10336. * Class representing a ray with position and direction
  10337. */
  10338. export class Ray {
  10339. /** origin point */
  10340. origin: Vector3;
  10341. /** direction */
  10342. direction: Vector3;
  10343. /** length of the ray */
  10344. length: number;
  10345. private static readonly TmpVector3;
  10346. private _tmpRay;
  10347. /**
  10348. * Creates a new ray
  10349. * @param origin origin point
  10350. * @param direction direction
  10351. * @param length length of the ray
  10352. */
  10353. constructor(
  10354. /** origin point */
  10355. origin: Vector3,
  10356. /** direction */
  10357. direction: Vector3,
  10358. /** length of the ray */
  10359. length?: number);
  10360. /**
  10361. * Checks if the ray intersects a box
  10362. * This does not account for the ray lenght by design to improve perfs.
  10363. * @param minimum bound of the box
  10364. * @param maximum bound of the box
  10365. * @param intersectionTreshold extra extend to be added to the box in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * Checks if the ray intersects a box
  10371. * This does not account for the ray lenght by design to improve perfs.
  10372. * @param box the bounding box to check
  10373. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10374. * @returns if the box was hit
  10375. */
  10376. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10377. /**
  10378. * If the ray hits a sphere
  10379. * @param sphere the bounding sphere to check
  10380. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10381. * @returns true if it hits the sphere
  10382. */
  10383. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10384. /**
  10385. * If the ray hits a triange
  10386. * @param vertex0 triangle vertex
  10387. * @param vertex1 triangle vertex
  10388. * @param vertex2 triangle vertex
  10389. * @returns intersection information if hit
  10390. */
  10391. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10392. /**
  10393. * Checks if ray intersects a plane
  10394. * @param plane the plane to check
  10395. * @returns the distance away it was hit
  10396. */
  10397. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10398. /**
  10399. * Calculate the intercept of a ray on a given axis
  10400. * @param axis to check 'x' | 'y' | 'z'
  10401. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10402. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10403. */
  10404. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10405. /**
  10406. * Checks if ray intersects a mesh
  10407. * @param mesh the mesh to check
  10408. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10409. * @returns picking info of the intersecton
  10410. */
  10411. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10412. /**
  10413. * Checks if ray intersects a mesh
  10414. * @param meshes the meshes to check
  10415. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10416. * @param results array to store result in
  10417. * @returns Array of picking infos
  10418. */
  10419. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10420. private _comparePickingInfo;
  10421. private static smallnum;
  10422. private static rayl;
  10423. /**
  10424. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10425. * @param sega the first point of the segment to test the intersection against
  10426. * @param segb the second point of the segment to test the intersection against
  10427. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10428. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10429. */
  10430. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10431. /**
  10432. * Update the ray from viewport position
  10433. * @param x position
  10434. * @param y y position
  10435. * @param viewportWidth viewport width
  10436. * @param viewportHeight viewport height
  10437. * @param world world matrix
  10438. * @param view view matrix
  10439. * @param projection projection matrix
  10440. * @returns this ray updated
  10441. */
  10442. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10443. /**
  10444. * Creates a ray with origin and direction of 0,0,0
  10445. * @returns the new ray
  10446. */
  10447. static Zero(): Ray;
  10448. /**
  10449. * Creates a new ray from screen space and viewport
  10450. * @param x position
  10451. * @param y y position
  10452. * @param viewportWidth viewport width
  10453. * @param viewportHeight viewport height
  10454. * @param world world matrix
  10455. * @param view view matrix
  10456. * @param projection projection matrix
  10457. * @returns new ray
  10458. */
  10459. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10460. /**
  10461. * 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
  10462. * transformed to the given world matrix.
  10463. * @param origin The origin point
  10464. * @param end The end point
  10465. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10466. * @returns the new ray
  10467. */
  10468. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10469. /**
  10470. * Transforms a ray by a matrix
  10471. * @param ray ray to transform
  10472. * @param matrix matrix to apply
  10473. * @returns the resulting new ray
  10474. */
  10475. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * Transforms a ray by a matrix
  10478. * @param ray ray to transform
  10479. * @param matrix matrix to apply
  10480. * @param result ray to store result in
  10481. */
  10482. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10483. /**
  10484. * Unproject a ray from screen space to object space
  10485. * @param sourceX defines the screen space x coordinate to use
  10486. * @param sourceY defines the screen space y coordinate to use
  10487. * @param viewportWidth defines the current width of the viewport
  10488. * @param viewportHeight defines the current height of the viewport
  10489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10490. * @param view defines the view matrix to use
  10491. * @param projection defines the projection matrix to use
  10492. */
  10493. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10494. }
  10495. /**
  10496. * Type used to define predicate used to select faces when a mesh intersection is detected
  10497. */
  10498. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10499. interface Scene {
  10500. /** @hidden */
  10501. _tempPickingRay: Nullable<Ray>;
  10502. /** @hidden */
  10503. _cachedRayForTransform: Ray;
  10504. /** @hidden */
  10505. _pickWithRayInverseMatrix: Matrix;
  10506. /** @hidden */
  10507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10508. /** @hidden */
  10509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10510. }
  10511. }
  10512. declare module BABYLON {
  10513. /**
  10514. * Groups all the scene component constants in one place to ease maintenance.
  10515. * @hidden
  10516. */
  10517. export class SceneComponentConstants {
  10518. static readonly NAME_EFFECTLAYER: string;
  10519. static readonly NAME_LAYER: string;
  10520. static readonly NAME_LENSFLARESYSTEM: string;
  10521. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10522. static readonly NAME_PARTICLESYSTEM: string;
  10523. static readonly NAME_GAMEPAD: string;
  10524. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10525. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10526. static readonly NAME_DEPTHRENDERER: string;
  10527. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10528. static readonly NAME_SPRITE: string;
  10529. static readonly NAME_OUTLINERENDERER: string;
  10530. static readonly NAME_PROCEDURALTEXTURE: string;
  10531. static readonly NAME_SHADOWGENERATOR: string;
  10532. static readonly NAME_OCTREE: string;
  10533. static readonly NAME_PHYSICSENGINE: string;
  10534. static readonly NAME_AUDIO: string;
  10535. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10536. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10541. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10543. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10546. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10548. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10549. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10550. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10554. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10555. static readonly STEP_AFTERRENDER_AUDIO: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10559. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10560. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10561. static readonly STEP_POINTERMOVE_SPRITE: number;
  10562. static readonly STEP_POINTERDOWN_SPRITE: number;
  10563. static readonly STEP_POINTERUP_SPRITE: number;
  10564. }
  10565. /**
  10566. * This represents a scene component.
  10567. *
  10568. * This is used to decouple the dependency the scene is having on the different workloads like
  10569. * layers, post processes...
  10570. */
  10571. export interface ISceneComponent {
  10572. /**
  10573. * The name of the component. Each component must have a unique name.
  10574. */
  10575. name: string;
  10576. /**
  10577. * The scene the component belongs to.
  10578. */
  10579. scene: Scene;
  10580. /**
  10581. * Register the component to one instance of a scene.
  10582. */
  10583. register(): void;
  10584. /**
  10585. * Rebuilds the elements related to this component in case of
  10586. * context lost for instance.
  10587. */
  10588. rebuild(): void;
  10589. /**
  10590. * Disposes the component and the associated ressources.
  10591. */
  10592. dispose(): void;
  10593. }
  10594. /**
  10595. * This represents a SERIALIZABLE scene component.
  10596. *
  10597. * This extends Scene Component to add Serialization methods on top.
  10598. */
  10599. export interface ISceneSerializableComponent extends ISceneComponent {
  10600. /**
  10601. * Adds all the elements from the container to the scene
  10602. * @param container the container holding the elements
  10603. */
  10604. addFromContainer(container: AbstractScene): void;
  10605. /**
  10606. * Removes all the elements in the container from the scene
  10607. * @param container contains the elements to remove
  10608. * @param dispose if the removed element should be disposed (default: false)
  10609. */
  10610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10611. /**
  10612. * Serializes the component data to the specified json object
  10613. * @param serializationObject The object to serialize to
  10614. */
  10615. serialize(serializationObject: any): void;
  10616. }
  10617. /**
  10618. * Strong typing of a Mesh related stage step action
  10619. */
  10620. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10621. /**
  10622. * Strong typing of a Evaluate Sub Mesh related stage step action
  10623. */
  10624. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10625. /**
  10626. * Strong typing of a Active Mesh related stage step action
  10627. */
  10628. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10629. /**
  10630. * Strong typing of a Camera related stage step action
  10631. */
  10632. export type CameraStageAction = (camera: Camera) => void;
  10633. /**
  10634. * Strong typing of a Camera Frame buffer related stage step action
  10635. */
  10636. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10637. /**
  10638. * Strong typing of a Render Target related stage step action
  10639. */
  10640. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10641. /**
  10642. * Strong typing of a RenderingGroup related stage step action
  10643. */
  10644. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10645. /**
  10646. * Strong typing of a Mesh Render related stage step action
  10647. */
  10648. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10649. /**
  10650. * Strong typing of a simple stage step action
  10651. */
  10652. export type SimpleStageAction = () => void;
  10653. /**
  10654. * Strong typing of a render target action.
  10655. */
  10656. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10657. /**
  10658. * Strong typing of a pointer move action.
  10659. */
  10660. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10661. /**
  10662. * Strong typing of a pointer up/down action.
  10663. */
  10664. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10665. /**
  10666. * Representation of a stage in the scene (Basically a list of ordered steps)
  10667. * @hidden
  10668. */
  10669. export class Stage<T extends Function> extends Array<{
  10670. index: number;
  10671. component: ISceneComponent;
  10672. action: T;
  10673. }> {
  10674. /**
  10675. * Hide ctor from the rest of the world.
  10676. * @param items The items to add.
  10677. */
  10678. private constructor();
  10679. /**
  10680. * Creates a new Stage.
  10681. * @returns A new instance of a Stage
  10682. */
  10683. static Create<T extends Function>(): Stage<T>;
  10684. /**
  10685. * Registers a step in an ordered way in the targeted stage.
  10686. * @param index Defines the position to register the step in
  10687. * @param component Defines the component attached to the step
  10688. * @param action Defines the action to launch during the step
  10689. */
  10690. registerStep(index: number, component: ISceneComponent, action: T): void;
  10691. /**
  10692. * Clears all the steps from the stage.
  10693. */
  10694. clear(): void;
  10695. }
  10696. }
  10697. declare module BABYLON {
  10698. interface Scene {
  10699. /** @hidden */
  10700. _pointerOverSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _pickedDownSprite: Nullable<Sprite>;
  10703. /** @hidden */
  10704. _tempSpritePickingRay: Nullable<Ray>;
  10705. /**
  10706. * All of the sprite managers added to this scene
  10707. * @see http://doc.babylonjs.com/babylon101/sprites
  10708. */
  10709. spriteManagers: Array<ISpriteManager>;
  10710. /**
  10711. * An event triggered when sprites rendering is about to start
  10712. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10713. */
  10714. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10715. /**
  10716. * An event triggered when sprites rendering is done
  10717. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10718. */
  10719. onAfterSpritesRenderingObservable: Observable<Scene>;
  10720. /** @hidden */
  10721. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10722. /** Launch a ray to try to pick a sprite in the scene
  10723. * @param x position on screen
  10724. * @param y position on screen
  10725. * @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
  10726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10727. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10728. * @returns a PickingInfo
  10729. */
  10730. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10731. /** Use the given ray to pick a sprite in the scene
  10732. * @param ray The ray (in world space) to use to pick meshes
  10733. * @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
  10734. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10735. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10736. * @returns a PickingInfo
  10737. */
  10738. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10739. /** @hidden */
  10740. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10741. /** Launch a ray to try to pick sprites in the scene
  10742. * @param x position on screen
  10743. * @param y position on screen
  10744. * @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
  10745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10746. * @returns a PickingInfo array
  10747. */
  10748. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10749. /** Use the given ray to pick sprites in the scene
  10750. * @param ray The ray (in world space) to use to pick meshes
  10751. * @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
  10752. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10753. * @returns a PickingInfo array
  10754. */
  10755. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10756. /**
  10757. * Force the sprite under the pointer
  10758. * @param sprite defines the sprite to use
  10759. */
  10760. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10761. /**
  10762. * Gets the sprite under the pointer
  10763. * @returns a Sprite or null if no sprite is under the pointer
  10764. */
  10765. getPointerOverSprite(): Nullable<Sprite>;
  10766. }
  10767. /**
  10768. * Defines the sprite scene component responsible to manage sprites
  10769. * in a given scene.
  10770. */
  10771. export class SpriteSceneComponent implements ISceneComponent {
  10772. /**
  10773. * The component name helpfull to identify the component in the list of scene components.
  10774. */
  10775. readonly name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /** @hidden */
  10781. private _spritePredicate;
  10782. /**
  10783. * Creates a new instance of the component for the given scene
  10784. * @param scene Defines the scene to register the component in
  10785. */
  10786. constructor(scene: Scene);
  10787. /**
  10788. * Registers the component in a given scene
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. private _pickSpriteButKeepRay;
  10801. private _pointerMove;
  10802. private _pointerDown;
  10803. private _pointerUp;
  10804. }
  10805. }
  10806. declare module BABYLON {
  10807. /** @hidden */
  10808. export var fogFragmentDeclaration: {
  10809. name: string;
  10810. shader: string;
  10811. };
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var fogFragment: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /** @hidden */
  10822. export var spritesPixelShader: {
  10823. name: string;
  10824. shader: string;
  10825. };
  10826. }
  10827. declare module BABYLON {
  10828. /** @hidden */
  10829. export var fogVertexDeclaration: {
  10830. name: string;
  10831. shader: string;
  10832. };
  10833. }
  10834. declare module BABYLON {
  10835. /** @hidden */
  10836. export var spritesVertexShader: {
  10837. name: string;
  10838. shader: string;
  10839. };
  10840. }
  10841. declare module BABYLON {
  10842. /**
  10843. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10844. */
  10845. export interface ISpriteManager extends IDisposable {
  10846. /**
  10847. * Gets manager's name
  10848. */
  10849. name: string;
  10850. /**
  10851. * Restricts the camera to viewing objects with the same layerMask.
  10852. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10853. */
  10854. layerMask: number;
  10855. /**
  10856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10857. */
  10858. isPickable: boolean;
  10859. /**
  10860. * Gets the hosting scene
  10861. */
  10862. scene: Scene;
  10863. /**
  10864. * Specifies the rendering group id for this mesh (0 by default)
  10865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10866. */
  10867. renderingGroupId: number;
  10868. /**
  10869. * Defines the list of sprites managed by the manager.
  10870. */
  10871. sprites: Array<Sprite>;
  10872. /**
  10873. * Gets or sets the spritesheet texture
  10874. */
  10875. texture: Texture;
  10876. /** Defines the default width of a cell in the spritesheet */
  10877. cellWidth: number;
  10878. /** Defines the default height of a cell in the spritesheet */
  10879. cellHeight: number;
  10880. /**
  10881. * Tests the intersection of a sprite with a specific ray.
  10882. * @param ray The ray we are sending to test the collision
  10883. * @param camera The camera space we are sending rays in
  10884. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10886. * @returns picking info or null.
  10887. */
  10888. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10889. /**
  10890. * Intersects the sprites with a ray
  10891. * @param ray defines the ray to intersect with
  10892. * @param camera defines the current active camera
  10893. * @param predicate defines a predicate used to select candidate sprites
  10894. * @returns null if no hit or a PickingInfo array
  10895. */
  10896. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10897. /**
  10898. * Renders the list of sprites on screen.
  10899. */
  10900. render(): void;
  10901. }
  10902. /**
  10903. * Class used to manage multiple sprites on the same spritesheet
  10904. * @see http://doc.babylonjs.com/babylon101/sprites
  10905. */
  10906. export class SpriteManager implements ISpriteManager {
  10907. /** defines the manager's name */
  10908. name: string;
  10909. /** Define the Url to load snippets */
  10910. static SnippetUrl: string;
  10911. /** Snippet ID if the manager was created from the snippet server */
  10912. snippetId: string;
  10913. /** Gets the list of sprites */
  10914. sprites: Sprite[];
  10915. /** Gets or sets the rendering group id (0 by default) */
  10916. renderingGroupId: number;
  10917. /** Gets or sets camera layer mask */
  10918. layerMask: number;
  10919. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10920. fogEnabled: boolean;
  10921. /** Gets or sets a boolean indicating if the sprites are pickable */
  10922. isPickable: boolean;
  10923. /** Defines the default width of a cell in the spritesheet */
  10924. cellWidth: number;
  10925. /** Defines the default height of a cell in the spritesheet */
  10926. cellHeight: number;
  10927. /** Associative array from JSON sprite data file */
  10928. private _cellData;
  10929. /** Array of sprite names from JSON sprite data file */
  10930. private _spriteMap;
  10931. /** True when packed cell data from JSON file is ready*/
  10932. private _packedAndReady;
  10933. private _textureContent;
  10934. /**
  10935. * An event triggered when the manager is disposed.
  10936. */
  10937. onDisposeObservable: Observable<SpriteManager>;
  10938. private _onDisposeObserver;
  10939. /**
  10940. * Callback called when the manager is disposed
  10941. */
  10942. set onDispose(callback: () => void);
  10943. private _capacity;
  10944. private _fromPacked;
  10945. private _spriteTexture;
  10946. private _epsilon;
  10947. private _scene;
  10948. private _vertexData;
  10949. private _buffer;
  10950. private _vertexBuffers;
  10951. private _indexBuffer;
  10952. private _effectBase;
  10953. private _effectFog;
  10954. /**
  10955. * Gets or sets the unique id of the sprite
  10956. */
  10957. uniqueId: number;
  10958. /**
  10959. * Gets the array of sprites
  10960. */
  10961. get children(): Sprite[];
  10962. /**
  10963. * Gets the hosting scene
  10964. */
  10965. get scene(): Scene;
  10966. /**
  10967. * Gets the capacity of the manager
  10968. */
  10969. get capacity(): number;
  10970. /**
  10971. * Gets or sets the spritesheet texture
  10972. */
  10973. get texture(): Texture;
  10974. set texture(value: Texture);
  10975. private _blendMode;
  10976. /**
  10977. * Blend mode use to render the particle, it can be any of
  10978. * the static Constants.ALPHA_x properties provided in this class.
  10979. * Default value is Constants.ALPHA_COMBINE
  10980. */
  10981. get blendMode(): number;
  10982. set blendMode(blendMode: number);
  10983. /** Disables writing to the depth buffer when rendering the sprites.
  10984. * It can be handy to disable depth writing when using textures without alpha channel
  10985. * and setting some specific blend modes.
  10986. */
  10987. disableDepthWrite: boolean;
  10988. /**
  10989. * Creates a new sprite manager
  10990. * @param name defines the manager's name
  10991. * @param imgUrl defines the sprite sheet url
  10992. * @param capacity defines the maximum allowed number of sprites
  10993. * @param cellSize defines the size of a sprite cell
  10994. * @param scene defines the hosting scene
  10995. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10996. * @param samplingMode defines the smapling mode to use with spritesheet
  10997. * @param fromPacked set to false; do not alter
  10998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10999. */
  11000. constructor(
  11001. /** defines the manager's name */
  11002. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11003. /**
  11004. * Returns the string "SpriteManager"
  11005. * @returns "SpriteManager"
  11006. */
  11007. getClassName(): string;
  11008. private _makePacked;
  11009. private _appendSpriteVertex;
  11010. private _checkTextureAlpha;
  11011. /**
  11012. * Intersects the sprites with a ray
  11013. * @param ray defines the ray to intersect with
  11014. * @param camera defines the current active camera
  11015. * @param predicate defines a predicate used to select candidate sprites
  11016. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11017. * @returns null if no hit or a PickingInfo
  11018. */
  11019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11020. /**
  11021. * Intersects the sprites with a ray
  11022. * @param ray defines the ray to intersect with
  11023. * @param camera defines the current active camera
  11024. * @param predicate defines a predicate used to select candidate sprites
  11025. * @returns null if no hit or a PickingInfo array
  11026. */
  11027. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11028. /**
  11029. * Render all child sprites
  11030. */
  11031. render(): void;
  11032. /**
  11033. * Release associated resources
  11034. */
  11035. dispose(): void;
  11036. /**
  11037. * Serializes the sprite manager to a JSON object
  11038. * @param serializeTexture defines if the texture must be serialized as well
  11039. * @returns the JSON object
  11040. */
  11041. serialize(serializeTexture?: boolean): any;
  11042. /**
  11043. * Parses a JSON object to create a new sprite manager.
  11044. * @param parsedManager The JSON object to parse
  11045. * @param scene The scene to create the sprite managerin
  11046. * @param rootUrl The root url to use to load external dependencies like texture
  11047. * @returns the new sprite manager
  11048. */
  11049. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11050. /**
  11051. * Creates a sprite manager from a snippet saved in a remote file
  11052. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11053. * @param url defines the url to load from
  11054. * @param scene defines the hosting scene
  11055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11056. * @returns a promise that will resolve to the new sprite manager
  11057. */
  11058. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11059. /**
  11060. * Creates a sprite manager from a snippet saved by the sprite editor
  11061. * @param snippetId defines the snippet to load
  11062. * @param scene defines the hosting scene
  11063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11064. * @returns a promise that will resolve to the new sprite manager
  11065. */
  11066. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11067. }
  11068. }
  11069. declare module BABYLON {
  11070. /** Interface used by value gradients (color, factor, ...) */
  11071. export interface IValueGradient {
  11072. /**
  11073. * Gets or sets the gradient value (between 0 and 1)
  11074. */
  11075. gradient: number;
  11076. }
  11077. /** Class used to store color4 gradient */
  11078. export class ColorGradient implements IValueGradient {
  11079. /**
  11080. * Gets or sets the gradient value (between 0 and 1)
  11081. */
  11082. gradient: number;
  11083. /**
  11084. * Gets or sets first associated color
  11085. */
  11086. color1: Color4;
  11087. /**
  11088. * Gets or sets second associated color
  11089. */
  11090. color2?: Color4 | undefined;
  11091. /**
  11092. * Creates a new color4 gradient
  11093. * @param gradient gets or sets the gradient value (between 0 and 1)
  11094. * @param color1 gets or sets first associated color
  11095. * @param color2 gets or sets first second color
  11096. */
  11097. constructor(
  11098. /**
  11099. * Gets or sets the gradient value (between 0 and 1)
  11100. */
  11101. gradient: number,
  11102. /**
  11103. * Gets or sets first associated color
  11104. */
  11105. color1: Color4,
  11106. /**
  11107. * Gets or sets second associated color
  11108. */
  11109. color2?: Color4 | undefined);
  11110. /**
  11111. * Will get a color picked randomly between color1 and color2.
  11112. * If color2 is undefined then color1 will be used
  11113. * @param result defines the target Color4 to store the result in
  11114. */
  11115. getColorToRef(result: Color4): void;
  11116. }
  11117. /** Class used to store color 3 gradient */
  11118. export class Color3Gradient implements IValueGradient {
  11119. /**
  11120. * Gets or sets the gradient value (between 0 and 1)
  11121. */
  11122. gradient: number;
  11123. /**
  11124. * Gets or sets the associated color
  11125. */
  11126. color: Color3;
  11127. /**
  11128. * Creates a new color3 gradient
  11129. * @param gradient gets or sets the gradient value (between 0 and 1)
  11130. * @param color gets or sets associated color
  11131. */
  11132. constructor(
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number,
  11137. /**
  11138. * Gets or sets the associated color
  11139. */
  11140. color: Color3);
  11141. }
  11142. /** Class used to store factor gradient */
  11143. export class FactorGradient implements IValueGradient {
  11144. /**
  11145. * Gets or sets the gradient value (between 0 and 1)
  11146. */
  11147. gradient: number;
  11148. /**
  11149. * Gets or sets first associated factor
  11150. */
  11151. factor1: number;
  11152. /**
  11153. * Gets or sets second associated factor
  11154. */
  11155. factor2?: number | undefined;
  11156. /**
  11157. * Creates a new factor gradient
  11158. * @param gradient gets or sets the gradient value (between 0 and 1)
  11159. * @param factor1 gets or sets first associated factor
  11160. * @param factor2 gets or sets second associated factor
  11161. */
  11162. constructor(
  11163. /**
  11164. * Gets or sets the gradient value (between 0 and 1)
  11165. */
  11166. gradient: number,
  11167. /**
  11168. * Gets or sets first associated factor
  11169. */
  11170. factor1: number,
  11171. /**
  11172. * Gets or sets second associated factor
  11173. */
  11174. factor2?: number | undefined);
  11175. /**
  11176. * Will get a number picked randomly between factor1 and factor2.
  11177. * If factor2 is undefined then factor1 will be used
  11178. * @returns the picked number
  11179. */
  11180. getFactor(): number;
  11181. }
  11182. /**
  11183. * Helper used to simplify some generic gradient tasks
  11184. */
  11185. export class GradientHelper {
  11186. /**
  11187. * Gets the current gradient from an array of IValueGradient
  11188. * @param ratio defines the current ratio to get
  11189. * @param gradients defines the array of IValueGradient
  11190. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11191. */
  11192. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface ThinEngine {
  11197. /**
  11198. * Creates a dynamic texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param generateMipMaps defines if the engine should generate the mip levels
  11202. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11203. * @returns the dynamic texture inside an InternalTexture
  11204. */
  11205. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11206. /**
  11207. * Update the content of a dynamic texture
  11208. * @param texture defines the texture to update
  11209. * @param canvas defines the canvas containing the source
  11210. * @param invertY defines if data must be stored with Y axis inverted
  11211. * @param premulAlpha defines if alpha is stored as premultiplied
  11212. * @param format defines the format of the data
  11213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11214. */
  11215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11216. }
  11217. }
  11218. declare module BABYLON {
  11219. /**
  11220. * Helper class used to generate a canvas to manipulate images
  11221. */
  11222. export class CanvasGenerator {
  11223. /**
  11224. * Create a new canvas (or offscreen canvas depending on the context)
  11225. * @param width defines the expected width
  11226. * @param height defines the expected height
  11227. * @return a new canvas or offscreen canvas
  11228. */
  11229. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11230. }
  11231. }
  11232. declare module BABYLON {
  11233. /**
  11234. * A class extending Texture allowing drawing on a texture
  11235. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11236. */
  11237. export class DynamicTexture extends Texture {
  11238. private _generateMipMaps;
  11239. private _canvas;
  11240. private _context;
  11241. /**
  11242. * Creates a DynamicTexture
  11243. * @param name defines the name of the texture
  11244. * @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
  11245. * @param scene defines the scene where you want the texture
  11246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11249. */
  11250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11251. /**
  11252. * Get the current class name of the texture useful for serialization or dynamic coding.
  11253. * @returns "DynamicTexture"
  11254. */
  11255. getClassName(): string;
  11256. /**
  11257. * Gets the current state of canRescale
  11258. */
  11259. get canRescale(): boolean;
  11260. private _recreate;
  11261. /**
  11262. * Scales the texture
  11263. * @param ratio the scale factor to apply to both width and height
  11264. */
  11265. scale(ratio: number): void;
  11266. /**
  11267. * Resizes the texture
  11268. * @param width the new width
  11269. * @param height the new height
  11270. */
  11271. scaleTo(width: number, height: number): void;
  11272. /**
  11273. * Gets the context of the canvas used by the texture
  11274. * @returns the canvas context of the dynamic texture
  11275. */
  11276. getContext(): CanvasRenderingContext2D;
  11277. /**
  11278. * Clears the texture
  11279. */
  11280. clear(): void;
  11281. /**
  11282. * Updates the texture
  11283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11285. */
  11286. update(invertY?: boolean, premulAlpha?: boolean): void;
  11287. /**
  11288. * Draws text onto the texture
  11289. * @param text defines the text to be drawn
  11290. * @param x defines the placement of the text from the left
  11291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11292. * @param font defines the font to be used with font-style, font-size, font-name
  11293. * @param color defines the color used for the text
  11294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11296. * @param update defines whether texture is immediately update (default is true)
  11297. */
  11298. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11299. /**
  11300. * Clones the texture
  11301. * @returns the clone of the texture.
  11302. */
  11303. clone(): DynamicTexture;
  11304. /**
  11305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11306. * @returns a serialized dynamic texture object
  11307. */
  11308. serialize(): any;
  11309. /** @hidden */
  11310. _rebuild(): void;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. interface ThinEngine {
  11315. /**
  11316. * Creates a raw texture
  11317. * @param data defines the data to store in the texture
  11318. * @param width defines the width of the texture
  11319. * @param height defines the height of the texture
  11320. * @param format defines the format of the data
  11321. * @param generateMipMaps defines if the engine should generate the mip levels
  11322. * @param invertY defines if data must be stored with Y axis inverted
  11323. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11324. * @param compression defines the compression used (null by default)
  11325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11326. * @returns the raw texture inside an InternalTexture
  11327. */
  11328. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11329. /**
  11330. * Update a raw texture
  11331. * @param texture defines the texture to update
  11332. * @param data defines the data to store in the texture
  11333. * @param format defines the format of the data
  11334. * @param invertY defines if data must be stored with Y axis inverted
  11335. */
  11336. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11337. /**
  11338. * Update a raw texture
  11339. * @param texture defines the texture to update
  11340. * @param data defines the data to store in the texture
  11341. * @param format defines the format of the data
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. */
  11346. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11347. /**
  11348. * Creates a new raw cube texture
  11349. * @param data defines the array of data to use to create each face
  11350. * @param size defines the size of the textures
  11351. * @param format defines the format of the data
  11352. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11356. * @param compression defines the compression used (null by default)
  11357. * @returns the cube texture as an InternalTexture
  11358. */
  11359. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11360. /**
  11361. * Update a raw cube texture
  11362. * @param texture defines the texture to udpdate
  11363. * @param data defines the data to store
  11364. * @param format defines the data format
  11365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw cube texture
  11371. * @param texture defines the texture to udpdate
  11372. * @param data defines the data to store
  11373. * @param format defines the data format
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11379. /**
  11380. * Update a raw cube texture
  11381. * @param texture defines the texture to udpdate
  11382. * @param data defines the data to store
  11383. * @param format defines the data format
  11384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the compression used (null by default)
  11387. * @param level defines which level of the texture to update
  11388. */
  11389. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11390. /**
  11391. * Creates a new raw cube texture from a specified url
  11392. * @param url defines the url where the data is located
  11393. * @param scene defines the current scene
  11394. * @param size defines the size of the textures
  11395. * @param format defines the format of the data
  11396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11397. * @param noMipmap defines if the engine should avoid generating the mip levels
  11398. * @param callback defines a callback used to extract texture data from loaded data
  11399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11400. * @param onLoad defines a callback called when texture is loaded
  11401. * @param onError defines a callback called if there is an error
  11402. * @returns the cube texture as an InternalTexture
  11403. */
  11404. 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;
  11405. /**
  11406. * Creates a new raw cube texture from a specified url
  11407. * @param url defines the url where the data is located
  11408. * @param scene defines the current scene
  11409. * @param size defines the size of the textures
  11410. * @param format defines the format of the data
  11411. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11412. * @param noMipmap defines if the engine should avoid generating the mip levels
  11413. * @param callback defines a callback used to extract texture data from loaded data
  11414. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11415. * @param onLoad defines a callback called when texture is loaded
  11416. * @param onError defines a callback called if there is an error
  11417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. 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;
  11422. /**
  11423. * Creates a new raw 3D texture
  11424. * @param data defines the data used to create the texture
  11425. * @param width defines the width of the texture
  11426. * @param height defines the height of the texture
  11427. * @param depth defines the depth of the texture
  11428. * @param format defines the format of the texture
  11429. * @param generateMipMaps defines if the engine must generate mip levels
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11432. * @param compression defines the compressed used (can be null)
  11433. * @param textureType defines the compressed used (can be null)
  11434. * @returns a new raw 3D texture (stored in an InternalTexture)
  11435. */
  11436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11437. /**
  11438. * Update a raw 3D texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store
  11441. * @param format defines the data format
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. */
  11444. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11445. /**
  11446. * Update a raw 3D texture
  11447. * @param texture defines the texture to update
  11448. * @param data defines the data to store
  11449. * @param format defines the data format
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the used compression (can be null)
  11452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11453. */
  11454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11455. /**
  11456. * Creates a new raw 2D array texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the number of layers of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 2D array texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 2D array texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. */
  11496. export class RawTexture extends Texture {
  11497. /**
  11498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. */
  11500. format: number;
  11501. /**
  11502. * Instantiates a new RawTexture.
  11503. * Raw texture can help creating a texture directly from an array of data.
  11504. * This can be super useful if you either get the data from an uncompressed source or
  11505. * if you wish to create your texture pixel by pixel.
  11506. * @param data define the array of data to use to create the texture
  11507. * @param width define the width of the texture
  11508. * @param height define the height of the texture
  11509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11510. * @param scene define the scene the texture belongs to
  11511. * @param generateMipMaps define whether mip maps should be generated or not
  11512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11515. */
  11516. constructor(data: ArrayBufferView, width: number, height: number,
  11517. /**
  11518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11519. */
  11520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11521. /**
  11522. * Updates the texture underlying data.
  11523. * @param data Define the new data of the texture
  11524. */
  11525. update(data: ArrayBufferView): void;
  11526. /**
  11527. * Creates a luminance texture from some data.
  11528. * @param data Define the texture data
  11529. * @param width Define the width of the texture
  11530. * @param height Define the height of the texture
  11531. * @param scene Define the scene the texture belongs to
  11532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11535. * @returns the luminance texture
  11536. */
  11537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11538. /**
  11539. * Creates a luminance alpha texture from some data.
  11540. * @param data Define the texture data
  11541. * @param width Define the width of the texture
  11542. * @param height Define the height of the texture
  11543. * @param scene Define the scene the texture belongs to
  11544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @returns the luminance alpha texture
  11548. */
  11549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11550. /**
  11551. * Creates an alpha texture from some data.
  11552. * @param data Define the texture data
  11553. * @param width Define the width of the texture
  11554. * @param height Define the height of the texture
  11555. * @param scene Define the scene the texture belongs to
  11556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11559. * @returns the alpha texture
  11560. */
  11561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11562. /**
  11563. * Creates a RGB texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the RGB alpha texture
  11573. */
  11574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. /**
  11576. * Creates a RGBA texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param scene Define the scene the texture belongs to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGBA texture
  11586. */
  11587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a R texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param scene Define the scene the texture belongs to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the R texture
  11599. */
  11600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface AbstractScene {
  11605. /**
  11606. * The list of procedural textures added to the scene
  11607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11608. */
  11609. proceduralTextures: Array<ProceduralTexture>;
  11610. }
  11611. /**
  11612. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11613. * in a given scene.
  11614. */
  11615. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11616. /**
  11617. * The component name helpfull to identify the component in the list of scene components.
  11618. */
  11619. readonly name: string;
  11620. /**
  11621. * The scene the component belongs to.
  11622. */
  11623. scene: Scene;
  11624. /**
  11625. * Creates a new instance of the component for the given scene
  11626. * @param scene Defines the scene to register the component in
  11627. */
  11628. constructor(scene: Scene);
  11629. /**
  11630. * Registers the component in a given scene
  11631. */
  11632. register(): void;
  11633. /**
  11634. * Rebuilds the elements related to this component in case of
  11635. * context lost for instance.
  11636. */
  11637. rebuild(): void;
  11638. /**
  11639. * Disposes the component and the associated ressources.
  11640. */
  11641. dispose(): void;
  11642. private _beforeClear;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Creates a new render target cube texture
  11649. * @param size defines the size of the texture
  11650. * @param options defines the options used to create the texture
  11651. * @returns a new render target cube texture stored in an InternalTexture
  11652. */
  11653. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var proceduralVertexShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /**
  11665. * 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.
  11666. * This is the base class of any Procedural texture and contains most of the shareable code.
  11667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11668. */
  11669. export class ProceduralTexture extends Texture {
  11670. isCube: boolean;
  11671. /**
  11672. * Define if the texture is enabled or not (disabled texture will not render)
  11673. */
  11674. isEnabled: boolean;
  11675. /**
  11676. * Define if the texture must be cleared before rendering (default is true)
  11677. */
  11678. autoClear: boolean;
  11679. /**
  11680. * Callback called when the texture is generated
  11681. */
  11682. onGenerated: () => void;
  11683. /**
  11684. * Event raised when the texture is generated
  11685. */
  11686. onGeneratedObservable: Observable<ProceduralTexture>;
  11687. /** @hidden */
  11688. _generateMipMaps: boolean;
  11689. /** @hidden **/
  11690. _effect: Effect;
  11691. /** @hidden */
  11692. _textures: {
  11693. [key: string]: Texture;
  11694. };
  11695. /** @hidden */
  11696. protected _fallbackTexture: Nullable<Texture>;
  11697. private _size;
  11698. private _currentRefreshId;
  11699. private _frameId;
  11700. private _refreshRate;
  11701. private _vertexBuffers;
  11702. private _indexBuffer;
  11703. private _uniforms;
  11704. private _samplers;
  11705. private _fragment;
  11706. private _floats;
  11707. private _ints;
  11708. private _floatsArrays;
  11709. private _colors3;
  11710. private _colors4;
  11711. private _vectors2;
  11712. private _vectors3;
  11713. private _matrices;
  11714. private _fallbackTextureUsed;
  11715. private _fullEngine;
  11716. private _cachedDefines;
  11717. private _contentUpdateId;
  11718. private _contentData;
  11719. /**
  11720. * Instantiates a new procedural texture.
  11721. * 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.
  11722. * This is the base class of any Procedural texture and contains most of the shareable code.
  11723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11724. * @param name Define the name of the texture
  11725. * @param size Define the size of the texture to create
  11726. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11727. * @param scene Define the scene the texture belongs to
  11728. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11729. * @param generateMipMaps Define if the texture should creates mip maps or not
  11730. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11731. */
  11732. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11733. /**
  11734. * The effect that is created when initializing the post process.
  11735. * @returns The created effect corresponding the the postprocess.
  11736. */
  11737. getEffect(): Effect;
  11738. /**
  11739. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11740. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11741. */
  11742. getContent(): Nullable<ArrayBufferView>;
  11743. private _createIndexBuffer;
  11744. /** @hidden */
  11745. _rebuild(): void;
  11746. /**
  11747. * Resets the texture in order to recreate its associated resources.
  11748. * This can be called in case of context loss
  11749. */
  11750. reset(): void;
  11751. protected _getDefines(): string;
  11752. /**
  11753. * Is the texture ready to be used ? (rendered at least once)
  11754. * @returns true if ready, otherwise, false.
  11755. */
  11756. isReady(): boolean;
  11757. /**
  11758. * Resets the refresh counter of the texture and start bak from scratch.
  11759. * Could be useful to regenerate the texture if it is setup to render only once.
  11760. */
  11761. resetRefreshCounter(): void;
  11762. /**
  11763. * Set the fragment shader to use in order to render the texture.
  11764. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11765. */
  11766. setFragment(fragment: any): void;
  11767. /**
  11768. * Define the refresh rate of the texture or the rendering frequency.
  11769. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11770. */
  11771. get refreshRate(): number;
  11772. set refreshRate(value: number);
  11773. /** @hidden */
  11774. _shouldRender(): boolean;
  11775. /**
  11776. * Get the size the texture is rendering at.
  11777. * @returns the size (texture is always squared)
  11778. */
  11779. getRenderSize(): number;
  11780. /**
  11781. * Resize the texture to new value.
  11782. * @param size Define the new size the texture should have
  11783. * @param generateMipMaps Define whether the new texture should create mip maps
  11784. */
  11785. resize(size: number, generateMipMaps: boolean): void;
  11786. private _checkUniform;
  11787. /**
  11788. * Set a texture in the shader program used to render.
  11789. * @param name Define the name of the uniform samplers as defined in the shader
  11790. * @param texture Define the texture to bind to this sampler
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setTexture(name: string, texture: Texture): ProceduralTexture;
  11794. /**
  11795. * Set a float in the shader.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setFloat(name: string, value: number): ProceduralTexture;
  11801. /**
  11802. * Set a int in the shader.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setInt(name: string, value: number): ProceduralTexture;
  11808. /**
  11809. * Set an array of floats in the shader.
  11810. * @param name Define the name of the uniform as defined in the shader
  11811. * @param value Define the value to give to the uniform
  11812. * @return the texture itself allowing "fluent" like uniform updates
  11813. */
  11814. setFloats(name: string, value: number[]): ProceduralTexture;
  11815. /**
  11816. * Set a vec3 in the shader from a Color3.
  11817. * @param name Define the name of the uniform as defined in the shader
  11818. * @param value Define the value to give to the uniform
  11819. * @return the texture itself allowing "fluent" like uniform updates
  11820. */
  11821. setColor3(name: string, value: Color3): ProceduralTexture;
  11822. /**
  11823. * Set a vec4 in the shader from a Color4.
  11824. * @param name Define the name of the uniform as defined in the shader
  11825. * @param value Define the value to give to the uniform
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setColor4(name: string, value: Color4): ProceduralTexture;
  11829. /**
  11830. * Set a vec2 in the shader from a Vector2.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setVector2(name: string, value: Vector2): ProceduralTexture;
  11836. /**
  11837. * Set a vec3 in the shader from a Vector3.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setVector3(name: string, value: Vector3): ProceduralTexture;
  11843. /**
  11844. * Set a mat4 in the shader from a MAtrix.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11850. /**
  11851. * Render the texture to its associated render target.
  11852. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11853. */
  11854. render(useCameraPostProcess?: boolean): void;
  11855. /**
  11856. * Clone the texture.
  11857. * @returns the cloned texture
  11858. */
  11859. clone(): ProceduralTexture;
  11860. /**
  11861. * Dispose the texture and release its asoociated resources.
  11862. */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * This represents the base class for particle system in Babylon.
  11869. * 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.
  11870. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11871. * @example https://doc.babylonjs.com/babylon101/particles
  11872. */
  11873. export class BaseParticleSystem {
  11874. /**
  11875. * Source color is added to the destination color without alpha affecting the result
  11876. */
  11877. static BLENDMODE_ONEONE: number;
  11878. /**
  11879. * Blend current color and particle color using particle’s alpha
  11880. */
  11881. static BLENDMODE_STANDARD: number;
  11882. /**
  11883. * Add current color and particle color multiplied by particle’s alpha
  11884. */
  11885. static BLENDMODE_ADD: number;
  11886. /**
  11887. * Multiply current color with particle color
  11888. */
  11889. static BLENDMODE_MULTIPLY: number;
  11890. /**
  11891. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11892. */
  11893. static BLENDMODE_MULTIPLYADD: number;
  11894. /**
  11895. * List of animations used by the particle system.
  11896. */
  11897. animations: Animation[];
  11898. /**
  11899. * Gets or sets the unique id of the particle system
  11900. */
  11901. uniqueId: number;
  11902. /**
  11903. * The id of the Particle system.
  11904. */
  11905. id: string;
  11906. /**
  11907. * The friendly name of the Particle system.
  11908. */
  11909. name: string;
  11910. /**
  11911. * Snippet ID if the particle system was created from the snippet server
  11912. */
  11913. snippetId: string;
  11914. /**
  11915. * The rendering group used by the Particle system to chose when to render.
  11916. */
  11917. renderingGroupId: number;
  11918. /**
  11919. * The emitter represents the Mesh or position we are attaching the particle system to.
  11920. */
  11921. emitter: Nullable<AbstractMesh | Vector3>;
  11922. /**
  11923. * The maximum number of particles to emit per frame
  11924. */
  11925. emitRate: number;
  11926. /**
  11927. * If you want to launch only a few particles at once, that can be done, as well.
  11928. */
  11929. manualEmitCount: number;
  11930. /**
  11931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11932. */
  11933. updateSpeed: number;
  11934. /**
  11935. * The amount of time the particle system is running (depends of the overall update speed).
  11936. */
  11937. targetStopDuration: number;
  11938. /**
  11939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11940. */
  11941. disposeOnStop: boolean;
  11942. /**
  11943. * Minimum power of emitting particles.
  11944. */
  11945. minEmitPower: number;
  11946. /**
  11947. * Maximum power of emitting particles.
  11948. */
  11949. maxEmitPower: number;
  11950. /**
  11951. * Minimum life time of emitting particles.
  11952. */
  11953. minLifeTime: number;
  11954. /**
  11955. * Maximum life time of emitting particles.
  11956. */
  11957. maxLifeTime: number;
  11958. /**
  11959. * Minimum Size of emitting particles.
  11960. */
  11961. minSize: number;
  11962. /**
  11963. * Maximum Size of emitting particles.
  11964. */
  11965. maxSize: number;
  11966. /**
  11967. * Minimum scale of emitting particles on X axis.
  11968. */
  11969. minScaleX: number;
  11970. /**
  11971. * Maximum scale of emitting particles on X axis.
  11972. */
  11973. maxScaleX: number;
  11974. /**
  11975. * Minimum scale of emitting particles on Y axis.
  11976. */
  11977. minScaleY: number;
  11978. /**
  11979. * Maximum scale of emitting particles on Y axis.
  11980. */
  11981. maxScaleY: number;
  11982. /**
  11983. * Gets or sets the minimal initial rotation in radians.
  11984. */
  11985. minInitialRotation: number;
  11986. /**
  11987. * Gets or sets the maximal initial rotation in radians.
  11988. */
  11989. maxInitialRotation: number;
  11990. /**
  11991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. minAngularSpeed: number;
  11994. /**
  11995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11996. */
  11997. maxAngularSpeed: number;
  11998. /**
  11999. * The texture used to render each particle. (this can be a spritesheet)
  12000. */
  12001. particleTexture: Nullable<Texture>;
  12002. /**
  12003. * The layer mask we are rendering the particles through.
  12004. */
  12005. layerMask: number;
  12006. /**
  12007. * This can help using your own shader to render the particle system.
  12008. * The according effect will be created
  12009. */
  12010. customShader: any;
  12011. /**
  12012. * By default particle system starts as soon as they are created. This prevents the
  12013. * automatic start to happen and let you decide when to start emitting particles.
  12014. */
  12015. preventAutoStart: boolean;
  12016. private _noiseTexture;
  12017. /**
  12018. * Gets or sets a texture used to add random noise to particle positions
  12019. */
  12020. get noiseTexture(): Nullable<ProceduralTexture>;
  12021. set noiseTexture(value: Nullable<ProceduralTexture>);
  12022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12023. noiseStrength: Vector3;
  12024. /**
  12025. * Callback triggered when the particle animation is ending.
  12026. */
  12027. onAnimationEnd: Nullable<() => void>;
  12028. /**
  12029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12030. */
  12031. blendMode: number;
  12032. /**
  12033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12034. * to override the particles.
  12035. */
  12036. forceDepthWrite: boolean;
  12037. /** 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 */
  12038. preWarmCycles: number;
  12039. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12040. preWarmStepOffset: number;
  12041. /**
  12042. * 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)
  12043. */
  12044. spriteCellChangeSpeed: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12047. */
  12048. startSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12051. */
  12052. endSpriteCellID: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12055. */
  12056. spriteCellWidth: number;
  12057. /**
  12058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12059. */
  12060. spriteCellHeight: number;
  12061. /**
  12062. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12063. */
  12064. spriteRandomStartCell: boolean;
  12065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12066. translationPivot: Vector2;
  12067. /** @hidden */
  12068. protected _isAnimationSheetEnabled: boolean;
  12069. /**
  12070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12071. */
  12072. beginAnimationOnStart: boolean;
  12073. /**
  12074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationFrom: number;
  12077. /**
  12078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationTo: number;
  12081. /**
  12082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12083. */
  12084. beginAnimationLoop: boolean;
  12085. /**
  12086. * Gets or sets a world offset applied to all particles
  12087. */
  12088. worldOffset: Vector3;
  12089. /**
  12090. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12091. */
  12092. get isAnimationSheetEnabled(): boolean;
  12093. set isAnimationSheetEnabled(value: boolean);
  12094. /**
  12095. * Get hosting scene
  12096. * @returns the scene
  12097. */
  12098. getScene(): Scene;
  12099. /**
  12100. * You can use gravity if you want to give an orientation to your particles.
  12101. */
  12102. gravity: Vector3;
  12103. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12104. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12106. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12107. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12109. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12110. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12111. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12112. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12113. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12115. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12116. /**
  12117. * Defines the delay in milliseconds before starting the system (0 by default)
  12118. */
  12119. startDelay: number;
  12120. /**
  12121. * Gets the current list of drag gradients.
  12122. * You must use addDragGradient and removeDragGradient to udpate this list
  12123. * @returns the list of drag gradients
  12124. */
  12125. getDragGradients(): Nullable<Array<FactorGradient>>;
  12126. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12127. limitVelocityDamping: number;
  12128. /**
  12129. * Gets the current list of limit velocity gradients.
  12130. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12131. * @returns the list of limit velocity gradients
  12132. */
  12133. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of color gradients.
  12136. * You must use addColorGradient and removeColorGradient to udpate this list
  12137. * @returns the list of color gradients
  12138. */
  12139. getColorGradients(): Nullable<Array<ColorGradient>>;
  12140. /**
  12141. * Gets the current list of size gradients.
  12142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12143. * @returns the list of size gradients
  12144. */
  12145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of color remap gradients.
  12148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12149. * @returns the list of color remap gradients
  12150. */
  12151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of alpha remap gradients.
  12154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12155. * @returns the list of alpha remap gradients
  12156. */
  12157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Gets the current list of life time gradients.
  12160. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12161. * @returns the list of life time gradients
  12162. */
  12163. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12164. /**
  12165. * Gets the current list of angular speed gradients.
  12166. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12167. * @returns the list of angular speed gradients
  12168. */
  12169. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12170. /**
  12171. * Gets the current list of velocity gradients.
  12172. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12173. * @returns the list of velocity gradients
  12174. */
  12175. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12176. /**
  12177. * Gets the current list of start size gradients.
  12178. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12179. * @returns the list of start size gradients
  12180. */
  12181. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12182. /**
  12183. * Gets the current list of emit rate gradients.
  12184. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12185. * @returns the list of emit rate gradients
  12186. */
  12187. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12188. /**
  12189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12191. */
  12192. get direction1(): Vector3;
  12193. set direction1(value: Vector3);
  12194. /**
  12195. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12197. */
  12198. get direction2(): Vector3;
  12199. set direction2(value: Vector3);
  12200. /**
  12201. * 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.
  12202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12203. */
  12204. get minEmitBox(): Vector3;
  12205. set minEmitBox(value: Vector3);
  12206. /**
  12207. * 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.
  12208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12209. */
  12210. get maxEmitBox(): Vector3;
  12211. set maxEmitBox(value: Vector3);
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color1: Color4;
  12216. /**
  12217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12218. */
  12219. color2: Color4;
  12220. /**
  12221. * Color the particle will have at the end of its lifetime
  12222. */
  12223. colorDead: Color4;
  12224. /**
  12225. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12226. */
  12227. textureMask: Color4;
  12228. /**
  12229. * The particle emitter type defines the emitter used by the particle system.
  12230. * It can be for example box, sphere, or cone...
  12231. */
  12232. particleEmitterType: IParticleEmitterType;
  12233. /** @hidden */
  12234. _isSubEmitter: boolean;
  12235. /**
  12236. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12237. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12238. */
  12239. billboardMode: number;
  12240. protected _isBillboardBased: boolean;
  12241. /**
  12242. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12243. */
  12244. get isBillboardBased(): boolean;
  12245. set isBillboardBased(value: boolean);
  12246. /**
  12247. * The scene the particle system belongs to.
  12248. */
  12249. protected _scene: Scene;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * 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.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * 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)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param scene defines the hosting scene
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * This represents a particle system in Babylon.
  12448. * 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.
  12449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12450. * @example https://doc.babylonjs.com/babylon101/particles
  12451. */
  12452. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12453. /**
  12454. * Billboard mode will only apply to Y axis
  12455. */
  12456. static readonly BILLBOARDMODE_Y: number;
  12457. /**
  12458. * Billboard mode will apply to all axes
  12459. */
  12460. static readonly BILLBOARDMODE_ALL: number;
  12461. /**
  12462. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12463. */
  12464. static readonly BILLBOARDMODE_STRETCHED: number;
  12465. /**
  12466. * This function can be defined to provide custom update for active particles.
  12467. * This function will be called instead of regular update (age, position, color, etc.).
  12468. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12469. */
  12470. updateFunction: (particles: Particle[]) => void;
  12471. private _emitterWorldMatrix;
  12472. /**
  12473. * This function can be defined to specify initial direction for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * This function can be defined to specify initial position for every new particle.
  12479. * It by default use the emitterType defined function
  12480. */
  12481. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12482. /**
  12483. * @hidden
  12484. */
  12485. _inheritedVelocityOffset: Vector3;
  12486. /**
  12487. * An event triggered when the system is disposed
  12488. */
  12489. onDisposeObservable: Observable<IParticleSystem>;
  12490. private _onDisposeObserver;
  12491. /**
  12492. * Sets a callback that will be triggered when the system is disposed
  12493. */
  12494. set onDispose(callback: () => void);
  12495. private _particles;
  12496. private _epsilon;
  12497. private _capacity;
  12498. private _stockParticles;
  12499. private _newPartsExcess;
  12500. private _vertexData;
  12501. private _vertexBuffer;
  12502. private _vertexBuffers;
  12503. private _spriteBuffer;
  12504. private _indexBuffer;
  12505. private _effect;
  12506. private _customEffect;
  12507. private _cachedDefines;
  12508. private _scaledColorStep;
  12509. private _colorDiff;
  12510. private _scaledDirection;
  12511. private _scaledGravity;
  12512. private _currentRenderId;
  12513. private _alive;
  12514. private _useInstancing;
  12515. private _started;
  12516. private _stopped;
  12517. private _actualFrame;
  12518. private _scaledUpdateSpeed;
  12519. private _vertexBufferSize;
  12520. /** @hidden */
  12521. _currentEmitRateGradient: Nullable<FactorGradient>;
  12522. /** @hidden */
  12523. _currentEmitRate1: number;
  12524. /** @hidden */
  12525. _currentEmitRate2: number;
  12526. /** @hidden */
  12527. _currentStartSizeGradient: Nullable<FactorGradient>;
  12528. /** @hidden */
  12529. _currentStartSize1: number;
  12530. /** @hidden */
  12531. _currentStartSize2: number;
  12532. private readonly _rawTextureWidth;
  12533. private _rampGradientsTexture;
  12534. private _useRampGradients;
  12535. /** Gets or sets a boolean indicating that ramp gradients must be used
  12536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12537. */
  12538. get useRampGradients(): boolean;
  12539. set useRampGradients(value: boolean);
  12540. /**
  12541. * 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.
  12542. * 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: [])
  12543. */
  12544. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12545. private _subEmitters;
  12546. /**
  12547. * @hidden
  12548. * If the particle systems emitter should be disposed when the particle system is disposed
  12549. */
  12550. _disposeEmitterOnDispose: boolean;
  12551. /**
  12552. * The current active Sub-systems, this property is used by the root particle system only.
  12553. */
  12554. activeSubSystems: Array<ParticleSystem>;
  12555. /**
  12556. * Specifies if the particles are updated in emitter local space or world space
  12557. */
  12558. isLocal: boolean;
  12559. private _rootParticleSystem;
  12560. /**
  12561. * Gets the current list of active particles
  12562. */
  12563. get particles(): Particle[];
  12564. /**
  12565. * Gets the number of particles active at the same time.
  12566. * @returns The number of active particles.
  12567. */
  12568. getActiveCount(): number;
  12569. /**
  12570. * Returns the string "ParticleSystem"
  12571. * @returns a string containing the class name
  12572. */
  12573. getClassName(): string;
  12574. /**
  12575. * Gets a boolean indicating that the system is stopping
  12576. * @returns true if the system is currently stopping
  12577. */
  12578. isStopping(): boolean;
  12579. /**
  12580. * Gets the custom effect used to render the particles
  12581. * @param blendMode Blend mode for which the effect should be retrieved
  12582. * @returns The effect
  12583. */
  12584. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12585. /**
  12586. * Sets the custom effect used to render the particles
  12587. * @param effect The effect to set
  12588. * @param blendMode Blend mode for which the effect should be set
  12589. */
  12590. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12591. /** @hidden */
  12592. private _onBeforeDrawParticlesObservable;
  12593. /**
  12594. * Observable that will be called just before the particles are drawn
  12595. */
  12596. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12597. /**
  12598. * Gets the name of the particle vertex shader
  12599. */
  12600. get vertexShaderName(): string;
  12601. /**
  12602. * Instantiates a particle system.
  12603. * 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.
  12604. * @param name The name of the particle system
  12605. * @param capacity The max number of particles alive at the same time
  12606. * @param scene The scene the particle system belongs to
  12607. * @param customEffect a custom effect used to change the way particles are rendered by default
  12608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12609. * @param epsilon Offset used to render the particles
  12610. */
  12611. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12612. private _addFactorGradient;
  12613. private _removeFactorGradient;
  12614. /**
  12615. * Adds a new life time gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the life time factor to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific life time gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new size gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the size factor to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific size gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeSizeGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new color remap gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param min defines the color remap minimal range
  12646. * @param max defines the color remap maximal range
  12647. * @returns the current particle system
  12648. */
  12649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific color remap gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeColorRemapGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new alpha remap gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param min defines the alpha remap minimal range
  12660. * @param max defines the alpha remap maximal range
  12661. * @returns the current particle system
  12662. */
  12663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific alpha remap gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new angular speed gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the angular speed to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific angular speed gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new velocity gradient
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the velocity to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific velocity gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeVelocityGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new limit velocity gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the limit velocity value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific limit velocity gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12712. /**
  12713. * Adds a new drag gradient
  12714. * @param gradient defines the gradient to use (between 0 and 1)
  12715. * @param factor defines the drag value to affect to the specified gradient
  12716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12717. * @returns the current particle system
  12718. */
  12719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12720. /**
  12721. * Remove a specific drag gradient
  12722. * @param gradient defines the gradient to remove
  12723. * @returns the current particle system
  12724. */
  12725. removeDragGradient(gradient: number): IParticleSystem;
  12726. /**
  12727. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12728. * @param gradient defines the gradient to use (between 0 and 1)
  12729. * @param factor defines the emit rate value to affect to the specified gradient
  12730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12731. * @returns the current particle system
  12732. */
  12733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12734. /**
  12735. * Remove a specific emit rate gradient
  12736. * @param gradient defines the gradient to remove
  12737. * @returns the current particle system
  12738. */
  12739. removeEmitRateGradient(gradient: number): IParticleSystem;
  12740. /**
  12741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the start size value to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific start size gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeStartSizeGradient(gradient: number): IParticleSystem;
  12754. private _createRampGradientTexture;
  12755. /**
  12756. * Gets the current list of ramp gradients.
  12757. * You must use addRampGradient and removeRampGradient to udpate this list
  12758. * @returns the list of ramp gradients
  12759. */
  12760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12761. /** Force the system to rebuild all gradients that need to be resync */
  12762. forceRefreshGradients(): void;
  12763. private _syncRampGradientTexture;
  12764. /**
  12765. * Adds a new ramp gradient used to remap particle colors
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param color defines the color to affect to the specified gradient
  12768. * @returns the current particle system
  12769. */
  12770. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12771. /**
  12772. * Remove a specific ramp gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeRampGradient(gradient: number): ParticleSystem;
  12777. /**
  12778. * Adds a new color gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param color1 defines the color to affect to the specified gradient
  12781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12782. * @returns this particle system
  12783. */
  12784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12785. /**
  12786. * Remove a specific color gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns this particle system
  12789. */
  12790. removeColorGradient(gradient: number): IParticleSystem;
  12791. private _fetchR;
  12792. protected _reset(): void;
  12793. private _resetEffect;
  12794. private _createVertexBuffers;
  12795. private _createIndexBuffer;
  12796. /**
  12797. * Gets the maximum number of particles active at the same time.
  12798. * @returns The max number of active particles.
  12799. */
  12800. getCapacity(): number;
  12801. /**
  12802. * Gets whether there are still active particles in the system.
  12803. * @returns True if it is alive, otherwise false.
  12804. */
  12805. isAlive(): boolean;
  12806. /**
  12807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12808. * @returns True if it has been started, otherwise false.
  12809. */
  12810. isStarted(): boolean;
  12811. private _prepareSubEmitterInternalArray;
  12812. /**
  12813. * Starts the particle system and begins to emit
  12814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12815. */
  12816. start(delay?: number): void;
  12817. /**
  12818. * Stops the particle system.
  12819. * @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.
  12820. */
  12821. stop(stopSubEmitters?: boolean): void;
  12822. /**
  12823. * Remove all active particles
  12824. */
  12825. reset(): void;
  12826. /**
  12827. * @hidden (for internal use only)
  12828. */
  12829. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12830. /**
  12831. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12832. * Its lifetime will start back at 0.
  12833. */
  12834. recycleParticle: (particle: Particle) => void;
  12835. private _stopSubEmitters;
  12836. private _createParticle;
  12837. private _removeFromRoot;
  12838. private _emitFromParticle;
  12839. private _update;
  12840. /** @hidden */
  12841. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12842. /** @hidden */
  12843. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12844. /**
  12845. * Fill the defines array according to the current settings of the particle system
  12846. * @param defines Array to be updated
  12847. * @param blendMode blend mode to take into account when updating the array
  12848. */
  12849. fillDefines(defines: Array<string>, blendMode: number): void;
  12850. /**
  12851. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12852. * @param uniforms Uniforms array to fill
  12853. * @param attributes Attributes array to fill
  12854. * @param samplers Samplers array to fill
  12855. */
  12856. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12857. /** @hidden */
  12858. private _getEffect;
  12859. /**
  12860. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12861. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12862. */
  12863. animate(preWarmOnly?: boolean): void;
  12864. private _appendParticleVertices;
  12865. /**
  12866. * Rebuilds the particle system.
  12867. */
  12868. rebuild(): void;
  12869. /**
  12870. * Is this system ready to be used/rendered
  12871. * @return true if the system is ready
  12872. */
  12873. isReady(): boolean;
  12874. private _render;
  12875. /**
  12876. * Renders the particle system in its current state.
  12877. * @returns the current number of particles
  12878. */
  12879. render(): number;
  12880. /**
  12881. * Disposes the particle system and free the associated resources
  12882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12883. */
  12884. dispose(disposeTexture?: boolean): void;
  12885. /**
  12886. * Clones the particle system.
  12887. * @param name The name of the cloned object
  12888. * @param newEmitter The new emitter to use
  12889. * @returns the cloned particle system
  12890. */
  12891. clone(name: string, newEmitter: any): ParticleSystem;
  12892. /**
  12893. * Serializes the particle system to a JSON object
  12894. * @param serializeTexture defines if the texture must be serialized as well
  12895. * @returns the JSON object
  12896. */
  12897. serialize(serializeTexture?: boolean): any;
  12898. /** @hidden */
  12899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12900. /** @hidden */
  12901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12902. /**
  12903. * Parses a JSON object to create a particle system.
  12904. * @param parsedParticleSystem The JSON object to parse
  12905. * @param scene The scene to create the particle system in
  12906. * @param rootUrl The root url to use to load external dependencies like texture
  12907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12908. * @returns the Parsed particle system
  12909. */
  12910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * A particle represents one of the element emitted by a particle system.
  12916. * This is mainly define by its coordinates, direction, velocity and age.
  12917. */
  12918. export class Particle {
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem;
  12923. private static _Count;
  12924. /**
  12925. * Unique ID of the particle
  12926. */
  12927. id: number;
  12928. /**
  12929. * The world position of the particle in the scene.
  12930. */
  12931. position: Vector3;
  12932. /**
  12933. * The world direction of the particle in the scene.
  12934. */
  12935. direction: Vector3;
  12936. /**
  12937. * The color of the particle.
  12938. */
  12939. color: Color4;
  12940. /**
  12941. * The color change of the particle per step.
  12942. */
  12943. colorStep: Color4;
  12944. /**
  12945. * Defines how long will the life of the particle be.
  12946. */
  12947. lifeTime: number;
  12948. /**
  12949. * The current age of the particle.
  12950. */
  12951. age: number;
  12952. /**
  12953. * The current size of the particle.
  12954. */
  12955. size: number;
  12956. /**
  12957. * The current scale of the particle.
  12958. */
  12959. scale: Vector2;
  12960. /**
  12961. * The current angle of the particle.
  12962. */
  12963. angle: number;
  12964. /**
  12965. * Defines how fast is the angle changing.
  12966. */
  12967. angularSpeed: number;
  12968. /**
  12969. * Defines the cell index used by the particle to be rendered from a sprite.
  12970. */
  12971. cellIndex: number;
  12972. /**
  12973. * The information required to support color remapping
  12974. */
  12975. remapData: Vector4;
  12976. /** @hidden */
  12977. _randomCellOffset?: number;
  12978. /** @hidden */
  12979. _initialDirection: Nullable<Vector3>;
  12980. /** @hidden */
  12981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12982. /** @hidden */
  12983. _initialStartSpriteCellID: number;
  12984. /** @hidden */
  12985. _initialEndSpriteCellID: number;
  12986. /** @hidden */
  12987. _currentColorGradient: Nullable<ColorGradient>;
  12988. /** @hidden */
  12989. _currentColor1: Color4;
  12990. /** @hidden */
  12991. _currentColor2: Color4;
  12992. /** @hidden */
  12993. _currentSizeGradient: Nullable<FactorGradient>;
  12994. /** @hidden */
  12995. _currentSize1: number;
  12996. /** @hidden */
  12997. _currentSize2: number;
  12998. /** @hidden */
  12999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13000. /** @hidden */
  13001. _currentAngularSpeed1: number;
  13002. /** @hidden */
  13003. _currentAngularSpeed2: number;
  13004. /** @hidden */
  13005. _currentVelocityGradient: Nullable<FactorGradient>;
  13006. /** @hidden */
  13007. _currentVelocity1: number;
  13008. /** @hidden */
  13009. _currentVelocity2: number;
  13010. /** @hidden */
  13011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13012. /** @hidden */
  13013. _currentLimitVelocity1: number;
  13014. /** @hidden */
  13015. _currentLimitVelocity2: number;
  13016. /** @hidden */
  13017. _currentDragGradient: Nullable<FactorGradient>;
  13018. /** @hidden */
  13019. _currentDrag1: number;
  13020. /** @hidden */
  13021. _currentDrag2: number;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates1: Vector3;
  13024. /** @hidden */
  13025. _randomNoiseCoordinates2: Vector3;
  13026. /** @hidden */
  13027. _localPosition?: Vector3;
  13028. /**
  13029. * Creates a new instance Particle
  13030. * @param particleSystem the particle system the particle belongs to
  13031. */
  13032. constructor(
  13033. /**
  13034. * The particle system the particle belongs to.
  13035. */
  13036. particleSystem: ParticleSystem);
  13037. private updateCellInfoFromSystem;
  13038. /**
  13039. * Defines how the sprite cell index is updated for the particle
  13040. */
  13041. updateCellIndex(): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13044. /** @hidden */
  13045. _inheritParticleInfoToSubEmitters(): void;
  13046. /** @hidden */
  13047. _reset(): void;
  13048. /**
  13049. * Copy the properties of particle to another one.
  13050. * @param other the particle to copy the information to.
  13051. */
  13052. copyTo(other: Particle): void;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Particle emitter represents a volume emitting particles.
  13058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13059. */
  13060. export interface IParticleEmitterType {
  13061. /**
  13062. * Called by the particle System when the direction is computed for the created particle.
  13063. * @param worldMatrix is the world matrix of the particle system
  13064. * @param directionToUpdate is the direction vector to update with the result
  13065. * @param particle is the particle we are computed the direction for
  13066. * @param isLocal defines if the direction should be set in local space
  13067. */
  13068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13069. /**
  13070. * Called by the particle System when the position is computed for the created particle.
  13071. * @param worldMatrix is the world matrix of the particle system
  13072. * @param positionToUpdate is the position vector to update with the result
  13073. * @param particle is the particle we are computed the position for
  13074. * @param isLocal defines if the position should be set in local space
  13075. */
  13076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13077. /**
  13078. * Clones the current emitter and returns a copy of it
  13079. * @returns the new emitter
  13080. */
  13081. clone(): IParticleEmitterType;
  13082. /**
  13083. * Called by the GPUParticleSystem to setup the update shader
  13084. * @param effect defines the update shader
  13085. */
  13086. applyToShader(effect: Effect): void;
  13087. /**
  13088. * Returns a string to use to update the GPU particles update shader
  13089. * @returns the effect defines string
  13090. */
  13091. getEffectDefines(): string;
  13092. /**
  13093. * Returns a string representing the class name
  13094. * @returns a string containing the class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Serializes the particle system to a JSON object.
  13099. * @returns the JSON object
  13100. */
  13101. serialize(): any;
  13102. /**
  13103. * Parse properties from a JSON object
  13104. * @param serializationObject defines the JSON object
  13105. * @param scene defines the hosting scene
  13106. */
  13107. parse(serializationObject: any, scene: Scene): void;
  13108. }
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Particle emitter emitting particles from the inside of a box.
  13113. * It emits the particles randomly between 2 given directions.
  13114. */
  13115. export class BoxParticleEmitter implements IParticleEmitterType {
  13116. /**
  13117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13118. */
  13119. direction1: Vector3;
  13120. /**
  13121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13122. */
  13123. direction2: Vector3;
  13124. /**
  13125. * 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.
  13126. */
  13127. minEmitBox: Vector3;
  13128. /**
  13129. * 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.
  13130. */
  13131. maxEmitBox: Vector3;
  13132. /**
  13133. * Creates a new instance BoxParticleEmitter
  13134. */
  13135. constructor();
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. * @param isLocal defines if the direction should be set in local space
  13142. */
  13143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13144. /**
  13145. * Called by the particle System when the position is computed for the created particle.
  13146. * @param worldMatrix is the world matrix of the particle system
  13147. * @param positionToUpdate is the position vector to update with the result
  13148. * @param particle is the particle we are computed the position for
  13149. * @param isLocal defines if the position should be set in local space
  13150. */
  13151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13152. /**
  13153. * Clones the current emitter and returns a copy of it
  13154. * @returns the new emitter
  13155. */
  13156. clone(): BoxParticleEmitter;
  13157. /**
  13158. * Called by the GPUParticleSystem to setup the update shader
  13159. * @param effect defines the update shader
  13160. */
  13161. applyToShader(effect: Effect): void;
  13162. /**
  13163. * Returns a string to use to update the GPU particles update shader
  13164. * @returns a string containng the defines string
  13165. */
  13166. getEffectDefines(): string;
  13167. /**
  13168. * Returns the string "BoxParticleEmitter"
  13169. * @returns a string containing the class name
  13170. */
  13171. getClassName(): string;
  13172. /**
  13173. * Serializes the particle system to a JSON object.
  13174. * @returns the JSON object
  13175. */
  13176. serialize(): any;
  13177. /**
  13178. * Parse properties from a JSON object
  13179. * @param serializationObject defines the JSON object
  13180. */
  13181. parse(serializationObject: any): void;
  13182. }
  13183. }
  13184. declare module BABYLON {
  13185. /**
  13186. * Particle emitter emitting particles from the inside of a cone.
  13187. * It emits the particles alongside the cone volume from the base to the particle.
  13188. * The emission direction might be randomized.
  13189. */
  13190. export class ConeParticleEmitter implements IParticleEmitterType {
  13191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13192. directionRandomizer: number;
  13193. private _radius;
  13194. private _angle;
  13195. private _height;
  13196. /**
  13197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13198. */
  13199. radiusRange: number;
  13200. /**
  13201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13202. */
  13203. heightRange: number;
  13204. /**
  13205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13206. */
  13207. emitFromSpawnPointOnly: boolean;
  13208. /**
  13209. * Gets or sets the radius of the emission cone
  13210. */
  13211. get radius(): number;
  13212. set radius(value: number);
  13213. /**
  13214. * Gets or sets the angle of the emission cone
  13215. */
  13216. get angle(): number;
  13217. set angle(value: number);
  13218. private _buildHeight;
  13219. /**
  13220. * Creates a new instance ConeParticleEmitter
  13221. * @param radius the radius of the emission cone (1 by default)
  13222. * @param angle the cone base angle (PI by default)
  13223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13224. */
  13225. constructor(radius?: number, angle?: number,
  13226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13227. directionRandomizer?: number);
  13228. /**
  13229. * Called by the particle System when the direction is computed for the created particle.
  13230. * @param worldMatrix is the world matrix of the particle system
  13231. * @param directionToUpdate is the direction vector to update with the result
  13232. * @param particle is the particle we are computed the direction for
  13233. * @param isLocal defines if the direction should be set in local space
  13234. */
  13235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13236. /**
  13237. * Called by the particle System when the position is computed for the created particle.
  13238. * @param worldMatrix is the world matrix of the particle system
  13239. * @param positionToUpdate is the position vector to update with the result
  13240. * @param particle is the particle we are computed the position for
  13241. * @param isLocal defines if the position should be set in local space
  13242. */
  13243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13244. /**
  13245. * Clones the current emitter and returns a copy of it
  13246. * @returns the new emitter
  13247. */
  13248. clone(): ConeParticleEmitter;
  13249. /**
  13250. * Called by the GPUParticleSystem to setup the update shader
  13251. * @param effect defines the update shader
  13252. */
  13253. applyToShader(effect: Effect): void;
  13254. /**
  13255. * Returns a string to use to update the GPU particles update shader
  13256. * @returns a string containng the defines string
  13257. */
  13258. getEffectDefines(): string;
  13259. /**
  13260. * Returns the string "ConeParticleEmitter"
  13261. * @returns a string containing the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Serializes the particle system to a JSON object.
  13266. * @returns the JSON object
  13267. */
  13268. serialize(): any;
  13269. /**
  13270. * Parse properties from a JSON object
  13271. * @param serializationObject defines the JSON object
  13272. */
  13273. parse(serializationObject: any): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Particle emitter emitting particles from the inside of a cylinder.
  13279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13280. */
  13281. export class CylinderParticleEmitter implements IParticleEmitterType {
  13282. /**
  13283. * The radius of the emission cylinder.
  13284. */
  13285. radius: number;
  13286. /**
  13287. * The height of the emission cylinder.
  13288. */
  13289. height: number;
  13290. /**
  13291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13292. */
  13293. radiusRange: number;
  13294. /**
  13295. * How much to randomize the particle direction [0-1].
  13296. */
  13297. directionRandomizer: number;
  13298. /**
  13299. * Creates a new instance CylinderParticleEmitter
  13300. * @param radius the radius of the emission cylinder (1 by default)
  13301. * @param height the height of the emission cylinder (1 by default)
  13302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13304. */
  13305. constructor(
  13306. /**
  13307. * The radius of the emission cylinder.
  13308. */
  13309. radius?: number,
  13310. /**
  13311. * The height of the emission cylinder.
  13312. */
  13313. height?: number,
  13314. /**
  13315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13316. */
  13317. radiusRange?: number,
  13318. /**
  13319. * How much to randomize the particle direction [0-1].
  13320. */
  13321. directionRandomizer?: number);
  13322. /**
  13323. * Called by the particle System when the direction is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param directionToUpdate is the direction vector to update with the result
  13326. * @param particle is the particle we are computed the direction for
  13327. * @param isLocal defines if the direction should be set in local space
  13328. */
  13329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Called by the particle System when the position is computed for the created particle.
  13332. * @param worldMatrix is the world matrix of the particle system
  13333. * @param positionToUpdate is the position vector to update with the result
  13334. * @param particle is the particle we are computed the position for
  13335. * @param isLocal defines if the position should be set in local space
  13336. */
  13337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13338. /**
  13339. * Clones the current emitter and returns a copy of it
  13340. * @returns the new emitter
  13341. */
  13342. clone(): CylinderParticleEmitter;
  13343. /**
  13344. * Called by the GPUParticleSystem to setup the update shader
  13345. * @param effect defines the update shader
  13346. */
  13347. applyToShader(effect: Effect): void;
  13348. /**
  13349. * Returns a string to use to update the GPU particles update shader
  13350. * @returns a string containng the defines string
  13351. */
  13352. getEffectDefines(): string;
  13353. /**
  13354. * Returns the string "CylinderParticleEmitter"
  13355. * @returns a string containing the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Serializes the particle system to a JSON object.
  13360. * @returns the JSON object
  13361. */
  13362. serialize(): any;
  13363. /**
  13364. * Parse properties from a JSON object
  13365. * @param serializationObject defines the JSON object
  13366. */
  13367. parse(serializationObject: any): void;
  13368. }
  13369. /**
  13370. * Particle emitter emitting particles from the inside of a cylinder.
  13371. * It emits the particles randomly between two vectors.
  13372. */
  13373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13374. /**
  13375. * The min limit of the emission direction.
  13376. */
  13377. direction1: Vector3;
  13378. /**
  13379. * The max limit of the emission direction.
  13380. */
  13381. direction2: Vector3;
  13382. /**
  13383. * Creates a new instance CylinderDirectedParticleEmitter
  13384. * @param radius the radius of the emission cylinder (1 by default)
  13385. * @param height the height of the emission cylinder (1 by default)
  13386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13387. * @param direction1 the min limit of the emission direction (up vector by default)
  13388. * @param direction2 the max limit of the emission direction (up vector by default)
  13389. */
  13390. constructor(radius?: number, height?: number, radiusRange?: number,
  13391. /**
  13392. * The min limit of the emission direction.
  13393. */
  13394. direction1?: Vector3,
  13395. /**
  13396. * The max limit of the emission direction.
  13397. */
  13398. direction2?: Vector3);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. */
  13405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13406. /**
  13407. * Clones the current emitter and returns a copy of it
  13408. * @returns the new emitter
  13409. */
  13410. clone(): CylinderDirectedParticleEmitter;
  13411. /**
  13412. * Called by the GPUParticleSystem to setup the update shader
  13413. * @param effect defines the update shader
  13414. */
  13415. applyToShader(effect: Effect): void;
  13416. /**
  13417. * Returns a string to use to update the GPU particles update shader
  13418. * @returns a string containng the defines string
  13419. */
  13420. getEffectDefines(): string;
  13421. /**
  13422. * Returns the string "CylinderDirectedParticleEmitter"
  13423. * @returns a string containing the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Serializes the particle system to a JSON object.
  13428. * @returns the JSON object
  13429. */
  13430. serialize(): any;
  13431. /**
  13432. * Parse properties from a JSON object
  13433. * @param serializationObject defines the JSON object
  13434. */
  13435. parse(serializationObject: any): void;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * Particle emitter emitting particles from the inside of a hemisphere.
  13441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13442. */
  13443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13444. /**
  13445. * The radius of the emission hemisphere.
  13446. */
  13447. radius: number;
  13448. /**
  13449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13450. */
  13451. radiusRange: number;
  13452. /**
  13453. * How much to randomize the particle direction [0-1].
  13454. */
  13455. directionRandomizer: number;
  13456. /**
  13457. * Creates a new instance HemisphericParticleEmitter
  13458. * @param radius the radius of the emission hemisphere (1 by default)
  13459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13461. */
  13462. constructor(
  13463. /**
  13464. * The radius of the emission hemisphere.
  13465. */
  13466. radius?: number,
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange?: number,
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer?: number);
  13475. /**
  13476. * Called by the particle System when the direction is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param directionToUpdate is the direction vector to update with the result
  13479. * @param particle is the particle we are computed the direction for
  13480. * @param isLocal defines if the direction should be set in local space
  13481. */
  13482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Called by the particle System when the position is computed for the created particle.
  13485. * @param worldMatrix is the world matrix of the particle system
  13486. * @param positionToUpdate is the position vector to update with the result
  13487. * @param particle is the particle we are computed the position for
  13488. * @param isLocal defines if the position should be set in local space
  13489. */
  13490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13491. /**
  13492. * Clones the current emitter and returns a copy of it
  13493. * @returns the new emitter
  13494. */
  13495. clone(): HemisphericParticleEmitter;
  13496. /**
  13497. * Called by the GPUParticleSystem to setup the update shader
  13498. * @param effect defines the update shader
  13499. */
  13500. applyToShader(effect: Effect): void;
  13501. /**
  13502. * Returns a string to use to update the GPU particles update shader
  13503. * @returns a string containng the defines string
  13504. */
  13505. getEffectDefines(): string;
  13506. /**
  13507. * Returns the string "HemisphericParticleEmitter"
  13508. * @returns a string containing the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Serializes the particle system to a JSON object.
  13513. * @returns the JSON object
  13514. */
  13515. serialize(): any;
  13516. /**
  13517. * Parse properties from a JSON object
  13518. * @param serializationObject defines the JSON object
  13519. */
  13520. parse(serializationObject: any): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * Particle emitter emitting particles from a point.
  13526. * It emits the particles randomly between 2 given directions.
  13527. */
  13528. export class PointParticleEmitter implements IParticleEmitterType {
  13529. /**
  13530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13531. */
  13532. direction1: Vector3;
  13533. /**
  13534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13535. */
  13536. direction2: Vector3;
  13537. /**
  13538. * Creates a new instance PointParticleEmitter
  13539. */
  13540. constructor();
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): PointParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "PointParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module BABYLON {
  13590. /**
  13591. * Particle emitter emitting particles from the inside of a sphere.
  13592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13593. */
  13594. export class SphereParticleEmitter implements IParticleEmitterType {
  13595. /**
  13596. * The radius of the emission sphere.
  13597. */
  13598. radius: number;
  13599. /**
  13600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13601. */
  13602. radiusRange: number;
  13603. /**
  13604. * How much to randomize the particle direction [0-1].
  13605. */
  13606. directionRandomizer: number;
  13607. /**
  13608. * Creates a new instance SphereParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13612. */
  13613. constructor(
  13614. /**
  13615. * The radius of the emission sphere.
  13616. */
  13617. radius?: number,
  13618. /**
  13619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13620. */
  13621. radiusRange?: number,
  13622. /**
  13623. * How much to randomize the particle direction [0-1].
  13624. */
  13625. directionRandomizer?: number);
  13626. /**
  13627. * Called by the particle System when the direction is computed for the created particle.
  13628. * @param worldMatrix is the world matrix of the particle system
  13629. * @param directionToUpdate is the direction vector to update with the result
  13630. * @param particle is the particle we are computed the direction for
  13631. * @param isLocal defines if the direction should be set in local space
  13632. */
  13633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13634. /**
  13635. * Called by the particle System when the position is computed for the created particle.
  13636. * @param worldMatrix is the world matrix of the particle system
  13637. * @param positionToUpdate is the position vector to update with the result
  13638. * @param particle is the particle we are computed the position for
  13639. * @param isLocal defines if the position should be set in local space
  13640. */
  13641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13642. /**
  13643. * Clones the current emitter and returns a copy of it
  13644. * @returns the new emitter
  13645. */
  13646. clone(): SphereParticleEmitter;
  13647. /**
  13648. * Called by the GPUParticleSystem to setup the update shader
  13649. * @param effect defines the update shader
  13650. */
  13651. applyToShader(effect: Effect): void;
  13652. /**
  13653. * Returns a string to use to update the GPU particles update shader
  13654. * @returns a string containng the defines string
  13655. */
  13656. getEffectDefines(): string;
  13657. /**
  13658. * Returns the string "SphereParticleEmitter"
  13659. * @returns a string containing the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Serializes the particle system to a JSON object.
  13664. * @returns the JSON object
  13665. */
  13666. serialize(): any;
  13667. /**
  13668. * Parse properties from a JSON object
  13669. * @param serializationObject defines the JSON object
  13670. */
  13671. parse(serializationObject: any): void;
  13672. }
  13673. /**
  13674. * Particle emitter emitting particles from the inside of a sphere.
  13675. * It emits the particles randomly between two vectors.
  13676. */
  13677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13678. /**
  13679. * The min limit of the emission direction.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * The max limit of the emission direction.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance SphereDirectedParticleEmitter
  13688. * @param radius the radius of the emission sphere (1 by default)
  13689. * @param direction1 the min limit of the emission direction (up vector by default)
  13690. * @param direction2 the max limit of the emission direction (up vector by default)
  13691. */
  13692. constructor(radius?: number,
  13693. /**
  13694. * The min limit of the emission direction.
  13695. */
  13696. direction1?: Vector3,
  13697. /**
  13698. * The max limit of the emission direction.
  13699. */
  13700. direction2?: Vector3);
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. */
  13707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): SphereDirectedParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "SphereDirectedParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a custom list of positions.
  13743. */
  13744. export class CustomParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * Gets or sets the position generator that will create the inital position of each particle.
  13747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13750. /**
  13751. * Gets or sets the destination generator that will create the final destination of each particle.
  13752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13753. */
  13754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13755. /**
  13756. * Creates a new instance CustomParticleEmitter
  13757. */
  13758. constructor();
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): CustomParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "PointParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. */
  13804. parse(serializationObject: any): void;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. /**
  13809. * Particle emitter emitting particles from the inside of a box.
  13810. * It emits the particles randomly between 2 given directions.
  13811. */
  13812. export class MeshParticleEmitter implements IParticleEmitterType {
  13813. private _indices;
  13814. private _positions;
  13815. private _normals;
  13816. private _storedNormal;
  13817. private _mesh;
  13818. /**
  13819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13820. */
  13821. direction1: Vector3;
  13822. /**
  13823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13824. */
  13825. direction2: Vector3;
  13826. /**
  13827. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13828. */
  13829. useMeshNormalsForDirection: boolean;
  13830. /** Defines the mesh to use as source */
  13831. get mesh(): Nullable<AbstractMesh>;
  13832. set mesh(value: Nullable<AbstractMesh>);
  13833. /**
  13834. * Creates a new instance MeshParticleEmitter
  13835. * @param mesh defines the mesh to use as source
  13836. */
  13837. constructor(mesh?: Nullable<AbstractMesh>);
  13838. /**
  13839. * Called by the particle System when the direction is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param directionToUpdate is the direction vector to update with the result
  13842. * @param particle is the particle we are computed the direction for
  13843. * @param isLocal defines if the direction should be set in local space
  13844. */
  13845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Called by the particle System when the position is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param positionToUpdate is the position vector to update with the result
  13850. * @param particle is the particle we are computed the position for
  13851. * @param isLocal defines if the position should be set in local space
  13852. */
  13853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Clones the current emitter and returns a copy of it
  13856. * @returns the new emitter
  13857. */
  13858. clone(): MeshParticleEmitter;
  13859. /**
  13860. * Called by the GPUParticleSystem to setup the update shader
  13861. * @param effect defines the update shader
  13862. */
  13863. applyToShader(effect: Effect): void;
  13864. /**
  13865. * Returns a string to use to update the GPU particles update shader
  13866. * @returns a string containng the defines string
  13867. */
  13868. getEffectDefines(): string;
  13869. /**
  13870. * Returns the string "BoxParticleEmitter"
  13871. * @returns a string containing the class name
  13872. */
  13873. getClassName(): string;
  13874. /**
  13875. * Serializes the particle system to a JSON object.
  13876. * @returns the JSON object
  13877. */
  13878. serialize(): any;
  13879. /**
  13880. * Parse properties from a JSON object
  13881. * @param serializationObject defines the JSON object
  13882. * @param scene defines the hosting scene
  13883. */
  13884. parse(serializationObject: any, scene: Scene): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Interface representing a particle system in Babylon.js.
  13890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13892. */
  13893. export interface IParticleSystem {
  13894. /**
  13895. * List of animations used by the particle system.
  13896. */
  13897. animations: Animation[];
  13898. /**
  13899. * The id of the Particle system.
  13900. */
  13901. id: string;
  13902. /**
  13903. * The name of the Particle system.
  13904. */
  13905. name: string;
  13906. /**
  13907. * The emitter represents the Mesh or position we are attaching the particle system to.
  13908. */
  13909. emitter: Nullable<AbstractMesh | Vector3>;
  13910. /**
  13911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13912. */
  13913. isBillboardBased: boolean;
  13914. /**
  13915. * The rendering group used by the Particle system to chose when to render.
  13916. */
  13917. renderingGroupId: number;
  13918. /**
  13919. * The layer mask we are rendering the particles through.
  13920. */
  13921. layerMask: number;
  13922. /**
  13923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13924. */
  13925. updateSpeed: number;
  13926. /**
  13927. * The amount of time the particle system is running (depends of the overall update speed).
  13928. */
  13929. targetStopDuration: number;
  13930. /**
  13931. * The texture used to render each particle. (this can be a spritesheet)
  13932. */
  13933. particleTexture: Nullable<Texture>;
  13934. /**
  13935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13936. */
  13937. blendMode: number;
  13938. /**
  13939. * Minimum life time of emitting particles.
  13940. */
  13941. minLifeTime: number;
  13942. /**
  13943. * Maximum life time of emitting particles.
  13944. */
  13945. maxLifeTime: number;
  13946. /**
  13947. * Minimum Size of emitting particles.
  13948. */
  13949. minSize: number;
  13950. /**
  13951. * Maximum Size of emitting particles.
  13952. */
  13953. maxSize: number;
  13954. /**
  13955. * Minimum scale of emitting particles on X axis.
  13956. */
  13957. minScaleX: number;
  13958. /**
  13959. * Maximum scale of emitting particles on X axis.
  13960. */
  13961. maxScaleX: number;
  13962. /**
  13963. * Minimum scale of emitting particles on Y axis.
  13964. */
  13965. minScaleY: number;
  13966. /**
  13967. * Maximum scale of emitting particles on Y axis.
  13968. */
  13969. maxScaleY: number;
  13970. /**
  13971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13972. */
  13973. color1: Color4;
  13974. /**
  13975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13976. */
  13977. color2: Color4;
  13978. /**
  13979. * Color the particle will have at the end of its lifetime.
  13980. */
  13981. colorDead: Color4;
  13982. /**
  13983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13984. */
  13985. emitRate: number;
  13986. /**
  13987. * You can use gravity if you want to give an orientation to your particles.
  13988. */
  13989. gravity: Vector3;
  13990. /**
  13991. * Minimum power of emitting particles.
  13992. */
  13993. minEmitPower: number;
  13994. /**
  13995. * Maximum power of emitting particles.
  13996. */
  13997. maxEmitPower: number;
  13998. /**
  13999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14000. */
  14001. minAngularSpeed: number;
  14002. /**
  14003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14004. */
  14005. maxAngularSpeed: number;
  14006. /**
  14007. * Gets or sets the minimal initial rotation in radians.
  14008. */
  14009. minInitialRotation: number;
  14010. /**
  14011. * Gets or sets the maximal initial rotation in radians.
  14012. */
  14013. maxInitialRotation: number;
  14014. /**
  14015. * The particle emitter type defines the emitter used by the particle system.
  14016. * It can be for example box, sphere, or cone...
  14017. */
  14018. particleEmitterType: Nullable<IParticleEmitterType>;
  14019. /**
  14020. * Defines the delay in milliseconds before starting the system (0 by default)
  14021. */
  14022. startDelay: number;
  14023. /**
  14024. * 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
  14025. */
  14026. preWarmCycles: number;
  14027. /**
  14028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14029. */
  14030. preWarmStepOffset: number;
  14031. /**
  14032. * 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)
  14033. */
  14034. spriteCellChangeSpeed: number;
  14035. /**
  14036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14037. */
  14038. startSpriteCellID: number;
  14039. /**
  14040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14041. */
  14042. endSpriteCellID: number;
  14043. /**
  14044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14045. */
  14046. spriteCellWidth: number;
  14047. /**
  14048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14049. */
  14050. spriteCellHeight: number;
  14051. /**
  14052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14053. */
  14054. spriteRandomStartCell: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14057. */
  14058. isAnimationSheetEnabled: boolean;
  14059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14060. translationPivot: Vector2;
  14061. /**
  14062. * Gets or sets a texture used to add random noise to particle positions
  14063. */
  14064. noiseTexture: Nullable<BaseTexture>;
  14065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14066. noiseStrength: Vector3;
  14067. /**
  14068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14070. */
  14071. billboardMode: number;
  14072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14073. limitVelocityDamping: number;
  14074. /**
  14075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14076. */
  14077. beginAnimationOnStart: boolean;
  14078. /**
  14079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14080. */
  14081. beginAnimationFrom: number;
  14082. /**
  14083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14084. */
  14085. beginAnimationTo: number;
  14086. /**
  14087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14088. */
  14089. beginAnimationLoop: boolean;
  14090. /**
  14091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14092. */
  14093. disposeOnStop: boolean;
  14094. /**
  14095. * Specifies if the particles are updated in emitter local space or world space
  14096. */
  14097. isLocal: boolean;
  14098. /** Snippet ID if the particle system was created from the snippet server */
  14099. snippetId: string;
  14100. /**
  14101. * Gets the maximum number of particles active at the same time.
  14102. * @returns The max number of active particles.
  14103. */
  14104. getCapacity(): number;
  14105. /**
  14106. * Gets the number of particles active at the same time.
  14107. * @returns The number of active particles.
  14108. */
  14109. getActiveCount(): number;
  14110. /**
  14111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14112. * @returns True if it has been started, otherwise false.
  14113. */
  14114. isStarted(): boolean;
  14115. /**
  14116. * Animates the particle system for this frame.
  14117. */
  14118. animate(): void;
  14119. /**
  14120. * Renders the particle system in its current state.
  14121. * @returns the current number of particles
  14122. */
  14123. render(): number;
  14124. /**
  14125. * Dispose the particle system and frees its associated resources.
  14126. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14127. */
  14128. dispose(disposeTexture?: boolean): void;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<IParticleSystem>;
  14133. /**
  14134. * Clones the particle system.
  14135. * @param name The name of the cloned object
  14136. * @param newEmitter The new emitter to use
  14137. * @returns the cloned particle system
  14138. */
  14139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14140. /**
  14141. * Serializes the particle system to a JSON object
  14142. * @param serializeTexture defines if the texture must be serialized as well
  14143. * @returns the JSON object
  14144. */
  14145. serialize(serializeTexture: boolean): any;
  14146. /**
  14147. * Rebuild the particle system
  14148. */
  14149. rebuild(): void;
  14150. /** Force the system to rebuild all gradients that need to be resync */
  14151. forceRefreshGradients(): void;
  14152. /**
  14153. * Starts the particle system and begins to emit
  14154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14155. */
  14156. start(delay?: number): void;
  14157. /**
  14158. * Stops the particle system.
  14159. */
  14160. stop(): void;
  14161. /**
  14162. * Remove all active particles
  14163. */
  14164. reset(): void;
  14165. /**
  14166. * Gets a boolean indicating that the system is stopping
  14167. * @returns true if the system is currently stopping
  14168. */
  14169. isStopping(): boolean;
  14170. /**
  14171. * Is this system ready to be used/rendered
  14172. * @return true if the system is ready
  14173. */
  14174. isReady(): boolean;
  14175. /**
  14176. * Returns the string "ParticleSystem"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Gets the custom effect used to render the particles
  14182. * @param blendMode Blend mode for which the effect should be retrieved
  14183. * @returns The effect
  14184. */
  14185. getCustomEffect(blendMode: number): Nullable<Effect>;
  14186. /**
  14187. * Sets the custom effect used to render the particles
  14188. * @param effect The effect to set
  14189. * @param blendMode Blend mode for which the effect should be set
  14190. */
  14191. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14192. /**
  14193. * Fill the defines array according to the current settings of the particle system
  14194. * @param defines Array to be updated
  14195. * @param blendMode blend mode to take into account when updating the array
  14196. */
  14197. fillDefines(defines: Array<string>, blendMode: number): void;
  14198. /**
  14199. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14200. * @param uniforms Uniforms array to fill
  14201. * @param attributes Attributes array to fill
  14202. * @param samplers Samplers array to fill
  14203. */
  14204. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14205. /**
  14206. * Observable that will be called just before the particles are drawn
  14207. */
  14208. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14209. /**
  14210. * Gets the name of the particle vertex shader
  14211. */
  14212. vertexShaderName: string;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns the current particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Adds a new size gradient
  14229. * @param gradient defines the gradient to use (between 0 and 1)
  14230. * @param factor defines the size factor to affect to the specified gradient
  14231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14232. * @returns the current particle system
  14233. */
  14234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14235. /**
  14236. * Remove a specific size gradient
  14237. * @param gradient defines the gradient to remove
  14238. * @returns the current particle system
  14239. */
  14240. removeSizeGradient(gradient: number): IParticleSystem;
  14241. /**
  14242. * Gets the current list of color gradients.
  14243. * You must use addColorGradient and removeColorGradient to udpate this list
  14244. * @returns the list of color gradients
  14245. */
  14246. getColorGradients(): Nullable<Array<ColorGradient>>;
  14247. /**
  14248. * Gets the current list of size gradients.
  14249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14250. * @returns the list of size gradients
  14251. */
  14252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of angular speed gradients.
  14255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14256. * @returns the list of angular speed gradients
  14257. */
  14258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new angular speed gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the angular speed to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific angular speed gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of velocity gradients.
  14275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14276. * @returns the list of velocity gradients
  14277. */
  14278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Adds a new velocity gradient
  14281. * @param gradient defines the gradient to use (between 0 and 1)
  14282. * @param factor defines the velocity to affect to the specified gradient
  14283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14284. * @returns the current particle system
  14285. */
  14286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14287. /**
  14288. * Remove a specific velocity gradient
  14289. * @param gradient defines the gradient to remove
  14290. * @returns the current particle system
  14291. */
  14292. removeVelocityGradient(gradient: number): IParticleSystem;
  14293. /**
  14294. * Gets the current list of limit velocity gradients.
  14295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14296. * @returns the list of limit velocity gradients
  14297. */
  14298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Adds a new limit velocity gradient
  14301. * @param gradient defines the gradient to use (between 0 and 1)
  14302. * @param factor defines the limit velocity to affect to the specified gradient
  14303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14304. * @returns the current particle system
  14305. */
  14306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14307. /**
  14308. * Remove a specific limit velocity gradient
  14309. * @param gradient defines the gradient to remove
  14310. * @returns the current particle system
  14311. */
  14312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14313. /**
  14314. * Adds a new drag gradient
  14315. * @param gradient defines the gradient to use (between 0 and 1)
  14316. * @param factor defines the drag to affect to the specified gradient
  14317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14318. * @returns the current particle system
  14319. */
  14320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14321. /**
  14322. * Remove a specific drag gradient
  14323. * @param gradient defines the gradient to remove
  14324. * @returns the current particle system
  14325. */
  14326. removeDragGradient(gradient: number): IParticleSystem;
  14327. /**
  14328. * Gets the current list of drag gradients.
  14329. * You must use addDragGradient and removeDragGradient to udpate this list
  14330. * @returns the list of drag gradients
  14331. */
  14332. getDragGradients(): Nullable<Array<FactorGradient>>;
  14333. /**
  14334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14335. * @param gradient defines the gradient to use (between 0 and 1)
  14336. * @param factor defines the emit rate to affect to the specified gradient
  14337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14338. * @returns the current particle system
  14339. */
  14340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14341. /**
  14342. * Remove a specific emit rate gradient
  14343. * @param gradient defines the gradient to remove
  14344. * @returns the current particle system
  14345. */
  14346. removeEmitRateGradient(gradient: number): IParticleSystem;
  14347. /**
  14348. * Gets the current list of emit rate gradients.
  14349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14350. * @returns the list of emit rate gradients
  14351. */
  14352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param factor defines the start size to affect to the specified gradient
  14357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14358. * @returns the current particle system
  14359. */
  14360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14361. /**
  14362. * Remove a specific start size gradient
  14363. * @param gradient defines the gradient to remove
  14364. * @returns the current particle system
  14365. */
  14366. removeStartSizeGradient(gradient: number): IParticleSystem;
  14367. /**
  14368. * Gets the current list of start size gradients.
  14369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14370. * @returns the list of start size gradients
  14371. */
  14372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Adds a new life time gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param factor defines the life time factor to affect to the specified gradient
  14377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14378. * @returns the current particle system
  14379. */
  14380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14381. /**
  14382. * Remove a specific life time gradient
  14383. * @param gradient defines the gradient to remove
  14384. * @returns the current particle system
  14385. */
  14386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14387. /**
  14388. * Gets the current list of life time gradients.
  14389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14390. * @returns the list of life time gradients
  14391. */
  14392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Adds a new ramp gradient used to remap particle colors
  14401. * @param gradient defines the gradient to use (between 0 and 1)
  14402. * @param color defines the color to affect to the specified gradient
  14403. * @returns the current particle system
  14404. */
  14405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14406. /**
  14407. * Gets the current list of ramp gradients.
  14408. * You must use addRampGradient and removeRampGradient to udpate this list
  14409. * @returns the list of ramp gradients
  14410. */
  14411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14412. /** Gets or sets a boolean indicating that ramp gradients must be used
  14413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14414. */
  14415. useRampGradients: boolean;
  14416. /**
  14417. * Adds a new color remap gradient
  14418. * @param gradient defines the gradient to use (between 0 and 1)
  14419. * @param min defines the color remap minimal range
  14420. * @param max defines the color remap maximal range
  14421. * @returns the current particle system
  14422. */
  14423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color remap gradients.
  14426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14427. * @returns the list of color remap gradients
  14428. */
  14429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new alpha remap gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param min defines the alpha remap minimal range
  14434. * @param max defines the alpha remap maximal range
  14435. * @returns the current particle system
  14436. */
  14437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14438. /**
  14439. * Gets the current list of alpha remap gradients.
  14440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14441. * @returns the list of alpha remap gradients
  14442. */
  14443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14448. * @returns the emitter
  14449. */
  14450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14451. /**
  14452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14453. * @param radius The radius of the hemisphere to emit from
  14454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14455. * @returns the emitter
  14456. */
  14457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14458. /**
  14459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14460. * @param radius The radius of the sphere to emit from
  14461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14462. * @returns the emitter
  14463. */
  14464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14465. /**
  14466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14467. * @param radius The radius of the sphere to emit from
  14468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14470. * @returns the emitter
  14471. */
  14472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14473. /**
  14474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14475. * @param radius The radius of the emission cylinder
  14476. * @param height The height of the emission cylinder
  14477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14479. * @returns the emitter
  14480. */
  14481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14482. /**
  14483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14484. * @param radius The radius of the cylinder to emit from
  14485. * @param height The height of the emission cylinder
  14486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14489. * @returns the emitter
  14490. */
  14491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14492. /**
  14493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14494. * @param radius The radius of the cone to emit from
  14495. * @param angle The base angle of the cone
  14496. * @returns the emitter
  14497. */
  14498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14499. /**
  14500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14505. * @returns the emitter
  14506. */
  14507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14508. /**
  14509. * Get hosting scene
  14510. * @returns the scene
  14511. */
  14512. getScene(): Scene;
  14513. }
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * 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.
  14518. * @see https://doc.babylonjs.com/how_to/transformnode
  14519. */
  14520. export class TransformNode extends Node {
  14521. /**
  14522. * Object will not rotate to face the camera
  14523. */
  14524. static BILLBOARDMODE_NONE: number;
  14525. /**
  14526. * Object will rotate to face the camera but only on the x axis
  14527. */
  14528. static BILLBOARDMODE_X: number;
  14529. /**
  14530. * Object will rotate to face the camera but only on the y axis
  14531. */
  14532. static BILLBOARDMODE_Y: number;
  14533. /**
  14534. * Object will rotate to face the camera but only on the z axis
  14535. */
  14536. static BILLBOARDMODE_Z: number;
  14537. /**
  14538. * Object will rotate to face the camera
  14539. */
  14540. static BILLBOARDMODE_ALL: number;
  14541. /**
  14542. * Object will rotate to face the camera's position instead of orientation
  14543. */
  14544. static BILLBOARDMODE_USE_POSITION: number;
  14545. private _forward;
  14546. private _forwardInverted;
  14547. private _up;
  14548. private _right;
  14549. private _rightInverted;
  14550. private _position;
  14551. private _rotation;
  14552. private _rotationQuaternion;
  14553. protected _scaling: Vector3;
  14554. protected _isDirty: boolean;
  14555. private _transformToBoneReferal;
  14556. private _isAbsoluteSynced;
  14557. private _billboardMode;
  14558. /**
  14559. * Gets or sets the billboard mode. Default is 0.
  14560. *
  14561. * | Value | Type | Description |
  14562. * | --- | --- | --- |
  14563. * | 0 | BILLBOARDMODE_NONE | |
  14564. * | 1 | BILLBOARDMODE_X | |
  14565. * | 2 | BILLBOARDMODE_Y | |
  14566. * | 4 | BILLBOARDMODE_Z | |
  14567. * | 7 | BILLBOARDMODE_ALL | |
  14568. *
  14569. */
  14570. get billboardMode(): number;
  14571. set billboardMode(value: number);
  14572. private _preserveParentRotationForBillboard;
  14573. /**
  14574. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14575. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14576. */
  14577. get preserveParentRotationForBillboard(): boolean;
  14578. set preserveParentRotationForBillboard(value: boolean);
  14579. /**
  14580. * 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
  14581. */
  14582. scalingDeterminant: number;
  14583. private _infiniteDistance;
  14584. /**
  14585. * Gets or sets the distance of the object to max, often used by skybox
  14586. */
  14587. get infiniteDistance(): boolean;
  14588. set infiniteDistance(value: boolean);
  14589. /**
  14590. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14591. * By default the system will update normals to compensate
  14592. */
  14593. ignoreNonUniformScaling: boolean;
  14594. /**
  14595. * 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
  14596. */
  14597. reIntegrateRotationIntoRotationQuaternion: boolean;
  14598. /** @hidden */
  14599. _poseMatrix: Nullable<Matrix>;
  14600. /** @hidden */
  14601. _localMatrix: Matrix;
  14602. private _usePivotMatrix;
  14603. private _absolutePosition;
  14604. private _absoluteScaling;
  14605. private _absoluteRotationQuaternion;
  14606. private _pivotMatrix;
  14607. private _pivotMatrixInverse;
  14608. protected _postMultiplyPivotMatrix: boolean;
  14609. protected _isWorldMatrixFrozen: boolean;
  14610. /** @hidden */
  14611. _indexInSceneTransformNodesArray: number;
  14612. /**
  14613. * An event triggered after the world matrix is updated
  14614. */
  14615. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14616. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14617. /**
  14618. * Gets a string identifying the name of the class
  14619. * @returns "TransformNode" string
  14620. */
  14621. getClassName(): string;
  14622. /**
  14623. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14624. */
  14625. get position(): Vector3;
  14626. set position(newPosition: Vector3);
  14627. /**
  14628. * 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)).
  14629. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14630. */
  14631. get rotation(): Vector3;
  14632. set rotation(newRotation: Vector3);
  14633. /**
  14634. * 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)).
  14635. */
  14636. get scaling(): Vector3;
  14637. set scaling(newScaling: Vector3);
  14638. /**
  14639. * 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).
  14640. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14641. */
  14642. get rotationQuaternion(): Nullable<Quaternion>;
  14643. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14644. /**
  14645. * The forward direction of that transform in world space.
  14646. */
  14647. get forward(): Vector3;
  14648. /**
  14649. * The up direction of that transform in world space.
  14650. */
  14651. get up(): Vector3;
  14652. /**
  14653. * The right direction of that transform in world space.
  14654. */
  14655. get right(): Vector3;
  14656. /**
  14657. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14658. * @param matrix the matrix to copy the pose from
  14659. * @returns this TransformNode.
  14660. */
  14661. updatePoseMatrix(matrix: Matrix): TransformNode;
  14662. /**
  14663. * Returns the mesh Pose matrix.
  14664. * @returns the pose matrix
  14665. */
  14666. getPoseMatrix(): Matrix;
  14667. /** @hidden */
  14668. _isSynchronized(): boolean;
  14669. /** @hidden */
  14670. _initCache(): void;
  14671. /**
  14672. * Flag the transform node as dirty (Forcing it to update everything)
  14673. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14674. * @returns this transform node
  14675. */
  14676. markAsDirty(property: string): TransformNode;
  14677. /**
  14678. * Returns the current mesh absolute position.
  14679. * Returns a Vector3.
  14680. */
  14681. get absolutePosition(): Vector3;
  14682. /**
  14683. * Returns the current mesh absolute scaling.
  14684. * Returns a Vector3.
  14685. */
  14686. get absoluteScaling(): Vector3;
  14687. /**
  14688. * Returns the current mesh absolute rotation.
  14689. * Returns a Quaternion.
  14690. */
  14691. get absoluteRotationQuaternion(): Quaternion;
  14692. /**
  14693. * Sets a new matrix to apply before all other transformation
  14694. * @param matrix defines the transform matrix
  14695. * @returns the current TransformNode
  14696. */
  14697. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14698. /**
  14699. * Sets a new pivot matrix to the current node
  14700. * @param matrix defines the new pivot matrix to use
  14701. * @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
  14702. * @returns the current TransformNode
  14703. */
  14704. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14705. /**
  14706. * Returns the mesh pivot matrix.
  14707. * Default : Identity.
  14708. * @returns the matrix
  14709. */
  14710. getPivotMatrix(): Matrix;
  14711. /**
  14712. * Instantiate (when possible) or clone that node with its hierarchy
  14713. * @param newParent defines the new parent to use for the instance (or clone)
  14714. * @param options defines options to configure how copy is done
  14715. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14716. * @returns an instance (or a clone) of the current node with its hiearchy
  14717. */
  14718. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14719. doNotInstantiate: boolean;
  14720. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14721. /**
  14722. * Prevents the World matrix to be computed any longer
  14723. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14724. * @returns the TransformNode.
  14725. */
  14726. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14727. /**
  14728. * Allows back the World matrix computation.
  14729. * @returns the TransformNode.
  14730. */
  14731. unfreezeWorldMatrix(): this;
  14732. /**
  14733. * True if the World matrix has been frozen.
  14734. */
  14735. get isWorldMatrixFrozen(): boolean;
  14736. /**
  14737. * Retuns the mesh absolute position in the World.
  14738. * @returns a Vector3.
  14739. */
  14740. getAbsolutePosition(): Vector3;
  14741. /**
  14742. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14743. * @param absolutePosition the absolute position to set
  14744. * @returns the TransformNode.
  14745. */
  14746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14747. /**
  14748. * Sets the mesh position in its local space.
  14749. * @param vector3 the position to set in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14753. /**
  14754. * Returns the mesh position in the local space from the current World matrix values.
  14755. * @returns a new Vector3.
  14756. */
  14757. getPositionExpressedInLocalSpace(): Vector3;
  14758. /**
  14759. * Translates the mesh along the passed Vector3 in its local space.
  14760. * @param vector3 the distance to translate in localspace
  14761. * @returns the TransformNode.
  14762. */
  14763. locallyTranslate(vector3: Vector3): TransformNode;
  14764. private static _lookAtVectorCache;
  14765. /**
  14766. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14767. * @param targetPoint the position (must be in same space as current mesh) to look at
  14768. * @param yawCor optional yaw (y-axis) correction in radians
  14769. * @param pitchCor optional pitch (x-axis) correction in radians
  14770. * @param rollCor optional roll (z-axis) correction in radians
  14771. * @param space the choosen space of the target
  14772. * @returns the TransformNode.
  14773. */
  14774. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14775. /**
  14776. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14777. * This Vector3 is expressed in the World space.
  14778. * @param localAxis axis to rotate
  14779. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14780. */
  14781. getDirection(localAxis: Vector3): Vector3;
  14782. /**
  14783. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14784. * localAxis is expressed in the mesh local space.
  14785. * result is computed in the Wordl space from the mesh World matrix.
  14786. * @param localAxis axis to rotate
  14787. * @param result the resulting transformnode
  14788. * @returns this TransformNode.
  14789. */
  14790. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14791. /**
  14792. * Sets this transform node rotation to the given local axis.
  14793. * @param localAxis the axis in local space
  14794. * @param yawCor optional yaw (y-axis) correction in radians
  14795. * @param pitchCor optional pitch (x-axis) correction in radians
  14796. * @param rollCor optional roll (z-axis) correction in radians
  14797. * @returns this TransformNode
  14798. */
  14799. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14800. /**
  14801. * Sets a new pivot point to the current node
  14802. * @param point defines the new pivot point to use
  14803. * @param space defines if the point is in world or local space (local by default)
  14804. * @returns the current TransformNode
  14805. */
  14806. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14809. * @returns the pivot point
  14810. */
  14811. getPivotPoint(): Vector3;
  14812. /**
  14813. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14814. * @param result the vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getPivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14820. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14821. */
  14822. getAbsolutePivotPoint(): Vector3;
  14823. /**
  14824. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14825. * @param result vector3 to store the result
  14826. * @returns this TransformNode.
  14827. */
  14828. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14829. /**
  14830. * Defines the passed node as the parent of the current node.
  14831. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14832. * @see https://doc.babylonjs.com/how_to/parenting
  14833. * @param node the node ot set as the parent
  14834. * @returns this TransformNode.
  14835. */
  14836. setParent(node: Nullable<Node>): TransformNode;
  14837. private _nonUniformScaling;
  14838. /**
  14839. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14840. */
  14841. get nonUniformScaling(): boolean;
  14842. /** @hidden */
  14843. _updateNonUniformScalingState(value: boolean): boolean;
  14844. /**
  14845. * Attach the current TransformNode to another TransformNode associated with a bone
  14846. * @param bone Bone affecting the TransformNode
  14847. * @param affectedTransformNode TransformNode associated with the bone
  14848. * @returns this object
  14849. */
  14850. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14851. /**
  14852. * Detach the transform node if its associated with a bone
  14853. * @returns this object
  14854. */
  14855. detachFromBone(): TransformNode;
  14856. private static _rotationAxisCache;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14859. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14860. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14861. * The passed axis is also normalized.
  14862. * @param axis the axis to rotate around
  14863. * @param amount the amount to rotate in radians
  14864. * @param space Space to rotate in (Default: local)
  14865. * @returns the TransformNode.
  14866. */
  14867. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14868. /**
  14869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14870. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14871. * The passed axis is also normalized. .
  14872. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14873. * @param point the point to rotate around
  14874. * @param axis the axis to rotate around
  14875. * @param amount the amount to rotate in radians
  14876. * @returns the TransformNode
  14877. */
  14878. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14879. /**
  14880. * Translates the mesh along the axis vector for the passed distance in the given space.
  14881. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14882. * @param axis the axis to translate in
  14883. * @param distance the distance to translate
  14884. * @param space Space to rotate in (Default: local)
  14885. * @returns the TransformNode.
  14886. */
  14887. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14888. /**
  14889. * Adds a rotation step to the mesh current rotation.
  14890. * x, y, z are Euler angles expressed in radians.
  14891. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14892. * This means this rotation is made in the mesh local space only.
  14893. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14894. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14895. * ```javascript
  14896. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14897. * ```
  14898. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14899. * 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.
  14900. * @param x Rotation to add
  14901. * @param y Rotation to add
  14902. * @param z Rotation to add
  14903. * @returns the TransformNode.
  14904. */
  14905. addRotation(x: number, y: number, z: number): TransformNode;
  14906. /**
  14907. * @hidden
  14908. */
  14909. protected _getEffectiveParent(): Nullable<Node>;
  14910. /**
  14911. * Computes the world matrix of the node
  14912. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14913. * @returns the world matrix
  14914. */
  14915. computeWorldMatrix(force?: boolean): Matrix;
  14916. /**
  14917. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14918. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14919. */
  14920. resetLocalMatrix(independentOfChildren?: boolean): void;
  14921. protected _afterComputeWorldMatrix(): void;
  14922. /**
  14923. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14924. * @param func callback function to add
  14925. *
  14926. * @returns the TransformNode.
  14927. */
  14928. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14929. /**
  14930. * Removes a registered callback function.
  14931. * @param func callback function to remove
  14932. * @returns the TransformNode.
  14933. */
  14934. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14935. /**
  14936. * Gets the position of the current mesh in camera space
  14937. * @param camera defines the camera to use
  14938. * @returns a position
  14939. */
  14940. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14941. /**
  14942. * Returns the distance from the mesh to the active camera
  14943. * @param camera defines the camera to use
  14944. * @returns the distance
  14945. */
  14946. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14947. /**
  14948. * Clone the current transform node
  14949. * @param name Name of the new clone
  14950. * @param newParent New parent for the clone
  14951. * @param doNotCloneChildren Do not clone children hierarchy
  14952. * @returns the new transform node
  14953. */
  14954. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14955. /**
  14956. * Serializes the objects information.
  14957. * @param currentSerializationObject defines the object to serialize in
  14958. * @returns the serialized object
  14959. */
  14960. serialize(currentSerializationObject?: any): any;
  14961. /**
  14962. * Returns a new TransformNode object parsed from the source provided.
  14963. * @param parsedTransformNode is the source.
  14964. * @param scene the scne the object belongs to
  14965. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14966. * @returns a new TransformNode object parsed from the source provided.
  14967. */
  14968. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14969. /**
  14970. * Get all child-transformNodes of this node
  14971. * @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
  14972. * @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
  14973. * @returns an array of TransformNode
  14974. */
  14975. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14976. /**
  14977. * Releases resources associated with this transform node.
  14978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14980. */
  14981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14982. /**
  14983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14987. * @returns the current mesh
  14988. */
  14989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14990. private _syncAbsoluteScalingAndRotation;
  14991. }
  14992. }
  14993. declare module BABYLON {
  14994. /**
  14995. * Class used to override all child animations of a given target
  14996. */
  14997. export class AnimationPropertiesOverride {
  14998. /**
  14999. * Gets or sets a value indicating if animation blending must be used
  15000. */
  15001. enableBlending: boolean;
  15002. /**
  15003. * Gets or sets the blending speed to use when enableBlending is true
  15004. */
  15005. blendingSpeed: number;
  15006. /**
  15007. * Gets or sets the default loop mode to use
  15008. */
  15009. loopMode: number;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Class used to store bone information
  15015. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15016. */
  15017. export class Bone extends Node {
  15018. /**
  15019. * defines the bone name
  15020. */
  15021. name: string;
  15022. private static _tmpVecs;
  15023. private static _tmpQuat;
  15024. private static _tmpMats;
  15025. /**
  15026. * Gets the list of child bones
  15027. */
  15028. children: Bone[];
  15029. /** Gets the animations associated with this bone */
  15030. animations: Animation[];
  15031. /**
  15032. * Gets or sets bone length
  15033. */
  15034. length: number;
  15035. /**
  15036. * @hidden Internal only
  15037. * Set this value to map this bone to a different index in the transform matrices
  15038. * Set this value to -1 to exclude the bone from the transform matrices
  15039. */
  15040. _index: Nullable<number>;
  15041. private _skeleton;
  15042. private _localMatrix;
  15043. private _restPose;
  15044. private _baseMatrix;
  15045. private _absoluteTransform;
  15046. private _invertedAbsoluteTransform;
  15047. private _parent;
  15048. private _scalingDeterminant;
  15049. private _worldTransform;
  15050. private _localScaling;
  15051. private _localRotation;
  15052. private _localPosition;
  15053. private _needToDecompose;
  15054. private _needToCompose;
  15055. /** @hidden */
  15056. _linkedTransformNode: Nullable<TransformNode>;
  15057. /** @hidden */
  15058. _waitingTransformNodeId: Nullable<string>;
  15059. /** @hidden */
  15060. get _matrix(): Matrix;
  15061. /** @hidden */
  15062. set _matrix(value: Matrix);
  15063. /**
  15064. * Create a new bone
  15065. * @param name defines the bone name
  15066. * @param skeleton defines the parent skeleton
  15067. * @param parentBone defines the parent (can be null if the bone is the root)
  15068. * @param localMatrix defines the local matrix
  15069. * @param restPose defines the rest pose matrix
  15070. * @param baseMatrix defines the base matrix
  15071. * @param index defines index of the bone in the hiearchy
  15072. */
  15073. constructor(
  15074. /**
  15075. * defines the bone name
  15076. */
  15077. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15078. /**
  15079. * Gets the current object class name.
  15080. * @return the class name
  15081. */
  15082. getClassName(): string;
  15083. /**
  15084. * Gets the parent skeleton
  15085. * @returns a skeleton
  15086. */
  15087. getSkeleton(): Skeleton;
  15088. /**
  15089. * Gets parent bone
  15090. * @returns a bone or null if the bone is the root of the bone hierarchy
  15091. */
  15092. getParent(): Nullable<Bone>;
  15093. /**
  15094. * Returns an array containing the root bones
  15095. * @returns an array containing the root bones
  15096. */
  15097. getChildren(): Array<Bone>;
  15098. /**
  15099. * Gets the node index in matrix array generated for rendering
  15100. * @returns the node index
  15101. */
  15102. getIndex(): number;
  15103. /**
  15104. * Sets the parent bone
  15105. * @param parent defines the parent (can be null if the bone is the root)
  15106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15107. */
  15108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15109. /**
  15110. * Gets the local matrix
  15111. * @returns a matrix
  15112. */
  15113. getLocalMatrix(): Matrix;
  15114. /**
  15115. * Gets the base matrix (initial matrix which remains unchanged)
  15116. * @returns a matrix
  15117. */
  15118. getBaseMatrix(): Matrix;
  15119. /**
  15120. * Gets the rest pose matrix
  15121. * @returns a matrix
  15122. */
  15123. getRestPose(): Matrix;
  15124. /**
  15125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15126. */
  15127. getWorldMatrix(): Matrix;
  15128. /**
  15129. * Sets the local matrix to rest pose matrix
  15130. */
  15131. returnToRest(): void;
  15132. /**
  15133. * Gets the inverse of the absolute transform matrix.
  15134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15135. * @returns a matrix
  15136. */
  15137. getInvertedAbsoluteTransform(): Matrix;
  15138. /**
  15139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15140. * @returns a matrix
  15141. */
  15142. getAbsoluteTransform(): Matrix;
  15143. /**
  15144. * Links with the given transform node.
  15145. * The local matrix of this bone is copied from the transform node every frame.
  15146. * @param transformNode defines the transform node to link to
  15147. */
  15148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15149. /**
  15150. * Gets the node used to drive the bone's transformation
  15151. * @returns a transform node or null
  15152. */
  15153. getTransformNode(): Nullable<TransformNode>;
  15154. /** Gets or sets current position (in local space) */
  15155. get position(): Vector3;
  15156. set position(newPosition: Vector3);
  15157. /** Gets or sets current rotation (in local space) */
  15158. get rotation(): Vector3;
  15159. set rotation(newRotation: Vector3);
  15160. /** Gets or sets current rotation quaternion (in local space) */
  15161. get rotationQuaternion(): Quaternion;
  15162. set rotationQuaternion(newRotation: Quaternion);
  15163. /** Gets or sets current scaling (in local space) */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * Gets the animation properties override
  15168. */
  15169. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15170. private _decompose;
  15171. private _compose;
  15172. /**
  15173. * Update the base and local matrices
  15174. * @param matrix defines the new base or local matrix
  15175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15176. * @param updateLocalMatrix defines if the local matrix should be updated
  15177. */
  15178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15179. /** @hidden */
  15180. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15181. /**
  15182. * Flag the bone as dirty (Forcing it to update everything)
  15183. */
  15184. markAsDirty(): void;
  15185. /** @hidden */
  15186. _markAsDirtyAndCompose(): void;
  15187. private _markAsDirtyAndDecompose;
  15188. /**
  15189. * Translate the bone in local or world space
  15190. * @param vec The amount to translate the bone
  15191. * @param space The space that the translation is in
  15192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15193. */
  15194. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15195. /**
  15196. * Set the postion of the bone in local or world space
  15197. * @param position The position to set the bone
  15198. * @param space The space that the position is in
  15199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15200. */
  15201. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15202. /**
  15203. * Set the absolute position of the bone (world space)
  15204. * @param position The position to set the bone
  15205. * @param mesh The mesh that this bone is attached to
  15206. */
  15207. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15208. /**
  15209. * Scale the bone on the x, y and z axes (in local space)
  15210. * @param x The amount to scale the bone on the x axis
  15211. * @param y The amount to scale the bone on the y axis
  15212. * @param z The amount to scale the bone on the z axis
  15213. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15214. */
  15215. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15216. /**
  15217. * Set the bone scaling in local space
  15218. * @param scale defines the scaling vector
  15219. */
  15220. setScale(scale: Vector3): void;
  15221. /**
  15222. * Gets the current scaling in local space
  15223. * @returns the current scaling vector
  15224. */
  15225. getScale(): Vector3;
  15226. /**
  15227. * Gets the current scaling in local space and stores it in a target vector
  15228. * @param result defines the target vector
  15229. */
  15230. getScaleToRef(result: Vector3): void;
  15231. /**
  15232. * Set the yaw, pitch, and roll of the bone in local or world space
  15233. * @param yaw The rotation of the bone on the y axis
  15234. * @param pitch The rotation of the bone on the x axis
  15235. * @param roll The rotation of the bone on the z axis
  15236. * @param space The space that the axes of rotation are in
  15237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15238. */
  15239. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15240. /**
  15241. * Add a rotation to the bone on an axis in local or world space
  15242. * @param axis The axis to rotate the bone on
  15243. * @param amount The amount to rotate the bone
  15244. * @param space The space that the axis is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation of the bone to a particular axis angle in local or world space
  15250. * @param axis The axis to rotate the bone on
  15251. * @param angle The angle that the bone should be rotated to
  15252. * @param space The space that the axis is in
  15253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15254. */
  15255. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15256. /**
  15257. * Set the euler rotation of the bone in local of world space
  15258. * @param rotation The euler rotation that the bone should be set to
  15259. * @param space The space that the rotation is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. */
  15262. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15263. /**
  15264. * Set the quaternion rotation of the bone in local of world space
  15265. * @param quat The quaternion rotation that the bone should be set to
  15266. * @param space The space that the rotation is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. */
  15269. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15270. /**
  15271. * Set the rotation matrix of the bone in local of world space
  15272. * @param rotMat The rotation matrix that the bone should be set to
  15273. * @param space The space that the rotation is in
  15274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15275. */
  15276. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15277. private _rotateWithMatrix;
  15278. private _getNegativeRotationToRef;
  15279. /**
  15280. * Get the position of the bone in local or world space
  15281. * @param space The space that the returned position is in
  15282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15283. * @returns The position of the bone
  15284. */
  15285. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15286. /**
  15287. * Copy the position of the bone to a vector3 in local or world space
  15288. * @param space The space that the returned position is in
  15289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15290. * @param result The vector3 to copy the position to
  15291. */
  15292. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15293. /**
  15294. * Get the absolute position of the bone (world space)
  15295. * @param mesh The mesh that this bone is attached to
  15296. * @returns The absolute position of the bone
  15297. */
  15298. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15299. /**
  15300. * Copy the absolute position of the bone (world space) to the result param
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @param result The vector3 to copy the absolute position to
  15303. */
  15304. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15305. /**
  15306. * Compute the absolute transforms of this bone and its children
  15307. */
  15308. computeAbsoluteTransforms(): void;
  15309. /**
  15310. * Get the world direction from an axis that is in the local space of the bone
  15311. * @param localAxis The local direction that is used to compute the world direction
  15312. * @param mesh The mesh that this bone is attached to
  15313. * @returns The world direction
  15314. */
  15315. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15316. /**
  15317. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15318. * @param localAxis The local direction that is used to compute the world direction
  15319. * @param mesh The mesh that this bone is attached to
  15320. * @param result The vector3 that the world direction will be copied to
  15321. */
  15322. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15323. /**
  15324. * Get the euler rotation of the bone in local or world space
  15325. * @param space The space that the rotation should be in
  15326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15327. * @returns The euler rotation
  15328. */
  15329. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15330. /**
  15331. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15332. * @param space The space that the rotation should be in
  15333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15334. * @param result The vector3 that the rotation should be copied to
  15335. */
  15336. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15337. /**
  15338. * Get the quaternion rotation of the bone in either local or world space
  15339. * @param space The space that the rotation should be in
  15340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15341. * @returns The quaternion rotation
  15342. */
  15343. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15344. /**
  15345. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15346. * @param space The space that the rotation should be in
  15347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15348. * @param result The quaternion that the rotation should be copied to
  15349. */
  15350. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15351. /**
  15352. * Get the rotation matrix of the bone in local or world space
  15353. * @param space The space that the rotation should be in
  15354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15355. * @returns The rotation matrix
  15356. */
  15357. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15358. /**
  15359. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15360. * @param space The space that the rotation should be in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. * @param result The quaternion that the rotation should be copied to
  15363. */
  15364. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15365. /**
  15366. * Get the world position of a point that is in the local space of the bone
  15367. * @param position The local position
  15368. * @param mesh The mesh that this bone is attached to
  15369. * @returns The world position
  15370. */
  15371. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15372. /**
  15373. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15374. * @param position The local position
  15375. * @param mesh The mesh that this bone is attached to
  15376. * @param result The vector3 that the world position should be copied to
  15377. */
  15378. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15379. /**
  15380. * Get the local position of a point that is in world space
  15381. * @param position The world position
  15382. * @param mesh The mesh that this bone is attached to
  15383. * @returns The local position
  15384. */
  15385. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15386. /**
  15387. * Get the local position of a point that is in world space and copy it to the result param
  15388. * @param position The world position
  15389. * @param mesh The mesh that this bone is attached to
  15390. * @param result The vector3 that the local position should be copied to
  15391. */
  15392. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. /**
  15397. * Defines a runtime animation
  15398. */
  15399. export class RuntimeAnimation {
  15400. private _events;
  15401. /**
  15402. * The current frame of the runtime animation
  15403. */
  15404. private _currentFrame;
  15405. /**
  15406. * The animation used by the runtime animation
  15407. */
  15408. private _animation;
  15409. /**
  15410. * The target of the runtime animation
  15411. */
  15412. private _target;
  15413. /**
  15414. * The initiating animatable
  15415. */
  15416. private _host;
  15417. /**
  15418. * The original value of the runtime animation
  15419. */
  15420. private _originalValue;
  15421. /**
  15422. * The original blend value of the runtime animation
  15423. */
  15424. private _originalBlendValue;
  15425. /**
  15426. * The offsets cache of the runtime animation
  15427. */
  15428. private _offsetsCache;
  15429. /**
  15430. * The high limits cache of the runtime animation
  15431. */
  15432. private _highLimitsCache;
  15433. /**
  15434. * Specifies if the runtime animation has been stopped
  15435. */
  15436. private _stopped;
  15437. /**
  15438. * The blending factor of the runtime animation
  15439. */
  15440. private _blendingFactor;
  15441. /**
  15442. * The BabylonJS scene
  15443. */
  15444. private _scene;
  15445. /**
  15446. * The current value of the runtime animation
  15447. */
  15448. private _currentValue;
  15449. /** @hidden */
  15450. _animationState: _IAnimationState;
  15451. /**
  15452. * The active target of the runtime animation
  15453. */
  15454. private _activeTargets;
  15455. private _currentActiveTarget;
  15456. private _directTarget;
  15457. /**
  15458. * The target path of the runtime animation
  15459. */
  15460. private _targetPath;
  15461. /**
  15462. * The weight of the runtime animation
  15463. */
  15464. private _weight;
  15465. /**
  15466. * The ratio offset of the runtime animation
  15467. */
  15468. private _ratioOffset;
  15469. /**
  15470. * The previous delay of the runtime animation
  15471. */
  15472. private _previousDelay;
  15473. /**
  15474. * The previous ratio of the runtime animation
  15475. */
  15476. private _previousRatio;
  15477. private _enableBlending;
  15478. private _keys;
  15479. private _minFrame;
  15480. private _maxFrame;
  15481. private _minValue;
  15482. private _maxValue;
  15483. private _targetIsArray;
  15484. /**
  15485. * Gets the current frame of the runtime animation
  15486. */
  15487. get currentFrame(): number;
  15488. /**
  15489. * Gets the weight of the runtime animation
  15490. */
  15491. get weight(): number;
  15492. /**
  15493. * Gets the current value of the runtime animation
  15494. */
  15495. get currentValue(): any;
  15496. /**
  15497. * Gets the target path of the runtime animation
  15498. */
  15499. get targetPath(): string;
  15500. /**
  15501. * Gets the actual target of the runtime animation
  15502. */
  15503. get target(): any;
  15504. /**
  15505. * Gets the additive state of the runtime animation
  15506. */
  15507. get isAdditive(): boolean;
  15508. /** @hidden */
  15509. _onLoop: () => void;
  15510. /**
  15511. * Create a new RuntimeAnimation object
  15512. * @param target defines the target of the animation
  15513. * @param animation defines the source animation object
  15514. * @param scene defines the hosting scene
  15515. * @param host defines the initiating Animatable
  15516. */
  15517. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15518. private _preparePath;
  15519. /**
  15520. * Gets the animation from the runtime animation
  15521. */
  15522. get animation(): Animation;
  15523. /**
  15524. * Resets the runtime animation to the beginning
  15525. * @param restoreOriginal defines whether to restore the target property to the original value
  15526. */
  15527. reset(restoreOriginal?: boolean): void;
  15528. /**
  15529. * Specifies if the runtime animation is stopped
  15530. * @returns Boolean specifying if the runtime animation is stopped
  15531. */
  15532. isStopped(): boolean;
  15533. /**
  15534. * Disposes of the runtime animation
  15535. */
  15536. dispose(): void;
  15537. /**
  15538. * Apply the interpolated value to the target
  15539. * @param currentValue defines the value computed by the animation
  15540. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15541. */
  15542. setValue(currentValue: any, weight: number): void;
  15543. private _getOriginalValues;
  15544. private _setValue;
  15545. /**
  15546. * Gets the loop pmode of the runtime animation
  15547. * @returns Loop Mode
  15548. */
  15549. private _getCorrectLoopMode;
  15550. /**
  15551. * Move the current animation to a given frame
  15552. * @param frame defines the frame to move to
  15553. */
  15554. goToFrame(frame: number): void;
  15555. /**
  15556. * @hidden Internal use only
  15557. */
  15558. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15559. /**
  15560. * Execute the current animation
  15561. * @param delay defines the delay to add to the current frame
  15562. * @param from defines the lower bound of the animation range
  15563. * @param to defines the upper bound of the animation range
  15564. * @param loop defines if the current animation must loop
  15565. * @param speedRatio defines the current speed ratio
  15566. * @param weight defines the weight of the animation (default is -1 so no weight)
  15567. * @param onLoop optional callback called when animation loops
  15568. * @returns a boolean indicating if the animation is running
  15569. */
  15570. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * Class used to store an actual running animation
  15576. */
  15577. export class Animatable {
  15578. /** defines the target object */
  15579. target: any;
  15580. /** defines the starting frame number (default is 0) */
  15581. fromFrame: number;
  15582. /** defines the ending frame number (default is 100) */
  15583. toFrame: number;
  15584. /** defines if the animation must loop (default is false) */
  15585. loopAnimation: boolean;
  15586. /** defines a callback to call when animation ends if it is not looping */
  15587. onAnimationEnd?: (() => void) | null | undefined;
  15588. /** defines a callback to call when animation loops */
  15589. onAnimationLoop?: (() => void) | null | undefined;
  15590. /** defines whether the animation should be evaluated additively */
  15591. isAdditive: boolean;
  15592. private _localDelayOffset;
  15593. private _pausedDelay;
  15594. private _runtimeAnimations;
  15595. private _paused;
  15596. private _scene;
  15597. private _speedRatio;
  15598. private _weight;
  15599. private _syncRoot;
  15600. /**
  15601. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15602. * This will only apply for non looping animation (default is true)
  15603. */
  15604. disposeOnEnd: boolean;
  15605. /**
  15606. * Gets a boolean indicating if the animation has started
  15607. */
  15608. animationStarted: boolean;
  15609. /**
  15610. * Observer raised when the animation ends
  15611. */
  15612. onAnimationEndObservable: Observable<Animatable>;
  15613. /**
  15614. * Observer raised when the animation loops
  15615. */
  15616. onAnimationLoopObservable: Observable<Animatable>;
  15617. /**
  15618. * Gets the root Animatable used to synchronize and normalize animations
  15619. */
  15620. get syncRoot(): Nullable<Animatable>;
  15621. /**
  15622. * Gets the current frame of the first RuntimeAnimation
  15623. * Used to synchronize Animatables
  15624. */
  15625. get masterFrame(): number;
  15626. /**
  15627. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15628. */
  15629. get weight(): number;
  15630. set weight(value: number);
  15631. /**
  15632. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15633. */
  15634. get speedRatio(): number;
  15635. set speedRatio(value: number);
  15636. /**
  15637. * Creates a new Animatable
  15638. * @param scene defines the hosting scene
  15639. * @param target defines the target object
  15640. * @param fromFrame defines the starting frame number (default is 0)
  15641. * @param toFrame defines the ending frame number (default is 100)
  15642. * @param loopAnimation defines if the animation must loop (default is false)
  15643. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15644. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15645. * @param animations defines a group of animation to add to the new Animatable
  15646. * @param onAnimationLoop defines a callback to call when animation loops
  15647. * @param isAdditive defines whether the animation should be evaluated additively
  15648. */
  15649. constructor(scene: Scene,
  15650. /** defines the target object */
  15651. target: any,
  15652. /** defines the starting frame number (default is 0) */
  15653. fromFrame?: number,
  15654. /** defines the ending frame number (default is 100) */
  15655. toFrame?: number,
  15656. /** defines if the animation must loop (default is false) */
  15657. loopAnimation?: boolean, speedRatio?: number,
  15658. /** defines a callback to call when animation ends if it is not looping */
  15659. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15660. /** defines a callback to call when animation loops */
  15661. onAnimationLoop?: (() => void) | null | undefined,
  15662. /** defines whether the animation should be evaluated additively */
  15663. isAdditive?: boolean);
  15664. /**
  15665. * Synchronize and normalize current Animatable with a source Animatable
  15666. * This is useful when using animation weights and when animations are not of the same length
  15667. * @param root defines the root Animatable to synchronize with
  15668. * @returns the current Animatable
  15669. */
  15670. syncWith(root: Animatable): Animatable;
  15671. /**
  15672. * Gets the list of runtime animations
  15673. * @returns an array of RuntimeAnimation
  15674. */
  15675. getAnimations(): RuntimeAnimation[];
  15676. /**
  15677. * Adds more animations to the current animatable
  15678. * @param target defines the target of the animations
  15679. * @param animations defines the new animations to add
  15680. */
  15681. appendAnimations(target: any, animations: Animation[]): void;
  15682. /**
  15683. * Gets the source animation for a specific property
  15684. * @param property defines the propertyu to look for
  15685. * @returns null or the source animation for the given property
  15686. */
  15687. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15688. /**
  15689. * Gets the runtime animation for a specific property
  15690. * @param property defines the propertyu to look for
  15691. * @returns null or the runtime animation for the given property
  15692. */
  15693. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15694. /**
  15695. * Resets the animatable to its original state
  15696. */
  15697. reset(): void;
  15698. /**
  15699. * Allows the animatable to blend with current running animations
  15700. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15701. * @param blendingSpeed defines the blending speed to use
  15702. */
  15703. enableBlending(blendingSpeed: number): void;
  15704. /**
  15705. * Disable animation blending
  15706. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15707. */
  15708. disableBlending(): void;
  15709. /**
  15710. * Jump directly to a given frame
  15711. * @param frame defines the frame to jump to
  15712. */
  15713. goToFrame(frame: number): void;
  15714. /**
  15715. * Pause the animation
  15716. */
  15717. pause(): void;
  15718. /**
  15719. * Restart the animation
  15720. */
  15721. restart(): void;
  15722. private _raiseOnAnimationEnd;
  15723. /**
  15724. * Stop and delete the current animation
  15725. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15726. * @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)
  15727. */
  15728. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15729. /**
  15730. * Wait asynchronously for the animation to end
  15731. * @returns a promise which will be fullfilled when the animation ends
  15732. */
  15733. waitAsync(): Promise<Animatable>;
  15734. /** @hidden */
  15735. _animate(delay: number): boolean;
  15736. }
  15737. interface Scene {
  15738. /** @hidden */
  15739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15740. /** @hidden */
  15741. _processLateAnimationBindingsForMatrices(holder: {
  15742. totalWeight: number;
  15743. totalAdditiveWeight: number;
  15744. animations: RuntimeAnimation[];
  15745. additiveAnimations: RuntimeAnimation[];
  15746. originalValue: Matrix;
  15747. }): any;
  15748. /** @hidden */
  15749. _processLateAnimationBindingsForQuaternions(holder: {
  15750. totalWeight: number;
  15751. totalAdditiveWeight: number;
  15752. animations: RuntimeAnimation[];
  15753. additiveAnimations: RuntimeAnimation[];
  15754. originalValue: Quaternion;
  15755. }, refQuaternion: Quaternion): Quaternion;
  15756. /** @hidden */
  15757. _processLateAnimationBindings(): void;
  15758. /**
  15759. * Will start the animation sequence of a given target
  15760. * @param target defines the target
  15761. * @param from defines from which frame should animation start
  15762. * @param to defines until which frame should animation run.
  15763. * @param weight defines the weight to apply to the animation (1.0 by default)
  15764. * @param loop defines if the animation loops
  15765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15766. * @param onAnimationEnd defines the function to be executed when the animation ends
  15767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15769. * @param onAnimationLoop defines the callback to call when an animation loops
  15770. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15771. * @returns the animatable object created for this animation
  15772. */
  15773. 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;
  15774. /**
  15775. * Will start the animation sequence of a given target
  15776. * @param target defines the target
  15777. * @param from defines from which frame should animation start
  15778. * @param to defines until which frame should animation run.
  15779. * @param loop defines if the animation loops
  15780. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15781. * @param onAnimationEnd defines the function to be executed when the animation ends
  15782. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15783. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15784. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15785. * @param onAnimationLoop defines the callback to call when an animation loops
  15786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15787. * @returns the animatable object created for this animation
  15788. */
  15789. 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;
  15790. /**
  15791. * Will start the animation sequence of a given target and its hierarchy
  15792. * @param target defines the target
  15793. * @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.
  15794. * @param from defines from which frame should animation start
  15795. * @param to defines until which frame should animation run.
  15796. * @param loop defines if the animation loops
  15797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15798. * @param onAnimationEnd defines the function to be executed when the animation ends
  15799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15802. * @param onAnimationLoop defines the callback to call when an animation loops
  15803. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15804. * @returns the list of created animatables
  15805. */
  15806. 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[];
  15807. /**
  15808. * Begin a new animation on a given node
  15809. * @param target defines the target where the animation will take place
  15810. * @param animations defines the list of animations to start
  15811. * @param from defines the initial value
  15812. * @param to defines the final value
  15813. * @param loop defines if you want animation to loop (off by default)
  15814. * @param speedRatio defines the speed ratio to apply to all animations
  15815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15816. * @param onAnimationLoop defines the callback to call when an animation loops
  15817. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15818. * @returns the list of created animatables
  15819. */
  15820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15821. /**
  15822. * Begin a new animation on a given node and its hierarchy
  15823. * @param target defines the root node where the animation will take place
  15824. * @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.
  15825. * @param animations defines the list of animations to start
  15826. * @param from defines the initial value
  15827. * @param to defines the final value
  15828. * @param loop defines if you want animation to loop (off by default)
  15829. * @param speedRatio defines the speed ratio to apply to all animations
  15830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15831. * @param onAnimationLoop defines the callback to call when an animation loops
  15832. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15833. * @returns the list of animatables created for all nodes
  15834. */
  15835. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15836. /**
  15837. * Gets the animatable associated with a specific target
  15838. * @param target defines the target of the animatable
  15839. * @returns the required animatable if found
  15840. */
  15841. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15842. /**
  15843. * Gets all animatables associated with a given target
  15844. * @param target defines the target to look animatables for
  15845. * @returns an array of Animatables
  15846. */
  15847. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15848. /**
  15849. * Stops and removes all animations that have been applied to the scene
  15850. */
  15851. stopAllAnimations(): void;
  15852. /**
  15853. * Gets the current delta time used by animation engine
  15854. */
  15855. deltaTime: number;
  15856. }
  15857. interface Bone {
  15858. /**
  15859. * Copy an animation range from another bone
  15860. * @param source defines the source bone
  15861. * @param rangeName defines the range name to copy
  15862. * @param frameOffset defines the frame offset
  15863. * @param rescaleAsRequired defines if rescaling must be applied if required
  15864. * @param skelDimensionsRatio defines the scaling ratio
  15865. * @returns true if operation was successful
  15866. */
  15867. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. /**
  15872. * Class used to handle skinning animations
  15873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15874. */
  15875. export class Skeleton implements IAnimatable {
  15876. /** defines the skeleton name */
  15877. name: string;
  15878. /** defines the skeleton Id */
  15879. id: string;
  15880. /**
  15881. * Defines the list of child bones
  15882. */
  15883. bones: Bone[];
  15884. /**
  15885. * Defines an estimate of the dimension of the skeleton at rest
  15886. */
  15887. dimensionsAtRest: Vector3;
  15888. /**
  15889. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15890. */
  15891. needInitialSkinMatrix: boolean;
  15892. /**
  15893. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15894. */
  15895. overrideMesh: Nullable<AbstractMesh>;
  15896. /**
  15897. * Gets the list of animations attached to this skeleton
  15898. */
  15899. animations: Array<Animation>;
  15900. private _scene;
  15901. private _isDirty;
  15902. private _transformMatrices;
  15903. private _transformMatrixTexture;
  15904. private _meshesWithPoseMatrix;
  15905. private _animatables;
  15906. private _identity;
  15907. private _synchronizedWithMesh;
  15908. private _ranges;
  15909. private _lastAbsoluteTransformsUpdateId;
  15910. private _canUseTextureForBones;
  15911. private _uniqueId;
  15912. /** @hidden */
  15913. _numBonesWithLinkedTransformNode: number;
  15914. /** @hidden */
  15915. _hasWaitingData: Nullable<boolean>;
  15916. /**
  15917. * Specifies if the skeleton should be serialized
  15918. */
  15919. doNotSerialize: boolean;
  15920. private _useTextureToStoreBoneMatrices;
  15921. /**
  15922. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15923. * Please note that this option is not available if the hardware does not support it
  15924. */
  15925. get useTextureToStoreBoneMatrices(): boolean;
  15926. set useTextureToStoreBoneMatrices(value: boolean);
  15927. private _animationPropertiesOverride;
  15928. /**
  15929. * Gets or sets the animation properties override
  15930. */
  15931. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15932. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15933. /**
  15934. * List of inspectable custom properties (used by the Inspector)
  15935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15936. */
  15937. inspectableCustomProperties: IInspectable[];
  15938. /**
  15939. * An observable triggered before computing the skeleton's matrices
  15940. */
  15941. onBeforeComputeObservable: Observable<Skeleton>;
  15942. /**
  15943. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15944. */
  15945. get isUsingTextureForMatrices(): boolean;
  15946. /**
  15947. * Gets the unique ID of this skeleton
  15948. */
  15949. get uniqueId(): number;
  15950. /**
  15951. * Creates a new skeleton
  15952. * @param name defines the skeleton name
  15953. * @param id defines the skeleton Id
  15954. * @param scene defines the hosting scene
  15955. */
  15956. constructor(
  15957. /** defines the skeleton name */
  15958. name: string,
  15959. /** defines the skeleton Id */
  15960. id: string, scene: Scene);
  15961. /**
  15962. * Gets the current object class name.
  15963. * @return the class name
  15964. */
  15965. getClassName(): string;
  15966. /**
  15967. * Returns an array containing the root bones
  15968. * @returns an array containing the root bones
  15969. */
  15970. getChildren(): Array<Bone>;
  15971. /**
  15972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15974. * @returns a Float32Array containing matrices data
  15975. */
  15976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15977. /**
  15978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15980. * @returns a raw texture containing the data
  15981. */
  15982. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15983. /**
  15984. * Gets the current hosting scene
  15985. * @returns a scene object
  15986. */
  15987. getScene(): Scene;
  15988. /**
  15989. * Gets a string representing the current skeleton data
  15990. * @param fullDetails defines a boolean indicating if we want a verbose version
  15991. * @returns a string representing the current skeleton data
  15992. */
  15993. toString(fullDetails?: boolean): string;
  15994. /**
  15995. * Get bone's index searching by name
  15996. * @param name defines bone's name to search for
  15997. * @return the indice of the bone. Returns -1 if not found
  15998. */
  15999. getBoneIndexByName(name: string): number;
  16000. /**
  16001. * Creater a new animation range
  16002. * @param name defines the name of the range
  16003. * @param from defines the start key
  16004. * @param to defines the end key
  16005. */
  16006. createAnimationRange(name: string, from: number, to: number): void;
  16007. /**
  16008. * Delete a specific animation range
  16009. * @param name defines the name of the range
  16010. * @param deleteFrames defines if frames must be removed as well
  16011. */
  16012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16013. /**
  16014. * Gets a specific animation range
  16015. * @param name defines the name of the range to look for
  16016. * @returns the requested animation range or null if not found
  16017. */
  16018. getAnimationRange(name: string): Nullable<AnimationRange>;
  16019. /**
  16020. * Gets the list of all animation ranges defined on this skeleton
  16021. * @returns an array
  16022. */
  16023. getAnimationRanges(): Nullable<AnimationRange>[];
  16024. /**
  16025. * Copy animation range from a source skeleton.
  16026. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16027. * @param source defines the source skeleton
  16028. * @param name defines the name of the range to copy
  16029. * @param rescaleAsRequired defines if rescaling must be applied if required
  16030. * @returns true if operation was successful
  16031. */
  16032. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16033. /**
  16034. * Forces the skeleton to go to rest pose
  16035. */
  16036. returnToRest(): void;
  16037. private _getHighestAnimationFrame;
  16038. /**
  16039. * Begin a specific animation range
  16040. * @param name defines the name of the range to start
  16041. * @param loop defines if looping must be turned on (false by default)
  16042. * @param speedRatio defines the speed ratio to apply (1 by default)
  16043. * @param onAnimationEnd defines a callback which will be called when animation will end
  16044. * @returns a new animatable
  16045. */
  16046. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16047. /**
  16048. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16049. * @param skeleton defines the Skeleton containing the animation range to convert
  16050. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16051. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16052. * @returns the original skeleton
  16053. */
  16054. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16055. /** @hidden */
  16056. _markAsDirty(): void;
  16057. /** @hidden */
  16058. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. /** @hidden */
  16060. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16061. private _computeTransformMatrices;
  16062. /**
  16063. * Build all resources required to render a skeleton
  16064. */
  16065. prepare(): void;
  16066. /**
  16067. * Gets the list of animatables currently running for this skeleton
  16068. * @returns an array of animatables
  16069. */
  16070. getAnimatables(): IAnimatable[];
  16071. /**
  16072. * Clone the current skeleton
  16073. * @param name defines the name of the new skeleton
  16074. * @param id defines the id of the new skeleton
  16075. * @returns the new skeleton
  16076. */
  16077. clone(name: string, id?: string): Skeleton;
  16078. /**
  16079. * Enable animation blending for this skeleton
  16080. * @param blendingSpeed defines the blending speed to apply
  16081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16082. */
  16083. enableBlending(blendingSpeed?: number): void;
  16084. /**
  16085. * Releases all resources associated with the current skeleton
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Serialize the skeleton in a JSON object
  16090. * @returns a JSON object
  16091. */
  16092. serialize(): any;
  16093. /**
  16094. * Creates a new skeleton from serialized data
  16095. * @param parsedSkeleton defines the serialized data
  16096. * @param scene defines the hosting scene
  16097. * @returns a new skeleton
  16098. */
  16099. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16100. /**
  16101. * Compute all node absolute transforms
  16102. * @param forceUpdate defines if computation must be done even if cache is up to date
  16103. */
  16104. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16105. /**
  16106. * Gets the root pose matrix
  16107. * @returns a matrix
  16108. */
  16109. getPoseMatrix(): Nullable<Matrix>;
  16110. /**
  16111. * Sorts bones per internal index
  16112. */
  16113. sortBones(): void;
  16114. private _sortBones;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Creates an instance based on a source mesh.
  16120. */
  16121. export class InstancedMesh extends AbstractMesh {
  16122. private _sourceMesh;
  16123. private _currentLOD;
  16124. /** @hidden */
  16125. _indexInSourceMeshInstanceArray: number;
  16126. constructor(name: string, source: Mesh);
  16127. /**
  16128. * Returns the string "InstancedMesh".
  16129. */
  16130. getClassName(): string;
  16131. /** Gets the list of lights affecting that mesh */
  16132. get lightSources(): Light[];
  16133. _resyncLightSources(): void;
  16134. _resyncLightSource(light: Light): void;
  16135. _removeLightSource(light: Light, dispose: boolean): void;
  16136. /**
  16137. * If the source mesh receives shadows
  16138. */
  16139. get receiveShadows(): boolean;
  16140. /**
  16141. * The material of the source mesh
  16142. */
  16143. get material(): Nullable<Material>;
  16144. /**
  16145. * Visibility of the source mesh
  16146. */
  16147. get visibility(): number;
  16148. /**
  16149. * Skeleton of the source mesh
  16150. */
  16151. get skeleton(): Nullable<Skeleton>;
  16152. /**
  16153. * Rendering ground id of the source mesh
  16154. */
  16155. get renderingGroupId(): number;
  16156. set renderingGroupId(value: number);
  16157. /**
  16158. * Returns the total number of vertices (integer).
  16159. */
  16160. getTotalVertices(): number;
  16161. /**
  16162. * Returns a positive integer : the total number of indices in this mesh geometry.
  16163. * @returns the numner of indices or zero if the mesh has no geometry.
  16164. */
  16165. getTotalIndices(): number;
  16166. /**
  16167. * The source mesh of the instance
  16168. */
  16169. get sourceMesh(): Mesh;
  16170. /**
  16171. * Creates a new InstancedMesh object from the mesh model.
  16172. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16173. * @param name defines the name of the new instance
  16174. * @returns a new InstancedMesh
  16175. */
  16176. createInstance(name: string): InstancedMesh;
  16177. /**
  16178. * Is this node ready to be used/rendered
  16179. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16180. * @return {boolean} is it ready
  16181. */
  16182. isReady(completeCheck?: boolean): boolean;
  16183. /**
  16184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16185. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16186. * @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.
  16187. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16188. */
  16189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16190. /**
  16191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16193. * The `data` are either a numeric array either a Float32Array.
  16194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16195. * 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).
  16196. * Note that a new underlying VertexBuffer object is created each call.
  16197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16198. *
  16199. * Possible `kind` values :
  16200. * - VertexBuffer.PositionKind
  16201. * - VertexBuffer.UVKind
  16202. * - VertexBuffer.UV2Kind
  16203. * - VertexBuffer.UV3Kind
  16204. * - VertexBuffer.UV4Kind
  16205. * - VertexBuffer.UV5Kind
  16206. * - VertexBuffer.UV6Kind
  16207. * - VertexBuffer.ColorKind
  16208. * - VertexBuffer.MatricesIndicesKind
  16209. * - VertexBuffer.MatricesIndicesExtraKind
  16210. * - VertexBuffer.MatricesWeightsKind
  16211. * - VertexBuffer.MatricesWeightsExtraKind
  16212. *
  16213. * Returns the Mesh.
  16214. */
  16215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16216. /**
  16217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16218. * If the mesh has no geometry, it is simply returned as it is.
  16219. * The `data` are either a numeric array either a Float32Array.
  16220. * No new underlying VertexBuffer object is created.
  16221. * 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.
  16222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16223. *
  16224. * Possible `kind` values :
  16225. * - VertexBuffer.PositionKind
  16226. * - VertexBuffer.UVKind
  16227. * - VertexBuffer.UV2Kind
  16228. * - VertexBuffer.UV3Kind
  16229. * - VertexBuffer.UV4Kind
  16230. * - VertexBuffer.UV5Kind
  16231. * - VertexBuffer.UV6Kind
  16232. * - VertexBuffer.ColorKind
  16233. * - VertexBuffer.MatricesIndicesKind
  16234. * - VertexBuffer.MatricesIndicesExtraKind
  16235. * - VertexBuffer.MatricesWeightsKind
  16236. * - VertexBuffer.MatricesWeightsExtraKind
  16237. *
  16238. * Returns the Mesh.
  16239. */
  16240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16241. /**
  16242. * Sets the mesh indices.
  16243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16245. * This method creates a new index buffer each call.
  16246. * Returns the Mesh.
  16247. */
  16248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16249. /**
  16250. * Boolean : True if the mesh owns the requested kind of data.
  16251. */
  16252. isVerticesDataPresent(kind: string): boolean;
  16253. /**
  16254. * Returns an array of indices (IndicesArray).
  16255. */
  16256. getIndices(): Nullable<IndicesArray>;
  16257. get _positions(): Nullable<Vector3[]>;
  16258. /**
  16259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16260. * This means the mesh underlying bounding box and sphere are recomputed.
  16261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16262. * @returns the current mesh
  16263. */
  16264. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16265. /** @hidden */
  16266. _preActivate(): InstancedMesh;
  16267. /** @hidden */
  16268. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16269. /** @hidden */
  16270. _postActivate(): void;
  16271. getWorldMatrix(): Matrix;
  16272. get isAnInstance(): boolean;
  16273. /**
  16274. * Returns the current associated LOD AbstractMesh.
  16275. */
  16276. getLOD(camera: Camera): AbstractMesh;
  16277. /** @hidden */
  16278. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16279. /** @hidden */
  16280. _syncSubMeshes(): InstancedMesh;
  16281. /** @hidden */
  16282. _generatePointsArray(): boolean;
  16283. /**
  16284. * Creates a new InstancedMesh from the current mesh.
  16285. * - name (string) : the cloned mesh name
  16286. * - newParent (optional Node) : the optional Node to parent the clone to.
  16287. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16288. *
  16289. * Returns the clone.
  16290. */
  16291. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16292. /**
  16293. * Disposes the InstancedMesh.
  16294. * Returns nothing.
  16295. */
  16296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16297. }
  16298. interface Mesh {
  16299. /**
  16300. * Register a custom buffer that will be instanced
  16301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16302. * @param kind defines the buffer kind
  16303. * @param stride defines the stride in floats
  16304. */
  16305. registerInstancedBuffer(kind: string, stride: number): void;
  16306. /**
  16307. * true to use the edge renderer for all instances of this mesh
  16308. */
  16309. edgesShareWithInstances: boolean;
  16310. /** @hidden */
  16311. _userInstancedBuffersStorage: {
  16312. data: {
  16313. [key: string]: Float32Array;
  16314. };
  16315. sizes: {
  16316. [key: string]: number;
  16317. };
  16318. vertexBuffers: {
  16319. [key: string]: Nullable<VertexBuffer>;
  16320. };
  16321. strides: {
  16322. [key: string]: number;
  16323. };
  16324. };
  16325. }
  16326. interface AbstractMesh {
  16327. /**
  16328. * Object used to store instanced buffers defined by user
  16329. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16330. */
  16331. instancedBuffers: {
  16332. [key: string]: any;
  16333. };
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /**
  16338. * Defines the options associated with the creation of a shader material.
  16339. */
  16340. export interface IShaderMaterialOptions {
  16341. /**
  16342. * Does the material work in alpha blend mode
  16343. */
  16344. needAlphaBlending: boolean;
  16345. /**
  16346. * Does the material work in alpha test mode
  16347. */
  16348. needAlphaTesting: boolean;
  16349. /**
  16350. * The list of attribute names used in the shader
  16351. */
  16352. attributes: string[];
  16353. /**
  16354. * The list of unifrom names used in the shader
  16355. */
  16356. uniforms: string[];
  16357. /**
  16358. * The list of UBO names used in the shader
  16359. */
  16360. uniformBuffers: string[];
  16361. /**
  16362. * The list of sampler names used in the shader
  16363. */
  16364. samplers: string[];
  16365. /**
  16366. * The list of defines used in the shader
  16367. */
  16368. defines: string[];
  16369. }
  16370. /**
  16371. * 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.
  16372. *
  16373. * This returned material effects how the mesh will look based on the code in the shaders.
  16374. *
  16375. * @see http://doc.babylonjs.com/how_to/shader_material
  16376. */
  16377. export class ShaderMaterial extends Material {
  16378. private _shaderPath;
  16379. private _options;
  16380. private _textures;
  16381. private _textureArrays;
  16382. private _floats;
  16383. private _ints;
  16384. private _floatsArrays;
  16385. private _colors3;
  16386. private _colors3Arrays;
  16387. private _colors4;
  16388. private _colors4Arrays;
  16389. private _vectors2;
  16390. private _vectors3;
  16391. private _vectors4;
  16392. private _matrices;
  16393. private _matrixArrays;
  16394. private _matrices3x3;
  16395. private _matrices2x2;
  16396. private _vectors2Arrays;
  16397. private _vectors3Arrays;
  16398. private _vectors4Arrays;
  16399. private _cachedWorldViewMatrix;
  16400. private _cachedWorldViewProjectionMatrix;
  16401. private _renderId;
  16402. private _multiview;
  16403. private _cachedDefines;
  16404. /** Define the Url to load snippets */
  16405. static SnippetUrl: string;
  16406. /** Snippet ID if the material was created from the snippet server */
  16407. snippetId: string;
  16408. /**
  16409. * Instantiate a new shader material.
  16410. * 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.
  16411. * This returned material effects how the mesh will look based on the code in the shaders.
  16412. * @see http://doc.babylonjs.com/how_to/shader_material
  16413. * @param name Define the name of the material in the scene
  16414. * @param scene Define the scene the material belongs to
  16415. * @param shaderPath Defines the route to the shader code in one of three ways:
  16416. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16417. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16418. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16419. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16420. * @param options Define the options used to create the shader
  16421. */
  16422. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16423. /**
  16424. * Gets the shader path used to define the shader code
  16425. * It can be modified to trigger a new compilation
  16426. */
  16427. get shaderPath(): any;
  16428. /**
  16429. * Sets the shader path used to define the shader code
  16430. * It can be modified to trigger a new compilation
  16431. */
  16432. set shaderPath(shaderPath: any);
  16433. /**
  16434. * Gets the options used to compile the shader.
  16435. * They can be modified to trigger a new compilation
  16436. */
  16437. get options(): IShaderMaterialOptions;
  16438. /**
  16439. * Gets the current class name of the material e.g. "ShaderMaterial"
  16440. * Mainly use in serialization.
  16441. * @returns the class name
  16442. */
  16443. getClassName(): string;
  16444. /**
  16445. * Specifies if the material will require alpha blending
  16446. * @returns a boolean specifying if alpha blending is needed
  16447. */
  16448. needAlphaBlending(): boolean;
  16449. /**
  16450. * Specifies if this material should be rendered in alpha test mode
  16451. * @returns a boolean specifying if an alpha test is needed.
  16452. */
  16453. needAlphaTesting(): boolean;
  16454. private _checkUniform;
  16455. /**
  16456. * Set a texture in the shader.
  16457. * @param name Define the name of the uniform samplers as defined in the shader
  16458. * @param texture Define the texture to bind to this sampler
  16459. * @return the material itself allowing "fluent" like uniform updates
  16460. */
  16461. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16462. /**
  16463. * Set a texture array in the shader.
  16464. * @param name Define the name of the uniform sampler array as defined in the shader
  16465. * @param textures Define the list of textures to bind to this sampler
  16466. * @return the material itself allowing "fluent" like uniform updates
  16467. */
  16468. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16469. /**
  16470. * Set a float in the shader.
  16471. * @param name Define the name of the uniform as defined in the shader
  16472. * @param value Define the value to give to the uniform
  16473. * @return the material itself allowing "fluent" like uniform updates
  16474. */
  16475. setFloat(name: string, value: number): ShaderMaterial;
  16476. /**
  16477. * Set a int in the shader.
  16478. * @param name Define the name of the uniform as defined in the shader
  16479. * @param value Define the value to give to the uniform
  16480. * @return the material itself allowing "fluent" like uniform updates
  16481. */
  16482. setInt(name: string, value: number): ShaderMaterial;
  16483. /**
  16484. * Set an array of floats in the shader.
  16485. * @param name Define the name of the uniform as defined in the shader
  16486. * @param value Define the value to give to the uniform
  16487. * @return the material itself allowing "fluent" like uniform updates
  16488. */
  16489. setFloats(name: string, value: number[]): ShaderMaterial;
  16490. /**
  16491. * Set a vec3 in the shader from a Color3.
  16492. * @param name Define the name of the uniform as defined in the shader
  16493. * @param value Define the value to give to the uniform
  16494. * @return the material itself allowing "fluent" like uniform updates
  16495. */
  16496. setColor3(name: string, value: Color3): ShaderMaterial;
  16497. /**
  16498. * Set a vec3 array in the shader from a Color3 array.
  16499. * @param name Define the name of the uniform as defined in the shader
  16500. * @param value Define the value to give to the uniform
  16501. * @return the material itself allowing "fluent" like uniform updates
  16502. */
  16503. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16504. /**
  16505. * Set a vec4 in the shader from a Color4.
  16506. * @param name Define the name of the uniform as defined in the shader
  16507. * @param value Define the value to give to the uniform
  16508. * @return the material itself allowing "fluent" like uniform updates
  16509. */
  16510. setColor4(name: string, value: Color4): ShaderMaterial;
  16511. /**
  16512. * Set a vec4 array in the shader from a Color4 array.
  16513. * @param name Define the name of the uniform as defined in the shader
  16514. * @param value Define the value to give to the uniform
  16515. * @return the material itself allowing "fluent" like uniform updates
  16516. */
  16517. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16518. /**
  16519. * Set a vec2 in the shader from a Vector2.
  16520. * @param name Define the name of the uniform as defined in the shader
  16521. * @param value Define the value to give to the uniform
  16522. * @return the material itself allowing "fluent" like uniform updates
  16523. */
  16524. setVector2(name: string, value: Vector2): ShaderMaterial;
  16525. /**
  16526. * Set a vec3 in the shader from a Vector3.
  16527. * @param name Define the name of the uniform as defined in the shader
  16528. * @param value Define the value to give to the uniform
  16529. * @return the material itself allowing "fluent" like uniform updates
  16530. */
  16531. setVector3(name: string, value: Vector3): ShaderMaterial;
  16532. /**
  16533. * Set a vec4 in the shader from a Vector4.
  16534. * @param name Define the name of the uniform as defined in the shader
  16535. * @param value Define the value to give to the uniform
  16536. * @return the material itself allowing "fluent" like uniform updates
  16537. */
  16538. setVector4(name: string, value: Vector4): ShaderMaterial;
  16539. /**
  16540. * Set a mat4 in the shader from a Matrix.
  16541. * @param name Define the name of the uniform as defined in the shader
  16542. * @param value Define the value to give to the uniform
  16543. * @return the material itself allowing "fluent" like uniform updates
  16544. */
  16545. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16546. /**
  16547. * Set a float32Array in the shader from a matrix array.
  16548. * @param name Define the name of the uniform as defined in the shader
  16549. * @param value Define the value to give to the uniform
  16550. * @return the material itself allowing "fluent" like uniform updates
  16551. */
  16552. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16553. /**
  16554. * Set a mat3 in the shader from a Float32Array.
  16555. * @param name Define the name of the uniform as defined in the shader
  16556. * @param value Define the value to give to the uniform
  16557. * @return the material itself allowing "fluent" like uniform updates
  16558. */
  16559. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16560. /**
  16561. * Set a mat2 in the shader from a Float32Array.
  16562. * @param name Define the name of the uniform as defined in the shader
  16563. * @param value Define the value to give to the uniform
  16564. * @return the material itself allowing "fluent" like uniform updates
  16565. */
  16566. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16567. /**
  16568. * Set a vec2 array in the shader from a number array.
  16569. * @param name Define the name of the uniform as defined in the shader
  16570. * @param value Define the value to give to the uniform
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setArray2(name: string, value: number[]): ShaderMaterial;
  16574. /**
  16575. * Set a vec3 array in the shader from a number array.
  16576. * @param name Define the name of the uniform as defined in the shader
  16577. * @param value Define the value to give to the uniform
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setArray3(name: string, value: number[]): ShaderMaterial;
  16581. /**
  16582. * Set a vec4 array in the shader from a number array.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setArray4(name: string, value: number[]): ShaderMaterial;
  16588. private _checkCache;
  16589. /**
  16590. * Specifies that the submesh is ready to be used
  16591. * @param mesh defines the mesh to check
  16592. * @param subMesh defines which submesh to check
  16593. * @param useInstances specifies that instances should be used
  16594. * @returns a boolean indicating that the submesh is ready or not
  16595. */
  16596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16597. /**
  16598. * Checks if the material is ready to render the requested mesh
  16599. * @param mesh Define the mesh to render
  16600. * @param useInstances Define whether or not the material is used with instances
  16601. * @returns true if ready, otherwise false
  16602. */
  16603. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16604. /**
  16605. * Binds the world matrix to the material
  16606. * @param world defines the world transformation matrix
  16607. * @param effectOverride - If provided, use this effect instead of internal effect
  16608. */
  16609. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16610. /**
  16611. * Binds the submesh to this material by preparing the effect and shader to draw
  16612. * @param world defines the world transformation matrix
  16613. * @param mesh defines the mesh containing the submesh
  16614. * @param subMesh defines the submesh to bind the material to
  16615. */
  16616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16617. /**
  16618. * Binds the material to the mesh
  16619. * @param world defines the world transformation matrix
  16620. * @param mesh defines the mesh to bind the material to
  16621. * @param effectOverride - If provided, use this effect instead of internal effect
  16622. */
  16623. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16624. protected _afterBind(mesh?: Mesh): void;
  16625. /**
  16626. * Gets the active textures from the material
  16627. * @returns an array of textures
  16628. */
  16629. getActiveTextures(): BaseTexture[];
  16630. /**
  16631. * Specifies if the material uses a texture
  16632. * @param texture defines the texture to check against the material
  16633. * @returns a boolean specifying if the material uses the texture
  16634. */
  16635. hasTexture(texture: BaseTexture): boolean;
  16636. /**
  16637. * Makes a duplicate of the material, and gives it a new name
  16638. * @param name defines the new name for the duplicated material
  16639. * @returns the cloned material
  16640. */
  16641. clone(name: string): ShaderMaterial;
  16642. /**
  16643. * Disposes the material
  16644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16647. */
  16648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16649. /**
  16650. * Serializes this material in a JSON representation
  16651. * @returns the serialized material object
  16652. */
  16653. serialize(): any;
  16654. /**
  16655. * Creates a shader material from parsed shader material data
  16656. * @param source defines the JSON represnetation of the material
  16657. * @param scene defines the hosting scene
  16658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16659. * @returns a new material
  16660. */
  16661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16662. /**
  16663. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16664. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16665. * @param url defines the url to load from
  16666. * @param scene defines the hosting scene
  16667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16668. * @returns a promise that will resolve to the new ShaderMaterial
  16669. */
  16670. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16671. /**
  16672. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16673. * @param snippetId defines the snippet to load
  16674. * @param scene defines the hosting scene
  16675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16676. * @returns a promise that will resolve to the new ShaderMaterial
  16677. */
  16678. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16679. }
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var colorPixelShader: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var colorVertexShader: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /**
  16697. * Line mesh
  16698. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16699. */
  16700. export class LinesMesh extends Mesh {
  16701. /**
  16702. * If vertex color should be applied to the mesh
  16703. */
  16704. readonly useVertexColor?: boolean | undefined;
  16705. /**
  16706. * If vertex alpha should be applied to the mesh
  16707. */
  16708. readonly useVertexAlpha?: boolean | undefined;
  16709. /**
  16710. * Color of the line (Default: White)
  16711. */
  16712. color: Color3;
  16713. /**
  16714. * Alpha of the line (Default: 1)
  16715. */
  16716. alpha: number;
  16717. /**
  16718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16719. * This margin is expressed in world space coordinates, so its value may vary.
  16720. * Default value is 0.1
  16721. */
  16722. intersectionThreshold: number;
  16723. private _colorShader;
  16724. private color4;
  16725. /**
  16726. * Creates a new LinesMesh
  16727. * @param name defines the name
  16728. * @param scene defines the hosting scene
  16729. * @param parent defines the parent mesh if any
  16730. * @param source defines the optional source LinesMesh used to clone data from
  16731. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16732. * When false, achieved by calling a clone(), also passing False.
  16733. * This will make creation of children, recursive.
  16734. * @param useVertexColor defines if this LinesMesh supports vertex color
  16735. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16736. */
  16737. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16738. /**
  16739. * If vertex color should be applied to the mesh
  16740. */
  16741. useVertexColor?: boolean | undefined,
  16742. /**
  16743. * If vertex alpha should be applied to the mesh
  16744. */
  16745. useVertexAlpha?: boolean | undefined);
  16746. private _addClipPlaneDefine;
  16747. private _removeClipPlaneDefine;
  16748. isReady(): boolean;
  16749. /**
  16750. * Returns the string "LineMesh"
  16751. */
  16752. getClassName(): string;
  16753. /**
  16754. * @hidden
  16755. */
  16756. get material(): Material;
  16757. /**
  16758. * @hidden
  16759. */
  16760. set material(value: Material);
  16761. /**
  16762. * @hidden
  16763. */
  16764. get checkCollisions(): boolean;
  16765. /** @hidden */
  16766. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16767. /** @hidden */
  16768. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16769. /**
  16770. * Disposes of the line mesh
  16771. * @param doNotRecurse If children should be disposed
  16772. */
  16773. dispose(doNotRecurse?: boolean): void;
  16774. /**
  16775. * Returns a new LineMesh object cloned from the current one.
  16776. */
  16777. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16778. /**
  16779. * Creates a new InstancedLinesMesh object from the mesh model.
  16780. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16781. * @param name defines the name of the new instance
  16782. * @returns a new InstancedLinesMesh
  16783. */
  16784. createInstance(name: string): InstancedLinesMesh;
  16785. }
  16786. /**
  16787. * Creates an instance based on a source LinesMesh
  16788. */
  16789. export class InstancedLinesMesh extends InstancedMesh {
  16790. /**
  16791. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16792. * This margin is expressed in world space coordinates, so its value may vary.
  16793. * Initilized with the intersectionThreshold value of the source LinesMesh
  16794. */
  16795. intersectionThreshold: number;
  16796. constructor(name: string, source: LinesMesh);
  16797. /**
  16798. * Returns the string "InstancedLinesMesh".
  16799. */
  16800. getClassName(): string;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /** @hidden */
  16805. export var linePixelShader: {
  16806. name: string;
  16807. shader: string;
  16808. };
  16809. }
  16810. declare module BABYLON {
  16811. /** @hidden */
  16812. export var lineVertexShader: {
  16813. name: string;
  16814. shader: string;
  16815. };
  16816. }
  16817. declare module BABYLON {
  16818. interface Scene {
  16819. /** @hidden */
  16820. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16821. }
  16822. interface AbstractMesh {
  16823. /**
  16824. * Gets the edgesRenderer associated with the mesh
  16825. */
  16826. edgesRenderer: Nullable<EdgesRenderer>;
  16827. }
  16828. interface LinesMesh {
  16829. /**
  16830. * Enables the edge rendering mode on the mesh.
  16831. * This mode makes the mesh edges visible
  16832. * @param epsilon defines the maximal distance between two angles to detect a face
  16833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16834. * @returns the currentAbstractMesh
  16835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16836. */
  16837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16838. }
  16839. interface InstancedLinesMesh {
  16840. /**
  16841. * Enables the edge rendering mode on the mesh.
  16842. * This mode makes the mesh edges visible
  16843. * @param epsilon defines the maximal distance between two angles to detect a face
  16844. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16845. * @returns the current InstancedLinesMesh
  16846. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16847. */
  16848. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16849. }
  16850. /**
  16851. * Defines the minimum contract an Edges renderer should follow.
  16852. */
  16853. export interface IEdgesRenderer extends IDisposable {
  16854. /**
  16855. * Gets or sets a boolean indicating if the edgesRenderer is active
  16856. */
  16857. isEnabled: boolean;
  16858. /**
  16859. * Renders the edges of the attached mesh,
  16860. */
  16861. render(): void;
  16862. /**
  16863. * Checks wether or not the edges renderer is ready to render.
  16864. * @return true if ready, otherwise false.
  16865. */
  16866. isReady(): boolean;
  16867. /**
  16868. * List of instances to render in case the source mesh has instances
  16869. */
  16870. customInstances: SmartArray<Matrix>;
  16871. }
  16872. /**
  16873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16874. */
  16875. export class EdgesRenderer implements IEdgesRenderer {
  16876. /**
  16877. * Define the size of the edges with an orthographic camera
  16878. */
  16879. edgesWidthScalerForOrthographic: number;
  16880. /**
  16881. * Define the size of the edges with a perspective camera
  16882. */
  16883. edgesWidthScalerForPerspective: number;
  16884. protected _source: AbstractMesh;
  16885. protected _linesPositions: number[];
  16886. protected _linesNormals: number[];
  16887. protected _linesIndices: number[];
  16888. protected _epsilon: number;
  16889. protected _indicesCount: number;
  16890. protected _lineShader: ShaderMaterial;
  16891. protected _ib: DataBuffer;
  16892. protected _buffers: {
  16893. [key: string]: Nullable<VertexBuffer>;
  16894. };
  16895. protected _buffersForInstances: {
  16896. [key: string]: Nullable<VertexBuffer>;
  16897. };
  16898. protected _checkVerticesInsteadOfIndices: boolean;
  16899. private _meshRebuildObserver;
  16900. private _meshDisposeObserver;
  16901. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16902. isEnabled: boolean;
  16903. /**
  16904. * List of instances to render in case the source mesh has instances
  16905. */
  16906. customInstances: SmartArray<Matrix>;
  16907. private static GetShader;
  16908. /**
  16909. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16910. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16911. * @param source Mesh used to create edges
  16912. * @param epsilon sum of angles in adjacency to check for edge
  16913. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16914. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16915. */
  16916. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16917. protected _prepareRessources(): void;
  16918. /** @hidden */
  16919. _rebuild(): void;
  16920. /**
  16921. * Releases the required resources for the edges renderer
  16922. */
  16923. dispose(): void;
  16924. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16925. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16926. /**
  16927. * Checks if the pair of p0 and p1 is en edge
  16928. * @param faceIndex
  16929. * @param edge
  16930. * @param faceNormals
  16931. * @param p0
  16932. * @param p1
  16933. * @private
  16934. */
  16935. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16936. /**
  16937. * push line into the position, normal and index buffer
  16938. * @protected
  16939. */
  16940. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16941. /**
  16942. * Generates lines edges from adjacencjes
  16943. * @private
  16944. */
  16945. _generateEdgesLines(): void;
  16946. /**
  16947. * Checks wether or not the edges renderer is ready to render.
  16948. * @return true if ready, otherwise false.
  16949. */
  16950. isReady(): boolean;
  16951. /**
  16952. * Renders the edges of the attached mesh,
  16953. */
  16954. render(): void;
  16955. }
  16956. /**
  16957. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16958. */
  16959. export class LineEdgesRenderer extends EdgesRenderer {
  16960. /**
  16961. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16962. * @param source LineMesh used to generate edges
  16963. * @param epsilon not important (specified angle for edge detection)
  16964. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16965. */
  16966. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16967. /**
  16968. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16969. */
  16970. _generateEdgesLines(): void;
  16971. }
  16972. }
  16973. declare module BABYLON {
  16974. /**
  16975. * This represents the object necessary to create a rendering group.
  16976. * This is exclusively used and created by the rendering manager.
  16977. * To modify the behavior, you use the available helpers in your scene or meshes.
  16978. * @hidden
  16979. */
  16980. export class RenderingGroup {
  16981. index: number;
  16982. private static _zeroVector;
  16983. private _scene;
  16984. private _opaqueSubMeshes;
  16985. private _transparentSubMeshes;
  16986. private _alphaTestSubMeshes;
  16987. private _depthOnlySubMeshes;
  16988. private _particleSystems;
  16989. private _spriteManagers;
  16990. private _opaqueSortCompareFn;
  16991. private _alphaTestSortCompareFn;
  16992. private _transparentSortCompareFn;
  16993. private _renderOpaque;
  16994. private _renderAlphaTest;
  16995. private _renderTransparent;
  16996. /** @hidden */
  16997. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16998. onBeforeTransparentRendering: () => void;
  16999. /**
  17000. * Set the opaque sort comparison function.
  17001. * If null the sub meshes will be render in the order they were created
  17002. */
  17003. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17004. /**
  17005. * Set the alpha test sort comparison function.
  17006. * If null the sub meshes will be render in the order they were created
  17007. */
  17008. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17009. /**
  17010. * Set the transparent sort comparison function.
  17011. * If null the sub meshes will be render in the order they were created
  17012. */
  17013. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17014. /**
  17015. * Creates a new rendering group.
  17016. * @param index The rendering group index
  17017. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17018. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17019. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17020. */
  17021. 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>);
  17022. /**
  17023. * Render all the sub meshes contained in the group.
  17024. * @param customRenderFunction Used to override the default render behaviour of the group.
  17025. * @returns true if rendered some submeshes.
  17026. */
  17027. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17028. /**
  17029. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17030. * @param subMeshes The submeshes to render
  17031. */
  17032. private renderOpaqueSorted;
  17033. /**
  17034. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17035. * @param subMeshes The submeshes to render
  17036. */
  17037. private renderAlphaTestSorted;
  17038. /**
  17039. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17040. * @param subMeshes The submeshes to render
  17041. */
  17042. private renderTransparentSorted;
  17043. /**
  17044. * Renders the submeshes in a specified order.
  17045. * @param subMeshes The submeshes to sort before render
  17046. * @param sortCompareFn The comparison function use to sort
  17047. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17048. * @param transparent Specifies to activate blending if true
  17049. */
  17050. private static renderSorted;
  17051. /**
  17052. * Renders the submeshes in the order they were dispatched (no sort applied).
  17053. * @param subMeshes The submeshes to render
  17054. */
  17055. private static renderUnsorted;
  17056. /**
  17057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17058. * are rendered back to front if in the same alpha index.
  17059. *
  17060. * @param a The first submesh
  17061. * @param b The second submesh
  17062. * @returns The result of the comparison
  17063. */
  17064. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17065. /**
  17066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17067. * are rendered back to front.
  17068. *
  17069. * @param a The first submesh
  17070. * @param b The second submesh
  17071. * @returns The result of the comparison
  17072. */
  17073. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17074. /**
  17075. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17076. * are rendered front to back (prevent overdraw).
  17077. *
  17078. * @param a The first submesh
  17079. * @param b The second submesh
  17080. * @returns The result of the comparison
  17081. */
  17082. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17083. /**
  17084. * Resets the different lists of submeshes to prepare a new frame.
  17085. */
  17086. prepare(): void;
  17087. dispose(): void;
  17088. /**
  17089. * Inserts the submesh in its correct queue depending on its material.
  17090. * @param subMesh The submesh to dispatch
  17091. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17092. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17093. */
  17094. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17095. dispatchSprites(spriteManager: ISpriteManager): void;
  17096. dispatchParticles(particleSystem: IParticleSystem): void;
  17097. private _renderParticles;
  17098. private _renderSprites;
  17099. }
  17100. }
  17101. declare module BABYLON {
  17102. /**
  17103. * Interface describing the different options available in the rendering manager
  17104. * regarding Auto Clear between groups.
  17105. */
  17106. export interface IRenderingManagerAutoClearSetup {
  17107. /**
  17108. * Defines whether or not autoclear is enable.
  17109. */
  17110. autoClear: boolean;
  17111. /**
  17112. * Defines whether or not to autoclear the depth buffer.
  17113. */
  17114. depth: boolean;
  17115. /**
  17116. * Defines whether or not to autoclear the stencil buffer.
  17117. */
  17118. stencil: boolean;
  17119. }
  17120. /**
  17121. * This class is used by the onRenderingGroupObservable
  17122. */
  17123. export class RenderingGroupInfo {
  17124. /**
  17125. * The Scene that being rendered
  17126. */
  17127. scene: Scene;
  17128. /**
  17129. * The camera currently used for the rendering pass
  17130. */
  17131. camera: Nullable<Camera>;
  17132. /**
  17133. * The ID of the renderingGroup being processed
  17134. */
  17135. renderingGroupId: number;
  17136. }
  17137. /**
  17138. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17139. * It is enable to manage the different groups as well as the different necessary sort functions.
  17140. * This should not be used directly aside of the few static configurations
  17141. */
  17142. export class RenderingManager {
  17143. /**
  17144. * The max id used for rendering groups (not included)
  17145. */
  17146. static MAX_RENDERINGGROUPS: number;
  17147. /**
  17148. * The min id used for rendering groups (included)
  17149. */
  17150. static MIN_RENDERINGGROUPS: number;
  17151. /**
  17152. * Used to globally prevent autoclearing scenes.
  17153. */
  17154. static AUTOCLEAR: boolean;
  17155. /**
  17156. * @hidden
  17157. */
  17158. _useSceneAutoClearSetup: boolean;
  17159. private _scene;
  17160. private _renderingGroups;
  17161. private _depthStencilBufferAlreadyCleaned;
  17162. private _autoClearDepthStencil;
  17163. private _customOpaqueSortCompareFn;
  17164. private _customAlphaTestSortCompareFn;
  17165. private _customTransparentSortCompareFn;
  17166. private _renderingGroupInfo;
  17167. /**
  17168. * Instantiates a new rendering group for a particular scene
  17169. * @param scene Defines the scene the groups belongs to
  17170. */
  17171. constructor(scene: Scene);
  17172. private _clearDepthStencilBuffer;
  17173. /**
  17174. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17175. * @hidden
  17176. */
  17177. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17178. /**
  17179. * Resets the different information of the group to prepare a new frame
  17180. * @hidden
  17181. */
  17182. reset(): void;
  17183. /**
  17184. * Dispose and release the group and its associated resources.
  17185. * @hidden
  17186. */
  17187. dispose(): void;
  17188. /**
  17189. * Clear the info related to rendering groups preventing retention points during dispose.
  17190. */
  17191. freeRenderingGroups(): void;
  17192. private _prepareRenderingGroup;
  17193. /**
  17194. * Add a sprite manager to the rendering manager in order to render it this frame.
  17195. * @param spriteManager Define the sprite manager to render
  17196. */
  17197. dispatchSprites(spriteManager: ISpriteManager): void;
  17198. /**
  17199. * Add a particle system to the rendering manager in order to render it this frame.
  17200. * @param particleSystem Define the particle system to render
  17201. */
  17202. dispatchParticles(particleSystem: IParticleSystem): void;
  17203. /**
  17204. * Add a submesh to the manager in order to render it this frame
  17205. * @param subMesh The submesh to dispatch
  17206. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17207. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17208. */
  17209. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17210. /**
  17211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17212. * This allowed control for front to back rendering or reversly depending of the special needs.
  17213. *
  17214. * @param renderingGroupId The rendering group id corresponding to its index
  17215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17218. */
  17219. 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;
  17220. /**
  17221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17222. *
  17223. * @param renderingGroupId The rendering group id corresponding to its index
  17224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17227. */
  17228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17229. /**
  17230. * Gets the current auto clear configuration for one rendering group of the rendering
  17231. * manager.
  17232. * @param index the rendering group index to get the information for
  17233. * @returns The auto clear setup for the requested rendering group
  17234. */
  17235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17236. }
  17237. }
  17238. declare module BABYLON {
  17239. /**
  17240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17241. */
  17242. export interface ICustomShaderOptions {
  17243. /**
  17244. * Gets or sets the custom shader name to use
  17245. */
  17246. shaderName: string;
  17247. /**
  17248. * The list of attribute names used in the shader
  17249. */
  17250. attributes?: string[];
  17251. /**
  17252. * The list of unifrom names used in the shader
  17253. */
  17254. uniforms?: string[];
  17255. /**
  17256. * The list of sampler names used in the shader
  17257. */
  17258. samplers?: string[];
  17259. /**
  17260. * The list of defines used in the shader
  17261. */
  17262. defines?: string[];
  17263. }
  17264. /**
  17265. * Interface to implement to create a shadow generator compatible with BJS.
  17266. */
  17267. export interface IShadowGenerator {
  17268. /**
  17269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17270. * @returns The render target texture if present otherwise, null
  17271. */
  17272. getShadowMap(): Nullable<RenderTargetTexture>;
  17273. /**
  17274. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17275. * @param subMesh The submesh we want to render in the shadow map
  17276. * @param useInstances Defines wether will draw in the map using instances
  17277. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17278. * @returns true if ready otherwise, false
  17279. */
  17280. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17281. /**
  17282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17283. * @param defines Defines of the material we want to update
  17284. * @param lightIndex Index of the light in the enabled light list of the material
  17285. */
  17286. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17287. /**
  17288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17289. * defined in the generator but impacting the effect).
  17290. * It implies the unifroms available on the materials are the standard BJS ones.
  17291. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17292. * @param effect The effect we are binfing the information for
  17293. */
  17294. bindShadowLight(lightIndex: string, effect: Effect): void;
  17295. /**
  17296. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17297. * (eq to shadow prjection matrix * light transform matrix)
  17298. * @returns The transform matrix used to create the shadow map
  17299. */
  17300. getTransformMatrix(): Matrix;
  17301. /**
  17302. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17303. * Cube and 2D textures for instance.
  17304. */
  17305. recreateShadowMap(): void;
  17306. /**
  17307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17308. * @param onCompiled Callback triggered at the and of the effects compilation
  17309. * @param options Sets of optional options forcing the compilation with different modes
  17310. */
  17311. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17312. useInstances: boolean;
  17313. }>): void;
  17314. /**
  17315. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17316. * @param options Sets of optional options forcing the compilation with different modes
  17317. * @returns A promise that resolves when the compilation completes
  17318. */
  17319. forceCompilationAsync(options?: Partial<{
  17320. useInstances: boolean;
  17321. }>): Promise<void>;
  17322. /**
  17323. * Serializes the shadow generator setup to a json object.
  17324. * @returns The serialized JSON object
  17325. */
  17326. serialize(): any;
  17327. /**
  17328. * Disposes the Shadow map and related Textures and effects.
  17329. */
  17330. dispose(): void;
  17331. }
  17332. /**
  17333. * Default implementation IShadowGenerator.
  17334. * This is the main object responsible of generating shadows in the framework.
  17335. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17336. */
  17337. export class ShadowGenerator implements IShadowGenerator {
  17338. /**
  17339. * Name of the shadow generator class
  17340. */
  17341. static CLASSNAME: string;
  17342. /**
  17343. * Shadow generator mode None: no filtering applied.
  17344. */
  17345. static readonly FILTER_NONE: number;
  17346. /**
  17347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17349. */
  17350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17351. /**
  17352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17354. */
  17355. static readonly FILTER_POISSONSAMPLING: number;
  17356. /**
  17357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17359. */
  17360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17361. /**
  17362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17363. * edge artifacts on steep falloff.
  17364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17365. */
  17366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17367. /**
  17368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17369. * edge artifacts on steep falloff.
  17370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17371. */
  17372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17373. /**
  17374. * Shadow generator mode PCF: Percentage Closer Filtering
  17375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17377. */
  17378. static readonly FILTER_PCF: number;
  17379. /**
  17380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17382. * Contact Hardening
  17383. */
  17384. static readonly FILTER_PCSS: number;
  17385. /**
  17386. * Reserved for PCF and PCSS
  17387. * Highest Quality.
  17388. *
  17389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17390. *
  17391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17392. */
  17393. static readonly QUALITY_HIGH: number;
  17394. /**
  17395. * Reserved for PCF and PCSS
  17396. * Good tradeoff for quality/perf cross devices
  17397. *
  17398. * Execute PCF on a 3*3 kernel.
  17399. *
  17400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17401. */
  17402. static readonly QUALITY_MEDIUM: number;
  17403. /**
  17404. * Reserved for PCF and PCSS
  17405. * The lowest quality but the fastest.
  17406. *
  17407. * Execute PCF on a 1*1 kernel.
  17408. *
  17409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17410. */
  17411. static readonly QUALITY_LOW: number;
  17412. /** Gets or sets the custom shader name to use */
  17413. customShaderOptions: ICustomShaderOptions;
  17414. /**
  17415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17416. */
  17417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17418. /**
  17419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17420. */
  17421. onAfterShadowMapRenderObservable: Observable<Effect>;
  17422. /**
  17423. * Observable triggered before a mesh is rendered in the shadow map.
  17424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17425. */
  17426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17427. /**
  17428. * Observable triggered after a mesh is rendered in the shadow map.
  17429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17430. */
  17431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17432. protected _bias: number;
  17433. /**
  17434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17435. */
  17436. get bias(): number;
  17437. /**
  17438. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17439. */
  17440. set bias(bias: number);
  17441. protected _normalBias: number;
  17442. /**
  17443. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17444. */
  17445. get normalBias(): number;
  17446. /**
  17447. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17448. */
  17449. set normalBias(normalBias: number);
  17450. protected _blurBoxOffset: number;
  17451. /**
  17452. * Gets the blur box offset: offset applied during the blur pass.
  17453. * Only useful if useKernelBlur = false
  17454. */
  17455. get blurBoxOffset(): number;
  17456. /**
  17457. * Sets the blur box offset: offset applied during the blur pass.
  17458. * Only useful if useKernelBlur = false
  17459. */
  17460. set blurBoxOffset(value: number);
  17461. protected _blurScale: number;
  17462. /**
  17463. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17464. * 2 means half of the size.
  17465. */
  17466. get blurScale(): number;
  17467. /**
  17468. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17469. * 2 means half of the size.
  17470. */
  17471. set blurScale(value: number);
  17472. protected _blurKernel: number;
  17473. /**
  17474. * Gets the blur kernel: kernel size of the blur pass.
  17475. * Only useful if useKernelBlur = true
  17476. */
  17477. get blurKernel(): number;
  17478. /**
  17479. * Sets the blur kernel: kernel size of the blur pass.
  17480. * Only useful if useKernelBlur = true
  17481. */
  17482. set blurKernel(value: number);
  17483. protected _useKernelBlur: boolean;
  17484. /**
  17485. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17486. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17487. */
  17488. get useKernelBlur(): boolean;
  17489. /**
  17490. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17492. */
  17493. set useKernelBlur(value: boolean);
  17494. protected _depthScale: number;
  17495. /**
  17496. * Gets the depth scale used in ESM mode.
  17497. */
  17498. get depthScale(): number;
  17499. /**
  17500. * Sets the depth scale used in ESM mode.
  17501. * This can override the scale stored on the light.
  17502. */
  17503. set depthScale(value: number);
  17504. protected _validateFilter(filter: number): number;
  17505. protected _filter: number;
  17506. /**
  17507. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17508. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17509. */
  17510. get filter(): number;
  17511. /**
  17512. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17513. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17514. */
  17515. set filter(value: number);
  17516. /**
  17517. * Gets if the current filter is set to Poisson Sampling.
  17518. */
  17519. get usePoissonSampling(): boolean;
  17520. /**
  17521. * Sets the current filter to Poisson Sampling.
  17522. */
  17523. set usePoissonSampling(value: boolean);
  17524. /**
  17525. * Gets if the current filter is set to ESM.
  17526. */
  17527. get useExponentialShadowMap(): boolean;
  17528. /**
  17529. * Sets the current filter is to ESM.
  17530. */
  17531. set useExponentialShadowMap(value: boolean);
  17532. /**
  17533. * Gets if the current filter is set to filtered ESM.
  17534. */
  17535. get useBlurExponentialShadowMap(): boolean;
  17536. /**
  17537. * Gets if the current filter is set to filtered ESM.
  17538. */
  17539. set useBlurExponentialShadowMap(value: boolean);
  17540. /**
  17541. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17542. * exponential to prevent steep falloff artifacts).
  17543. */
  17544. get useCloseExponentialShadowMap(): boolean;
  17545. /**
  17546. * Sets the current filter to "close ESM" (using the inverse of the
  17547. * exponential to prevent steep falloff artifacts).
  17548. */
  17549. set useCloseExponentialShadowMap(value: boolean);
  17550. /**
  17551. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17552. * exponential to prevent steep falloff artifacts).
  17553. */
  17554. get useBlurCloseExponentialShadowMap(): boolean;
  17555. /**
  17556. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17557. * exponential to prevent steep falloff artifacts).
  17558. */
  17559. set useBlurCloseExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17562. */
  17563. get usePercentageCloserFiltering(): boolean;
  17564. /**
  17565. * Sets the current filter to "PCF" (percentage closer filtering).
  17566. */
  17567. set usePercentageCloserFiltering(value: boolean);
  17568. protected _filteringQuality: number;
  17569. /**
  17570. * Gets the PCF or PCSS Quality.
  17571. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17572. */
  17573. get filteringQuality(): number;
  17574. /**
  17575. * Sets the PCF or PCSS Quality.
  17576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17577. */
  17578. set filteringQuality(filteringQuality: number);
  17579. /**
  17580. * Gets if the current filter is set to "PCSS" (contact hardening).
  17581. */
  17582. get useContactHardeningShadow(): boolean;
  17583. /**
  17584. * Sets the current filter to "PCSS" (contact hardening).
  17585. */
  17586. set useContactHardeningShadow(value: boolean);
  17587. protected _contactHardeningLightSizeUVRatio: number;
  17588. /**
  17589. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17590. * Using a ratio helps keeping shape stability independently of the map size.
  17591. *
  17592. * It does not account for the light projection as it was having too much
  17593. * instability during the light setup or during light position changes.
  17594. *
  17595. * Only valid if useContactHardeningShadow is true.
  17596. */
  17597. get contactHardeningLightSizeUVRatio(): number;
  17598. /**
  17599. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17600. * Using a ratio helps keeping shape stability independently of the map size.
  17601. *
  17602. * It does not account for the light projection as it was having too much
  17603. * instability during the light setup or during light position changes.
  17604. *
  17605. * Only valid if useContactHardeningShadow is true.
  17606. */
  17607. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17608. protected _darkness: number;
  17609. /** Gets or sets the actual darkness of a shadow */
  17610. get darkness(): number;
  17611. set darkness(value: number);
  17612. /**
  17613. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17614. * 0 means strongest and 1 would means no shadow.
  17615. * @returns the darkness.
  17616. */
  17617. getDarkness(): number;
  17618. /**
  17619. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17620. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17621. * @returns the shadow generator allowing fluent coding.
  17622. */
  17623. setDarkness(darkness: number): ShadowGenerator;
  17624. protected _transparencyShadow: boolean;
  17625. /** Gets or sets the ability to have transparent shadow */
  17626. get transparencyShadow(): boolean;
  17627. set transparencyShadow(value: boolean);
  17628. /**
  17629. * Sets the ability to have transparent shadow (boolean).
  17630. * @param transparent True if transparent else False
  17631. * @returns the shadow generator allowing fluent coding
  17632. */
  17633. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17634. /**
  17635. * Enables or disables shadows with varying strength based on the transparency
  17636. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17637. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17638. * mesh.visibility * alphaTexture.a
  17639. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17640. */
  17641. enableSoftTransparentShadow: boolean;
  17642. protected _shadowMap: Nullable<RenderTargetTexture>;
  17643. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17644. /**
  17645. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17646. * @returns The render target texture if present otherwise, null
  17647. */
  17648. getShadowMap(): Nullable<RenderTargetTexture>;
  17649. /**
  17650. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17651. * @returns The render target texture if the shadow map is present otherwise, null
  17652. */
  17653. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17654. /**
  17655. * Gets the class name of that object
  17656. * @returns "ShadowGenerator"
  17657. */
  17658. getClassName(): string;
  17659. /**
  17660. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17661. * @param mesh Mesh to add
  17662. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17663. * @returns the Shadow Generator itself
  17664. */
  17665. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17666. /**
  17667. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17668. * @param mesh Mesh to remove
  17669. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17670. * @returns the Shadow Generator itself
  17671. */
  17672. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17673. /**
  17674. * Controls the extent to which the shadows fade out at the edge of the frustum
  17675. */
  17676. frustumEdgeFalloff: number;
  17677. protected _light: IShadowLight;
  17678. /**
  17679. * Returns the associated light object.
  17680. * @returns the light generating the shadow
  17681. */
  17682. getLight(): IShadowLight;
  17683. /**
  17684. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17685. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17686. * It might on the other hand introduce peter panning.
  17687. */
  17688. forceBackFacesOnly: boolean;
  17689. protected _scene: Scene;
  17690. protected _lightDirection: Vector3;
  17691. protected _effect: Effect;
  17692. protected _viewMatrix: Matrix;
  17693. protected _projectionMatrix: Matrix;
  17694. protected _transformMatrix: Matrix;
  17695. protected _cachedPosition: Vector3;
  17696. protected _cachedDirection: Vector3;
  17697. protected _cachedDefines: string;
  17698. protected _currentRenderID: number;
  17699. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17700. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17701. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17702. protected _blurPostProcesses: PostProcess[];
  17703. protected _mapSize: number;
  17704. protected _currentFaceIndex: number;
  17705. protected _currentFaceIndexCache: number;
  17706. protected _textureType: number;
  17707. protected _defaultTextureMatrix: Matrix;
  17708. protected _storedUniqueId: Nullable<number>;
  17709. /** @hidden */
  17710. static _SceneComponentInitialization: (scene: Scene) => void;
  17711. /**
  17712. * Creates a ShadowGenerator object.
  17713. * A ShadowGenerator is the required tool to use the shadows.
  17714. * Each light casting shadows needs to use its own ShadowGenerator.
  17715. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17716. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17717. * @param light The light object generating the shadows.
  17718. * @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.
  17719. */
  17720. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17721. protected _initializeGenerator(): void;
  17722. protected _createTargetRenderTexture(): void;
  17723. protected _initializeShadowMap(): void;
  17724. protected _initializeBlurRTTAndPostProcesses(): void;
  17725. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17726. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17727. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17728. protected _applyFilterValues(): void;
  17729. /**
  17730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17731. * @param onCompiled Callback triggered at the and of the effects compilation
  17732. * @param options Sets of optional options forcing the compilation with different modes
  17733. */
  17734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17735. useInstances: boolean;
  17736. }>): void;
  17737. /**
  17738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17739. * @param options Sets of optional options forcing the compilation with different modes
  17740. * @returns A promise that resolves when the compilation completes
  17741. */
  17742. forceCompilationAsync(options?: Partial<{
  17743. useInstances: boolean;
  17744. }>): Promise<void>;
  17745. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17746. private _prepareShadowDefines;
  17747. /**
  17748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17749. * @param subMesh The submesh we want to render in the shadow map
  17750. * @param useInstances Defines wether will draw in the map using instances
  17751. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17752. * @returns true if ready otherwise, false
  17753. */
  17754. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17755. /**
  17756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17757. * @param defines Defines of the material we want to update
  17758. * @param lightIndex Index of the light in the enabled light list of the material
  17759. */
  17760. prepareDefines(defines: any, lightIndex: number): void;
  17761. /**
  17762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17763. * defined in the generator but impacting the effect).
  17764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17765. * @param effect The effect we are binfing the information for
  17766. */
  17767. bindShadowLight(lightIndex: string, effect: Effect): void;
  17768. /**
  17769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17770. * (eq to shadow prjection matrix * light transform matrix)
  17771. * @returns The transform matrix used to create the shadow map
  17772. */
  17773. getTransformMatrix(): Matrix;
  17774. /**
  17775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17776. * Cube and 2D textures for instance.
  17777. */
  17778. recreateShadowMap(): void;
  17779. protected _disposeBlurPostProcesses(): void;
  17780. protected _disposeRTTandPostProcesses(): void;
  17781. /**
  17782. * Disposes the ShadowGenerator.
  17783. * Returns nothing.
  17784. */
  17785. dispose(): void;
  17786. /**
  17787. * Serializes the shadow generator setup to a json object.
  17788. * @returns The serialized JSON object
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17793. * @param parsedShadowGenerator The JSON object to parse
  17794. * @param scene The scene to create the shadow map for
  17795. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17796. * @returns The parsed shadow generator
  17797. */
  17798. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17799. }
  17800. }
  17801. declare module BABYLON {
  17802. /**
  17803. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17804. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17805. * 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.
  17806. */
  17807. export abstract class Light extends Node {
  17808. /**
  17809. * Falloff Default: light is falling off following the material specification:
  17810. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17811. */
  17812. static readonly FALLOFF_DEFAULT: number;
  17813. /**
  17814. * Falloff Physical: light is falling off following the inverse squared distance law.
  17815. */
  17816. static readonly FALLOFF_PHYSICAL: number;
  17817. /**
  17818. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17819. * to enhance interoperability with other engines.
  17820. */
  17821. static readonly FALLOFF_GLTF: number;
  17822. /**
  17823. * Falloff Standard: light is falling off like in the standard material
  17824. * to enhance interoperability with other materials.
  17825. */
  17826. static readonly FALLOFF_STANDARD: number;
  17827. /**
  17828. * If every light affecting the material is in this lightmapMode,
  17829. * material.lightmapTexture adds or multiplies
  17830. * (depends on material.useLightmapAsShadowmap)
  17831. * after every other light calculations.
  17832. */
  17833. static readonly LIGHTMAP_DEFAULT: number;
  17834. /**
  17835. * material.lightmapTexture as only diffuse lighting from this light
  17836. * adds only specular lighting from this light
  17837. * adds dynamic shadows
  17838. */
  17839. static readonly LIGHTMAP_SPECULAR: number;
  17840. /**
  17841. * material.lightmapTexture as only lighting
  17842. * no light calculation from this light
  17843. * only adds dynamic shadows from this light
  17844. */
  17845. static readonly LIGHTMAP_SHADOWSONLY: number;
  17846. /**
  17847. * Each light type uses the default quantity according to its type:
  17848. * point/spot lights use luminous intensity
  17849. * directional lights use illuminance
  17850. */
  17851. static readonly INTENSITYMODE_AUTOMATIC: number;
  17852. /**
  17853. * lumen (lm)
  17854. */
  17855. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17856. /**
  17857. * candela (lm/sr)
  17858. */
  17859. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17860. /**
  17861. * lux (lm/m^2)
  17862. */
  17863. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17864. /**
  17865. * nit (cd/m^2)
  17866. */
  17867. static readonly INTENSITYMODE_LUMINANCE: number;
  17868. /**
  17869. * Light type const id of the point light.
  17870. */
  17871. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17872. /**
  17873. * Light type const id of the directional light.
  17874. */
  17875. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17876. /**
  17877. * Light type const id of the spot light.
  17878. */
  17879. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17880. /**
  17881. * Light type const id of the hemispheric light.
  17882. */
  17883. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17884. /**
  17885. * Diffuse gives the basic color to an object.
  17886. */
  17887. diffuse: Color3;
  17888. /**
  17889. * Specular produces a highlight color on an object.
  17890. * Note: This is note affecting PBR materials.
  17891. */
  17892. specular: Color3;
  17893. /**
  17894. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17895. * falling off base on range or angle.
  17896. * This can be set to any values in Light.FALLOFF_x.
  17897. *
  17898. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17899. * other types of materials.
  17900. */
  17901. falloffType: number;
  17902. /**
  17903. * Strength of the light.
  17904. * Note: By default it is define in the framework own unit.
  17905. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17906. */
  17907. intensity: number;
  17908. private _range;
  17909. protected _inverseSquaredRange: number;
  17910. /**
  17911. * Defines how far from the source the light is impacting in scene units.
  17912. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17913. */
  17914. get range(): number;
  17915. /**
  17916. * Defines how far from the source the light is impacting in scene units.
  17917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17918. */
  17919. set range(value: number);
  17920. /**
  17921. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17922. * of light.
  17923. */
  17924. private _photometricScale;
  17925. private _intensityMode;
  17926. /**
  17927. * Gets the photometric scale used to interpret the intensity.
  17928. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17929. */
  17930. get intensityMode(): number;
  17931. /**
  17932. * Sets the photometric scale used to interpret the intensity.
  17933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17934. */
  17935. set intensityMode(value: number);
  17936. private _radius;
  17937. /**
  17938. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17939. */
  17940. get radius(): number;
  17941. /**
  17942. * sets the light radius used by PBR Materials to simulate soft area lights.
  17943. */
  17944. set radius(value: number);
  17945. private _renderPriority;
  17946. /**
  17947. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17948. * exceeding the number allowed of the materials.
  17949. */
  17950. renderPriority: number;
  17951. private _shadowEnabled;
  17952. /**
  17953. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17954. * the current shadow generator.
  17955. */
  17956. get shadowEnabled(): boolean;
  17957. /**
  17958. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17959. * the current shadow generator.
  17960. */
  17961. set shadowEnabled(value: boolean);
  17962. private _includedOnlyMeshes;
  17963. /**
  17964. * Gets the only meshes impacted by this light.
  17965. */
  17966. get includedOnlyMeshes(): AbstractMesh[];
  17967. /**
  17968. * Sets the only meshes impacted by this light.
  17969. */
  17970. set includedOnlyMeshes(value: AbstractMesh[]);
  17971. private _excludedMeshes;
  17972. /**
  17973. * Gets the meshes not impacted by this light.
  17974. */
  17975. get excludedMeshes(): AbstractMesh[];
  17976. /**
  17977. * Sets the meshes not impacted by this light.
  17978. */
  17979. set excludedMeshes(value: AbstractMesh[]);
  17980. private _excludeWithLayerMask;
  17981. /**
  17982. * Gets the layer id use to find what meshes are not impacted by the light.
  17983. * Inactive if 0
  17984. */
  17985. get excludeWithLayerMask(): number;
  17986. /**
  17987. * Sets the layer id use to find what meshes are not impacted by the light.
  17988. * Inactive if 0
  17989. */
  17990. set excludeWithLayerMask(value: number);
  17991. private _includeOnlyWithLayerMask;
  17992. /**
  17993. * Gets the layer id use to find what meshes are impacted by the light.
  17994. * Inactive if 0
  17995. */
  17996. get includeOnlyWithLayerMask(): number;
  17997. /**
  17998. * Sets the layer id use to find what meshes are impacted by the light.
  17999. * Inactive if 0
  18000. */
  18001. set includeOnlyWithLayerMask(value: number);
  18002. private _lightmapMode;
  18003. /**
  18004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18005. */
  18006. get lightmapMode(): number;
  18007. /**
  18008. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18009. */
  18010. set lightmapMode(value: number);
  18011. /**
  18012. * Shadow generator associted to the light.
  18013. * @hidden Internal use only.
  18014. */
  18015. _shadowGenerator: Nullable<IShadowGenerator>;
  18016. /**
  18017. * @hidden Internal use only.
  18018. */
  18019. _excludedMeshesIds: string[];
  18020. /**
  18021. * @hidden Internal use only.
  18022. */
  18023. _includedOnlyMeshesIds: string[];
  18024. /**
  18025. * The current light unifom buffer.
  18026. * @hidden Internal use only.
  18027. */
  18028. _uniformBuffer: UniformBuffer;
  18029. /** @hidden */
  18030. _renderId: number;
  18031. /**
  18032. * Creates a Light object in the scene.
  18033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18034. * @param name The firendly name of the light
  18035. * @param scene The scene the light belongs too
  18036. */
  18037. constructor(name: string, scene: Scene);
  18038. protected abstract _buildUniformLayout(): void;
  18039. /**
  18040. * Sets the passed Effect "effect" with the Light information.
  18041. * @param effect The effect to update
  18042. * @param lightIndex The index of the light in the effect to update
  18043. * @returns The light
  18044. */
  18045. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18046. /**
  18047. * Sets the passed Effect "effect" with the Light textures.
  18048. * @param effect The effect to update
  18049. * @param lightIndex The index of the light in the effect to update
  18050. * @returns The light
  18051. */
  18052. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18053. /**
  18054. * Binds the lights information from the scene to the effect for the given mesh.
  18055. * @param lightIndex Light index
  18056. * @param scene The scene where the light belongs to
  18057. * @param effect The effect we are binding the data to
  18058. * @param useSpecular Defines if specular is supported
  18059. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18060. */
  18061. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18062. /**
  18063. * Sets the passed Effect "effect" with the Light information.
  18064. * @param effect The effect to update
  18065. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18066. * @returns The light
  18067. */
  18068. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18069. /**
  18070. * Returns the string "Light".
  18071. * @returns the class name
  18072. */
  18073. getClassName(): string;
  18074. /** @hidden */
  18075. readonly _isLight: boolean;
  18076. /**
  18077. * Converts the light information to a readable string for debug purpose.
  18078. * @param fullDetails Supports for multiple levels of logging within scene loading
  18079. * @returns the human readable light info
  18080. */
  18081. toString(fullDetails?: boolean): string;
  18082. /** @hidden */
  18083. protected _syncParentEnabledState(): void;
  18084. /**
  18085. * Set the enabled state of this node.
  18086. * @param value - the new enabled state
  18087. */
  18088. setEnabled(value: boolean): void;
  18089. /**
  18090. * Returns the Light associated shadow generator if any.
  18091. * @return the associated shadow generator.
  18092. */
  18093. getShadowGenerator(): Nullable<IShadowGenerator>;
  18094. /**
  18095. * Returns a Vector3, the absolute light position in the World.
  18096. * @returns the world space position of the light
  18097. */
  18098. getAbsolutePosition(): Vector3;
  18099. /**
  18100. * Specifies if the light will affect the passed mesh.
  18101. * @param mesh The mesh to test against the light
  18102. * @return true the mesh is affected otherwise, false.
  18103. */
  18104. canAffectMesh(mesh: AbstractMesh): boolean;
  18105. /**
  18106. * Sort function to order lights for rendering.
  18107. * @param a First Light object to compare to second.
  18108. * @param b Second Light object to compare first.
  18109. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18110. */
  18111. static CompareLightsPriority(a: Light, b: Light): number;
  18112. /**
  18113. * Releases resources associated with this node.
  18114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18116. */
  18117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18118. /**
  18119. * Returns the light type ID (integer).
  18120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18121. */
  18122. getTypeID(): number;
  18123. /**
  18124. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18125. * @returns the scaled intensity in intensity mode unit
  18126. */
  18127. getScaledIntensity(): number;
  18128. /**
  18129. * Returns a new Light object, named "name", from the current one.
  18130. * @param name The name of the cloned light
  18131. * @param newParent The parent of this light, if it has one
  18132. * @returns the new created light
  18133. */
  18134. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18135. /**
  18136. * Serializes the current light into a Serialization object.
  18137. * @returns the serialized object.
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18142. * This new light is named "name" and added to the passed scene.
  18143. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18144. * @param name The friendly name of the light
  18145. * @param scene The scene the new light will belong to
  18146. * @returns the constructor function
  18147. */
  18148. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18149. /**
  18150. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18151. * @param parsedLight The JSON representation of the light
  18152. * @param scene The scene to create the parsed light in
  18153. * @returns the created light after parsing
  18154. */
  18155. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18156. private _hookArrayForExcluded;
  18157. private _hookArrayForIncludedOnly;
  18158. private _resyncMeshes;
  18159. /**
  18160. * Forces the meshes to update their light related information in their rendering used effects
  18161. * @hidden Internal Use Only
  18162. */
  18163. _markMeshesAsLightDirty(): void;
  18164. /**
  18165. * Recomputes the cached photometric scale if needed.
  18166. */
  18167. private _computePhotometricScale;
  18168. /**
  18169. * Returns the Photometric Scale according to the light type and intensity mode.
  18170. */
  18171. private _getPhotometricScale;
  18172. /**
  18173. * Reorder the light in the scene according to their defined priority.
  18174. * @hidden Internal Use Only
  18175. */
  18176. _reorderLightsInScene(): void;
  18177. /**
  18178. * Prepares the list of defines specific to the light type.
  18179. * @param defines the list of defines
  18180. * @param lightIndex defines the index of the light for the effect
  18181. */
  18182. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. /**
  18187. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18188. * This is the base of the follow, arc rotate cameras and Free camera
  18189. * @see http://doc.babylonjs.com/features/cameras
  18190. */
  18191. export class TargetCamera extends Camera {
  18192. private static _RigCamTransformMatrix;
  18193. private static _TargetTransformMatrix;
  18194. private static _TargetFocalPoint;
  18195. /**
  18196. * Define the current direction the camera is moving to
  18197. */
  18198. cameraDirection: Vector3;
  18199. /**
  18200. * Define the current rotation the camera is rotating to
  18201. */
  18202. cameraRotation: Vector2;
  18203. /**
  18204. * When set, the up vector of the camera will be updated by the rotation of the camera
  18205. */
  18206. updateUpVectorFromRotation: boolean;
  18207. private _tmpQuaternion;
  18208. /**
  18209. * Define the current rotation of the camera
  18210. */
  18211. rotation: Vector3;
  18212. /**
  18213. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18214. */
  18215. rotationQuaternion: Quaternion;
  18216. /**
  18217. * Define the current speed of the camera
  18218. */
  18219. speed: number;
  18220. /**
  18221. * Add constraint to the camera to prevent it to move freely in all directions and
  18222. * around all axis.
  18223. */
  18224. noRotationConstraint: boolean;
  18225. /**
  18226. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18227. * panning
  18228. */
  18229. invertRotation: boolean;
  18230. /**
  18231. * Speed multiplier for inverse camera panning
  18232. */
  18233. inverseRotationSpeed: number;
  18234. /**
  18235. * Define the current target of the camera as an object or a position.
  18236. */
  18237. lockedTarget: any;
  18238. /** @hidden */
  18239. _currentTarget: Vector3;
  18240. /** @hidden */
  18241. _initialFocalDistance: number;
  18242. /** @hidden */
  18243. _viewMatrix: Matrix;
  18244. /** @hidden */
  18245. _camMatrix: Matrix;
  18246. /** @hidden */
  18247. _cameraTransformMatrix: Matrix;
  18248. /** @hidden */
  18249. _cameraRotationMatrix: Matrix;
  18250. /** @hidden */
  18251. _referencePoint: Vector3;
  18252. /** @hidden */
  18253. _transformedReferencePoint: Vector3;
  18254. protected _globalCurrentTarget: Vector3;
  18255. protected _globalCurrentUpVector: Vector3;
  18256. /** @hidden */
  18257. _reset: () => void;
  18258. private _defaultUp;
  18259. /**
  18260. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18261. * This is the base of the follow, arc rotate cameras and Free camera
  18262. * @see http://doc.babylonjs.com/features/cameras
  18263. * @param name Defines the name of the camera in the scene
  18264. * @param position Defines the start position of the camera in the scene
  18265. * @param scene Defines the scene the camera belongs to
  18266. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18267. */
  18268. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18269. /**
  18270. * Gets the position in front of the camera at a given distance.
  18271. * @param distance The distance from the camera we want the position to be
  18272. * @returns the position
  18273. */
  18274. getFrontPosition(distance: number): Vector3;
  18275. /** @hidden */
  18276. _getLockedTargetPosition(): Nullable<Vector3>;
  18277. private _storedPosition;
  18278. private _storedRotation;
  18279. private _storedRotationQuaternion;
  18280. /**
  18281. * Store current camera state of the camera (fov, position, rotation, etc..)
  18282. * @returns the camera
  18283. */
  18284. storeState(): Camera;
  18285. /**
  18286. * Restored camera state. You must call storeState() first
  18287. * @returns whether it was successful or not
  18288. * @hidden
  18289. */
  18290. _restoreStateValues(): boolean;
  18291. /** @hidden */
  18292. _initCache(): void;
  18293. /** @hidden */
  18294. _updateCache(ignoreParentClass?: boolean): void;
  18295. /** @hidden */
  18296. _isSynchronizedViewMatrix(): boolean;
  18297. /** @hidden */
  18298. _computeLocalCameraSpeed(): number;
  18299. /**
  18300. * Defines the target the camera should look at.
  18301. * @param target Defines the new target as a Vector or a mesh
  18302. */
  18303. setTarget(target: Vector3): void;
  18304. /**
  18305. * Return the current target position of the camera. This value is expressed in local space.
  18306. * @returns the target position
  18307. */
  18308. getTarget(): Vector3;
  18309. /** @hidden */
  18310. _decideIfNeedsToMove(): boolean;
  18311. /** @hidden */
  18312. _updatePosition(): void;
  18313. /** @hidden */
  18314. _checkInputs(): void;
  18315. protected _updateCameraRotationMatrix(): void;
  18316. /**
  18317. * 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)
  18318. * @returns the current camera
  18319. */
  18320. private _rotateUpVectorWithCameraRotationMatrix;
  18321. private _cachedRotationZ;
  18322. private _cachedQuaternionRotationZ;
  18323. /** @hidden */
  18324. _getViewMatrix(): Matrix;
  18325. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18326. /**
  18327. * @hidden
  18328. */
  18329. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18330. /**
  18331. * @hidden
  18332. */
  18333. _updateRigCameras(): void;
  18334. private _getRigCamPositionAndTarget;
  18335. /**
  18336. * Gets the current object class name.
  18337. * @return the class name
  18338. */
  18339. getClassName(): string;
  18340. }
  18341. }
  18342. declare module BABYLON {
  18343. /**
  18344. * Gather the list of keyboard event types as constants.
  18345. */
  18346. export class KeyboardEventTypes {
  18347. /**
  18348. * The keydown event is fired when a key becomes active (pressed).
  18349. */
  18350. static readonly KEYDOWN: number;
  18351. /**
  18352. * The keyup event is fired when a key has been released.
  18353. */
  18354. static readonly KEYUP: number;
  18355. }
  18356. /**
  18357. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18358. */
  18359. export class KeyboardInfo {
  18360. /**
  18361. * Defines the type of event (KeyboardEventTypes)
  18362. */
  18363. type: number;
  18364. /**
  18365. * Defines the related dom event
  18366. */
  18367. event: KeyboardEvent;
  18368. /**
  18369. * Instantiates a new keyboard info.
  18370. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18371. * @param type Defines the type of event (KeyboardEventTypes)
  18372. * @param event Defines the related dom event
  18373. */
  18374. constructor(
  18375. /**
  18376. * Defines the type of event (KeyboardEventTypes)
  18377. */
  18378. type: number,
  18379. /**
  18380. * Defines the related dom event
  18381. */
  18382. event: KeyboardEvent);
  18383. }
  18384. /**
  18385. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18386. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18387. */
  18388. export class KeyboardInfoPre extends KeyboardInfo {
  18389. /**
  18390. * Defines the type of event (KeyboardEventTypes)
  18391. */
  18392. type: number;
  18393. /**
  18394. * Defines the related dom event
  18395. */
  18396. event: KeyboardEvent;
  18397. /**
  18398. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18399. */
  18400. skipOnPointerObservable: boolean;
  18401. /**
  18402. * Instantiates a new keyboard pre info.
  18403. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18404. * @param type Defines the type of event (KeyboardEventTypes)
  18405. * @param event Defines the related dom event
  18406. */
  18407. constructor(
  18408. /**
  18409. * Defines the type of event (KeyboardEventTypes)
  18410. */
  18411. type: number,
  18412. /**
  18413. * Defines the related dom event
  18414. */
  18415. event: KeyboardEvent);
  18416. }
  18417. }
  18418. declare module BABYLON {
  18419. /**
  18420. * Manage the keyboard inputs to control the movement of a free camera.
  18421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18422. */
  18423. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18424. /**
  18425. * Defines the camera the input is attached to.
  18426. */
  18427. camera: FreeCamera;
  18428. /**
  18429. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18430. */
  18431. keysUp: number[];
  18432. /**
  18433. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18434. */
  18435. keysUpward: number[];
  18436. /**
  18437. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18438. */
  18439. keysDown: number[];
  18440. /**
  18441. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18442. */
  18443. keysDownward: number[];
  18444. /**
  18445. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18446. */
  18447. keysLeft: number[];
  18448. /**
  18449. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18450. */
  18451. keysRight: number[];
  18452. private _keys;
  18453. private _onCanvasBlurObserver;
  18454. private _onKeyboardObserver;
  18455. private _engine;
  18456. private _scene;
  18457. /**
  18458. * Attach the input controls to a specific dom element to get the input from.
  18459. * @param element Defines the element the controls should be listened from
  18460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18461. */
  18462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18463. /**
  18464. * Detach the current controls from the specified dom element.
  18465. * @param element Defines the element to stop listening the inputs from
  18466. */
  18467. detachControl(element: Nullable<HTMLElement>): void;
  18468. /**
  18469. * Update the current camera state depending on the inputs that have been used this frame.
  18470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18471. */
  18472. checkInputs(): void;
  18473. /**
  18474. * Gets the class name of the current intput.
  18475. * @returns the class name
  18476. */
  18477. getClassName(): string;
  18478. /** @hidden */
  18479. _onLostFocus(): void;
  18480. /**
  18481. * Get the friendly name associated with the input class.
  18482. * @returns the input friendly name
  18483. */
  18484. getSimpleName(): string;
  18485. }
  18486. }
  18487. declare module BABYLON {
  18488. /**
  18489. * Gather the list of pointer event types as constants.
  18490. */
  18491. export class PointerEventTypes {
  18492. /**
  18493. * 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.
  18494. */
  18495. static readonly POINTERDOWN: number;
  18496. /**
  18497. * The pointerup event is fired when a pointer is no longer active.
  18498. */
  18499. static readonly POINTERUP: number;
  18500. /**
  18501. * The pointermove event is fired when a pointer changes coordinates.
  18502. */
  18503. static readonly POINTERMOVE: number;
  18504. /**
  18505. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18506. */
  18507. static readonly POINTERWHEEL: number;
  18508. /**
  18509. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18510. */
  18511. static readonly POINTERPICK: number;
  18512. /**
  18513. * The pointertap event is fired when a the object has been touched and released without drag.
  18514. */
  18515. static readonly POINTERTAP: number;
  18516. /**
  18517. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18518. */
  18519. static readonly POINTERDOUBLETAP: number;
  18520. }
  18521. /**
  18522. * Base class of pointer info types.
  18523. */
  18524. export class PointerInfoBase {
  18525. /**
  18526. * Defines the type of event (PointerEventTypes)
  18527. */
  18528. type: number;
  18529. /**
  18530. * Defines the related dom event
  18531. */
  18532. event: PointerEvent | MouseWheelEvent;
  18533. /**
  18534. * Instantiates the base class of pointers info.
  18535. * @param type Defines the type of event (PointerEventTypes)
  18536. * @param event Defines the related dom event
  18537. */
  18538. constructor(
  18539. /**
  18540. * Defines the type of event (PointerEventTypes)
  18541. */
  18542. type: number,
  18543. /**
  18544. * Defines the related dom event
  18545. */
  18546. event: PointerEvent | MouseWheelEvent);
  18547. }
  18548. /**
  18549. * This class is used to store pointer related info for the onPrePointerObservable event.
  18550. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18551. */
  18552. export class PointerInfoPre extends PointerInfoBase {
  18553. /**
  18554. * Ray from a pointer if availible (eg. 6dof controller)
  18555. */
  18556. ray: Nullable<Ray>;
  18557. /**
  18558. * Defines the local position of the pointer on the canvas.
  18559. */
  18560. localPosition: Vector2;
  18561. /**
  18562. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18563. */
  18564. skipOnPointerObservable: boolean;
  18565. /**
  18566. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18567. * @param type Defines the type of event (PointerEventTypes)
  18568. * @param event Defines the related dom event
  18569. * @param localX Defines the local x coordinates of the pointer when the event occured
  18570. * @param localY Defines the local y coordinates of the pointer when the event occured
  18571. */
  18572. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18573. }
  18574. /**
  18575. * This type contains all the data related to a pointer event in Babylon.js.
  18576. * 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.
  18577. */
  18578. export class PointerInfo extends PointerInfoBase {
  18579. /**
  18580. * Defines the picking info associated to the info (if any)\
  18581. */
  18582. pickInfo: Nullable<PickingInfo>;
  18583. /**
  18584. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18585. * @param type Defines the type of event (PointerEventTypes)
  18586. * @param event Defines the related dom event
  18587. * @param pickInfo Defines the picking info associated to the info (if any)\
  18588. */
  18589. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18590. /**
  18591. * Defines the picking info associated to the info (if any)\
  18592. */
  18593. pickInfo: Nullable<PickingInfo>);
  18594. }
  18595. /**
  18596. * Data relating to a touch event on the screen.
  18597. */
  18598. export interface PointerTouch {
  18599. /**
  18600. * X coordinate of touch.
  18601. */
  18602. x: number;
  18603. /**
  18604. * Y coordinate of touch.
  18605. */
  18606. y: number;
  18607. /**
  18608. * Id of touch. Unique for each finger.
  18609. */
  18610. pointerId: number;
  18611. /**
  18612. * Event type passed from DOM.
  18613. */
  18614. type: any;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /**
  18619. * Manage the mouse inputs to control the movement of a free camera.
  18620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18621. */
  18622. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18623. /**
  18624. * Define if touch is enabled in the mouse input
  18625. */
  18626. touchEnabled: boolean;
  18627. /**
  18628. * Defines the camera the input is attached to.
  18629. */
  18630. camera: FreeCamera;
  18631. /**
  18632. * Defines the buttons associated with the input to handle camera move.
  18633. */
  18634. buttons: number[];
  18635. /**
  18636. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18637. */
  18638. angularSensibility: number;
  18639. private _pointerInput;
  18640. private _onMouseMove;
  18641. private _observer;
  18642. private previousPosition;
  18643. /**
  18644. * Observable for when a pointer move event occurs containing the move offset
  18645. */
  18646. onPointerMovedObservable: Observable<{
  18647. offsetX: number;
  18648. offsetY: number;
  18649. }>;
  18650. /**
  18651. * @hidden
  18652. * If the camera should be rotated automatically based on pointer movement
  18653. */
  18654. _allowCameraRotation: boolean;
  18655. /**
  18656. * Manage the mouse inputs to control the movement of a free camera.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. * @param touchEnabled Defines if touch is enabled or not
  18659. */
  18660. constructor(
  18661. /**
  18662. * Define if touch is enabled in the mouse input
  18663. */
  18664. touchEnabled?: boolean);
  18665. /**
  18666. * Attach the input controls to a specific dom element to get the input from.
  18667. * @param element Defines the element the controls should be listened from
  18668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18669. */
  18670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18671. /**
  18672. * Called on JS contextmenu event.
  18673. * Override this method to provide functionality.
  18674. */
  18675. protected onContextMenu(evt: PointerEvent): void;
  18676. /**
  18677. * Detach the current controls from the specified dom element.
  18678. * @param element Defines the element to stop listening the inputs from
  18679. */
  18680. detachControl(element: Nullable<HTMLElement>): void;
  18681. /**
  18682. * Gets the class name of the current intput.
  18683. * @returns the class name
  18684. */
  18685. getClassName(): string;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module BABYLON {
  18694. /**
  18695. * Manage the touch inputs to control the movement of a free camera.
  18696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18697. */
  18698. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18699. /**
  18700. * Defines the camera the input is attached to.
  18701. */
  18702. camera: FreeCamera;
  18703. /**
  18704. * Defines the touch sensibility for rotation.
  18705. * The higher the faster.
  18706. */
  18707. touchAngularSensibility: number;
  18708. /**
  18709. * Defines the touch sensibility for move.
  18710. * The higher the faster.
  18711. */
  18712. touchMoveSensibility: number;
  18713. private _offsetX;
  18714. private _offsetY;
  18715. private _pointerPressed;
  18716. private _pointerInput;
  18717. private _observer;
  18718. private _onLostFocus;
  18719. /**
  18720. * Attach the input controls to a specific dom element to get the input from.
  18721. * @param element Defines the element the controls should be listened from
  18722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18723. */
  18724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18725. /**
  18726. * Detach the current controls from the specified dom element.
  18727. * @param element Defines the element to stop listening the inputs from
  18728. */
  18729. detachControl(element: Nullable<HTMLElement>): void;
  18730. /**
  18731. * Update the current camera state depending on the inputs that have been used this frame.
  18732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18733. */
  18734. checkInputs(): void;
  18735. /**
  18736. * Gets the class name of the current intput.
  18737. * @returns the class name
  18738. */
  18739. getClassName(): string;
  18740. /**
  18741. * Get the friendly name associated with the input class.
  18742. * @returns the input friendly name
  18743. */
  18744. getSimpleName(): string;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * Default Inputs manager for the FreeCamera.
  18750. * It groups all the default supported inputs for ease of use.
  18751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18752. */
  18753. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18754. /**
  18755. * @hidden
  18756. */
  18757. _mouseInput: Nullable<FreeCameraMouseInput>;
  18758. /**
  18759. * Instantiates a new FreeCameraInputsManager.
  18760. * @param camera Defines the camera the inputs belong to
  18761. */
  18762. constructor(camera: FreeCamera);
  18763. /**
  18764. * Add keyboard input support to the input manager.
  18765. * @returns the current input manager
  18766. */
  18767. addKeyboard(): FreeCameraInputsManager;
  18768. /**
  18769. * Add mouse input support to the input manager.
  18770. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18771. * @returns the current input manager
  18772. */
  18773. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18774. /**
  18775. * Removes the mouse input support from the manager
  18776. * @returns the current input manager
  18777. */
  18778. removeMouse(): FreeCameraInputsManager;
  18779. /**
  18780. * Add touch input support to the input manager.
  18781. * @returns the current input manager
  18782. */
  18783. addTouch(): FreeCameraInputsManager;
  18784. /**
  18785. * Remove all attached input methods from a camera
  18786. */
  18787. clear(): void;
  18788. }
  18789. }
  18790. declare module BABYLON {
  18791. /**
  18792. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18793. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18795. */
  18796. export class FreeCamera extends TargetCamera {
  18797. /**
  18798. * Define the collision ellipsoid of the camera.
  18799. * This is helpful to simulate a camera body like the player body around the camera
  18800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18801. */
  18802. ellipsoid: Vector3;
  18803. /**
  18804. * Define an offset for the position of the ellipsoid around the camera.
  18805. * This can be helpful to determine the center of the body near the gravity center of the body
  18806. * instead of its head.
  18807. */
  18808. ellipsoidOffset: Vector3;
  18809. /**
  18810. * Enable or disable collisions of the camera with the rest of the scene objects.
  18811. */
  18812. checkCollisions: boolean;
  18813. /**
  18814. * Enable or disable gravity on the camera.
  18815. */
  18816. applyGravity: boolean;
  18817. /**
  18818. * Define the input manager associated to the camera.
  18819. */
  18820. inputs: FreeCameraInputsManager;
  18821. /**
  18822. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18823. * Higher values reduce sensitivity.
  18824. */
  18825. get angularSensibility(): number;
  18826. /**
  18827. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18828. * Higher values reduce sensitivity.
  18829. */
  18830. set angularSensibility(value: number);
  18831. /**
  18832. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18833. */
  18834. get keysUp(): number[];
  18835. set keysUp(value: number[]);
  18836. /**
  18837. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18838. */
  18839. get keysUpward(): number[];
  18840. set keysUpward(value: number[]);
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18843. */
  18844. get keysDown(): number[];
  18845. set keysDown(value: number[]);
  18846. /**
  18847. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18848. */
  18849. get keysDownward(): number[];
  18850. set keysDownward(value: number[]);
  18851. /**
  18852. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18853. */
  18854. get keysLeft(): number[];
  18855. set keysLeft(value: number[]);
  18856. /**
  18857. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18858. */
  18859. get keysRight(): number[];
  18860. set keysRight(value: number[]);
  18861. /**
  18862. * Event raised when the camera collide with a mesh in the scene.
  18863. */
  18864. onCollide: (collidedMesh: AbstractMesh) => void;
  18865. private _collider;
  18866. private _needMoveForGravity;
  18867. private _oldPosition;
  18868. private _diffPosition;
  18869. private _newPosition;
  18870. /** @hidden */
  18871. _localDirection: Vector3;
  18872. /** @hidden */
  18873. _transformedDirection: Vector3;
  18874. /**
  18875. * Instantiates a Free Camera.
  18876. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18877. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18879. * @param name Define the name of the camera in the scene
  18880. * @param position Define the start position of the camera in the scene
  18881. * @param scene Define the scene the camera belongs to
  18882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18883. */
  18884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18885. /**
  18886. * Attached controls to the current camera.
  18887. * @param element Defines the element the controls should be listened from
  18888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18889. */
  18890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18891. /**
  18892. * Detach the current controls from the camera.
  18893. * The camera will stop reacting to inputs.
  18894. * @param element Defines the element to stop listening the inputs from
  18895. */
  18896. detachControl(element: HTMLElement): void;
  18897. private _collisionMask;
  18898. /**
  18899. * Define a collision mask to limit the list of object the camera can collide with
  18900. */
  18901. get collisionMask(): number;
  18902. set collisionMask(mask: number);
  18903. /** @hidden */
  18904. _collideWithWorld(displacement: Vector3): void;
  18905. private _onCollisionPositionChange;
  18906. /** @hidden */
  18907. _checkInputs(): void;
  18908. /** @hidden */
  18909. _decideIfNeedsToMove(): boolean;
  18910. /** @hidden */
  18911. _updatePosition(): void;
  18912. /**
  18913. * Destroy the camera and release the current resources hold by it.
  18914. */
  18915. dispose(): void;
  18916. /**
  18917. * Gets the current object class name.
  18918. * @return the class name
  18919. */
  18920. getClassName(): string;
  18921. }
  18922. }
  18923. declare module BABYLON {
  18924. /**
  18925. * Represents a gamepad control stick position
  18926. */
  18927. export class StickValues {
  18928. /**
  18929. * The x component of the control stick
  18930. */
  18931. x: number;
  18932. /**
  18933. * The y component of the control stick
  18934. */
  18935. y: number;
  18936. /**
  18937. * Initializes the gamepad x and y control stick values
  18938. * @param x The x component of the gamepad control stick value
  18939. * @param y The y component of the gamepad control stick value
  18940. */
  18941. constructor(
  18942. /**
  18943. * The x component of the control stick
  18944. */
  18945. x: number,
  18946. /**
  18947. * The y component of the control stick
  18948. */
  18949. y: number);
  18950. }
  18951. /**
  18952. * An interface which manages callbacks for gamepad button changes
  18953. */
  18954. export interface GamepadButtonChanges {
  18955. /**
  18956. * Called when a gamepad has been changed
  18957. */
  18958. changed: boolean;
  18959. /**
  18960. * Called when a gamepad press event has been triggered
  18961. */
  18962. pressChanged: boolean;
  18963. /**
  18964. * Called when a touch event has been triggered
  18965. */
  18966. touchChanged: boolean;
  18967. /**
  18968. * Called when a value has changed
  18969. */
  18970. valueChanged: boolean;
  18971. }
  18972. /**
  18973. * Represents a gamepad
  18974. */
  18975. export class Gamepad {
  18976. /**
  18977. * The id of the gamepad
  18978. */
  18979. id: string;
  18980. /**
  18981. * The index of the gamepad
  18982. */
  18983. index: number;
  18984. /**
  18985. * The browser gamepad
  18986. */
  18987. browserGamepad: any;
  18988. /**
  18989. * Specifies what type of gamepad this represents
  18990. */
  18991. type: number;
  18992. private _leftStick;
  18993. private _rightStick;
  18994. /** @hidden */
  18995. _isConnected: boolean;
  18996. private _leftStickAxisX;
  18997. private _leftStickAxisY;
  18998. private _rightStickAxisX;
  18999. private _rightStickAxisY;
  19000. /**
  19001. * Triggered when the left control stick has been changed
  19002. */
  19003. private _onleftstickchanged;
  19004. /**
  19005. * Triggered when the right control stick has been changed
  19006. */
  19007. private _onrightstickchanged;
  19008. /**
  19009. * Represents a gamepad controller
  19010. */
  19011. static GAMEPAD: number;
  19012. /**
  19013. * Represents a generic controller
  19014. */
  19015. static GENERIC: number;
  19016. /**
  19017. * Represents an XBox controller
  19018. */
  19019. static XBOX: number;
  19020. /**
  19021. * Represents a pose-enabled controller
  19022. */
  19023. static POSE_ENABLED: number;
  19024. /**
  19025. * Represents an Dual Shock controller
  19026. */
  19027. static DUALSHOCK: number;
  19028. /**
  19029. * Specifies whether the left control stick should be Y-inverted
  19030. */
  19031. protected _invertLeftStickY: boolean;
  19032. /**
  19033. * Specifies if the gamepad has been connected
  19034. */
  19035. get isConnected(): boolean;
  19036. /**
  19037. * Initializes the gamepad
  19038. * @param id The id of the gamepad
  19039. * @param index The index of the gamepad
  19040. * @param browserGamepad The browser gamepad
  19041. * @param leftStickX The x component of the left joystick
  19042. * @param leftStickY The y component of the left joystick
  19043. * @param rightStickX The x component of the right joystick
  19044. * @param rightStickY The y component of the right joystick
  19045. */
  19046. constructor(
  19047. /**
  19048. * The id of the gamepad
  19049. */
  19050. id: string,
  19051. /**
  19052. * The index of the gamepad
  19053. */
  19054. index: number,
  19055. /**
  19056. * The browser gamepad
  19057. */
  19058. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19059. /**
  19060. * Callback triggered when the left joystick has changed
  19061. * @param callback
  19062. */
  19063. onleftstickchanged(callback: (values: StickValues) => void): void;
  19064. /**
  19065. * Callback triggered when the right joystick has changed
  19066. * @param callback
  19067. */
  19068. onrightstickchanged(callback: (values: StickValues) => void): void;
  19069. /**
  19070. * Gets the left joystick
  19071. */
  19072. get leftStick(): StickValues;
  19073. /**
  19074. * Sets the left joystick values
  19075. */
  19076. set leftStick(newValues: StickValues);
  19077. /**
  19078. * Gets the right joystick
  19079. */
  19080. get rightStick(): StickValues;
  19081. /**
  19082. * Sets the right joystick value
  19083. */
  19084. set rightStick(newValues: StickValues);
  19085. /**
  19086. * Updates the gamepad joystick positions
  19087. */
  19088. update(): void;
  19089. /**
  19090. * Disposes the gamepad
  19091. */
  19092. dispose(): void;
  19093. }
  19094. /**
  19095. * Represents a generic gamepad
  19096. */
  19097. export class GenericPad extends Gamepad {
  19098. private _buttons;
  19099. private _onbuttondown;
  19100. private _onbuttonup;
  19101. /**
  19102. * Observable triggered when a button has been pressed
  19103. */
  19104. onButtonDownObservable: Observable<number>;
  19105. /**
  19106. * Observable triggered when a button has been released
  19107. */
  19108. onButtonUpObservable: Observable<number>;
  19109. /**
  19110. * Callback triggered when a button has been pressed
  19111. * @param callback Called when a button has been pressed
  19112. */
  19113. onbuttondown(callback: (buttonPressed: number) => void): void;
  19114. /**
  19115. * Callback triggered when a button has been released
  19116. * @param callback Called when a button has been released
  19117. */
  19118. onbuttonup(callback: (buttonReleased: number) => void): void;
  19119. /**
  19120. * Initializes the generic gamepad
  19121. * @param id The id of the generic gamepad
  19122. * @param index The index of the generic gamepad
  19123. * @param browserGamepad The browser gamepad
  19124. */
  19125. constructor(id: string, index: number, browserGamepad: any);
  19126. private _setButtonValue;
  19127. /**
  19128. * Updates the generic gamepad
  19129. */
  19130. update(): void;
  19131. /**
  19132. * Disposes the generic gamepad
  19133. */
  19134. dispose(): void;
  19135. }
  19136. }
  19137. declare module BABYLON {
  19138. /**
  19139. * Defines the types of pose enabled controllers that are supported
  19140. */
  19141. export enum PoseEnabledControllerType {
  19142. /**
  19143. * HTC Vive
  19144. */
  19145. VIVE = 0,
  19146. /**
  19147. * Oculus Rift
  19148. */
  19149. OCULUS = 1,
  19150. /**
  19151. * Windows mixed reality
  19152. */
  19153. WINDOWS = 2,
  19154. /**
  19155. * Samsung gear VR
  19156. */
  19157. GEAR_VR = 3,
  19158. /**
  19159. * Google Daydream
  19160. */
  19161. DAYDREAM = 4,
  19162. /**
  19163. * Generic
  19164. */
  19165. GENERIC = 5
  19166. }
  19167. /**
  19168. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19169. */
  19170. export interface MutableGamepadButton {
  19171. /**
  19172. * Value of the button/trigger
  19173. */
  19174. value: number;
  19175. /**
  19176. * If the button/trigger is currently touched
  19177. */
  19178. touched: boolean;
  19179. /**
  19180. * If the button/trigger is currently pressed
  19181. */
  19182. pressed: boolean;
  19183. }
  19184. /**
  19185. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19186. * @hidden
  19187. */
  19188. export interface ExtendedGamepadButton extends GamepadButton {
  19189. /**
  19190. * If the button/trigger is currently pressed
  19191. */
  19192. readonly pressed: boolean;
  19193. /**
  19194. * If the button/trigger is currently touched
  19195. */
  19196. readonly touched: boolean;
  19197. /**
  19198. * Value of the button/trigger
  19199. */
  19200. readonly value: number;
  19201. }
  19202. /** @hidden */
  19203. export interface _GamePadFactory {
  19204. /**
  19205. * Returns whether or not the current gamepad can be created for this type of controller.
  19206. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19207. * @returns true if it can be created, otherwise false
  19208. */
  19209. canCreate(gamepadInfo: any): boolean;
  19210. /**
  19211. * Creates a new instance of the Gamepad.
  19212. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19213. * @returns the new gamepad instance
  19214. */
  19215. create(gamepadInfo: any): Gamepad;
  19216. }
  19217. /**
  19218. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19219. */
  19220. export class PoseEnabledControllerHelper {
  19221. /** @hidden */
  19222. static _ControllerFactories: _GamePadFactory[];
  19223. /** @hidden */
  19224. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19225. /**
  19226. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19227. * @param vrGamepad the gamepad to initialized
  19228. * @returns a vr controller of the type the gamepad identified as
  19229. */
  19230. static InitiateController(vrGamepad: any): Gamepad;
  19231. }
  19232. /**
  19233. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19234. */
  19235. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19236. /**
  19237. * If the controller is used in a webXR session
  19238. */
  19239. isXR: boolean;
  19240. private _deviceRoomPosition;
  19241. private _deviceRoomRotationQuaternion;
  19242. /**
  19243. * The device position in babylon space
  19244. */
  19245. devicePosition: Vector3;
  19246. /**
  19247. * The device rotation in babylon space
  19248. */
  19249. deviceRotationQuaternion: Quaternion;
  19250. /**
  19251. * The scale factor of the device in babylon space
  19252. */
  19253. deviceScaleFactor: number;
  19254. /**
  19255. * (Likely devicePosition should be used instead) The device position in its room space
  19256. */
  19257. position: Vector3;
  19258. /**
  19259. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19260. */
  19261. rotationQuaternion: Quaternion;
  19262. /**
  19263. * The type of controller (Eg. Windows mixed reality)
  19264. */
  19265. controllerType: PoseEnabledControllerType;
  19266. protected _calculatedPosition: Vector3;
  19267. private _calculatedRotation;
  19268. /**
  19269. * The raw pose from the device
  19270. */
  19271. rawPose: DevicePose;
  19272. private _trackPosition;
  19273. private _maxRotationDistFromHeadset;
  19274. private _draggedRoomRotation;
  19275. /**
  19276. * @hidden
  19277. */
  19278. _disableTrackPosition(fixedPosition: Vector3): void;
  19279. /**
  19280. * Internal, the mesh attached to the controller
  19281. * @hidden
  19282. */
  19283. _mesh: Nullable<AbstractMesh>;
  19284. private _poseControlledCamera;
  19285. private _leftHandSystemQuaternion;
  19286. /**
  19287. * Internal, matrix used to convert room space to babylon space
  19288. * @hidden
  19289. */
  19290. _deviceToWorld: Matrix;
  19291. /**
  19292. * Node to be used when casting a ray from the controller
  19293. * @hidden
  19294. */
  19295. _pointingPoseNode: Nullable<TransformNode>;
  19296. /**
  19297. * Name of the child mesh that can be used to cast a ray from the controller
  19298. */
  19299. static readonly POINTING_POSE: string;
  19300. /**
  19301. * Creates a new PoseEnabledController from a gamepad
  19302. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19303. */
  19304. constructor(browserGamepad: any);
  19305. private _workingMatrix;
  19306. /**
  19307. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19308. */
  19309. update(): void;
  19310. /**
  19311. * Updates only the pose device and mesh without doing any button event checking
  19312. */
  19313. protected _updatePoseAndMesh(): void;
  19314. /**
  19315. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19316. * @param poseData raw pose fromthe device
  19317. */
  19318. updateFromDevice(poseData: DevicePose): void;
  19319. /**
  19320. * @hidden
  19321. */
  19322. _meshAttachedObservable: Observable<AbstractMesh>;
  19323. /**
  19324. * Attaches a mesh to the controller
  19325. * @param mesh the mesh to be attached
  19326. */
  19327. attachToMesh(mesh: AbstractMesh): void;
  19328. /**
  19329. * Attaches the controllers mesh to a camera
  19330. * @param camera the camera the mesh should be attached to
  19331. */
  19332. attachToPoseControlledCamera(camera: TargetCamera): void;
  19333. /**
  19334. * Disposes of the controller
  19335. */
  19336. dispose(): void;
  19337. /**
  19338. * The mesh that is attached to the controller
  19339. */
  19340. get mesh(): Nullable<AbstractMesh>;
  19341. /**
  19342. * Gets the ray of the controller in the direction the controller is pointing
  19343. * @param length the length the resulting ray should be
  19344. * @returns a ray in the direction the controller is pointing
  19345. */
  19346. getForwardRay(length?: number): Ray;
  19347. }
  19348. }
  19349. declare module BABYLON {
  19350. /**
  19351. * Defines the WebVRController object that represents controllers tracked in 3D space
  19352. */
  19353. export abstract class WebVRController extends PoseEnabledController {
  19354. /**
  19355. * Internal, the default controller model for the controller
  19356. */
  19357. protected _defaultModel: Nullable<AbstractMesh>;
  19358. /**
  19359. * Fired when the trigger state has changed
  19360. */
  19361. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19362. /**
  19363. * Fired when the main button state has changed
  19364. */
  19365. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19366. /**
  19367. * Fired when the secondary button state has changed
  19368. */
  19369. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19370. /**
  19371. * Fired when the pad state has changed
  19372. */
  19373. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19374. /**
  19375. * Fired when controllers stick values have changed
  19376. */
  19377. onPadValuesChangedObservable: Observable<StickValues>;
  19378. /**
  19379. * Array of button availible on the controller
  19380. */
  19381. protected _buttons: Array<MutableGamepadButton>;
  19382. private _onButtonStateChange;
  19383. /**
  19384. * Fired when a controller button's state has changed
  19385. * @param callback the callback containing the button that was modified
  19386. */
  19387. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19388. /**
  19389. * X and Y axis corresponding to the controllers joystick
  19390. */
  19391. pad: StickValues;
  19392. /**
  19393. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19394. */
  19395. hand: string;
  19396. /**
  19397. * The default controller model for the controller
  19398. */
  19399. get defaultModel(): Nullable<AbstractMesh>;
  19400. /**
  19401. * Creates a new WebVRController from a gamepad
  19402. * @param vrGamepad the gamepad that the WebVRController should be created from
  19403. */
  19404. constructor(vrGamepad: any);
  19405. /**
  19406. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19407. */
  19408. update(): void;
  19409. /**
  19410. * Function to be called when a button is modified
  19411. */
  19412. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19413. /**
  19414. * Loads a mesh and attaches it to the controller
  19415. * @param scene the scene the mesh should be added to
  19416. * @param meshLoaded callback for when the mesh has been loaded
  19417. */
  19418. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19419. private _setButtonValue;
  19420. private _changes;
  19421. private _checkChanges;
  19422. /**
  19423. * Disposes of th webVRCOntroller
  19424. */
  19425. dispose(): void;
  19426. }
  19427. }
  19428. declare module BABYLON {
  19429. /**
  19430. * The HemisphericLight simulates the ambient environment light,
  19431. * so the passed direction is the light reflection direction, not the incoming direction.
  19432. */
  19433. export class HemisphericLight extends Light {
  19434. /**
  19435. * The groundColor is the light in the opposite direction to the one specified during creation.
  19436. * 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.
  19437. */
  19438. groundColor: Color3;
  19439. /**
  19440. * The light reflection direction, not the incoming direction.
  19441. */
  19442. direction: Vector3;
  19443. /**
  19444. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19445. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19446. * The HemisphericLight can't cast shadows.
  19447. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19448. * @param name The friendly name of the light
  19449. * @param direction The direction of the light reflection
  19450. * @param scene The scene the light belongs to
  19451. */
  19452. constructor(name: string, direction: Vector3, scene: Scene);
  19453. protected _buildUniformLayout(): void;
  19454. /**
  19455. * Returns the string "HemisphericLight".
  19456. * @return The class name
  19457. */
  19458. getClassName(): string;
  19459. /**
  19460. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19461. * Returns the updated direction.
  19462. * @param target The target the direction should point to
  19463. * @return The computed direction
  19464. */
  19465. setDirectionToTarget(target: Vector3): Vector3;
  19466. /**
  19467. * Returns the shadow generator associated to the light.
  19468. * @returns Always null for hemispheric lights because it does not support shadows.
  19469. */
  19470. getShadowGenerator(): Nullable<IShadowGenerator>;
  19471. /**
  19472. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19473. * @param effect The effect to update
  19474. * @param lightIndex The index of the light in the effect to update
  19475. * @returns The hemispheric light
  19476. */
  19477. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19478. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19479. /**
  19480. * Computes the world matrix of the node
  19481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19482. * @param useWasUpdatedFlag defines a reserved property
  19483. * @returns the world matrix
  19484. */
  19485. computeWorldMatrix(): Matrix;
  19486. /**
  19487. * Returns the integer 3.
  19488. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19489. */
  19490. getTypeID(): number;
  19491. /**
  19492. * Prepares the list of defines specific to the light type.
  19493. * @param defines the list of defines
  19494. * @param lightIndex defines the index of the light for the effect
  19495. */
  19496. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19497. }
  19498. }
  19499. declare module BABYLON {
  19500. /** @hidden */
  19501. export var vrMultiviewToSingleviewPixelShader: {
  19502. name: string;
  19503. shader: string;
  19504. };
  19505. }
  19506. declare module BABYLON {
  19507. /**
  19508. * Renders to multiple views with a single draw call
  19509. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19510. */
  19511. export class MultiviewRenderTarget extends RenderTargetTexture {
  19512. /**
  19513. * Creates a multiview render target
  19514. * @param scene scene used with the render target
  19515. * @param size the size of the render target (used for each view)
  19516. */
  19517. constructor(scene: Scene, size?: number | {
  19518. width: number;
  19519. height: number;
  19520. } | {
  19521. ratio: number;
  19522. });
  19523. /**
  19524. * @hidden
  19525. * @param faceIndex the face index, if its a cube texture
  19526. */
  19527. _bindFrameBuffer(faceIndex?: number): void;
  19528. /**
  19529. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19530. * @returns the view count
  19531. */
  19532. getViewCount(): number;
  19533. }
  19534. }
  19535. declare module BABYLON {
  19536. interface Engine {
  19537. /**
  19538. * Creates a new multiview render target
  19539. * @param width defines the width of the texture
  19540. * @param height defines the height of the texture
  19541. * @returns the created multiview texture
  19542. */
  19543. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19544. /**
  19545. * Binds a multiview framebuffer to be drawn to
  19546. * @param multiviewTexture texture to bind
  19547. */
  19548. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19549. }
  19550. interface Camera {
  19551. /**
  19552. * @hidden
  19553. * 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)
  19554. */
  19555. _useMultiviewToSingleView: boolean;
  19556. /**
  19557. * @hidden
  19558. * 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)
  19559. */
  19560. _multiviewTexture: Nullable<RenderTargetTexture>;
  19561. /**
  19562. * @hidden
  19563. * ensures the multiview texture of the camera exists and has the specified width/height
  19564. * @param width height to set on the multiview texture
  19565. * @param height width to set on the multiview texture
  19566. */
  19567. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19568. }
  19569. interface Scene {
  19570. /** @hidden */
  19571. _transformMatrixR: Matrix;
  19572. /** @hidden */
  19573. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19574. /** @hidden */
  19575. _createMultiviewUbo(): void;
  19576. /** @hidden */
  19577. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19578. /** @hidden */
  19579. _renderMultiviewToSingleView(camera: Camera): void;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19585. * This will not be used for webXR as it supports displaying texture arrays directly
  19586. */
  19587. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19588. /**
  19589. * Initializes a VRMultiviewToSingleview
  19590. * @param name name of the post process
  19591. * @param camera camera to be applied to
  19592. * @param scaleFactor scaling factor to the size of the output texture
  19593. */
  19594. constructor(name: string, camera: Camera, scaleFactor: number);
  19595. }
  19596. }
  19597. declare module BABYLON {
  19598. /**
  19599. * Interface used to define additional presentation attributes
  19600. */
  19601. export interface IVRPresentationAttributes {
  19602. /**
  19603. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19604. */
  19605. highRefreshRate: boolean;
  19606. /**
  19607. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19608. */
  19609. foveationLevel: number;
  19610. }
  19611. interface Engine {
  19612. /** @hidden */
  19613. _vrDisplay: any;
  19614. /** @hidden */
  19615. _vrSupported: boolean;
  19616. /** @hidden */
  19617. _oldSize: Size;
  19618. /** @hidden */
  19619. _oldHardwareScaleFactor: number;
  19620. /** @hidden */
  19621. _vrExclusivePointerMode: boolean;
  19622. /** @hidden */
  19623. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _onVRDisplayPointerRestricted: () => void;
  19626. /** @hidden */
  19627. _onVRDisplayPointerUnrestricted: () => void;
  19628. /** @hidden */
  19629. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19630. /** @hidden */
  19631. _onVrDisplayDisconnect: Nullable<() => void>;
  19632. /** @hidden */
  19633. _onVrDisplayPresentChange: Nullable<() => void>;
  19634. /**
  19635. * Observable signaled when VR display mode changes
  19636. */
  19637. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19638. /**
  19639. * Observable signaled when VR request present is complete
  19640. */
  19641. onVRRequestPresentComplete: Observable<boolean>;
  19642. /**
  19643. * Observable signaled when VR request present starts
  19644. */
  19645. onVRRequestPresentStart: Observable<Engine>;
  19646. /**
  19647. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19648. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19649. */
  19650. isInVRExclusivePointerMode: boolean;
  19651. /**
  19652. * Gets a boolean indicating if a webVR device was detected
  19653. * @returns true if a webVR device was detected
  19654. */
  19655. isVRDevicePresent(): boolean;
  19656. /**
  19657. * Gets the current webVR device
  19658. * @returns the current webVR device (or null)
  19659. */
  19660. getVRDevice(): any;
  19661. /**
  19662. * Initializes a webVR display and starts listening to display change events
  19663. * The onVRDisplayChangedObservable will be notified upon these changes
  19664. * @returns A promise containing a VRDisplay and if vr is supported
  19665. */
  19666. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19667. /** @hidden */
  19668. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19669. /**
  19670. * Gets or sets the presentation attributes used to configure VR rendering
  19671. */
  19672. vrPresentationAttributes?: IVRPresentationAttributes;
  19673. /**
  19674. * Call this function to switch to webVR mode
  19675. * Will do nothing if webVR is not supported or if there is no webVR device
  19676. * @param options the webvr options provided to the camera. mainly used for multiview
  19677. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19678. */
  19679. enableVR(options: WebVROptions): void;
  19680. /** @hidden */
  19681. _onVRFullScreenTriggered(): void;
  19682. }
  19683. }
  19684. declare module BABYLON {
  19685. /**
  19686. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19687. * IMPORTANT!! The data is right-hand data.
  19688. * @export
  19689. * @interface DevicePose
  19690. */
  19691. export interface DevicePose {
  19692. /**
  19693. * The position of the device, values in array are [x,y,z].
  19694. */
  19695. readonly position: Nullable<Float32Array>;
  19696. /**
  19697. * The linearVelocity of the device, values in array are [x,y,z].
  19698. */
  19699. readonly linearVelocity: Nullable<Float32Array>;
  19700. /**
  19701. * The linearAcceleration of the device, values in array are [x,y,z].
  19702. */
  19703. readonly linearAcceleration: Nullable<Float32Array>;
  19704. /**
  19705. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19706. */
  19707. readonly orientation: Nullable<Float32Array>;
  19708. /**
  19709. * The angularVelocity of the device, values in array are [x,y,z].
  19710. */
  19711. readonly angularVelocity: Nullable<Float32Array>;
  19712. /**
  19713. * The angularAcceleration of the device, values in array are [x,y,z].
  19714. */
  19715. readonly angularAcceleration: Nullable<Float32Array>;
  19716. }
  19717. /**
  19718. * Interface representing a pose controlled object in Babylon.
  19719. * A pose controlled object has both regular pose values as well as pose values
  19720. * from an external device such as a VR head mounted display
  19721. */
  19722. export interface PoseControlled {
  19723. /**
  19724. * The position of the object in babylon space.
  19725. */
  19726. position: Vector3;
  19727. /**
  19728. * The rotation quaternion of the object in babylon space.
  19729. */
  19730. rotationQuaternion: Quaternion;
  19731. /**
  19732. * The position of the device in babylon space.
  19733. */
  19734. devicePosition?: Vector3;
  19735. /**
  19736. * The rotation quaternion of the device in babylon space.
  19737. */
  19738. deviceRotationQuaternion: Quaternion;
  19739. /**
  19740. * The raw pose coming from the device.
  19741. */
  19742. rawPose: Nullable<DevicePose>;
  19743. /**
  19744. * The scale of the device to be used when translating from device space to babylon space.
  19745. */
  19746. deviceScaleFactor: number;
  19747. /**
  19748. * Updates the poseControlled values based on the input device pose.
  19749. * @param poseData the pose data to update the object with
  19750. */
  19751. updateFromDevice(poseData: DevicePose): void;
  19752. }
  19753. /**
  19754. * Set of options to customize the webVRCamera
  19755. */
  19756. export interface WebVROptions {
  19757. /**
  19758. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19759. */
  19760. trackPosition?: boolean;
  19761. /**
  19762. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19763. */
  19764. positionScale?: number;
  19765. /**
  19766. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19767. */
  19768. displayName?: string;
  19769. /**
  19770. * Should the native controller meshes be initialized. (default: true)
  19771. */
  19772. controllerMeshes?: boolean;
  19773. /**
  19774. * Creating a default HemiLight only on controllers. (default: true)
  19775. */
  19776. defaultLightingOnControllers?: boolean;
  19777. /**
  19778. * If you don't want to use the default VR button of the helper. (default: false)
  19779. */
  19780. useCustomVRButton?: boolean;
  19781. /**
  19782. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19783. */
  19784. customVRButton?: HTMLButtonElement;
  19785. /**
  19786. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19787. */
  19788. rayLength?: number;
  19789. /**
  19790. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19791. */
  19792. defaultHeight?: number;
  19793. /**
  19794. * If multiview should be used if availible (default: false)
  19795. */
  19796. useMultiview?: boolean;
  19797. }
  19798. /**
  19799. * This represents a WebVR camera.
  19800. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19801. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19802. */
  19803. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19804. private webVROptions;
  19805. /**
  19806. * @hidden
  19807. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19808. */
  19809. _vrDevice: any;
  19810. /**
  19811. * The rawPose of the vrDevice.
  19812. */
  19813. rawPose: Nullable<DevicePose>;
  19814. private _onVREnabled;
  19815. private _specsVersion;
  19816. private _attached;
  19817. private _frameData;
  19818. protected _descendants: Array<Node>;
  19819. private _deviceRoomPosition;
  19820. /** @hidden */
  19821. _deviceRoomRotationQuaternion: Quaternion;
  19822. private _standingMatrix;
  19823. /**
  19824. * Represents device position in babylon space.
  19825. */
  19826. devicePosition: Vector3;
  19827. /**
  19828. * Represents device rotation in babylon space.
  19829. */
  19830. deviceRotationQuaternion: Quaternion;
  19831. /**
  19832. * The scale of the device to be used when translating from device space to babylon space.
  19833. */
  19834. deviceScaleFactor: number;
  19835. private _deviceToWorld;
  19836. private _worldToDevice;
  19837. /**
  19838. * References to the webVR controllers for the vrDevice.
  19839. */
  19840. controllers: Array<WebVRController>;
  19841. /**
  19842. * Emits an event when a controller is attached.
  19843. */
  19844. onControllersAttachedObservable: Observable<WebVRController[]>;
  19845. /**
  19846. * Emits an event when a controller's mesh has been loaded;
  19847. */
  19848. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19849. /**
  19850. * Emits an event when the HMD's pose has been updated.
  19851. */
  19852. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19853. private _poseSet;
  19854. /**
  19855. * If the rig cameras be used as parent instead of this camera.
  19856. */
  19857. rigParenting: boolean;
  19858. private _lightOnControllers;
  19859. private _defaultHeight?;
  19860. /**
  19861. * Instantiates a WebVRFreeCamera.
  19862. * @param name The name of the WebVRFreeCamera
  19863. * @param position The starting anchor position for the camera
  19864. * @param scene The scene the camera belongs to
  19865. * @param webVROptions a set of customizable options for the webVRCamera
  19866. */
  19867. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19868. /**
  19869. * Gets the device distance from the ground in meters.
  19870. * @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.
  19871. */
  19872. deviceDistanceToRoomGround(): number;
  19873. /**
  19874. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19875. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19876. */
  19877. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19878. /**
  19879. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19880. * @returns A promise with a boolean set to if the standing matrix is supported.
  19881. */
  19882. useStandingMatrixAsync(): Promise<boolean>;
  19883. /**
  19884. * Disposes the camera
  19885. */
  19886. dispose(): void;
  19887. /**
  19888. * Gets a vrController by name.
  19889. * @param name The name of the controller to retreive
  19890. * @returns the controller matching the name specified or null if not found
  19891. */
  19892. getControllerByName(name: string): Nullable<WebVRController>;
  19893. private _leftController;
  19894. /**
  19895. * The controller corresponding to the users left hand.
  19896. */
  19897. get leftController(): Nullable<WebVRController>;
  19898. private _rightController;
  19899. /**
  19900. * The controller corresponding to the users right hand.
  19901. */
  19902. get rightController(): Nullable<WebVRController>;
  19903. /**
  19904. * Casts a ray forward from the vrCamera's gaze.
  19905. * @param length Length of the ray (default: 100)
  19906. * @returns the ray corresponding to the gaze
  19907. */
  19908. getForwardRay(length?: number): Ray;
  19909. /**
  19910. * @hidden
  19911. * Updates the camera based on device's frame data
  19912. */
  19913. _checkInputs(): void;
  19914. /**
  19915. * Updates the poseControlled values based on the input device pose.
  19916. * @param poseData Pose coming from the device
  19917. */
  19918. updateFromDevice(poseData: DevicePose): void;
  19919. private _htmlElementAttached;
  19920. private _detachIfAttached;
  19921. /**
  19922. * WebVR's attach control will start broadcasting frames to the device.
  19923. * Note that in certain browsers (chrome for example) this function must be called
  19924. * within a user-interaction callback. Example:
  19925. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19926. *
  19927. * @param element html element to attach the vrDevice to
  19928. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19929. */
  19930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19931. /**
  19932. * Detaches the camera from the html element and disables VR
  19933. *
  19934. * @param element html element to detach from
  19935. */
  19936. detachControl(element: HTMLElement): void;
  19937. /**
  19938. * @returns the name of this class
  19939. */
  19940. getClassName(): string;
  19941. /**
  19942. * Calls resetPose on the vrDisplay
  19943. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19944. */
  19945. resetToCurrentRotation(): void;
  19946. /**
  19947. * @hidden
  19948. * Updates the rig cameras (left and right eye)
  19949. */
  19950. _updateRigCameras(): void;
  19951. private _workingVector;
  19952. private _oneVector;
  19953. private _workingMatrix;
  19954. private updateCacheCalled;
  19955. private _correctPositionIfNotTrackPosition;
  19956. /**
  19957. * @hidden
  19958. * Updates the cached values of the camera
  19959. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19960. */
  19961. _updateCache(ignoreParentClass?: boolean): void;
  19962. /**
  19963. * @hidden
  19964. * Get current device position in babylon world
  19965. */
  19966. _computeDevicePosition(): void;
  19967. /**
  19968. * Updates the current device position and rotation in the babylon world
  19969. */
  19970. update(): void;
  19971. /**
  19972. * @hidden
  19973. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19974. * @returns an identity matrix
  19975. */
  19976. _getViewMatrix(): Matrix;
  19977. private _tmpMatrix;
  19978. /**
  19979. * This function is called by the two RIG cameras.
  19980. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19981. * @hidden
  19982. */
  19983. _getWebVRViewMatrix(): Matrix;
  19984. /** @hidden */
  19985. _getWebVRProjectionMatrix(): Matrix;
  19986. private _onGamepadConnectedObserver;
  19987. private _onGamepadDisconnectedObserver;
  19988. private _updateCacheWhenTrackingDisabledObserver;
  19989. /**
  19990. * Initializes the controllers and their meshes
  19991. */
  19992. initControllers(): void;
  19993. }
  19994. }
  19995. declare module BABYLON {
  19996. /**
  19997. * "Static Class" containing the most commonly used helper while dealing with material for
  19998. * rendering purpose.
  19999. *
  20000. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20001. *
  20002. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20003. */
  20004. export class MaterialHelper {
  20005. /**
  20006. * Bind the current view position to an effect.
  20007. * @param effect The effect to be bound
  20008. * @param scene The scene the eyes position is used from
  20009. * @param variableName name of the shader variable that will hold the eye position
  20010. */
  20011. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20012. /**
  20013. * Helps preparing the defines values about the UVs in used in the effect.
  20014. * UVs are shared as much as we can accross channels in the shaders.
  20015. * @param texture The texture we are preparing the UVs for
  20016. * @param defines The defines to update
  20017. * @param key The channel key "diffuse", "specular"... used in the shader
  20018. */
  20019. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20020. /**
  20021. * Binds a texture matrix value to its corrsponding uniform
  20022. * @param texture The texture to bind the matrix for
  20023. * @param uniformBuffer The uniform buffer receivin the data
  20024. * @param key The channel key "diffuse", "specular"... used in the shader
  20025. */
  20026. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20027. /**
  20028. * Gets the current status of the fog (should it be enabled?)
  20029. * @param mesh defines the mesh to evaluate for fog support
  20030. * @param scene defines the hosting scene
  20031. * @returns true if fog must be enabled
  20032. */
  20033. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20034. /**
  20035. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20036. * @param mesh defines the current mesh
  20037. * @param scene defines the current scene
  20038. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20039. * @param pointsCloud defines if point cloud rendering has to be turned on
  20040. * @param fogEnabled defines if fog has to be turned on
  20041. * @param alphaTest defines if alpha testing has to be turned on
  20042. * @param defines defines the current list of defines
  20043. */
  20044. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20045. /**
  20046. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20047. * @param scene defines the current scene
  20048. * @param engine defines the current engine
  20049. * @param defines specifies the list of active defines
  20050. * @param useInstances defines if instances have to be turned on
  20051. * @param useClipPlane defines if clip plane have to be turned on
  20052. * @param useInstances defines if instances have to be turned on
  20053. * @param useThinInstances defines if thin instances have to be turned on
  20054. */
  20055. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20056. /**
  20057. * Prepares the defines for bones
  20058. * @param mesh The mesh containing the geometry data we will draw
  20059. * @param defines The defines to update
  20060. */
  20061. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20062. /**
  20063. * Prepares the defines for morph targets
  20064. * @param mesh The mesh containing the geometry data we will draw
  20065. * @param defines The defines to update
  20066. */
  20067. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20068. /**
  20069. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20070. * @param mesh The mesh containing the geometry data we will draw
  20071. * @param defines The defines to update
  20072. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20073. * @param useBones Precise whether bones should be used or not (override mesh info)
  20074. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20075. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20076. * @returns false if defines are considered not dirty and have not been checked
  20077. */
  20078. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20079. /**
  20080. * Prepares the defines related to multiview
  20081. * @param scene The scene we are intending to draw
  20082. * @param defines The defines to update
  20083. */
  20084. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20085. /**
  20086. * Prepares the defines related to the light information passed in parameter
  20087. * @param scene The scene we are intending to draw
  20088. * @param mesh The mesh the effect is compiling for
  20089. * @param light The light the effect is compiling for
  20090. * @param lightIndex The index of the light
  20091. * @param defines The defines to update
  20092. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20093. * @param state Defines the current state regarding what is needed (normals, etc...)
  20094. */
  20095. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20096. needNormals: boolean;
  20097. needRebuild: boolean;
  20098. shadowEnabled: boolean;
  20099. specularEnabled: boolean;
  20100. lightmapMode: boolean;
  20101. }): void;
  20102. /**
  20103. * Prepares the defines related to the light information passed in parameter
  20104. * @param scene The scene we are intending to draw
  20105. * @param mesh The mesh the effect is compiling for
  20106. * @param defines The defines to update
  20107. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20108. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20109. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20110. * @returns true if normals will be required for the rest of the effect
  20111. */
  20112. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20113. /**
  20114. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20115. * @param lightIndex defines the light index
  20116. * @param uniformsList The uniform list
  20117. * @param samplersList The sampler list
  20118. * @param projectedLightTexture defines if projected texture must be used
  20119. * @param uniformBuffersList defines an optional list of uniform buffers
  20120. */
  20121. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20122. /**
  20123. * Prepares the uniforms and samplers list to be used in the effect
  20124. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20125. * @param samplersList The sampler list
  20126. * @param defines The defines helping in the list generation
  20127. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20128. */
  20129. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20130. /**
  20131. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20132. * @param defines The defines to update while falling back
  20133. * @param fallbacks The authorized effect fallbacks
  20134. * @param maxSimultaneousLights The maximum number of lights allowed
  20135. * @param rank the current rank of the Effect
  20136. * @returns The newly affected rank
  20137. */
  20138. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20139. private static _TmpMorphInfluencers;
  20140. /**
  20141. * Prepares the list of attributes required for morph targets according to the effect defines.
  20142. * @param attribs The current list of supported attribs
  20143. * @param mesh The mesh to prepare the morph targets attributes for
  20144. * @param influencers The number of influencers
  20145. */
  20146. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20147. /**
  20148. * Prepares the list of attributes required for morph targets according to the effect defines.
  20149. * @param attribs The current list of supported attribs
  20150. * @param mesh The mesh to prepare the morph targets attributes for
  20151. * @param defines The current Defines of the effect
  20152. */
  20153. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20154. /**
  20155. * Prepares the list of attributes required for bones according to the effect defines.
  20156. * @param attribs The current list of supported attribs
  20157. * @param mesh The mesh to prepare the bones attributes for
  20158. * @param defines The current Defines of the effect
  20159. * @param fallbacks The current efffect fallback strategy
  20160. */
  20161. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20162. /**
  20163. * Check and prepare the list of attributes required for instances according to the effect defines.
  20164. * @param attribs The current list of supported attribs
  20165. * @param defines The current MaterialDefines of the effect
  20166. */
  20167. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20168. /**
  20169. * Add the list of attributes required for instances to the attribs array.
  20170. * @param attribs The current list of supported attribs
  20171. */
  20172. static PushAttributesForInstances(attribs: string[]): void;
  20173. /**
  20174. * Binds the light information to the effect.
  20175. * @param light The light containing the generator
  20176. * @param effect The effect we are binding the data to
  20177. * @param lightIndex The light index in the effect used to render
  20178. */
  20179. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20180. /**
  20181. * Binds the lights information from the scene to the effect for the given mesh.
  20182. * @param light Light to bind
  20183. * @param lightIndex Light index
  20184. * @param scene The scene where the light belongs to
  20185. * @param effect The effect we are binding the data to
  20186. * @param useSpecular Defines if specular is supported
  20187. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20188. */
  20189. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20190. /**
  20191. * Binds the lights information from the scene to the effect for the given mesh.
  20192. * @param scene The scene the lights belongs to
  20193. * @param mesh The mesh we are binding the information to render
  20194. * @param effect The effect we are binding the data to
  20195. * @param defines The generated defines for the effect
  20196. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20197. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20198. */
  20199. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20200. private static _tempFogColor;
  20201. /**
  20202. * Binds the fog information from the scene to the effect for the given mesh.
  20203. * @param scene The scene the lights belongs to
  20204. * @param mesh The mesh we are binding the information to render
  20205. * @param effect The effect we are binding the data to
  20206. * @param linearSpace Defines if the fog effect is applied in linear space
  20207. */
  20208. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20209. /**
  20210. * Binds the bones information from the mesh to the effect.
  20211. * @param mesh The mesh we are binding the information to render
  20212. * @param effect The effect we are binding the data to
  20213. */
  20214. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20215. /**
  20216. * Binds the morph targets information from the mesh to the effect.
  20217. * @param abstractMesh The mesh we are binding the information to render
  20218. * @param effect The effect we are binding the data to
  20219. */
  20220. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20221. /**
  20222. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20223. * @param defines The generated defines used in the effect
  20224. * @param effect The effect we are binding the data to
  20225. * @param scene The scene we are willing to render with logarithmic scale for
  20226. */
  20227. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20228. /**
  20229. * Binds the clip plane information from the scene to the effect.
  20230. * @param scene The scene the clip plane information are extracted from
  20231. * @param effect The effect we are binding the data to
  20232. */
  20233. static BindClipPlane(effect: Effect, scene: Scene): void;
  20234. }
  20235. }
  20236. declare module BABYLON {
  20237. /**
  20238. * Block used to expose an input value
  20239. */
  20240. export class InputBlock extends NodeMaterialBlock {
  20241. private _mode;
  20242. private _associatedVariableName;
  20243. private _storedValue;
  20244. private _valueCallback;
  20245. private _type;
  20246. private _animationType;
  20247. /** Gets or set a value used to limit the range of float values */
  20248. min: number;
  20249. /** Gets or set a value used to limit the range of float values */
  20250. max: number;
  20251. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20252. isBoolean: boolean;
  20253. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20254. matrixMode: number;
  20255. /** @hidden */
  20256. _systemValue: Nullable<NodeMaterialSystemValues>;
  20257. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20258. visibleInInspector: boolean;
  20259. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20260. isConstant: boolean;
  20261. /** Gets or sets the group to use to display this block in the Inspector */
  20262. groupInInspector: string;
  20263. /** Gets an observable raised when the value is changed */
  20264. onValueChangedObservable: Observable<InputBlock>;
  20265. /**
  20266. * Gets or sets the connection point type (default is float)
  20267. */
  20268. get type(): NodeMaterialBlockConnectionPointTypes;
  20269. /**
  20270. * Creates a new InputBlock
  20271. * @param name defines the block name
  20272. * @param target defines the target of that block (Vertex by default)
  20273. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20274. */
  20275. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20276. /**
  20277. * Gets the output component
  20278. */
  20279. get output(): NodeMaterialConnectionPoint;
  20280. /**
  20281. * Set the source of this connection point to a vertex attribute
  20282. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20283. * @returns the current connection point
  20284. */
  20285. setAsAttribute(attributeName?: string): InputBlock;
  20286. /**
  20287. * Set the source of this connection point to a system value
  20288. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20289. * @returns the current connection point
  20290. */
  20291. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20292. /**
  20293. * Gets or sets the value of that point.
  20294. * Please note that this value will be ignored if valueCallback is defined
  20295. */
  20296. get value(): any;
  20297. set value(value: any);
  20298. /**
  20299. * Gets or sets a callback used to get the value of that point.
  20300. * Please note that setting this value will force the connection point to ignore the value property
  20301. */
  20302. get valueCallback(): () => any;
  20303. set valueCallback(value: () => any);
  20304. /**
  20305. * Gets or sets the associated variable name in the shader
  20306. */
  20307. get associatedVariableName(): string;
  20308. set associatedVariableName(value: string);
  20309. /** Gets or sets the type of animation applied to the input */
  20310. get animationType(): AnimatedInputBlockTypes;
  20311. set animationType(value: AnimatedInputBlockTypes);
  20312. /**
  20313. * Gets a boolean indicating that this connection point not defined yet
  20314. */
  20315. get isUndefined(): boolean;
  20316. /**
  20317. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20318. * In this case the connection point name must be the name of the uniform to use.
  20319. * Can only be set on inputs
  20320. */
  20321. get isUniform(): boolean;
  20322. set isUniform(value: boolean);
  20323. /**
  20324. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20325. * In this case the connection point name must be the name of the attribute to use
  20326. * Can only be set on inputs
  20327. */
  20328. get isAttribute(): boolean;
  20329. set isAttribute(value: boolean);
  20330. /**
  20331. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20332. * Can only be set on exit points
  20333. */
  20334. get isVarying(): boolean;
  20335. set isVarying(value: boolean);
  20336. /**
  20337. * Gets a boolean indicating that the current connection point is a system value
  20338. */
  20339. get isSystemValue(): boolean;
  20340. /**
  20341. * Gets or sets the current well known value or null if not defined as a system value
  20342. */
  20343. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20344. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20345. /**
  20346. * Gets the current class name
  20347. * @returns the class name
  20348. */
  20349. getClassName(): string;
  20350. /**
  20351. * Animate the input if animationType !== None
  20352. * @param scene defines the rendering scene
  20353. */
  20354. animate(scene: Scene): void;
  20355. private _emitDefine;
  20356. initialize(state: NodeMaterialBuildState): void;
  20357. /**
  20358. * Set the input block to its default value (based on its type)
  20359. */
  20360. setDefaultValue(): void;
  20361. private _emitConstant;
  20362. /** @hidden */
  20363. get _noContextSwitch(): boolean;
  20364. private _emit;
  20365. /** @hidden */
  20366. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20367. /** @hidden */
  20368. _transmit(effect: Effect, scene: Scene): void;
  20369. protected _buildBlock(state: NodeMaterialBuildState): void;
  20370. protected _dumpPropertiesCode(): string;
  20371. dispose(): void;
  20372. serialize(): any;
  20373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20374. }
  20375. }
  20376. declare module BABYLON {
  20377. /**
  20378. * Enum used to define the compatibility state between two connection points
  20379. */
  20380. export enum NodeMaterialConnectionPointCompatibilityStates {
  20381. /** Points are compatibles */
  20382. Compatible = 0,
  20383. /** Points are incompatible because of their types */
  20384. TypeIncompatible = 1,
  20385. /** Points are incompatible because of their targets (vertex vs fragment) */
  20386. TargetIncompatible = 2
  20387. }
  20388. /**
  20389. * Defines the direction of a connection point
  20390. */
  20391. export enum NodeMaterialConnectionPointDirection {
  20392. /** Input */
  20393. Input = 0,
  20394. /** Output */
  20395. Output = 1
  20396. }
  20397. /**
  20398. * Defines a connection point for a block
  20399. */
  20400. export class NodeMaterialConnectionPoint {
  20401. /** @hidden */
  20402. _ownerBlock: NodeMaterialBlock;
  20403. /** @hidden */
  20404. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20405. private _endpoints;
  20406. private _associatedVariableName;
  20407. private _direction;
  20408. /** @hidden */
  20409. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20410. /** @hidden */
  20411. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20412. private _type;
  20413. /** @hidden */
  20414. _enforceAssociatedVariableName: boolean;
  20415. /** Gets the direction of the point */
  20416. get direction(): NodeMaterialConnectionPointDirection;
  20417. /** Indicates that this connection point needs dual validation before being connected to another point */
  20418. needDualDirectionValidation: boolean;
  20419. /**
  20420. * Gets or sets the additional types supported by this connection point
  20421. */
  20422. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20423. /**
  20424. * Gets or sets the additional types excluded by this connection point
  20425. */
  20426. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20427. /**
  20428. * Observable triggered when this point is connected
  20429. */
  20430. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20431. /**
  20432. * Gets or sets the associated variable name in the shader
  20433. */
  20434. get associatedVariableName(): string;
  20435. set associatedVariableName(value: string);
  20436. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20437. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20438. /**
  20439. * Gets or sets the connection point type (default is float)
  20440. */
  20441. get type(): NodeMaterialBlockConnectionPointTypes;
  20442. set type(value: NodeMaterialBlockConnectionPointTypes);
  20443. /**
  20444. * Gets or sets the connection point name
  20445. */
  20446. name: string;
  20447. /**
  20448. * Gets or sets the connection point name
  20449. */
  20450. displayName: string;
  20451. /**
  20452. * Gets or sets a boolean indicating that this connection point can be omitted
  20453. */
  20454. isOptional: boolean;
  20455. /**
  20456. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20457. */
  20458. define: string;
  20459. /** @hidden */
  20460. _prioritizeVertex: boolean;
  20461. private _target;
  20462. /** Gets or sets the target of that connection point */
  20463. get target(): NodeMaterialBlockTargets;
  20464. set target(value: NodeMaterialBlockTargets);
  20465. /**
  20466. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20467. */
  20468. get isConnected(): boolean;
  20469. /**
  20470. * Gets a boolean indicating that the current point is connected to an input block
  20471. */
  20472. get isConnectedToInputBlock(): boolean;
  20473. /**
  20474. * Gets a the connected input block (if any)
  20475. */
  20476. get connectInputBlock(): Nullable<InputBlock>;
  20477. /** Get the other side of the connection (if any) */
  20478. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20479. /** Get the block that owns this connection point */
  20480. get ownerBlock(): NodeMaterialBlock;
  20481. /** Get the block connected on the other side of this connection (if any) */
  20482. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20483. /** Get the block connected on the endpoints of this connection (if any) */
  20484. get connectedBlocks(): Array<NodeMaterialBlock>;
  20485. /** Gets the list of connected endpoints */
  20486. get endpoints(): NodeMaterialConnectionPoint[];
  20487. /** Gets a boolean indicating if that output point is connected to at least one input */
  20488. get hasEndpoints(): boolean;
  20489. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20490. get isConnectedInVertexShader(): boolean;
  20491. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20492. get isConnectedInFragmentShader(): boolean;
  20493. /**
  20494. * Creates a block suitable to be used as an input for this input point.
  20495. * If null is returned, a block based on the point type will be created.
  20496. * @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
  20497. */
  20498. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20499. /**
  20500. * Creates a new connection point
  20501. * @param name defines the connection point name
  20502. * @param ownerBlock defines the block hosting this connection point
  20503. * @param direction defines the direction of the connection point
  20504. */
  20505. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20506. /**
  20507. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20508. * @returns the class name
  20509. */
  20510. getClassName(): string;
  20511. /**
  20512. * Gets a boolean indicating if the current point can be connected to another point
  20513. * @param connectionPoint defines the other connection point
  20514. * @returns a boolean
  20515. */
  20516. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20517. /**
  20518. * Gets a number indicating if the current point can be connected to another point
  20519. * @param connectionPoint defines the other connection point
  20520. * @returns a number defining the compatibility state
  20521. */
  20522. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20523. /**
  20524. * Connect this point to another connection point
  20525. * @param connectionPoint defines the other connection point
  20526. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20527. * @returns the current connection point
  20528. */
  20529. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20530. /**
  20531. * Disconnect this point from one of his endpoint
  20532. * @param endpoint defines the other connection point
  20533. * @returns the current connection point
  20534. */
  20535. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20536. /**
  20537. * Serializes this point in a JSON representation
  20538. * @param isInput defines if the connection point is an input (default is true)
  20539. * @returns the serialized point object
  20540. */
  20541. serialize(isInput?: boolean): any;
  20542. /**
  20543. * Release resources
  20544. */
  20545. dispose(): void;
  20546. }
  20547. }
  20548. declare module BABYLON {
  20549. /**
  20550. * Enum used to define the material modes
  20551. */
  20552. export enum NodeMaterialModes {
  20553. /** Regular material */
  20554. Material = 0,
  20555. /** For post process */
  20556. PostProcess = 1,
  20557. /** For particle system */
  20558. Particle = 2
  20559. }
  20560. }
  20561. declare module BABYLON {
  20562. /**
  20563. * Block used to read a texture from a sampler
  20564. */
  20565. export class TextureBlock extends NodeMaterialBlock {
  20566. private _defineName;
  20567. private _linearDefineName;
  20568. private _gammaDefineName;
  20569. private _tempTextureRead;
  20570. private _samplerName;
  20571. private _transformedUVName;
  20572. private _textureTransformName;
  20573. private _textureInfoName;
  20574. private _mainUVName;
  20575. private _mainUVDefineName;
  20576. private _fragmentOnly;
  20577. /**
  20578. * Gets or sets the texture associated with the node
  20579. */
  20580. texture: Nullable<Texture>;
  20581. /**
  20582. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20583. */
  20584. convertToGammaSpace: boolean;
  20585. /**
  20586. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20587. */
  20588. convertToLinearSpace: boolean;
  20589. /**
  20590. * Create a new TextureBlock
  20591. * @param name defines the block name
  20592. */
  20593. constructor(name: string, fragmentOnly?: boolean);
  20594. /**
  20595. * Gets the current class name
  20596. * @returns the class name
  20597. */
  20598. getClassName(): string;
  20599. /**
  20600. * Gets the uv input component
  20601. */
  20602. get uv(): NodeMaterialConnectionPoint;
  20603. /**
  20604. * Gets the rgba output component
  20605. */
  20606. get rgba(): NodeMaterialConnectionPoint;
  20607. /**
  20608. * Gets the rgb output component
  20609. */
  20610. get rgb(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the r output component
  20613. */
  20614. get r(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the g output component
  20617. */
  20618. get g(): NodeMaterialConnectionPoint;
  20619. /**
  20620. * Gets the b output component
  20621. */
  20622. get b(): NodeMaterialConnectionPoint;
  20623. /**
  20624. * Gets the a output component
  20625. */
  20626. get a(): NodeMaterialConnectionPoint;
  20627. get target(): NodeMaterialBlockTargets;
  20628. autoConfigure(material: NodeMaterial): void;
  20629. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20631. isReady(): boolean;
  20632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20633. private get _isMixed();
  20634. private _injectVertexCode;
  20635. private _writeTextureRead;
  20636. private _writeOutput;
  20637. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20638. protected _dumpPropertiesCode(): string;
  20639. serialize(): any;
  20640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20641. }
  20642. }
  20643. declare module BABYLON {
  20644. /** @hidden */
  20645. export var reflectionFunction: {
  20646. name: string;
  20647. shader: string;
  20648. };
  20649. }
  20650. declare module BABYLON {
  20651. /**
  20652. * Base block used to read a reflection texture from a sampler
  20653. */
  20654. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20655. /** @hidden */
  20656. _define3DName: string;
  20657. /** @hidden */
  20658. _defineCubicName: string;
  20659. /** @hidden */
  20660. _defineExplicitName: string;
  20661. /** @hidden */
  20662. _defineProjectionName: string;
  20663. /** @hidden */
  20664. _defineLocalCubicName: string;
  20665. /** @hidden */
  20666. _defineSphericalName: string;
  20667. /** @hidden */
  20668. _definePlanarName: string;
  20669. /** @hidden */
  20670. _defineEquirectangularName: string;
  20671. /** @hidden */
  20672. _defineMirroredEquirectangularFixedName: string;
  20673. /** @hidden */
  20674. _defineEquirectangularFixedName: string;
  20675. /** @hidden */
  20676. _defineSkyboxName: string;
  20677. /** @hidden */
  20678. _defineOppositeZ: string;
  20679. /** @hidden */
  20680. _cubeSamplerName: string;
  20681. /** @hidden */
  20682. _2DSamplerName: string;
  20683. protected _positionUVWName: string;
  20684. protected _directionWName: string;
  20685. protected _reflectionVectorName: string;
  20686. /** @hidden */
  20687. _reflectionCoordsName: string;
  20688. /** @hidden */
  20689. _reflectionMatrixName: string;
  20690. protected _reflectionColorName: string;
  20691. /**
  20692. * Gets or sets the texture associated with the node
  20693. */
  20694. texture: Nullable<BaseTexture>;
  20695. /**
  20696. * Create a new ReflectionTextureBaseBlock
  20697. * @param name defines the block name
  20698. */
  20699. constructor(name: string);
  20700. /**
  20701. * Gets the current class name
  20702. * @returns the class name
  20703. */
  20704. getClassName(): string;
  20705. /**
  20706. * Gets the world position input component
  20707. */
  20708. abstract get position(): NodeMaterialConnectionPoint;
  20709. /**
  20710. * Gets the world position input component
  20711. */
  20712. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20713. /**
  20714. * Gets the world normal input component
  20715. */
  20716. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20717. /**
  20718. * Gets the world input component
  20719. */
  20720. abstract get world(): NodeMaterialConnectionPoint;
  20721. /**
  20722. * Gets the camera (or eye) position component
  20723. */
  20724. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20725. /**
  20726. * Gets the view input component
  20727. */
  20728. abstract get view(): NodeMaterialConnectionPoint;
  20729. protected _getTexture(): Nullable<BaseTexture>;
  20730. autoConfigure(material: NodeMaterial): void;
  20731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20732. isReady(): boolean;
  20733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20734. /**
  20735. * Gets the code to inject in the vertex shader
  20736. * @param state current state of the node material building
  20737. * @returns the shader code
  20738. */
  20739. handleVertexSide(state: NodeMaterialBuildState): string;
  20740. /**
  20741. * Handles the inits for the fragment code path
  20742. * @param state node material build state
  20743. */
  20744. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20745. /**
  20746. * Generates the reflection coords code for the fragment code path
  20747. * @param worldNormalVarName name of the world normal variable
  20748. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20749. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20750. * @returns the shader code
  20751. */
  20752. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20753. /**
  20754. * Generates the reflection color code for the fragment code path
  20755. * @param lodVarName name of the lod variable
  20756. * @param swizzleLookupTexture swizzle to use for the final color variable
  20757. * @returns the shader code
  20758. */
  20759. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20760. /**
  20761. * Generates the code corresponding to the connected output points
  20762. * @param state node material build state
  20763. * @param varName name of the variable to output
  20764. * @returns the shader code
  20765. */
  20766. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20767. protected _buildBlock(state: NodeMaterialBuildState): this;
  20768. protected _dumpPropertiesCode(): string;
  20769. serialize(): any;
  20770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20771. }
  20772. }
  20773. declare module BABYLON {
  20774. /**
  20775. * Defines a connection point to be used for points with a custom object type
  20776. */
  20777. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20778. private _blockType;
  20779. private _blockName;
  20780. private _nameForCheking?;
  20781. /**
  20782. * Creates a new connection point
  20783. * @param name defines the connection point name
  20784. * @param ownerBlock defines the block hosting this connection point
  20785. * @param direction defines the direction of the connection point
  20786. */
  20787. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20788. /**
  20789. * Gets a number indicating if the current point can be connected to another point
  20790. * @param connectionPoint defines the other connection point
  20791. * @returns a number defining the compatibility state
  20792. */
  20793. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20794. /**
  20795. * Creates a block suitable to be used as an input for this input point.
  20796. * If null is returned, a block based on the point type will be created.
  20797. * @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
  20798. */
  20799. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20800. }
  20801. }
  20802. declare module BABYLON {
  20803. /**
  20804. * Enum defining the type of properties that can be edited in the property pages in the NME
  20805. */
  20806. export enum PropertyTypeForEdition {
  20807. /** property is a boolean */
  20808. Boolean = 0,
  20809. /** property is a float */
  20810. Float = 1,
  20811. /** property is a Vector2 */
  20812. Vector2 = 2,
  20813. /** property is a list of values */
  20814. List = 3
  20815. }
  20816. /**
  20817. * Interface that defines an option in a variable of type list
  20818. */
  20819. export interface IEditablePropertyListOption {
  20820. /** label of the option */
  20821. "label": string;
  20822. /** value of the option */
  20823. "value": number;
  20824. }
  20825. /**
  20826. * Interface that defines the options available for an editable property
  20827. */
  20828. export interface IEditablePropertyOption {
  20829. /** min value */
  20830. "min"?: number;
  20831. /** max value */
  20832. "max"?: number;
  20833. /** notifiers: indicates which actions to take when the property is changed */
  20834. "notifiers"?: {
  20835. /** the material should be rebuilt */
  20836. "rebuild"?: boolean;
  20837. /** the preview should be updated */
  20838. "update"?: boolean;
  20839. };
  20840. /** list of the options for a variable of type list */
  20841. "options"?: IEditablePropertyListOption[];
  20842. }
  20843. /**
  20844. * Interface that describes an editable property
  20845. */
  20846. export interface IPropertyDescriptionForEdition {
  20847. /** name of the property */
  20848. "propertyName": string;
  20849. /** display name of the property */
  20850. "displayName": string;
  20851. /** type of the property */
  20852. "type": PropertyTypeForEdition;
  20853. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20854. "groupName": string;
  20855. /** options for the property */
  20856. "options": IEditablePropertyOption;
  20857. }
  20858. /**
  20859. * Decorator that flags a property in a node material block as being editable
  20860. */
  20861. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20862. }
  20863. declare module BABYLON {
  20864. /**
  20865. * Block used to implement the refraction part of the sub surface module of the PBR material
  20866. */
  20867. export class RefractionBlock extends NodeMaterialBlock {
  20868. /** @hidden */
  20869. _define3DName: string;
  20870. /** @hidden */
  20871. _refractionMatrixName: string;
  20872. /** @hidden */
  20873. _defineLODRefractionAlpha: string;
  20874. /** @hidden */
  20875. _defineLinearSpecularRefraction: string;
  20876. /** @hidden */
  20877. _defineOppositeZ: string;
  20878. /** @hidden */
  20879. _cubeSamplerName: string;
  20880. /** @hidden */
  20881. _2DSamplerName: string;
  20882. /** @hidden */
  20883. _vRefractionMicrosurfaceInfosName: string;
  20884. /** @hidden */
  20885. _vRefractionInfosName: string;
  20886. private _scene;
  20887. /**
  20888. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20889. * Materials half opaque for instance using refraction could benefit from this control.
  20890. */
  20891. linkRefractionWithTransparency: boolean;
  20892. /**
  20893. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20894. */
  20895. invertRefractionY: boolean;
  20896. /**
  20897. * Gets or sets the texture associated with the node
  20898. */
  20899. texture: Nullable<BaseTexture>;
  20900. /**
  20901. * Create a new RefractionBlock
  20902. * @param name defines the block name
  20903. */
  20904. constructor(name: string);
  20905. /**
  20906. * Gets the current class name
  20907. * @returns the class name
  20908. */
  20909. getClassName(): string;
  20910. /**
  20911. * Gets the intensity input component
  20912. */
  20913. get intensity(): NodeMaterialConnectionPoint;
  20914. /**
  20915. * Gets the index of refraction input component
  20916. */
  20917. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20918. /**
  20919. * Gets the tint at distance input component
  20920. */
  20921. get tintAtDistance(): NodeMaterialConnectionPoint;
  20922. /**
  20923. * Gets the view input component
  20924. */
  20925. get view(): NodeMaterialConnectionPoint;
  20926. /**
  20927. * Gets the refraction object output component
  20928. */
  20929. get refraction(): NodeMaterialConnectionPoint;
  20930. /**
  20931. * Returns true if the block has a texture
  20932. */
  20933. get hasTexture(): boolean;
  20934. protected _getTexture(): Nullable<BaseTexture>;
  20935. autoConfigure(material: NodeMaterial): void;
  20936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20937. isReady(): boolean;
  20938. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20939. /**
  20940. * Gets the main code of the block (fragment side)
  20941. * @param state current state of the node material building
  20942. * @returns the shader code
  20943. */
  20944. getCode(state: NodeMaterialBuildState): string;
  20945. protected _buildBlock(state: NodeMaterialBuildState): this;
  20946. protected _dumpPropertiesCode(): string;
  20947. serialize(): any;
  20948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20949. }
  20950. }
  20951. declare module BABYLON {
  20952. /**
  20953. * Base block used as input for post process
  20954. */
  20955. export class CurrentScreenBlock extends NodeMaterialBlock {
  20956. private _samplerName;
  20957. private _linearDefineName;
  20958. private _gammaDefineName;
  20959. private _mainUVName;
  20960. private _tempTextureRead;
  20961. /**
  20962. * Gets or sets the texture associated with the node
  20963. */
  20964. texture: Nullable<BaseTexture>;
  20965. /**
  20966. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20967. */
  20968. convertToGammaSpace: boolean;
  20969. /**
  20970. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20971. */
  20972. convertToLinearSpace: boolean;
  20973. /**
  20974. * Create a new CurrentScreenBlock
  20975. * @param name defines the block name
  20976. */
  20977. constructor(name: string);
  20978. /**
  20979. * Gets the current class name
  20980. * @returns the class name
  20981. */
  20982. getClassName(): string;
  20983. /**
  20984. * Gets the uv input component
  20985. */
  20986. get uv(): NodeMaterialConnectionPoint;
  20987. /**
  20988. * Gets the rgba output component
  20989. */
  20990. get rgba(): NodeMaterialConnectionPoint;
  20991. /**
  20992. * Gets the rgb output component
  20993. */
  20994. get rgb(): NodeMaterialConnectionPoint;
  20995. /**
  20996. * Gets the r output component
  20997. */
  20998. get r(): NodeMaterialConnectionPoint;
  20999. /**
  21000. * Gets the g output component
  21001. */
  21002. get g(): NodeMaterialConnectionPoint;
  21003. /**
  21004. * Gets the b output component
  21005. */
  21006. get b(): NodeMaterialConnectionPoint;
  21007. /**
  21008. * Gets the a output component
  21009. */
  21010. get a(): NodeMaterialConnectionPoint;
  21011. /**
  21012. * Initialize the block and prepare the context for build
  21013. * @param state defines the state that will be used for the build
  21014. */
  21015. initialize(state: NodeMaterialBuildState): void;
  21016. get target(): NodeMaterialBlockTargets;
  21017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21018. isReady(): boolean;
  21019. private _injectVertexCode;
  21020. private _writeTextureRead;
  21021. private _writeOutput;
  21022. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21023. serialize(): any;
  21024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21025. }
  21026. }
  21027. declare module BABYLON {
  21028. /**
  21029. * Base block used for the particle texture
  21030. */
  21031. export class ParticleTextureBlock extends NodeMaterialBlock {
  21032. private _samplerName;
  21033. private _linearDefineName;
  21034. private _gammaDefineName;
  21035. private _tempTextureRead;
  21036. /**
  21037. * Gets or sets the texture associated with the node
  21038. */
  21039. texture: Nullable<BaseTexture>;
  21040. /**
  21041. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21042. */
  21043. convertToGammaSpace: boolean;
  21044. /**
  21045. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21046. */
  21047. convertToLinearSpace: boolean;
  21048. /**
  21049. * Create a new ParticleTextureBlock
  21050. * @param name defines the block name
  21051. */
  21052. constructor(name: string);
  21053. /**
  21054. * Gets the current class name
  21055. * @returns the class name
  21056. */
  21057. getClassName(): string;
  21058. /**
  21059. * Gets the uv input component
  21060. */
  21061. get uv(): NodeMaterialConnectionPoint;
  21062. /**
  21063. * Gets the rgba output component
  21064. */
  21065. get rgba(): NodeMaterialConnectionPoint;
  21066. /**
  21067. * Gets the rgb output component
  21068. */
  21069. get rgb(): NodeMaterialConnectionPoint;
  21070. /**
  21071. * Gets the r output component
  21072. */
  21073. get r(): NodeMaterialConnectionPoint;
  21074. /**
  21075. * Gets the g output component
  21076. */
  21077. get g(): NodeMaterialConnectionPoint;
  21078. /**
  21079. * Gets the b output component
  21080. */
  21081. get b(): NodeMaterialConnectionPoint;
  21082. /**
  21083. * Gets the a output component
  21084. */
  21085. get a(): NodeMaterialConnectionPoint;
  21086. /**
  21087. * Initialize the block and prepare the context for build
  21088. * @param state defines the state that will be used for the build
  21089. */
  21090. initialize(state: NodeMaterialBuildState): void;
  21091. autoConfigure(material: NodeMaterial): void;
  21092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21093. isReady(): boolean;
  21094. private _writeOutput;
  21095. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21096. serialize(): any;
  21097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21098. }
  21099. }
  21100. declare module BABYLON {
  21101. /**
  21102. * Class used to store shared data between 2 NodeMaterialBuildState
  21103. */
  21104. export class NodeMaterialBuildStateSharedData {
  21105. /**
  21106. * Gets the list of emitted varyings
  21107. */
  21108. temps: string[];
  21109. /**
  21110. * Gets the list of emitted varyings
  21111. */
  21112. varyings: string[];
  21113. /**
  21114. * Gets the varying declaration string
  21115. */
  21116. varyingDeclaration: string;
  21117. /**
  21118. * Input blocks
  21119. */
  21120. inputBlocks: InputBlock[];
  21121. /**
  21122. * Input blocks
  21123. */
  21124. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21125. /**
  21126. * Bindable blocks (Blocks that need to set data to the effect)
  21127. */
  21128. bindableBlocks: NodeMaterialBlock[];
  21129. /**
  21130. * List of blocks that can provide a compilation fallback
  21131. */
  21132. blocksWithFallbacks: NodeMaterialBlock[];
  21133. /**
  21134. * List of blocks that can provide a define update
  21135. */
  21136. blocksWithDefines: NodeMaterialBlock[];
  21137. /**
  21138. * List of blocks that can provide a repeatable content
  21139. */
  21140. repeatableContentBlocks: NodeMaterialBlock[];
  21141. /**
  21142. * List of blocks that can provide a dynamic list of uniforms
  21143. */
  21144. dynamicUniformBlocks: NodeMaterialBlock[];
  21145. /**
  21146. * List of blocks that can block the isReady function for the material
  21147. */
  21148. blockingBlocks: NodeMaterialBlock[];
  21149. /**
  21150. * Gets the list of animated inputs
  21151. */
  21152. animatedInputs: InputBlock[];
  21153. /**
  21154. * Build Id used to avoid multiple recompilations
  21155. */
  21156. buildId: number;
  21157. /** List of emitted variables */
  21158. variableNames: {
  21159. [key: string]: number;
  21160. };
  21161. /** List of emitted defines */
  21162. defineNames: {
  21163. [key: string]: number;
  21164. };
  21165. /** Should emit comments? */
  21166. emitComments: boolean;
  21167. /** Emit build activity */
  21168. verbose: boolean;
  21169. /** Gets or sets the hosting scene */
  21170. scene: Scene;
  21171. /**
  21172. * Gets the compilation hints emitted at compilation time
  21173. */
  21174. hints: {
  21175. needWorldViewMatrix: boolean;
  21176. needWorldViewProjectionMatrix: boolean;
  21177. needAlphaBlending: boolean;
  21178. needAlphaTesting: boolean;
  21179. };
  21180. /**
  21181. * List of compilation checks
  21182. */
  21183. checks: {
  21184. emitVertex: boolean;
  21185. emitFragment: boolean;
  21186. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21187. };
  21188. /**
  21189. * Is vertex program allowed to be empty?
  21190. */
  21191. allowEmptyVertexProgram: boolean;
  21192. /** Creates a new shared data */
  21193. constructor();
  21194. /**
  21195. * Emits console errors and exceptions if there is a failing check
  21196. */
  21197. emitErrors(): void;
  21198. }
  21199. }
  21200. declare module BABYLON {
  21201. /**
  21202. * Class used to store node based material build state
  21203. */
  21204. export class NodeMaterialBuildState {
  21205. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21206. supportUniformBuffers: boolean;
  21207. /**
  21208. * Gets the list of emitted attributes
  21209. */
  21210. attributes: string[];
  21211. /**
  21212. * Gets the list of emitted uniforms
  21213. */
  21214. uniforms: string[];
  21215. /**
  21216. * Gets the list of emitted constants
  21217. */
  21218. constants: string[];
  21219. /**
  21220. * Gets the list of emitted samplers
  21221. */
  21222. samplers: string[];
  21223. /**
  21224. * Gets the list of emitted functions
  21225. */
  21226. functions: {
  21227. [key: string]: string;
  21228. };
  21229. /**
  21230. * Gets the list of emitted extensions
  21231. */
  21232. extensions: {
  21233. [key: string]: string;
  21234. };
  21235. /**
  21236. * Gets the target of the compilation state
  21237. */
  21238. target: NodeMaterialBlockTargets;
  21239. /**
  21240. * Gets the list of emitted counters
  21241. */
  21242. counters: {
  21243. [key: string]: number;
  21244. };
  21245. /**
  21246. * Shared data between multiple NodeMaterialBuildState instances
  21247. */
  21248. sharedData: NodeMaterialBuildStateSharedData;
  21249. /** @hidden */
  21250. _vertexState: NodeMaterialBuildState;
  21251. /** @hidden */
  21252. _attributeDeclaration: string;
  21253. /** @hidden */
  21254. _uniformDeclaration: string;
  21255. /** @hidden */
  21256. _constantDeclaration: string;
  21257. /** @hidden */
  21258. _samplerDeclaration: string;
  21259. /** @hidden */
  21260. _varyingTransfer: string;
  21261. /** @hidden */
  21262. _injectAtEnd: string;
  21263. private _repeatableContentAnchorIndex;
  21264. /** @hidden */
  21265. _builtCompilationString: string;
  21266. /**
  21267. * Gets the emitted compilation strings
  21268. */
  21269. compilationString: string;
  21270. /**
  21271. * Finalize the compilation strings
  21272. * @param state defines the current compilation state
  21273. */
  21274. finalize(state: NodeMaterialBuildState): void;
  21275. /** @hidden */
  21276. get _repeatableContentAnchor(): string;
  21277. /** @hidden */
  21278. _getFreeVariableName(prefix: string): string;
  21279. /** @hidden */
  21280. _getFreeDefineName(prefix: string): string;
  21281. /** @hidden */
  21282. _excludeVariableName(name: string): void;
  21283. /** @hidden */
  21284. _emit2DSampler(name: string): void;
  21285. /** @hidden */
  21286. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21287. /** @hidden */
  21288. _emitExtension(name: string, extension: string, define?: string): void;
  21289. /** @hidden */
  21290. _emitFunction(name: string, code: string, comments: string): void;
  21291. /** @hidden */
  21292. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21293. replaceStrings?: {
  21294. search: RegExp;
  21295. replace: string;
  21296. }[];
  21297. repeatKey?: string;
  21298. }): string;
  21299. /** @hidden */
  21300. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21301. repeatKey?: string;
  21302. removeAttributes?: boolean;
  21303. removeUniforms?: boolean;
  21304. removeVaryings?: boolean;
  21305. removeIfDef?: boolean;
  21306. replaceStrings?: {
  21307. search: RegExp;
  21308. replace: string;
  21309. }[];
  21310. }, storeKey?: string): void;
  21311. /** @hidden */
  21312. _registerTempVariable(name: string): boolean;
  21313. /** @hidden */
  21314. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21315. /** @hidden */
  21316. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21317. /** @hidden */
  21318. _emitFloat(value: number): string;
  21319. }
  21320. }
  21321. declare module BABYLON {
  21322. /**
  21323. * Helper class used to generate session unique ID
  21324. */
  21325. export class UniqueIdGenerator {
  21326. private static _UniqueIdCounter;
  21327. /**
  21328. * Gets an unique (relatively to the current scene) Id
  21329. */
  21330. static get UniqueId(): number;
  21331. }
  21332. }
  21333. declare module BABYLON {
  21334. /**
  21335. * Defines a block that can be used inside a node based material
  21336. */
  21337. export class NodeMaterialBlock {
  21338. private _buildId;
  21339. private _buildTarget;
  21340. private _target;
  21341. private _isFinalMerger;
  21342. private _isInput;
  21343. protected _isUnique: boolean;
  21344. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21345. inputsAreExclusive: boolean;
  21346. /** @hidden */
  21347. _codeVariableName: string;
  21348. /** @hidden */
  21349. _inputs: NodeMaterialConnectionPoint[];
  21350. /** @hidden */
  21351. _outputs: NodeMaterialConnectionPoint[];
  21352. /** @hidden */
  21353. _preparationId: number;
  21354. /**
  21355. * Gets or sets the name of the block
  21356. */
  21357. name: string;
  21358. /**
  21359. * Gets or sets the unique id of the node
  21360. */
  21361. uniqueId: number;
  21362. /**
  21363. * Gets or sets the comments associated with this block
  21364. */
  21365. comments: string;
  21366. /**
  21367. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21368. */
  21369. get isUnique(): boolean;
  21370. /**
  21371. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21372. */
  21373. get isFinalMerger(): boolean;
  21374. /**
  21375. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21376. */
  21377. get isInput(): boolean;
  21378. /**
  21379. * Gets or sets the build Id
  21380. */
  21381. get buildId(): number;
  21382. set buildId(value: number);
  21383. /**
  21384. * Gets or sets the target of the block
  21385. */
  21386. get target(): NodeMaterialBlockTargets;
  21387. set target(value: NodeMaterialBlockTargets);
  21388. /**
  21389. * Gets the list of input points
  21390. */
  21391. get inputs(): NodeMaterialConnectionPoint[];
  21392. /** Gets the list of output points */
  21393. get outputs(): NodeMaterialConnectionPoint[];
  21394. /**
  21395. * Find an input by its name
  21396. * @param name defines the name of the input to look for
  21397. * @returns the input or null if not found
  21398. */
  21399. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21400. /**
  21401. * Find an output by its name
  21402. * @param name defines the name of the outputto look for
  21403. * @returns the output or null if not found
  21404. */
  21405. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21406. /**
  21407. * Creates a new NodeMaterialBlock
  21408. * @param name defines the block name
  21409. * @param target defines the target of that block (Vertex by default)
  21410. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21411. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21412. */
  21413. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21414. /**
  21415. * Initialize the block and prepare the context for build
  21416. * @param state defines the state that will be used for the build
  21417. */
  21418. initialize(state: NodeMaterialBuildState): void;
  21419. /**
  21420. * Bind data to effect. Will only be called for blocks with isBindable === true
  21421. * @param effect defines the effect to bind data to
  21422. * @param nodeMaterial defines the hosting NodeMaterial
  21423. * @param mesh defines the mesh that will be rendered
  21424. * @param subMesh defines the submesh that will be rendered
  21425. */
  21426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21427. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21428. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21429. protected _writeFloat(value: number): string;
  21430. /**
  21431. * Gets the current class name e.g. "NodeMaterialBlock"
  21432. * @returns the class name
  21433. */
  21434. getClassName(): string;
  21435. /**
  21436. * Register a new input. Must be called inside a block constructor
  21437. * @param name defines the connection point name
  21438. * @param type defines the connection point type
  21439. * @param isOptional defines a boolean indicating that this input can be omitted
  21440. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21441. * @param point an already created connection point. If not provided, create a new one
  21442. * @returns the current block
  21443. */
  21444. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21445. /**
  21446. * Register a new output. Must be called inside a block constructor
  21447. * @param name defines the connection point name
  21448. * @param type defines the connection point type
  21449. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21450. * @param point an already created connection point. If not provided, create a new one
  21451. * @returns the current block
  21452. */
  21453. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21454. /**
  21455. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21456. * @param forOutput defines an optional connection point to check compatibility with
  21457. * @returns the first available input or null
  21458. */
  21459. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21460. /**
  21461. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21462. * @param forBlock defines an optional block to check compatibility with
  21463. * @returns the first available input or null
  21464. */
  21465. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21466. /**
  21467. * Gets the sibling of the given output
  21468. * @param current defines the current output
  21469. * @returns the next output in the list or null
  21470. */
  21471. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21472. /**
  21473. * Connect current block with another block
  21474. * @param other defines the block to connect with
  21475. * @param options define the various options to help pick the right connections
  21476. * @returns the current block
  21477. */
  21478. connectTo(other: NodeMaterialBlock, options?: {
  21479. input?: string;
  21480. output?: string;
  21481. outputSwizzle?: string;
  21482. }): this | undefined;
  21483. protected _buildBlock(state: NodeMaterialBuildState): void;
  21484. /**
  21485. * Add uniforms, samplers and uniform buffers at compilation time
  21486. * @param state defines the state to update
  21487. * @param nodeMaterial defines the node material requesting the update
  21488. * @param defines defines the material defines to update
  21489. * @param uniformBuffers defines the list of uniform buffer names
  21490. */
  21491. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21492. /**
  21493. * Add potential fallbacks if shader compilation fails
  21494. * @param mesh defines the mesh to be rendered
  21495. * @param fallbacks defines the current prioritized list of fallbacks
  21496. */
  21497. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21498. /**
  21499. * Initialize defines for shader compilation
  21500. * @param mesh defines the mesh to be rendered
  21501. * @param nodeMaterial defines the node material requesting the update
  21502. * @param defines defines the material defines to update
  21503. * @param useInstances specifies that instances should be used
  21504. */
  21505. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21506. /**
  21507. * Update defines for shader compilation
  21508. * @param mesh defines the mesh to be rendered
  21509. * @param nodeMaterial defines the node material requesting the update
  21510. * @param defines defines the material defines to update
  21511. * @param useInstances specifies that instances should be used
  21512. * @param subMesh defines which submesh to render
  21513. */
  21514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21515. /**
  21516. * Lets the block try to connect some inputs automatically
  21517. * @param material defines the hosting NodeMaterial
  21518. */
  21519. autoConfigure(material: NodeMaterial): void;
  21520. /**
  21521. * Function called when a block is declared as repeatable content generator
  21522. * @param vertexShaderState defines the current compilation state for the vertex shader
  21523. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21524. * @param mesh defines the mesh to be rendered
  21525. * @param defines defines the material defines to update
  21526. */
  21527. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21528. /**
  21529. * Checks if the block is ready
  21530. * @param mesh defines the mesh to be rendered
  21531. * @param nodeMaterial defines the node material requesting the update
  21532. * @param defines defines the material defines to update
  21533. * @param useInstances specifies that instances should be used
  21534. * @returns true if the block is ready
  21535. */
  21536. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21537. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21538. private _processBuild;
  21539. /**
  21540. * Compile the current node and generate the shader code
  21541. * @param state defines the current compilation state (uniforms, samplers, current string)
  21542. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21543. * @returns true if already built
  21544. */
  21545. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21546. protected _inputRename(name: string): string;
  21547. protected _outputRename(name: string): string;
  21548. protected _dumpPropertiesCode(): string;
  21549. /** @hidden */
  21550. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21551. /** @hidden */
  21552. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21553. /**
  21554. * Clone the current block to a new identical block
  21555. * @param scene defines the hosting scene
  21556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21557. * @returns a copy of the current block
  21558. */
  21559. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21560. /**
  21561. * Serializes this block in a JSON representation
  21562. * @returns the serialized block object
  21563. */
  21564. serialize(): any;
  21565. /** @hidden */
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. private _deserializePortDisplayNames;
  21568. /**
  21569. * Release resources
  21570. */
  21571. dispose(): void;
  21572. }
  21573. }
  21574. declare module BABYLON {
  21575. /**
  21576. * Base class of materials working in push mode in babylon JS
  21577. * @hidden
  21578. */
  21579. export class PushMaterial extends Material {
  21580. protected _activeEffect: Effect;
  21581. protected _normalMatrix: Matrix;
  21582. constructor(name: string, scene: Scene);
  21583. getEffect(): Effect;
  21584. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21585. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21586. /**
  21587. * Binds the given world matrix to the active effect
  21588. *
  21589. * @param world the matrix to bind
  21590. */
  21591. bindOnlyWorldMatrix(world: Matrix): void;
  21592. /**
  21593. * Binds the given normal matrix to the active effect
  21594. *
  21595. * @param normalMatrix the matrix to bind
  21596. */
  21597. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21598. bind(world: Matrix, mesh?: Mesh): void;
  21599. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21600. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21601. }
  21602. }
  21603. declare module BABYLON {
  21604. /**
  21605. * Root class for all node material optimizers
  21606. */
  21607. export class NodeMaterialOptimizer {
  21608. /**
  21609. * Function used to optimize a NodeMaterial graph
  21610. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21611. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21612. */
  21613. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21614. }
  21615. }
  21616. declare module BABYLON {
  21617. /**
  21618. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21619. */
  21620. export class TransformBlock extends NodeMaterialBlock {
  21621. /**
  21622. * Defines the value to use to complement W value to transform it to a Vector4
  21623. */
  21624. complementW: number;
  21625. /**
  21626. * Defines the value to use to complement z value to transform it to a Vector4
  21627. */
  21628. complementZ: number;
  21629. /**
  21630. * Creates a new TransformBlock
  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
  21641. */
  21642. get vector(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the output component
  21645. */
  21646. get output(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the xyz output component
  21649. */
  21650. get xyz(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the matrix transform input
  21653. */
  21654. get transform(): NodeMaterialConnectionPoint;
  21655. protected _buildBlock(state: NodeMaterialBuildState): this;
  21656. /**
  21657. * Update defines for shader compilation
  21658. * @param mesh defines the mesh to be rendered
  21659. * @param nodeMaterial defines the node material requesting the update
  21660. * @param defines defines the material defines to update
  21661. * @param useInstances specifies that instances should be used
  21662. * @param subMesh defines which submesh to render
  21663. */
  21664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21665. serialize(): any;
  21666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21667. protected _dumpPropertiesCode(): string;
  21668. }
  21669. }
  21670. declare module BABYLON {
  21671. /**
  21672. * Block used to output the vertex position
  21673. */
  21674. export class VertexOutputBlock extends NodeMaterialBlock {
  21675. /**
  21676. * Creates a new VertexOutputBlock
  21677. * @param name defines the block name
  21678. */
  21679. constructor(name: string);
  21680. /**
  21681. * Gets the current class name
  21682. * @returns the class name
  21683. */
  21684. getClassName(): string;
  21685. /**
  21686. * Gets the vector input component
  21687. */
  21688. get vector(): NodeMaterialConnectionPoint;
  21689. protected _buildBlock(state: NodeMaterialBuildState): this;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. /**
  21694. * Block used to output the final color
  21695. */
  21696. export class FragmentOutputBlock extends NodeMaterialBlock {
  21697. /**
  21698. * Create a new FragmentOutputBlock
  21699. * @param name defines the block name
  21700. */
  21701. constructor(name: string);
  21702. /**
  21703. * Gets the current class name
  21704. * @returns the class name
  21705. */
  21706. getClassName(): string;
  21707. /**
  21708. * Gets the rgba input component
  21709. */
  21710. get rgba(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the rgb input component
  21713. */
  21714. get rgb(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the a input component
  21717. */
  21718. get a(): NodeMaterialConnectionPoint;
  21719. protected _buildBlock(state: NodeMaterialBuildState): this;
  21720. }
  21721. }
  21722. declare module BABYLON {
  21723. /**
  21724. * Block used for the particle ramp gradient section
  21725. */
  21726. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21727. /**
  21728. * Create a new ParticleRampGradientBlock
  21729. * @param name defines the block name
  21730. */
  21731. constructor(name: string);
  21732. /**
  21733. * Gets the current class name
  21734. * @returns the class name
  21735. */
  21736. getClassName(): string;
  21737. /**
  21738. * Gets the color input component
  21739. */
  21740. get color(): NodeMaterialConnectionPoint;
  21741. /**
  21742. * Gets the rampColor output component
  21743. */
  21744. get rampColor(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Initialize the block and prepare the context for build
  21747. * @param state defines the state that will be used for the build
  21748. */
  21749. initialize(state: NodeMaterialBuildState): void;
  21750. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21751. }
  21752. }
  21753. declare module BABYLON {
  21754. /**
  21755. * Block used for the particle blend multiply section
  21756. */
  21757. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21758. /**
  21759. * Create a new ParticleBlendMultiplyBlock
  21760. * @param name defines the block name
  21761. */
  21762. constructor(name: string);
  21763. /**
  21764. * Gets the current class name
  21765. * @returns the class name
  21766. */
  21767. getClassName(): string;
  21768. /**
  21769. * Gets the color input component
  21770. */
  21771. get color(): NodeMaterialConnectionPoint;
  21772. /**
  21773. * Gets the alphaTexture input component
  21774. */
  21775. get alphaTexture(): NodeMaterialConnectionPoint;
  21776. /**
  21777. * Gets the alphaColor input component
  21778. */
  21779. get alphaColor(): NodeMaterialConnectionPoint;
  21780. /**
  21781. * Gets the blendColor output component
  21782. */
  21783. get blendColor(): NodeMaterialConnectionPoint;
  21784. /**
  21785. * Initialize the block and prepare the context for build
  21786. * @param state defines the state that will be used for the build
  21787. */
  21788. initialize(state: NodeMaterialBuildState): void;
  21789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21790. }
  21791. }
  21792. declare module BABYLON {
  21793. /**
  21794. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21795. */
  21796. export class VectorMergerBlock extends NodeMaterialBlock {
  21797. /**
  21798. * Create a new VectorMergerBlock
  21799. * @param name defines the block name
  21800. */
  21801. constructor(name: string);
  21802. /**
  21803. * Gets the current class name
  21804. * @returns the class name
  21805. */
  21806. getClassName(): string;
  21807. /**
  21808. * Gets the xyz component (input)
  21809. */
  21810. get xyzIn(): NodeMaterialConnectionPoint;
  21811. /**
  21812. * Gets the xy component (input)
  21813. */
  21814. get xyIn(): NodeMaterialConnectionPoint;
  21815. /**
  21816. * Gets the x component (input)
  21817. */
  21818. get x(): NodeMaterialConnectionPoint;
  21819. /**
  21820. * Gets the y component (input)
  21821. */
  21822. get y(): NodeMaterialConnectionPoint;
  21823. /**
  21824. * Gets the z component (input)
  21825. */
  21826. get z(): NodeMaterialConnectionPoint;
  21827. /**
  21828. * Gets the w component (input)
  21829. */
  21830. get w(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the xyzw component (output)
  21833. */
  21834. get xyzw(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the xyz component (output)
  21837. */
  21838. get xyzOut(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the xy component (output)
  21841. */
  21842. get xyOut(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the xy component (output)
  21845. * @deprecated Please use xyOut instead.
  21846. */
  21847. get xy(): NodeMaterialConnectionPoint;
  21848. /**
  21849. * Gets the xyz component (output)
  21850. * @deprecated Please use xyzOut instead.
  21851. */
  21852. get xyz(): NodeMaterialConnectionPoint;
  21853. protected _buildBlock(state: NodeMaterialBuildState): this;
  21854. }
  21855. }
  21856. declare module BABYLON {
  21857. /**
  21858. * Block used to remap a float from a range to a new one
  21859. */
  21860. export class RemapBlock extends NodeMaterialBlock {
  21861. /**
  21862. * Gets or sets the source range
  21863. */
  21864. sourceRange: Vector2;
  21865. /**
  21866. * Gets or sets the target range
  21867. */
  21868. targetRange: Vector2;
  21869. /**
  21870. * Creates a new RemapBlock
  21871. * @param name defines the block name
  21872. */
  21873. constructor(name: string);
  21874. /**
  21875. * Gets the current class name
  21876. * @returns the class name
  21877. */
  21878. getClassName(): string;
  21879. /**
  21880. * Gets the input component
  21881. */
  21882. get input(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the source min input component
  21885. */
  21886. get sourceMin(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Gets the source max input component
  21889. */
  21890. get sourceMax(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the target min input component
  21893. */
  21894. get targetMin(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the target max input component
  21897. */
  21898. get targetMax(): NodeMaterialConnectionPoint;
  21899. /**
  21900. * Gets the output component
  21901. */
  21902. get output(): NodeMaterialConnectionPoint;
  21903. protected _buildBlock(state: NodeMaterialBuildState): this;
  21904. protected _dumpPropertiesCode(): string;
  21905. serialize(): any;
  21906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21907. }
  21908. }
  21909. declare module BABYLON {
  21910. /**
  21911. * Block used to multiply 2 values
  21912. */
  21913. export class MultiplyBlock extends NodeMaterialBlock {
  21914. /**
  21915. * Creates a new MultiplyBlock
  21916. * @param name defines the block name
  21917. */
  21918. constructor(name: string);
  21919. /**
  21920. * Gets the current class name
  21921. * @returns the class name
  21922. */
  21923. getClassName(): string;
  21924. /**
  21925. * Gets the left operand input component
  21926. */
  21927. get left(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the right operand input component
  21930. */
  21931. get right(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the output component
  21934. */
  21935. get output(): NodeMaterialConnectionPoint;
  21936. protected _buildBlock(state: NodeMaterialBuildState): this;
  21937. }
  21938. }
  21939. declare module BABYLON {
  21940. /**
  21941. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21942. */
  21943. export class ColorSplitterBlock extends NodeMaterialBlock {
  21944. /**
  21945. * Create a new ColorSplitterBlock
  21946. * @param name defines the block name
  21947. */
  21948. constructor(name: string);
  21949. /**
  21950. * Gets the current class name
  21951. * @returns the class name
  21952. */
  21953. getClassName(): string;
  21954. /**
  21955. * Gets the rgba component (input)
  21956. */
  21957. get rgba(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the rgb component (input)
  21960. */
  21961. get rgbIn(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the rgb component (output)
  21964. */
  21965. get rgbOut(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the r component (output)
  21968. */
  21969. get r(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the g component (output)
  21972. */
  21973. get g(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the b component (output)
  21976. */
  21977. get b(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the a component (output)
  21980. */
  21981. get a(): NodeMaterialConnectionPoint;
  21982. protected _inputRename(name: string): string;
  21983. protected _outputRename(name: string): string;
  21984. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21985. }
  21986. }
  21987. declare module BABYLON {
  21988. /**
  21989. * Interface used to configure the node material editor
  21990. */
  21991. export interface INodeMaterialEditorOptions {
  21992. /** Define the URl to load node editor script */
  21993. editorURL?: string;
  21994. }
  21995. /** @hidden */
  21996. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21997. NORMAL: boolean;
  21998. TANGENT: boolean;
  21999. UV1: boolean;
  22000. /** BONES */
  22001. NUM_BONE_INFLUENCERS: number;
  22002. BonesPerMesh: number;
  22003. BONETEXTURE: boolean;
  22004. /** MORPH TARGETS */
  22005. MORPHTARGETS: boolean;
  22006. MORPHTARGETS_NORMAL: boolean;
  22007. MORPHTARGETS_TANGENT: boolean;
  22008. MORPHTARGETS_UV: boolean;
  22009. NUM_MORPH_INFLUENCERS: number;
  22010. /** IMAGE PROCESSING */
  22011. IMAGEPROCESSING: boolean;
  22012. VIGNETTE: boolean;
  22013. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22014. VIGNETTEBLENDMODEOPAQUE: boolean;
  22015. TONEMAPPING: boolean;
  22016. TONEMAPPING_ACES: boolean;
  22017. CONTRAST: boolean;
  22018. EXPOSURE: boolean;
  22019. COLORCURVES: boolean;
  22020. COLORGRADING: boolean;
  22021. COLORGRADING3D: boolean;
  22022. SAMPLER3DGREENDEPTH: boolean;
  22023. SAMPLER3DBGRMAP: boolean;
  22024. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22025. /** MISC. */
  22026. BUMPDIRECTUV: number;
  22027. constructor();
  22028. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22029. }
  22030. /**
  22031. * Class used to configure NodeMaterial
  22032. */
  22033. export interface INodeMaterialOptions {
  22034. /**
  22035. * Defines if blocks should emit comments
  22036. */
  22037. emitComments: boolean;
  22038. }
  22039. /**
  22040. * Class used to create a node based material built by assembling shader blocks
  22041. */
  22042. export class NodeMaterial extends PushMaterial {
  22043. private static _BuildIdGenerator;
  22044. private _options;
  22045. private _vertexCompilationState;
  22046. private _fragmentCompilationState;
  22047. private _sharedData;
  22048. private _buildId;
  22049. private _buildWasSuccessful;
  22050. private _cachedWorldViewMatrix;
  22051. private _cachedWorldViewProjectionMatrix;
  22052. private _optimizers;
  22053. private _animationFrame;
  22054. /** Define the Url to load node editor script */
  22055. static EditorURL: string;
  22056. /** Define the Url to load snippets */
  22057. static SnippetUrl: string;
  22058. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22059. static IgnoreTexturesAtLoadTime: boolean;
  22060. private BJSNODEMATERIALEDITOR;
  22061. /** Get the inspector from bundle or global */
  22062. private _getGlobalNodeMaterialEditor;
  22063. /**
  22064. * Snippet ID if the material was created from the snippet server
  22065. */
  22066. snippetId: string;
  22067. /**
  22068. * Gets or sets data used by visual editor
  22069. * @see https://nme.babylonjs.com
  22070. */
  22071. editorData: any;
  22072. /**
  22073. * 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)
  22074. */
  22075. ignoreAlpha: boolean;
  22076. /**
  22077. * Defines the maximum number of lights that can be used in the material
  22078. */
  22079. maxSimultaneousLights: number;
  22080. /**
  22081. * Observable raised when the material is built
  22082. */
  22083. onBuildObservable: Observable<NodeMaterial>;
  22084. /**
  22085. * Gets or sets the root nodes of the material vertex shader
  22086. */
  22087. _vertexOutputNodes: NodeMaterialBlock[];
  22088. /**
  22089. * Gets or sets the root nodes of the material fragment (pixel) shader
  22090. */
  22091. _fragmentOutputNodes: NodeMaterialBlock[];
  22092. /** Gets or sets options to control the node material overall behavior */
  22093. get options(): INodeMaterialOptions;
  22094. set options(options: INodeMaterialOptions);
  22095. /**
  22096. * Default configuration related to image processing available in the standard Material.
  22097. */
  22098. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22099. /**
  22100. * Gets the image processing configuration used either in this material.
  22101. */
  22102. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22103. /**
  22104. * Sets the Default image processing configuration used either in the this material.
  22105. *
  22106. * If sets to null, the scene one is in use.
  22107. */
  22108. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22109. /**
  22110. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22111. */
  22112. attachedBlocks: NodeMaterialBlock[];
  22113. /**
  22114. * Specifies the mode of the node material
  22115. * @hidden
  22116. */
  22117. _mode: NodeMaterialModes;
  22118. /**
  22119. * Gets the mode property
  22120. */
  22121. get mode(): NodeMaterialModes;
  22122. /**
  22123. * Create a new node based material
  22124. * @param name defines the material name
  22125. * @param scene defines the hosting scene
  22126. * @param options defines creation option
  22127. */
  22128. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22129. /**
  22130. * Gets the current class name of the material e.g. "NodeMaterial"
  22131. * @returns the class name
  22132. */
  22133. getClassName(): string;
  22134. /**
  22135. * Keep track of the image processing observer to allow dispose and replace.
  22136. */
  22137. private _imageProcessingObserver;
  22138. /**
  22139. * Attaches a new image processing configuration to the Standard Material.
  22140. * @param configuration
  22141. */
  22142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22143. /**
  22144. * Get a block by its name
  22145. * @param name defines the name of the block to retrieve
  22146. * @returns the required block or null if not found
  22147. */
  22148. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22149. /**
  22150. * Get a block by its name
  22151. * @param predicate defines the predicate used to find the good candidate
  22152. * @returns the required block or null if not found
  22153. */
  22154. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22155. /**
  22156. * Get an input block by its name
  22157. * @param predicate defines the predicate used to find the good candidate
  22158. * @returns the required input block or null if not found
  22159. */
  22160. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22161. /**
  22162. * Gets the list of input blocks attached to this material
  22163. * @returns an array of InputBlocks
  22164. */
  22165. getInputBlocks(): InputBlock[];
  22166. /**
  22167. * Adds a new optimizer to the list of optimizers
  22168. * @param optimizer defines the optimizers to add
  22169. * @returns the current material
  22170. */
  22171. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22172. /**
  22173. * Remove an optimizer from the list of optimizers
  22174. * @param optimizer defines the optimizers to remove
  22175. * @returns the current material
  22176. */
  22177. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22178. /**
  22179. * Add a new block to the list of output nodes
  22180. * @param node defines the node to add
  22181. * @returns the current material
  22182. */
  22183. addOutputNode(node: NodeMaterialBlock): this;
  22184. /**
  22185. * Remove a block from the list of root nodes
  22186. * @param node defines the node to remove
  22187. * @returns the current material
  22188. */
  22189. removeOutputNode(node: NodeMaterialBlock): this;
  22190. private _addVertexOutputNode;
  22191. private _removeVertexOutputNode;
  22192. private _addFragmentOutputNode;
  22193. private _removeFragmentOutputNode;
  22194. /**
  22195. * Specifies if the material will require alpha blending
  22196. * @returns a boolean specifying if alpha blending is needed
  22197. */
  22198. needAlphaBlending(): boolean;
  22199. /**
  22200. * Specifies if this material should be rendered in alpha test mode
  22201. * @returns a boolean specifying if an alpha test is needed.
  22202. */
  22203. needAlphaTesting(): boolean;
  22204. private _initializeBlock;
  22205. private _resetDualBlocks;
  22206. /**
  22207. * Remove a block from the current node material
  22208. * @param block defines the block to remove
  22209. */
  22210. removeBlock(block: NodeMaterialBlock): void;
  22211. /**
  22212. * Build the material and generates the inner effect
  22213. * @param verbose defines if the build should log activity
  22214. */
  22215. build(verbose?: boolean): void;
  22216. /**
  22217. * Runs an otpimization phase to try to improve the shader code
  22218. */
  22219. optimize(): void;
  22220. private _prepareDefinesForAttributes;
  22221. /**
  22222. * Create a post process from the material
  22223. * @param camera The camera to apply the render pass to.
  22224. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22226. * @param engine The engine which the post process will be applied. (default: current engine)
  22227. * @param reusable If the post process can be reused on the same frame. (default: false)
  22228. * @param textureType Type of textures used when performing the post process. (default: 0)
  22229. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22230. * @returns the post process created
  22231. */
  22232. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22233. /**
  22234. * Create the post process effect from the material
  22235. * @param postProcess The post process to create the effect for
  22236. */
  22237. createEffectForPostProcess(postProcess: PostProcess): void;
  22238. private _createEffectOrPostProcess;
  22239. private _createEffectForParticles;
  22240. /**
  22241. * Create the effect to be used as the custom effect for a particle system
  22242. * @param particleSystem Particle system to create the effect for
  22243. * @param onCompiled defines a function to call when the effect creation is successful
  22244. * @param onError defines a function to call when the effect creation has failed
  22245. */
  22246. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22247. private _processDefines;
  22248. /**
  22249. * Get if the submesh is ready to be used and all its information available.
  22250. * Child classes can use it to update shaders
  22251. * @param mesh defines the mesh to check
  22252. * @param subMesh defines which submesh to check
  22253. * @param useInstances specifies that instances should be used
  22254. * @returns a boolean indicating that the submesh is ready or not
  22255. */
  22256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22257. /**
  22258. * Get a string representing the shaders built by the current node graph
  22259. */
  22260. get compiledShaders(): string;
  22261. /**
  22262. * Binds the world matrix to the material
  22263. * @param world defines the world transformation matrix
  22264. */
  22265. bindOnlyWorldMatrix(world: Matrix): void;
  22266. /**
  22267. * Binds the submesh to this material by preparing the effect and shader to draw
  22268. * @param world defines the world transformation matrix
  22269. * @param mesh defines the mesh containing the submesh
  22270. * @param subMesh defines the submesh to bind the material to
  22271. */
  22272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22273. /**
  22274. * Gets the active textures from the material
  22275. * @returns an array of textures
  22276. */
  22277. getActiveTextures(): BaseTexture[];
  22278. /**
  22279. * Gets the list of texture blocks
  22280. * @returns an array of texture blocks
  22281. */
  22282. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22283. /**
  22284. * Specifies if the material uses a texture
  22285. * @param texture defines the texture to check against the material
  22286. * @returns a boolean specifying if the material uses the texture
  22287. */
  22288. hasTexture(texture: BaseTexture): boolean;
  22289. /**
  22290. * Disposes the material
  22291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22293. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22294. */
  22295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22296. /** Creates the node editor window. */
  22297. private _createNodeEditor;
  22298. /**
  22299. * Launch the node material editor
  22300. * @param config Define the configuration of the editor
  22301. * @return a promise fulfilled when the node editor is visible
  22302. */
  22303. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22304. /**
  22305. * Clear the current material
  22306. */
  22307. clear(): void;
  22308. /**
  22309. * Clear the current material and set it to a default state
  22310. */
  22311. setToDefault(): void;
  22312. /**
  22313. * Clear the current material and set it to a default state for post process
  22314. */
  22315. setToDefaultPostProcess(): void;
  22316. /**
  22317. * Clear the current material and set it to a default state for particle
  22318. */
  22319. setToDefaultParticle(): void;
  22320. /**
  22321. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22322. * @param url defines the url to load from
  22323. * @returns a promise that will fullfil when the material is fully loaded
  22324. */
  22325. loadAsync(url: string): Promise<void>;
  22326. private _gatherBlocks;
  22327. /**
  22328. * Generate a string containing the code declaration required to create an equivalent of this material
  22329. * @returns a string
  22330. */
  22331. generateCode(): string;
  22332. /**
  22333. * Serializes this material in a JSON representation
  22334. * @returns the serialized material object
  22335. */
  22336. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22337. private _restoreConnections;
  22338. /**
  22339. * Clear the current graph and load a new one from a serialization object
  22340. * @param source defines the JSON representation of the material
  22341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22342. */
  22343. loadFromSerialization(source: any, rootUrl?: string): void;
  22344. /**
  22345. * Makes a duplicate of the current material.
  22346. * @param name - name to use for the new material.
  22347. */
  22348. clone(name: string): NodeMaterial;
  22349. /**
  22350. * Creates a node material from parsed material data
  22351. * @param source defines the JSON representation of the material
  22352. * @param scene defines the hosting scene
  22353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22354. * @returns a new node material
  22355. */
  22356. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22357. /**
  22358. * Creates a node material from a snippet saved in a remote file
  22359. * @param name defines the name of the material to create
  22360. * @param url defines the url to load from
  22361. * @param scene defines the hosting scene
  22362. * @returns a promise that will resolve to the new node material
  22363. */
  22364. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22365. /**
  22366. * Creates a node material from a snippet saved by the node material editor
  22367. * @param snippetId defines the snippet to load
  22368. * @param scene defines the hosting scene
  22369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22370. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22371. * @returns a promise that will resolve to the new node material
  22372. */
  22373. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22374. /**
  22375. * Creates a new node material set to default basic configuration
  22376. * @param name defines the name of the material
  22377. * @param scene defines the hosting scene
  22378. * @returns a new NodeMaterial
  22379. */
  22380. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22381. }
  22382. }
  22383. declare module BABYLON {
  22384. /**
  22385. * Size options for a post process
  22386. */
  22387. export type PostProcessOptions = {
  22388. width: number;
  22389. height: number;
  22390. };
  22391. /**
  22392. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22393. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22394. */
  22395. export class PostProcess {
  22396. /** Name of the PostProcess. */
  22397. name: string;
  22398. /**
  22399. * Gets or sets the unique id of the post process
  22400. */
  22401. uniqueId: number;
  22402. /**
  22403. * Width of the texture to apply the post process on
  22404. */
  22405. width: number;
  22406. /**
  22407. * Height of the texture to apply the post process on
  22408. */
  22409. height: number;
  22410. /**
  22411. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22412. */
  22413. nodeMaterialSource: Nullable<NodeMaterial>;
  22414. /**
  22415. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22416. * @hidden
  22417. */
  22418. _outputTexture: Nullable<InternalTexture>;
  22419. /**
  22420. * Sampling mode used by the shader
  22421. * See https://doc.babylonjs.com/classes/3.1/texture
  22422. */
  22423. renderTargetSamplingMode: number;
  22424. /**
  22425. * Clear color to use when screen clearing
  22426. */
  22427. clearColor: Color4;
  22428. /**
  22429. * If the buffer needs to be cleared before applying the post process. (default: true)
  22430. * Should be set to false if shader will overwrite all previous pixels.
  22431. */
  22432. autoClear: boolean;
  22433. /**
  22434. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22435. */
  22436. alphaMode: number;
  22437. /**
  22438. * Sets the setAlphaBlendConstants of the babylon engine
  22439. */
  22440. alphaConstants: Color4;
  22441. /**
  22442. * Animations to be used for the post processing
  22443. */
  22444. animations: Animation[];
  22445. /**
  22446. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22447. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22448. */
  22449. enablePixelPerfectMode: boolean;
  22450. /**
  22451. * Force the postprocess to be applied without taking in account viewport
  22452. */
  22453. forceFullscreenViewport: boolean;
  22454. /**
  22455. * List of inspectable custom properties (used by the Inspector)
  22456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22457. */
  22458. inspectableCustomProperties: IInspectable[];
  22459. /**
  22460. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22461. *
  22462. * | Value | Type | Description |
  22463. * | ----- | ----------------------------------- | ----------- |
  22464. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22465. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22466. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22467. *
  22468. */
  22469. scaleMode: number;
  22470. /**
  22471. * Force textures to be a power of two (default: false)
  22472. */
  22473. alwaysForcePOT: boolean;
  22474. private _samples;
  22475. /**
  22476. * Number of sample textures (default: 1)
  22477. */
  22478. get samples(): number;
  22479. set samples(n: number);
  22480. /**
  22481. * Modify the scale of the post process to be the same as the viewport (default: false)
  22482. */
  22483. adaptScaleToCurrentViewport: boolean;
  22484. private _camera;
  22485. private _scene;
  22486. private _engine;
  22487. private _options;
  22488. private _reusable;
  22489. private _textureType;
  22490. private _textureFormat;
  22491. /**
  22492. * Smart array of input and output textures for the post process.
  22493. * @hidden
  22494. */
  22495. _textures: SmartArray<InternalTexture>;
  22496. /**
  22497. * The index in _textures that corresponds to the output texture.
  22498. * @hidden
  22499. */
  22500. _currentRenderTextureInd: number;
  22501. private _effect;
  22502. private _samplers;
  22503. private _fragmentUrl;
  22504. private _vertexUrl;
  22505. private _parameters;
  22506. private _scaleRatio;
  22507. protected _indexParameters: any;
  22508. private _shareOutputWithPostProcess;
  22509. private _texelSize;
  22510. private _forcedOutputTexture;
  22511. /**
  22512. * Returns the fragment url or shader name used in the post process.
  22513. * @returns the fragment url or name in the shader store.
  22514. */
  22515. getEffectName(): string;
  22516. /**
  22517. * An event triggered when the postprocess is activated.
  22518. */
  22519. onActivateObservable: Observable<Camera>;
  22520. private _onActivateObserver;
  22521. /**
  22522. * A function that is added to the onActivateObservable
  22523. */
  22524. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22525. /**
  22526. * An event triggered when the postprocess changes its size.
  22527. */
  22528. onSizeChangedObservable: Observable<PostProcess>;
  22529. private _onSizeChangedObserver;
  22530. /**
  22531. * A function that is added to the onSizeChangedObservable
  22532. */
  22533. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22534. /**
  22535. * An event triggered when the postprocess applies its effect.
  22536. */
  22537. onApplyObservable: Observable<Effect>;
  22538. private _onApplyObserver;
  22539. /**
  22540. * A function that is added to the onApplyObservable
  22541. */
  22542. set onApply(callback: (effect: Effect) => void);
  22543. /**
  22544. * An event triggered before rendering the postprocess
  22545. */
  22546. onBeforeRenderObservable: Observable<Effect>;
  22547. private _onBeforeRenderObserver;
  22548. /**
  22549. * A function that is added to the onBeforeRenderObservable
  22550. */
  22551. set onBeforeRender(callback: (effect: Effect) => void);
  22552. /**
  22553. * An event triggered after rendering the postprocess
  22554. */
  22555. onAfterRenderObservable: Observable<Effect>;
  22556. private _onAfterRenderObserver;
  22557. /**
  22558. * A function that is added to the onAfterRenderObservable
  22559. */
  22560. set onAfterRender(callback: (efect: Effect) => void);
  22561. /**
  22562. * 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
  22563. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22564. */
  22565. get inputTexture(): InternalTexture;
  22566. set inputTexture(value: InternalTexture);
  22567. /**
  22568. * Gets the camera which post process is applied to.
  22569. * @returns The camera the post process is applied to.
  22570. */
  22571. getCamera(): Camera;
  22572. /**
  22573. * Gets the texel size of the postprocess.
  22574. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22575. */
  22576. get texelSize(): Vector2;
  22577. /**
  22578. * Creates a new instance PostProcess
  22579. * @param name The name of the PostProcess.
  22580. * @param fragmentUrl The url of the fragment shader to be used.
  22581. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22582. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22583. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22584. * @param camera The camera to apply the render pass to.
  22585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22586. * @param engine The engine which the post process will be applied. (default: current engine)
  22587. * @param reusable If the post process can be reused on the same frame. (default: false)
  22588. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22589. * @param textureType Type of textures used when performing the post process. (default: 0)
  22590. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22591. * @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
  22592. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22593. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22594. */
  22595. constructor(
  22596. /** Name of the PostProcess. */
  22597. 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);
  22598. /**
  22599. * Gets a string idenfifying the name of the class
  22600. * @returns "PostProcess" string
  22601. */
  22602. getClassName(): string;
  22603. /**
  22604. * Gets the engine which this post process belongs to.
  22605. * @returns The engine the post process was enabled with.
  22606. */
  22607. getEngine(): Engine;
  22608. /**
  22609. * The effect that is created when initializing the post process.
  22610. * @returns The created effect corresponding the the postprocess.
  22611. */
  22612. getEffect(): Effect;
  22613. /**
  22614. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22615. * @param postProcess The post process to share the output with.
  22616. * @returns This post process.
  22617. */
  22618. shareOutputWith(postProcess: PostProcess): PostProcess;
  22619. /**
  22620. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22621. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22622. */
  22623. useOwnOutput(): void;
  22624. /**
  22625. * Updates the effect with the current post process compile time values and recompiles the shader.
  22626. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22627. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22628. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22629. * @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
  22630. * @param onCompiled Called when the shader has been compiled.
  22631. * @param onError Called if there is an error when compiling a shader.
  22632. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22633. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22634. */
  22635. 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;
  22636. /**
  22637. * The post process is reusable if it can be used multiple times within one frame.
  22638. * @returns If the post process is reusable
  22639. */
  22640. isReusable(): boolean;
  22641. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22642. markTextureDirty(): void;
  22643. /**
  22644. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22645. * 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.
  22646. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22647. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22648. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22649. * @returns The target texture that was bound to be written to.
  22650. */
  22651. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22652. /**
  22653. * If the post process is supported.
  22654. */
  22655. get isSupported(): boolean;
  22656. /**
  22657. * The aspect ratio of the output texture.
  22658. */
  22659. get aspectRatio(): number;
  22660. /**
  22661. * Get a value indicating if the post-process is ready to be used
  22662. * @returns true if the post-process is ready (shader is compiled)
  22663. */
  22664. isReady(): boolean;
  22665. /**
  22666. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22667. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22668. */
  22669. apply(): Nullable<Effect>;
  22670. private _disposeTextures;
  22671. /**
  22672. * Disposes the post process.
  22673. * @param camera The camera to dispose the post process on.
  22674. */
  22675. dispose(camera?: Camera): void;
  22676. }
  22677. }
  22678. declare module BABYLON {
  22679. /** @hidden */
  22680. export var kernelBlurVaryingDeclaration: {
  22681. name: string;
  22682. shader: string;
  22683. };
  22684. }
  22685. declare module BABYLON {
  22686. /** @hidden */
  22687. export var kernelBlurFragment: {
  22688. name: string;
  22689. shader: string;
  22690. };
  22691. }
  22692. declare module BABYLON {
  22693. /** @hidden */
  22694. export var kernelBlurFragment2: {
  22695. name: string;
  22696. shader: string;
  22697. };
  22698. }
  22699. declare module BABYLON {
  22700. /** @hidden */
  22701. export var kernelBlurPixelShader: {
  22702. name: string;
  22703. shader: string;
  22704. };
  22705. }
  22706. declare module BABYLON {
  22707. /** @hidden */
  22708. export var kernelBlurVertex: {
  22709. name: string;
  22710. shader: string;
  22711. };
  22712. }
  22713. declare module BABYLON {
  22714. /** @hidden */
  22715. export var kernelBlurVertexShader: {
  22716. name: string;
  22717. shader: string;
  22718. };
  22719. }
  22720. declare module BABYLON {
  22721. /**
  22722. * The Blur Post Process which blurs an image based on a kernel and direction.
  22723. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22724. */
  22725. export class BlurPostProcess extends PostProcess {
  22726. /** The direction in which to blur the image. */
  22727. direction: Vector2;
  22728. private blockCompilation;
  22729. protected _kernel: number;
  22730. protected _idealKernel: number;
  22731. protected _packedFloat: boolean;
  22732. private _staticDefines;
  22733. /**
  22734. * Sets the length in pixels of the blur sample region
  22735. */
  22736. set kernel(v: number);
  22737. /**
  22738. * Gets the length in pixels of the blur sample region
  22739. */
  22740. get kernel(): number;
  22741. /**
  22742. * Sets wether or not the blur needs to unpack/repack floats
  22743. */
  22744. set packedFloat(v: boolean);
  22745. /**
  22746. * Gets wether or not the blur is unpacking/repacking floats
  22747. */
  22748. get packedFloat(): boolean;
  22749. /**
  22750. * Creates a new instance BlurPostProcess
  22751. * @param name The name of the effect.
  22752. * @param direction The direction in which to blur the image.
  22753. * @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.
  22754. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22755. * @param camera The camera to apply the render pass to.
  22756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22757. * @param engine The engine which the post process will be applied. (default: current engine)
  22758. * @param reusable If the post process can be reused on the same frame. (default: false)
  22759. * @param textureType Type of textures used when performing the post process. (default: 0)
  22760. * @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)
  22761. */
  22762. constructor(name: string,
  22763. /** The direction in which to blur the image. */
  22764. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22765. /**
  22766. * Updates the effect with the current post process compile time values and recompiles the shader.
  22767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22770. * @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
  22771. * @param onCompiled Called when the shader has been compiled.
  22772. * @param onError Called if there is an error when compiling a shader.
  22773. */
  22774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22775. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22776. /**
  22777. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22778. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22779. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22780. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22781. * The gaps between physical kernels are compensated for in the weighting of the samples
  22782. * @param idealKernel Ideal blur kernel.
  22783. * @return Nearest best kernel.
  22784. */
  22785. protected _nearestBestKernel(idealKernel: number): number;
  22786. /**
  22787. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22788. * @param x The point on the Gaussian distribution to sample.
  22789. * @return the value of the Gaussian function at x.
  22790. */
  22791. protected _gaussianWeight(x: number): number;
  22792. /**
  22793. * Generates a string that can be used as a floating point number in GLSL.
  22794. * @param x Value to print.
  22795. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22796. * @return GLSL float string.
  22797. */
  22798. protected _glslFloat(x: number, decimalFigures?: number): string;
  22799. }
  22800. }
  22801. declare module BABYLON {
  22802. /**
  22803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22805. * You can then easily use it as a reflectionTexture on a flat surface.
  22806. * In case the surface is not a plane, please consider relying on reflection probes.
  22807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22808. */
  22809. export class MirrorTexture extends RenderTargetTexture {
  22810. private scene;
  22811. /**
  22812. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22813. * 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.
  22814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22815. */
  22816. mirrorPlane: Plane;
  22817. /**
  22818. * Define the blur ratio used to blur the reflection if needed.
  22819. */
  22820. set blurRatio(value: number);
  22821. get blurRatio(): number;
  22822. /**
  22823. * Define the adaptive blur kernel used to blur the reflection if needed.
  22824. * This will autocompute the closest best match for the `blurKernel`
  22825. */
  22826. set adaptiveBlurKernel(value: number);
  22827. /**
  22828. * Define the blur kernel used to blur the reflection if needed.
  22829. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22830. */
  22831. set blurKernel(value: number);
  22832. /**
  22833. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22834. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22835. */
  22836. set blurKernelX(value: number);
  22837. get blurKernelX(): number;
  22838. /**
  22839. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22840. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22841. */
  22842. set blurKernelY(value: number);
  22843. get blurKernelY(): number;
  22844. private _autoComputeBlurKernel;
  22845. protected _onRatioRescale(): void;
  22846. private _updateGammaSpace;
  22847. private _imageProcessingConfigChangeObserver;
  22848. private _transformMatrix;
  22849. private _mirrorMatrix;
  22850. private _savedViewMatrix;
  22851. private _blurX;
  22852. private _blurY;
  22853. private _adaptiveBlurKernel;
  22854. private _blurKernelX;
  22855. private _blurKernelY;
  22856. private _blurRatio;
  22857. /**
  22858. * Instantiates a Mirror Texture.
  22859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22861. * You can then easily use it as a reflectionTexture on a flat surface.
  22862. * In case the surface is not a plane, please consider relying on reflection probes.
  22863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22864. * @param name
  22865. * @param size
  22866. * @param scene
  22867. * @param generateMipMaps
  22868. * @param type
  22869. * @param samplingMode
  22870. * @param generateDepthBuffer
  22871. */
  22872. constructor(name: string, size: number | {
  22873. width: number;
  22874. height: number;
  22875. } | {
  22876. ratio: number;
  22877. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22878. private _preparePostProcesses;
  22879. /**
  22880. * Clone the mirror texture.
  22881. * @returns the cloned texture
  22882. */
  22883. clone(): MirrorTexture;
  22884. /**
  22885. * Serialize the texture to a JSON representation you could use in Parse later on
  22886. * @returns the serialized JSON representation
  22887. */
  22888. serialize(): any;
  22889. /**
  22890. * Dispose the texture and release its associated resources.
  22891. */
  22892. dispose(): void;
  22893. }
  22894. }
  22895. declare module BABYLON {
  22896. /**
  22897. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22898. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22899. */
  22900. export class Texture extends BaseTexture {
  22901. /**
  22902. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22903. */
  22904. static SerializeBuffers: boolean;
  22905. /** @hidden */
  22906. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22907. /** @hidden */
  22908. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22909. /** @hidden */
  22910. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22911. /** nearest is mag = nearest and min = nearest and mip = linear */
  22912. static readonly NEAREST_SAMPLINGMODE: number;
  22913. /** nearest is mag = nearest and min = nearest and mip = linear */
  22914. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22915. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22916. static readonly BILINEAR_SAMPLINGMODE: number;
  22917. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22918. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22919. /** Trilinear is mag = linear and min = linear and mip = linear */
  22920. static readonly TRILINEAR_SAMPLINGMODE: number;
  22921. /** Trilinear is mag = linear and min = linear and mip = linear */
  22922. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22923. /** mag = nearest and min = nearest and mip = nearest */
  22924. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22925. /** mag = nearest and min = linear and mip = nearest */
  22926. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22927. /** mag = nearest and min = linear and mip = linear */
  22928. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22929. /** mag = nearest and min = linear and mip = none */
  22930. static readonly NEAREST_LINEAR: number;
  22931. /** mag = nearest and min = nearest and mip = none */
  22932. static readonly NEAREST_NEAREST: number;
  22933. /** mag = linear and min = nearest and mip = nearest */
  22934. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22935. /** mag = linear and min = nearest and mip = linear */
  22936. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22937. /** mag = linear and min = linear and mip = none */
  22938. static readonly LINEAR_LINEAR: number;
  22939. /** mag = linear and min = nearest and mip = none */
  22940. static readonly LINEAR_NEAREST: number;
  22941. /** Explicit coordinates mode */
  22942. static readonly EXPLICIT_MODE: number;
  22943. /** Spherical coordinates mode */
  22944. static readonly SPHERICAL_MODE: number;
  22945. /** Planar coordinates mode */
  22946. static readonly PLANAR_MODE: number;
  22947. /** Cubic coordinates mode */
  22948. static readonly CUBIC_MODE: number;
  22949. /** Projection coordinates mode */
  22950. static readonly PROJECTION_MODE: number;
  22951. /** Inverse Cubic coordinates mode */
  22952. static readonly SKYBOX_MODE: number;
  22953. /** Inverse Cubic coordinates mode */
  22954. static readonly INVCUBIC_MODE: number;
  22955. /** Equirectangular coordinates mode */
  22956. static readonly EQUIRECTANGULAR_MODE: number;
  22957. /** Equirectangular Fixed coordinates mode */
  22958. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22959. /** Equirectangular Fixed Mirrored coordinates mode */
  22960. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22961. /** Texture is not repeating outside of 0..1 UVs */
  22962. static readonly CLAMP_ADDRESSMODE: number;
  22963. /** Texture is repeating outside of 0..1 UVs */
  22964. static readonly WRAP_ADDRESSMODE: number;
  22965. /** Texture is repeating and mirrored */
  22966. static readonly MIRROR_ADDRESSMODE: number;
  22967. /**
  22968. * 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
  22969. */
  22970. static UseSerializedUrlIfAny: boolean;
  22971. /**
  22972. * Define the url of the texture.
  22973. */
  22974. url: Nullable<string>;
  22975. /**
  22976. * Define an offset on the texture to offset the u coordinates of the UVs
  22977. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22978. */
  22979. uOffset: number;
  22980. /**
  22981. * Define an offset on the texture to offset the v coordinates of the UVs
  22982. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22983. */
  22984. vOffset: number;
  22985. /**
  22986. * Define an offset on the texture to scale the u coordinates of the UVs
  22987. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22988. */
  22989. uScale: number;
  22990. /**
  22991. * Define an offset on the texture to scale the v coordinates of the UVs
  22992. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22993. */
  22994. vScale: number;
  22995. /**
  22996. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22997. * @see http://doc.babylonjs.com/how_to/more_materials
  22998. */
  22999. uAng: number;
  23000. /**
  23001. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23002. * @see http://doc.babylonjs.com/how_to/more_materials
  23003. */
  23004. vAng: number;
  23005. /**
  23006. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23007. * @see http://doc.babylonjs.com/how_to/more_materials
  23008. */
  23009. wAng: number;
  23010. /**
  23011. * Defines the center of rotation (U)
  23012. */
  23013. uRotationCenter: number;
  23014. /**
  23015. * Defines the center of rotation (V)
  23016. */
  23017. vRotationCenter: number;
  23018. /**
  23019. * Defines the center of rotation (W)
  23020. */
  23021. wRotationCenter: number;
  23022. /**
  23023. * Are mip maps generated for this texture or not.
  23024. */
  23025. get noMipmap(): boolean;
  23026. /**
  23027. * List of inspectable custom properties (used by the Inspector)
  23028. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23029. */
  23030. inspectableCustomProperties: Nullable<IInspectable[]>;
  23031. private _noMipmap;
  23032. /** @hidden */
  23033. _invertY: boolean;
  23034. private _rowGenerationMatrix;
  23035. private _cachedTextureMatrix;
  23036. private _projectionModeMatrix;
  23037. private _t0;
  23038. private _t1;
  23039. private _t2;
  23040. private _cachedUOffset;
  23041. private _cachedVOffset;
  23042. private _cachedUScale;
  23043. private _cachedVScale;
  23044. private _cachedUAng;
  23045. private _cachedVAng;
  23046. private _cachedWAng;
  23047. private _cachedProjectionMatrixId;
  23048. private _cachedCoordinatesMode;
  23049. /** @hidden */
  23050. protected _initialSamplingMode: number;
  23051. /** @hidden */
  23052. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23053. private _deleteBuffer;
  23054. protected _format: Nullable<number>;
  23055. private _delayedOnLoad;
  23056. private _delayedOnError;
  23057. private _mimeType?;
  23058. /**
  23059. * Observable triggered once the texture has been loaded.
  23060. */
  23061. onLoadObservable: Observable<Texture>;
  23062. protected _isBlocking: boolean;
  23063. /**
  23064. * Is the texture preventing material to render while loading.
  23065. * If false, a default texture will be used instead of the loading one during the preparation step.
  23066. */
  23067. set isBlocking(value: boolean);
  23068. get isBlocking(): boolean;
  23069. /**
  23070. * Get the current sampling mode associated with the texture.
  23071. */
  23072. get samplingMode(): number;
  23073. /**
  23074. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23075. */
  23076. get invertY(): boolean;
  23077. /**
  23078. * Instantiates a new texture.
  23079. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23080. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23081. * @param url defines the url of the picture to load as a texture
  23082. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23083. * @param noMipmap defines if the texture will require mip maps or not
  23084. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23085. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23086. * @param onLoad defines a callback triggered when the texture has been loaded
  23087. * @param onError defines a callback triggered when an error occurred during the loading session
  23088. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23089. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23090. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23091. * @param mimeType defines an optional mime type information
  23092. */
  23093. 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);
  23094. /**
  23095. * Update the url (and optional buffer) of this texture if url was null during construction.
  23096. * @param url the url of the texture
  23097. * @param buffer the buffer of the texture (defaults to null)
  23098. * @param onLoad callback called when the texture is loaded (defaults to null)
  23099. */
  23100. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23101. /**
  23102. * Finish the loading sequence of a texture flagged as delayed load.
  23103. * @hidden
  23104. */
  23105. delayLoad(): void;
  23106. private _prepareRowForTextureGeneration;
  23107. /**
  23108. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23109. * @returns the transform matrix of the texture.
  23110. */
  23111. getTextureMatrix(uBase?: number): Matrix;
  23112. /**
  23113. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23114. * @returns The reflection texture transform
  23115. */
  23116. getReflectionTextureMatrix(): Matrix;
  23117. /**
  23118. * Clones the texture.
  23119. * @returns the cloned texture
  23120. */
  23121. clone(): Texture;
  23122. /**
  23123. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23124. * @returns The JSON representation of the texture
  23125. */
  23126. serialize(): any;
  23127. /**
  23128. * Get the current class name of the texture useful for serialization or dynamic coding.
  23129. * @returns "Texture"
  23130. */
  23131. getClassName(): string;
  23132. /**
  23133. * Dispose the texture and release its associated resources.
  23134. */
  23135. dispose(): void;
  23136. /**
  23137. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23138. * @param parsedTexture Define the JSON representation of the texture
  23139. * @param scene Define the scene the parsed texture should be instantiated in
  23140. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23141. * @returns The parsed texture if successful
  23142. */
  23143. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23144. /**
  23145. * Creates a texture from its base 64 representation.
  23146. * @param data Define the base64 payload without the data: prefix
  23147. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23148. * @param scene Define the scene the texture should belong to
  23149. * @param noMipmap Forces the texture to not create mip map information if true
  23150. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23151. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23152. * @param onLoad define a callback triggered when the texture has been loaded
  23153. * @param onError define a callback triggered when an error occurred during the loading session
  23154. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23155. * @returns the created texture
  23156. */
  23157. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23158. /**
  23159. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23160. * @param data Define the base64 payload without the data: prefix
  23161. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23162. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23163. * @param scene Define the scene the texture should belong to
  23164. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23165. * @param noMipmap Forces the texture to not create mip map information if true
  23166. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23167. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23168. * @param onLoad define a callback triggered when the texture has been loaded
  23169. * @param onError define a callback triggered when an error occurred during the loading session
  23170. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23171. * @returns the created texture
  23172. */
  23173. 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;
  23174. }
  23175. }
  23176. declare module BABYLON {
  23177. /**
  23178. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23179. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23180. */
  23181. export class PostProcessManager {
  23182. private _scene;
  23183. private _indexBuffer;
  23184. private _vertexBuffers;
  23185. /**
  23186. * Creates a new instance PostProcess
  23187. * @param scene The scene that the post process is associated with.
  23188. */
  23189. constructor(scene: Scene);
  23190. private _prepareBuffers;
  23191. private _buildIndexBuffer;
  23192. /**
  23193. * Rebuilds the vertex buffers of the manager.
  23194. * @hidden
  23195. */
  23196. _rebuild(): void;
  23197. /**
  23198. * Prepares a frame to be run through a post process.
  23199. * @param sourceTexture The input texture to the post procesess. (default: null)
  23200. * @param postProcesses An array of post processes to be run. (default: null)
  23201. * @returns True if the post processes were able to be run.
  23202. * @hidden
  23203. */
  23204. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23205. /**
  23206. * Manually render a set of post processes to a texture.
  23207. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23208. * @param postProcesses An array of post processes to be run.
  23209. * @param targetTexture The target texture to render to.
  23210. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23211. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23212. * @param lodLevel defines which lod of the texture to render to
  23213. */
  23214. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23215. /**
  23216. * Finalize the result of the output of the postprocesses.
  23217. * @param doNotPresent If true the result will not be displayed to the screen.
  23218. * @param targetTexture The target texture to render to.
  23219. * @param faceIndex The index of the face to bind the target texture to.
  23220. * @param postProcesses The array of post processes to render.
  23221. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23222. * @hidden
  23223. */
  23224. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23225. /**
  23226. * Disposes of the post process manager.
  23227. */
  23228. dispose(): void;
  23229. }
  23230. }
  23231. declare module BABYLON {
  23232. /**
  23233. * This Helps creating a texture that will be created from a camera in your scene.
  23234. * It is basically a dynamic texture that could be used to create special effects for instance.
  23235. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23236. */
  23237. export class RenderTargetTexture extends Texture {
  23238. isCube: boolean;
  23239. /**
  23240. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23241. */
  23242. static readonly REFRESHRATE_RENDER_ONCE: number;
  23243. /**
  23244. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23245. */
  23246. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23247. /**
  23248. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23249. * the central point of your effect and can save a lot of performances.
  23250. */
  23251. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23252. /**
  23253. * Use this predicate to dynamically define the list of mesh you want to render.
  23254. * If set, the renderList property will be overwritten.
  23255. */
  23256. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23257. private _renderList;
  23258. /**
  23259. * Use this list to define the list of mesh you want to render.
  23260. */
  23261. get renderList(): Nullable<Array<AbstractMesh>>;
  23262. set renderList(value: Nullable<Array<AbstractMesh>>);
  23263. /**
  23264. * Use this function to overload the renderList array at rendering time.
  23265. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23266. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23267. * the cube (if the RTT is a cube, else layerOrFace=0).
  23268. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23269. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23270. * hold dummy elements!
  23271. */
  23272. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23273. private _hookArray;
  23274. /**
  23275. * Define if particles should be rendered in your texture.
  23276. */
  23277. renderParticles: boolean;
  23278. /**
  23279. * Define if sprites should be rendered in your texture.
  23280. */
  23281. renderSprites: boolean;
  23282. /**
  23283. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23284. */
  23285. coordinatesMode: number;
  23286. /**
  23287. * Define the camera used to render the texture.
  23288. */
  23289. activeCamera: Nullable<Camera>;
  23290. /**
  23291. * Override the mesh isReady function with your own one.
  23292. */
  23293. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23294. /**
  23295. * Override the render function of the texture with your own one.
  23296. */
  23297. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23298. /**
  23299. * Define if camera post processes should be use while rendering the texture.
  23300. */
  23301. useCameraPostProcesses: boolean;
  23302. /**
  23303. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23304. */
  23305. ignoreCameraViewport: boolean;
  23306. private _postProcessManager;
  23307. private _postProcesses;
  23308. private _resizeObserver;
  23309. /**
  23310. * An event triggered when the texture is unbind.
  23311. */
  23312. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23313. /**
  23314. * An event triggered when the texture is unbind.
  23315. */
  23316. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23317. private _onAfterUnbindObserver;
  23318. /**
  23319. * Set a after unbind callback in the texture.
  23320. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23321. */
  23322. set onAfterUnbind(callback: () => void);
  23323. /**
  23324. * An event triggered before rendering the texture
  23325. */
  23326. onBeforeRenderObservable: Observable<number>;
  23327. private _onBeforeRenderObserver;
  23328. /**
  23329. * Set a before render callback in the texture.
  23330. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23331. */
  23332. set onBeforeRender(callback: (faceIndex: number) => void);
  23333. /**
  23334. * An event triggered after rendering the texture
  23335. */
  23336. onAfterRenderObservable: Observable<number>;
  23337. private _onAfterRenderObserver;
  23338. /**
  23339. * Set a after render callback in the texture.
  23340. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23341. */
  23342. set onAfterRender(callback: (faceIndex: number) => void);
  23343. /**
  23344. * An event triggered after the texture clear
  23345. */
  23346. onClearObservable: Observable<Engine>;
  23347. private _onClearObserver;
  23348. /**
  23349. * Set a clear callback in the texture.
  23350. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23351. */
  23352. set onClear(callback: (Engine: Engine) => void);
  23353. /**
  23354. * An event triggered when the texture is resized.
  23355. */
  23356. onResizeObservable: Observable<RenderTargetTexture>;
  23357. /**
  23358. * Define the clear color of the Render Target if it should be different from the scene.
  23359. */
  23360. clearColor: Color4;
  23361. protected _size: number | {
  23362. width: number;
  23363. height: number;
  23364. layers?: number;
  23365. };
  23366. protected _initialSizeParameter: number | {
  23367. width: number;
  23368. height: number;
  23369. } | {
  23370. ratio: number;
  23371. };
  23372. protected _sizeRatio: Nullable<number>;
  23373. /** @hidden */
  23374. _generateMipMaps: boolean;
  23375. protected _renderingManager: RenderingManager;
  23376. /** @hidden */
  23377. _waitingRenderList: string[];
  23378. protected _doNotChangeAspectRatio: boolean;
  23379. protected _currentRefreshId: number;
  23380. protected _refreshRate: number;
  23381. protected _textureMatrix: Matrix;
  23382. protected _samples: number;
  23383. protected _renderTargetOptions: RenderTargetCreationOptions;
  23384. /**
  23385. * Gets render target creation options that were used.
  23386. */
  23387. get renderTargetOptions(): RenderTargetCreationOptions;
  23388. protected _onRatioRescale(): void;
  23389. /**
  23390. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23391. * It must define where the camera used to render the texture is set
  23392. */
  23393. boundingBoxPosition: Vector3;
  23394. private _boundingBoxSize;
  23395. /**
  23396. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23397. * When defined, the cubemap will switch to local mode
  23398. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23399. * @example https://www.babylonjs-playground.com/#RNASML
  23400. */
  23401. set boundingBoxSize(value: Vector3);
  23402. get boundingBoxSize(): Vector3;
  23403. /**
  23404. * In case the RTT has been created with a depth texture, get the associated
  23405. * depth texture.
  23406. * Otherwise, return null.
  23407. */
  23408. get depthStencilTexture(): Nullable<InternalTexture>;
  23409. /**
  23410. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23411. * or used a shadow, depth texture...
  23412. * @param name The friendly name of the texture
  23413. * @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)
  23414. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23415. * @param generateMipMaps True if mip maps need to be generated after render.
  23416. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23417. * @param type The type of the buffer in the RTT (int, half float, float...)
  23418. * @param isCube True if a cube texture needs to be created
  23419. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23420. * @param generateDepthBuffer True to generate a depth buffer
  23421. * @param generateStencilBuffer True to generate a stencil buffer
  23422. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23423. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23424. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23425. */
  23426. constructor(name: string, size: number | {
  23427. width: number;
  23428. height: number;
  23429. layers?: number;
  23430. } | {
  23431. ratio: number;
  23432. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23433. /**
  23434. * Creates a depth stencil texture.
  23435. * This is only available in WebGL 2 or with the depth texture extension available.
  23436. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23437. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23438. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23439. */
  23440. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23441. private _processSizeParameter;
  23442. /**
  23443. * Define the number of samples to use in case of MSAA.
  23444. * It defaults to one meaning no MSAA has been enabled.
  23445. */
  23446. get samples(): number;
  23447. set samples(value: number);
  23448. /**
  23449. * Resets the refresh counter of the texture and start bak from scratch.
  23450. * Could be useful to regenerate the texture if it is setup to render only once.
  23451. */
  23452. resetRefreshCounter(): void;
  23453. /**
  23454. * Define the refresh rate of the texture or the rendering frequency.
  23455. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23456. */
  23457. get refreshRate(): number;
  23458. set refreshRate(value: number);
  23459. /**
  23460. * Adds a post process to the render target rendering passes.
  23461. * @param postProcess define the post process to add
  23462. */
  23463. addPostProcess(postProcess: PostProcess): void;
  23464. /**
  23465. * Clear all the post processes attached to the render target
  23466. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23467. */
  23468. clearPostProcesses(dispose?: boolean): void;
  23469. /**
  23470. * Remove one of the post process from the list of attached post processes to the texture
  23471. * @param postProcess define the post process to remove from the list
  23472. */
  23473. removePostProcess(postProcess: PostProcess): void;
  23474. /** @hidden */
  23475. _shouldRender(): boolean;
  23476. /**
  23477. * Gets the actual render size of the texture.
  23478. * @returns the width of the render size
  23479. */
  23480. getRenderSize(): number;
  23481. /**
  23482. * Gets the actual render width of the texture.
  23483. * @returns the width of the render size
  23484. */
  23485. getRenderWidth(): number;
  23486. /**
  23487. * Gets the actual render height of the texture.
  23488. * @returns the height of the render size
  23489. */
  23490. getRenderHeight(): number;
  23491. /**
  23492. * Gets the actual number of layers of the texture.
  23493. * @returns the number of layers
  23494. */
  23495. getRenderLayers(): number;
  23496. /**
  23497. * Get if the texture can be rescaled or not.
  23498. */
  23499. get canRescale(): boolean;
  23500. /**
  23501. * Resize the texture using a ratio.
  23502. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23503. */
  23504. scale(ratio: number): void;
  23505. /**
  23506. * Get the texture reflection matrix used to rotate/transform the reflection.
  23507. * @returns the reflection matrix
  23508. */
  23509. getReflectionTextureMatrix(): Matrix;
  23510. /**
  23511. * Resize the texture to a new desired size.
  23512. * Be carrefull as it will recreate all the data in the new texture.
  23513. * @param size Define the new size. It can be:
  23514. * - a number for squared texture,
  23515. * - an object containing { width: number, height: number }
  23516. * - or an object containing a ratio { ratio: number }
  23517. */
  23518. resize(size: number | {
  23519. width: number;
  23520. height: number;
  23521. } | {
  23522. ratio: number;
  23523. }): void;
  23524. private _defaultRenderListPrepared;
  23525. /**
  23526. * Renders all the objects from the render list into the texture.
  23527. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23528. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23529. */
  23530. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23531. private _bestReflectionRenderTargetDimension;
  23532. private _prepareRenderingManager;
  23533. /**
  23534. * @hidden
  23535. * @param faceIndex face index to bind to if this is a cubetexture
  23536. * @param layer defines the index of the texture to bind in the array
  23537. */
  23538. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23539. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23540. private renderToTarget;
  23541. /**
  23542. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23543. * This allowed control for front to back rendering or reversly depending of the special needs.
  23544. *
  23545. * @param renderingGroupId The rendering group id corresponding to its index
  23546. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23547. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23548. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23549. */
  23550. 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;
  23551. /**
  23552. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23553. *
  23554. * @param renderingGroupId The rendering group id corresponding to its index
  23555. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23556. */
  23557. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23558. /**
  23559. * Clones the texture.
  23560. * @returns the cloned texture
  23561. */
  23562. clone(): RenderTargetTexture;
  23563. /**
  23564. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23565. * @returns The JSON representation of the texture
  23566. */
  23567. serialize(): any;
  23568. /**
  23569. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23570. */
  23571. disposeFramebufferObjects(): void;
  23572. /**
  23573. * Dispose the texture and release its associated resources.
  23574. */
  23575. dispose(): void;
  23576. /** @hidden */
  23577. _rebuild(): void;
  23578. /**
  23579. * Clear the info related to rendering groups preventing retention point in material dispose.
  23580. */
  23581. freeRenderingGroups(): void;
  23582. /**
  23583. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23584. * @returns the view count
  23585. */
  23586. getViewCount(): number;
  23587. }
  23588. }
  23589. declare module BABYLON {
  23590. /**
  23591. * Class used to manipulate GUIDs
  23592. */
  23593. export class GUID {
  23594. /**
  23595. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23596. * Be aware Math.random() could cause collisions, but:
  23597. * "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"
  23598. * @returns a pseudo random id
  23599. */
  23600. static RandomId(): string;
  23601. }
  23602. }
  23603. declare module BABYLON {
  23604. /**
  23605. * Options to be used when creating a shadow depth material
  23606. */
  23607. export interface IIOptionShadowDepthMaterial {
  23608. /** Variables in the vertex shader code that need to have their names remapped.
  23609. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23610. * "var_name" should be either: worldPos or vNormalW
  23611. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23612. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23613. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23614. */
  23615. remappedVariables?: string[];
  23616. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23617. standalone?: boolean;
  23618. }
  23619. /**
  23620. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23621. */
  23622. export class ShadowDepthWrapper {
  23623. private _scene;
  23624. private _options?;
  23625. private _baseMaterial;
  23626. private _onEffectCreatedObserver;
  23627. private _subMeshToEffect;
  23628. private _subMeshToDepthEffect;
  23629. private _meshes;
  23630. /** @hidden */
  23631. _matriceNames: any;
  23632. /** Gets the standalone status of the wrapper */
  23633. get standalone(): boolean;
  23634. /** Gets the base material the wrapper is built upon */
  23635. get baseMaterial(): Material;
  23636. /**
  23637. * Instantiate a new shadow depth wrapper.
  23638. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23639. * generate the shadow depth map. For more information, please refer to the documentation:
  23640. * https://doc.babylonjs.com/babylon101/shadows
  23641. * @param baseMaterial Material to wrap
  23642. * @param scene Define the scene the material belongs to
  23643. * @param options Options used to create the wrapper
  23644. */
  23645. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23646. /**
  23647. * Gets the effect to use to generate the depth map
  23648. * @param subMesh subMesh to get the effect for
  23649. * @param shadowGenerator shadow generator to get the effect for
  23650. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23651. */
  23652. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23653. /**
  23654. * Specifies that the submesh is ready to be used for depth rendering
  23655. * @param subMesh submesh to check
  23656. * @param defines the list of defines to take into account when checking the effect
  23657. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23658. * @param useInstances specifies that instances should be used
  23659. * @returns a boolean indicating that the submesh is ready or not
  23660. */
  23661. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23662. /**
  23663. * Disposes the resources
  23664. */
  23665. dispose(): void;
  23666. private _makeEffect;
  23667. }
  23668. }
  23669. declare module BABYLON {
  23670. /**
  23671. * Options for compiling materials.
  23672. */
  23673. export interface IMaterialCompilationOptions {
  23674. /**
  23675. * Defines whether clip planes are enabled.
  23676. */
  23677. clipPlane: boolean;
  23678. /**
  23679. * Defines whether instances are enabled.
  23680. */
  23681. useInstances: boolean;
  23682. }
  23683. /**
  23684. * Options passed when calling customShaderNameResolve
  23685. */
  23686. export interface ICustomShaderNameResolveOptions {
  23687. /**
  23688. * 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
  23689. */
  23690. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23691. }
  23692. /**
  23693. * Base class for the main features of a material in Babylon.js
  23694. */
  23695. export class Material implements IAnimatable {
  23696. /**
  23697. * Returns the triangle fill mode
  23698. */
  23699. static readonly TriangleFillMode: number;
  23700. /**
  23701. * Returns the wireframe mode
  23702. */
  23703. static readonly WireFrameFillMode: number;
  23704. /**
  23705. * Returns the point fill mode
  23706. */
  23707. static readonly PointFillMode: number;
  23708. /**
  23709. * Returns the point list draw mode
  23710. */
  23711. static readonly PointListDrawMode: number;
  23712. /**
  23713. * Returns the line list draw mode
  23714. */
  23715. static readonly LineListDrawMode: number;
  23716. /**
  23717. * Returns the line loop draw mode
  23718. */
  23719. static readonly LineLoopDrawMode: number;
  23720. /**
  23721. * Returns the line strip draw mode
  23722. */
  23723. static readonly LineStripDrawMode: number;
  23724. /**
  23725. * Returns the triangle strip draw mode
  23726. */
  23727. static readonly TriangleStripDrawMode: number;
  23728. /**
  23729. * Returns the triangle fan draw mode
  23730. */
  23731. static readonly TriangleFanDrawMode: number;
  23732. /**
  23733. * Stores the clock-wise side orientation
  23734. */
  23735. static readonly ClockWiseSideOrientation: number;
  23736. /**
  23737. * Stores the counter clock-wise side orientation
  23738. */
  23739. static readonly CounterClockWiseSideOrientation: number;
  23740. /**
  23741. * The dirty texture flag value
  23742. */
  23743. static readonly TextureDirtyFlag: number;
  23744. /**
  23745. * The dirty light flag value
  23746. */
  23747. static readonly LightDirtyFlag: number;
  23748. /**
  23749. * The dirty fresnel flag value
  23750. */
  23751. static readonly FresnelDirtyFlag: number;
  23752. /**
  23753. * The dirty attribute flag value
  23754. */
  23755. static readonly AttributesDirtyFlag: number;
  23756. /**
  23757. * The dirty misc flag value
  23758. */
  23759. static readonly MiscDirtyFlag: number;
  23760. /**
  23761. * The all dirty flag value
  23762. */
  23763. static readonly AllDirtyFlag: number;
  23764. /**
  23765. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23766. */
  23767. static readonly MATERIAL_OPAQUE: number;
  23768. /**
  23769. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23770. */
  23771. static readonly MATERIAL_ALPHATEST: number;
  23772. /**
  23773. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23774. */
  23775. static readonly MATERIAL_ALPHABLEND: number;
  23776. /**
  23777. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23778. * They are also discarded below the alpha cutoff threshold to improve performances.
  23779. */
  23780. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23781. /**
  23782. * Custom callback helping to override the default shader used in the material.
  23783. */
  23784. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23785. /**
  23786. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23787. */
  23788. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23789. /**
  23790. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23791. * This means that the material can keep using a previous shader while a new one is being compiled.
  23792. * This is mostly used when shader parallel compilation is supported (true by default)
  23793. */
  23794. allowShaderHotSwapping: boolean;
  23795. /**
  23796. * The ID of the material
  23797. */
  23798. id: string;
  23799. /**
  23800. * Gets or sets the unique id of the material
  23801. */
  23802. uniqueId: number;
  23803. /**
  23804. * The name of the material
  23805. */
  23806. name: string;
  23807. /**
  23808. * Gets or sets user defined metadata
  23809. */
  23810. metadata: any;
  23811. /**
  23812. * For internal use only. Please do not use.
  23813. */
  23814. reservedDataStore: any;
  23815. /**
  23816. * Specifies if the ready state should be checked on each call
  23817. */
  23818. checkReadyOnEveryCall: boolean;
  23819. /**
  23820. * Specifies if the ready state should be checked once
  23821. */
  23822. checkReadyOnlyOnce: boolean;
  23823. /**
  23824. * The state of the material
  23825. */
  23826. state: string;
  23827. /**
  23828. * The alpha value of the material
  23829. */
  23830. protected _alpha: number;
  23831. /**
  23832. * List of inspectable custom properties (used by the Inspector)
  23833. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23834. */
  23835. inspectableCustomProperties: IInspectable[];
  23836. /**
  23837. * Sets the alpha value of the material
  23838. */
  23839. set alpha(value: number);
  23840. /**
  23841. * Gets the alpha value of the material
  23842. */
  23843. get alpha(): number;
  23844. /**
  23845. * Specifies if back face culling is enabled
  23846. */
  23847. protected _backFaceCulling: boolean;
  23848. /**
  23849. * Sets the back-face culling state
  23850. */
  23851. set backFaceCulling(value: boolean);
  23852. /**
  23853. * Gets the back-face culling state
  23854. */
  23855. get backFaceCulling(): boolean;
  23856. /**
  23857. * Stores the value for side orientation
  23858. */
  23859. sideOrientation: number;
  23860. /**
  23861. * Callback triggered when the material is compiled
  23862. */
  23863. onCompiled: Nullable<(effect: Effect) => void>;
  23864. /**
  23865. * Callback triggered when an error occurs
  23866. */
  23867. onError: Nullable<(effect: Effect, errors: string) => void>;
  23868. /**
  23869. * Callback triggered to get the render target textures
  23870. */
  23871. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23872. /**
  23873. * Gets a boolean indicating that current material needs to register RTT
  23874. */
  23875. get hasRenderTargetTextures(): boolean;
  23876. /**
  23877. * Specifies if the material should be serialized
  23878. */
  23879. doNotSerialize: boolean;
  23880. /**
  23881. * @hidden
  23882. */
  23883. _storeEffectOnSubMeshes: boolean;
  23884. /**
  23885. * Stores the animations for the material
  23886. */
  23887. animations: Nullable<Array<Animation>>;
  23888. /**
  23889. * An event triggered when the material is disposed
  23890. */
  23891. onDisposeObservable: Observable<Material>;
  23892. /**
  23893. * An observer which watches for dispose events
  23894. */
  23895. private _onDisposeObserver;
  23896. private _onUnBindObservable;
  23897. /**
  23898. * Called during a dispose event
  23899. */
  23900. set onDispose(callback: () => void);
  23901. private _onBindObservable;
  23902. /**
  23903. * An event triggered when the material is bound
  23904. */
  23905. get onBindObservable(): Observable<AbstractMesh>;
  23906. /**
  23907. * An observer which watches for bind events
  23908. */
  23909. private _onBindObserver;
  23910. /**
  23911. * Called during a bind event
  23912. */
  23913. set onBind(callback: (Mesh: AbstractMesh) => void);
  23914. /**
  23915. * An event triggered when the material is unbound
  23916. */
  23917. get onUnBindObservable(): Observable<Material>;
  23918. protected _onEffectCreatedObservable: Nullable<Observable<{
  23919. effect: Effect;
  23920. subMesh: Nullable<SubMesh>;
  23921. }>>;
  23922. /**
  23923. * An event triggered when the effect is (re)created
  23924. */
  23925. get onEffectCreatedObservable(): Observable<{
  23926. effect: Effect;
  23927. subMesh: Nullable<SubMesh>;
  23928. }>;
  23929. /**
  23930. * Stores the value of the alpha mode
  23931. */
  23932. private _alphaMode;
  23933. /**
  23934. * Sets the value of the alpha mode.
  23935. *
  23936. * | Value | Type | Description |
  23937. * | --- | --- | --- |
  23938. * | 0 | ALPHA_DISABLE | |
  23939. * | 1 | ALPHA_ADD | |
  23940. * | 2 | ALPHA_COMBINE | |
  23941. * | 3 | ALPHA_SUBTRACT | |
  23942. * | 4 | ALPHA_MULTIPLY | |
  23943. * | 5 | ALPHA_MAXIMIZED | |
  23944. * | 6 | ALPHA_ONEONE | |
  23945. * | 7 | ALPHA_PREMULTIPLIED | |
  23946. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23947. * | 9 | ALPHA_INTERPOLATE | |
  23948. * | 10 | ALPHA_SCREENMODE | |
  23949. *
  23950. */
  23951. set alphaMode(value: number);
  23952. /**
  23953. * Gets the value of the alpha mode
  23954. */
  23955. get alphaMode(): number;
  23956. /**
  23957. * Stores the state of the need depth pre-pass value
  23958. */
  23959. private _needDepthPrePass;
  23960. /**
  23961. * Sets the need depth pre-pass value
  23962. */
  23963. set needDepthPrePass(value: boolean);
  23964. /**
  23965. * Gets the depth pre-pass value
  23966. */
  23967. get needDepthPrePass(): boolean;
  23968. /**
  23969. * Specifies if depth writing should be disabled
  23970. */
  23971. disableDepthWrite: boolean;
  23972. /**
  23973. * Specifies if color writing should be disabled
  23974. */
  23975. disableColorWrite: boolean;
  23976. /**
  23977. * Specifies if depth writing should be forced
  23978. */
  23979. forceDepthWrite: boolean;
  23980. /**
  23981. * Specifies the depth function that should be used. 0 means the default engine function
  23982. */
  23983. depthFunction: number;
  23984. /**
  23985. * Specifies if there should be a separate pass for culling
  23986. */
  23987. separateCullingPass: boolean;
  23988. /**
  23989. * Stores the state specifing if fog should be enabled
  23990. */
  23991. private _fogEnabled;
  23992. /**
  23993. * Sets the state for enabling fog
  23994. */
  23995. set fogEnabled(value: boolean);
  23996. /**
  23997. * Gets the value of the fog enabled state
  23998. */
  23999. get fogEnabled(): boolean;
  24000. /**
  24001. * Stores the size of points
  24002. */
  24003. pointSize: number;
  24004. /**
  24005. * Stores the z offset value
  24006. */
  24007. zOffset: number;
  24008. get wireframe(): boolean;
  24009. /**
  24010. * Sets the state of wireframe mode
  24011. */
  24012. set wireframe(value: boolean);
  24013. /**
  24014. * Gets the value specifying if point clouds are enabled
  24015. */
  24016. get pointsCloud(): boolean;
  24017. /**
  24018. * Sets the state of point cloud mode
  24019. */
  24020. set pointsCloud(value: boolean);
  24021. /**
  24022. * Gets the material fill mode
  24023. */
  24024. get fillMode(): number;
  24025. /**
  24026. * Sets the material fill mode
  24027. */
  24028. set fillMode(value: number);
  24029. /**
  24030. * @hidden
  24031. * Stores the effects for the material
  24032. */
  24033. _effect: Nullable<Effect>;
  24034. /**
  24035. * Specifies if uniform buffers should be used
  24036. */
  24037. private _useUBO;
  24038. /**
  24039. * Stores a reference to the scene
  24040. */
  24041. private _scene;
  24042. /**
  24043. * Stores the fill mode state
  24044. */
  24045. private _fillMode;
  24046. /**
  24047. * Specifies if the depth write state should be cached
  24048. */
  24049. private _cachedDepthWriteState;
  24050. /**
  24051. * Specifies if the color write state should be cached
  24052. */
  24053. private _cachedColorWriteState;
  24054. /**
  24055. * Specifies if the depth function state should be cached
  24056. */
  24057. private _cachedDepthFunctionState;
  24058. /**
  24059. * Stores the uniform buffer
  24060. */
  24061. protected _uniformBuffer: UniformBuffer;
  24062. /** @hidden */
  24063. _indexInSceneMaterialArray: number;
  24064. /** @hidden */
  24065. meshMap: Nullable<{
  24066. [id: string]: AbstractMesh | undefined;
  24067. }>;
  24068. /**
  24069. * Creates a material instance
  24070. * @param name defines the name of the material
  24071. * @param scene defines the scene to reference
  24072. * @param doNotAdd specifies if the material should be added to the scene
  24073. */
  24074. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24075. /**
  24076. * Returns a string representation of the current material
  24077. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24078. * @returns a string with material information
  24079. */
  24080. toString(fullDetails?: boolean): string;
  24081. /**
  24082. * Gets the class name of the material
  24083. * @returns a string with the class name of the material
  24084. */
  24085. getClassName(): string;
  24086. /**
  24087. * Specifies if updates for the material been locked
  24088. */
  24089. get isFrozen(): boolean;
  24090. /**
  24091. * Locks updates for the material
  24092. */
  24093. freeze(): void;
  24094. /**
  24095. * Unlocks updates for the material
  24096. */
  24097. unfreeze(): void;
  24098. /**
  24099. * Specifies if the material is ready to be used
  24100. * @param mesh defines the mesh to check
  24101. * @param useInstances specifies if instances should be used
  24102. * @returns a boolean indicating if the material is ready to be used
  24103. */
  24104. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24105. /**
  24106. * Specifies that the submesh is ready to be used
  24107. * @param mesh defines the mesh to check
  24108. * @param subMesh defines which submesh to check
  24109. * @param useInstances specifies that instances should be used
  24110. * @returns a boolean indicating that the submesh is ready or not
  24111. */
  24112. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24113. /**
  24114. * Returns the material effect
  24115. * @returns the effect associated with the material
  24116. */
  24117. getEffect(): Nullable<Effect>;
  24118. /**
  24119. * Returns the current scene
  24120. * @returns a Scene
  24121. */
  24122. getScene(): Scene;
  24123. /**
  24124. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24125. */
  24126. protected _forceAlphaTest: boolean;
  24127. /**
  24128. * The transparency mode of the material.
  24129. */
  24130. protected _transparencyMode: Nullable<number>;
  24131. /**
  24132. * Gets the current transparency mode.
  24133. */
  24134. get transparencyMode(): Nullable<number>;
  24135. /**
  24136. * Sets the transparency mode of the material.
  24137. *
  24138. * | Value | Type | Description |
  24139. * | ----- | ----------------------------------- | ----------- |
  24140. * | 0 | OPAQUE | |
  24141. * | 1 | ALPHATEST | |
  24142. * | 2 | ALPHABLEND | |
  24143. * | 3 | ALPHATESTANDBLEND | |
  24144. *
  24145. */
  24146. set transparencyMode(value: Nullable<number>);
  24147. /**
  24148. * Returns true if alpha blending should be disabled.
  24149. */
  24150. protected get _disableAlphaBlending(): boolean;
  24151. /**
  24152. * Specifies whether or not this material should be rendered in alpha blend mode.
  24153. * @returns a boolean specifying if alpha blending is needed
  24154. */
  24155. needAlphaBlending(): boolean;
  24156. /**
  24157. * Specifies if the mesh will require alpha blending
  24158. * @param mesh defines the mesh to check
  24159. * @returns a boolean specifying if alpha blending is needed for the mesh
  24160. */
  24161. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24162. /**
  24163. * Specifies whether or not this material should be rendered in alpha test mode.
  24164. * @returns a boolean specifying if an alpha test is needed.
  24165. */
  24166. needAlphaTesting(): boolean;
  24167. /**
  24168. * Specifies if material alpha testing should be turned on for the mesh
  24169. * @param mesh defines the mesh to check
  24170. */
  24171. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24172. /**
  24173. * Gets the texture used for the alpha test
  24174. * @returns the texture to use for alpha testing
  24175. */
  24176. getAlphaTestTexture(): Nullable<BaseTexture>;
  24177. /**
  24178. * Marks the material to indicate that it needs to be re-calculated
  24179. */
  24180. markDirty(): void;
  24181. /** @hidden */
  24182. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24183. /**
  24184. * Binds the material to the mesh
  24185. * @param world defines the world transformation matrix
  24186. * @param mesh defines the mesh to bind the material to
  24187. */
  24188. bind(world: Matrix, mesh?: Mesh): void;
  24189. /**
  24190. * Binds the submesh to the material
  24191. * @param world defines the world transformation matrix
  24192. * @param mesh defines the mesh containing the submesh
  24193. * @param subMesh defines the submesh to bind the material to
  24194. */
  24195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24196. /**
  24197. * Binds the world matrix to the material
  24198. * @param world defines the world transformation matrix
  24199. */
  24200. bindOnlyWorldMatrix(world: Matrix): void;
  24201. /**
  24202. * Binds the scene's uniform buffer to the effect.
  24203. * @param effect defines the effect to bind to the scene uniform buffer
  24204. * @param sceneUbo defines the uniform buffer storing scene data
  24205. */
  24206. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24207. /**
  24208. * Binds the view matrix to the effect
  24209. * @param effect defines the effect to bind the view matrix to
  24210. */
  24211. bindView(effect: Effect): void;
  24212. /**
  24213. * Binds the view projection matrix to the effect
  24214. * @param effect defines the effect to bind the view projection matrix to
  24215. */
  24216. bindViewProjection(effect: Effect): void;
  24217. /**
  24218. * Processes to execute after binding the material to a mesh
  24219. * @param mesh defines the rendered mesh
  24220. */
  24221. protected _afterBind(mesh?: Mesh): void;
  24222. /**
  24223. * Unbinds the material from the mesh
  24224. */
  24225. unbind(): void;
  24226. /**
  24227. * Gets the active textures from the material
  24228. * @returns an array of textures
  24229. */
  24230. getActiveTextures(): BaseTexture[];
  24231. /**
  24232. * Specifies if the material uses a texture
  24233. * @param texture defines the texture to check against the material
  24234. * @returns a boolean specifying if the material uses the texture
  24235. */
  24236. hasTexture(texture: BaseTexture): boolean;
  24237. /**
  24238. * Makes a duplicate of the material, and gives it a new name
  24239. * @param name defines the new name for the duplicated material
  24240. * @returns the cloned material
  24241. */
  24242. clone(name: string): Nullable<Material>;
  24243. /**
  24244. * Gets the meshes bound to the material
  24245. * @returns an array of meshes bound to the material
  24246. */
  24247. getBindedMeshes(): AbstractMesh[];
  24248. /**
  24249. * Force shader compilation
  24250. * @param mesh defines the mesh associated with this material
  24251. * @param onCompiled defines a function to execute once the material is compiled
  24252. * @param options defines the options to configure the compilation
  24253. * @param onError defines a function to execute if the material fails compiling
  24254. */
  24255. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24256. /**
  24257. * Force shader compilation
  24258. * @param mesh defines the mesh that will use this material
  24259. * @param options defines additional options for compiling the shaders
  24260. * @returns a promise that resolves when the compilation completes
  24261. */
  24262. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24263. private static readonly _AllDirtyCallBack;
  24264. private static readonly _ImageProcessingDirtyCallBack;
  24265. private static readonly _TextureDirtyCallBack;
  24266. private static readonly _FresnelDirtyCallBack;
  24267. private static readonly _MiscDirtyCallBack;
  24268. private static readonly _LightsDirtyCallBack;
  24269. private static readonly _AttributeDirtyCallBack;
  24270. private static _FresnelAndMiscDirtyCallBack;
  24271. private static _TextureAndMiscDirtyCallBack;
  24272. private static readonly _DirtyCallbackArray;
  24273. private static readonly _RunDirtyCallBacks;
  24274. /**
  24275. * Marks a define in the material to indicate that it needs to be re-computed
  24276. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24277. */
  24278. markAsDirty(flag: number): void;
  24279. /**
  24280. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24281. * @param func defines a function which checks material defines against the submeshes
  24282. */
  24283. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24284. /**
  24285. * Indicates that we need to re-calculated for all submeshes
  24286. */
  24287. protected _markAllSubMeshesAsAllDirty(): void;
  24288. /**
  24289. * Indicates that image processing needs to be re-calculated for all submeshes
  24290. */
  24291. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24292. /**
  24293. * Indicates that textures need to be re-calculated for all submeshes
  24294. */
  24295. protected _markAllSubMeshesAsTexturesDirty(): void;
  24296. /**
  24297. * Indicates that fresnel needs to be re-calculated for all submeshes
  24298. */
  24299. protected _markAllSubMeshesAsFresnelDirty(): void;
  24300. /**
  24301. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24302. */
  24303. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24304. /**
  24305. * Indicates that lights need to be re-calculated for all submeshes
  24306. */
  24307. protected _markAllSubMeshesAsLightsDirty(): void;
  24308. /**
  24309. * Indicates that attributes need to be re-calculated for all submeshes
  24310. */
  24311. protected _markAllSubMeshesAsAttributesDirty(): void;
  24312. /**
  24313. * Indicates that misc needs to be re-calculated for all submeshes
  24314. */
  24315. protected _markAllSubMeshesAsMiscDirty(): void;
  24316. /**
  24317. * Indicates that textures and misc need to be re-calculated for all submeshes
  24318. */
  24319. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24320. /**
  24321. * Disposes the material
  24322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24324. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24325. */
  24326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24327. /** @hidden */
  24328. private releaseVertexArrayObject;
  24329. /**
  24330. * Serializes this material
  24331. * @returns the serialized material object
  24332. */
  24333. serialize(): any;
  24334. /**
  24335. * Creates a material from parsed material data
  24336. * @param parsedMaterial defines parsed material data
  24337. * @param scene defines the hosting scene
  24338. * @param rootUrl defines the root URL to use to load textures
  24339. * @returns a new material
  24340. */
  24341. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24342. }
  24343. }
  24344. declare module BABYLON {
  24345. /**
  24346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24347. * separate meshes. This can be use to improve performances.
  24348. * @see http://doc.babylonjs.com/how_to/multi_materials
  24349. */
  24350. export class MultiMaterial extends Material {
  24351. private _subMaterials;
  24352. /**
  24353. * Gets or Sets the list of Materials used within the multi material.
  24354. * They need to be ordered according to the submeshes order in the associated mesh
  24355. */
  24356. get subMaterials(): Nullable<Material>[];
  24357. set subMaterials(value: Nullable<Material>[]);
  24358. /**
  24359. * Function used to align with Node.getChildren()
  24360. * @returns the list of Materials used within the multi material
  24361. */
  24362. getChildren(): Nullable<Material>[];
  24363. /**
  24364. * Instantiates a new Multi Material
  24365. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24366. * separate meshes. This can be use to improve performances.
  24367. * @see http://doc.babylonjs.com/how_to/multi_materials
  24368. * @param name Define the name in the scene
  24369. * @param scene Define the scene the material belongs to
  24370. */
  24371. constructor(name: string, scene: Scene);
  24372. private _hookArray;
  24373. /**
  24374. * Get one of the submaterial by its index in the submaterials array
  24375. * @param index The index to look the sub material at
  24376. * @returns The Material if the index has been defined
  24377. */
  24378. getSubMaterial(index: number): Nullable<Material>;
  24379. /**
  24380. * Get the list of active textures for the whole sub materials list.
  24381. * @returns All the textures that will be used during the rendering
  24382. */
  24383. getActiveTextures(): BaseTexture[];
  24384. /**
  24385. * Gets the current class name of the material e.g. "MultiMaterial"
  24386. * Mainly use in serialization.
  24387. * @returns the class name
  24388. */
  24389. getClassName(): string;
  24390. /**
  24391. * Checks if the material is ready to render the requested sub mesh
  24392. * @param mesh Define the mesh the submesh belongs to
  24393. * @param subMesh Define the sub mesh to look readyness for
  24394. * @param useInstances Define whether or not the material is used with instances
  24395. * @returns true if ready, otherwise false
  24396. */
  24397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24398. /**
  24399. * Clones the current material and its related sub materials
  24400. * @param name Define the name of the newly cloned material
  24401. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24402. * @returns the cloned material
  24403. */
  24404. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24405. /**
  24406. * Serializes the materials into a JSON representation.
  24407. * @returns the JSON representation
  24408. */
  24409. serialize(): any;
  24410. /**
  24411. * Dispose the material and release its associated resources
  24412. * @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)
  24413. * @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)
  24414. * @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)
  24415. */
  24416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24417. /**
  24418. * Creates a MultiMaterial from parsed MultiMaterial data.
  24419. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24420. * @param scene defines the hosting scene
  24421. * @returns a new MultiMaterial
  24422. */
  24423. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24424. }
  24425. }
  24426. declare module BABYLON {
  24427. /**
  24428. * Defines a subdivision inside a mesh
  24429. */
  24430. export class SubMesh implements ICullable {
  24431. /** the material index to use */
  24432. materialIndex: number;
  24433. /** vertex index start */
  24434. verticesStart: number;
  24435. /** vertices count */
  24436. verticesCount: number;
  24437. /** index start */
  24438. indexStart: number;
  24439. /** indices count */
  24440. indexCount: number;
  24441. /** @hidden */
  24442. _materialDefines: Nullable<MaterialDefines>;
  24443. /** @hidden */
  24444. _materialEffect: Nullable<Effect>;
  24445. /** @hidden */
  24446. _effectOverride: Nullable<Effect>;
  24447. /**
  24448. * Gets material defines used by the effect associated to the sub mesh
  24449. */
  24450. get materialDefines(): Nullable<MaterialDefines>;
  24451. /**
  24452. * Sets material defines used by the effect associated to the sub mesh
  24453. */
  24454. set materialDefines(defines: Nullable<MaterialDefines>);
  24455. /**
  24456. * Gets associated effect
  24457. */
  24458. get effect(): Nullable<Effect>;
  24459. /**
  24460. * Sets associated effect (effect used to render this submesh)
  24461. * @param effect defines the effect to associate with
  24462. * @param defines defines the set of defines used to compile this effect
  24463. */
  24464. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24465. /** @hidden */
  24466. _linesIndexCount: number;
  24467. private _mesh;
  24468. private _renderingMesh;
  24469. private _boundingInfo;
  24470. private _linesIndexBuffer;
  24471. /** @hidden */
  24472. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24473. /** @hidden */
  24474. _trianglePlanes: Plane[];
  24475. /** @hidden */
  24476. _lastColliderTransformMatrix: Nullable<Matrix>;
  24477. /** @hidden */
  24478. _renderId: number;
  24479. /** @hidden */
  24480. _alphaIndex: number;
  24481. /** @hidden */
  24482. _distanceToCamera: number;
  24483. /** @hidden */
  24484. _id: number;
  24485. private _currentMaterial;
  24486. /**
  24487. * Add a new submesh to a mesh
  24488. * @param materialIndex defines the material index to use
  24489. * @param verticesStart defines vertex index start
  24490. * @param verticesCount defines vertices count
  24491. * @param indexStart defines index start
  24492. * @param indexCount defines indices count
  24493. * @param mesh defines the parent mesh
  24494. * @param renderingMesh defines an optional rendering mesh
  24495. * @param createBoundingBox defines if bounding box should be created for this submesh
  24496. * @returns the new submesh
  24497. */
  24498. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24499. /**
  24500. * Creates a new submesh
  24501. * @param materialIndex defines the material index to use
  24502. * @param verticesStart defines vertex index start
  24503. * @param verticesCount defines vertices count
  24504. * @param indexStart defines index start
  24505. * @param indexCount defines indices count
  24506. * @param mesh defines the parent mesh
  24507. * @param renderingMesh defines an optional rendering mesh
  24508. * @param createBoundingBox defines if bounding box should be created for this submesh
  24509. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24510. */
  24511. constructor(
  24512. /** the material index to use */
  24513. materialIndex: number,
  24514. /** vertex index start */
  24515. verticesStart: number,
  24516. /** vertices count */
  24517. verticesCount: number,
  24518. /** index start */
  24519. indexStart: number,
  24520. /** indices count */
  24521. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24522. /**
  24523. * Returns true if this submesh covers the entire parent mesh
  24524. * @ignorenaming
  24525. */
  24526. get IsGlobal(): boolean;
  24527. /**
  24528. * Returns the submesh BoudingInfo object
  24529. * @returns current bounding info (or mesh's one if the submesh is global)
  24530. */
  24531. getBoundingInfo(): BoundingInfo;
  24532. /**
  24533. * Sets the submesh BoundingInfo
  24534. * @param boundingInfo defines the new bounding info to use
  24535. * @returns the SubMesh
  24536. */
  24537. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24538. /**
  24539. * Returns the mesh of the current submesh
  24540. * @return the parent mesh
  24541. */
  24542. getMesh(): AbstractMesh;
  24543. /**
  24544. * Returns the rendering mesh of the submesh
  24545. * @returns the rendering mesh (could be different from parent mesh)
  24546. */
  24547. getRenderingMesh(): Mesh;
  24548. /**
  24549. * Returns the replacement mesh of the submesh
  24550. * @returns the replacement mesh (could be different from parent mesh)
  24551. */
  24552. getReplacementMesh(): Nullable<AbstractMesh>;
  24553. /**
  24554. * Returns the effective mesh of the submesh
  24555. * @returns the effective mesh (could be different from parent mesh)
  24556. */
  24557. getEffectiveMesh(): AbstractMesh;
  24558. /**
  24559. * Returns the submesh material
  24560. * @returns null or the current material
  24561. */
  24562. getMaterial(): Nullable<Material>;
  24563. /**
  24564. * Sets a new updated BoundingInfo object to the submesh
  24565. * @param data defines an optional position array to use to determine the bounding info
  24566. * @returns the SubMesh
  24567. */
  24568. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24569. /** @hidden */
  24570. _checkCollision(collider: Collider): boolean;
  24571. /**
  24572. * Updates the submesh BoundingInfo
  24573. * @param world defines the world matrix to use to update the bounding info
  24574. * @returns the submesh
  24575. */
  24576. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24577. /**
  24578. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24579. * @param frustumPlanes defines the frustum planes
  24580. * @returns true if the submesh is intersecting with the frustum
  24581. */
  24582. isInFrustum(frustumPlanes: Plane[]): boolean;
  24583. /**
  24584. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24585. * @param frustumPlanes defines the frustum planes
  24586. * @returns true if the submesh is inside the frustum
  24587. */
  24588. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24589. /**
  24590. * Renders the submesh
  24591. * @param enableAlphaMode defines if alpha needs to be used
  24592. * @returns the submesh
  24593. */
  24594. render(enableAlphaMode: boolean): SubMesh;
  24595. /**
  24596. * @hidden
  24597. */
  24598. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24599. /**
  24600. * Checks if the submesh intersects with a ray
  24601. * @param ray defines the ray to test
  24602. * @returns true is the passed ray intersects the submesh bounding box
  24603. */
  24604. canIntersects(ray: Ray): boolean;
  24605. /**
  24606. * Intersects current submesh with a ray
  24607. * @param ray defines the ray to test
  24608. * @param positions defines mesh's positions array
  24609. * @param indices defines mesh's indices array
  24610. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24611. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24612. * @returns intersection info or null if no intersection
  24613. */
  24614. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24615. /** @hidden */
  24616. private _intersectLines;
  24617. /** @hidden */
  24618. private _intersectUnIndexedLines;
  24619. /** @hidden */
  24620. private _intersectTriangles;
  24621. /** @hidden */
  24622. private _intersectUnIndexedTriangles;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /**
  24626. * Creates a new submesh from the passed mesh
  24627. * @param newMesh defines the new hosting mesh
  24628. * @param newRenderingMesh defines an optional rendering mesh
  24629. * @returns the new submesh
  24630. */
  24631. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24632. /**
  24633. * Release associated resources
  24634. */
  24635. dispose(): void;
  24636. /**
  24637. * Gets the class name
  24638. * @returns the string "SubMesh".
  24639. */
  24640. getClassName(): string;
  24641. /**
  24642. * Creates a new submesh from indices data
  24643. * @param materialIndex the index of the main mesh material
  24644. * @param startIndex the index where to start the copy in the mesh indices array
  24645. * @param indexCount the number of indices to copy then from the startIndex
  24646. * @param mesh the main mesh to create the submesh from
  24647. * @param renderingMesh the optional rendering mesh
  24648. * @returns a new submesh
  24649. */
  24650. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24651. }
  24652. }
  24653. declare module BABYLON {
  24654. /**
  24655. * Class used to represent data loading progression
  24656. */
  24657. export class SceneLoaderFlags {
  24658. private static _ForceFullSceneLoadingForIncremental;
  24659. private static _ShowLoadingScreen;
  24660. private static _CleanBoneMatrixWeights;
  24661. private static _loggingLevel;
  24662. /**
  24663. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24664. */
  24665. static get ForceFullSceneLoadingForIncremental(): boolean;
  24666. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24667. /**
  24668. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24669. */
  24670. static get ShowLoadingScreen(): boolean;
  24671. static set ShowLoadingScreen(value: boolean);
  24672. /**
  24673. * Defines the current logging level (while loading the scene)
  24674. * @ignorenaming
  24675. */
  24676. static get loggingLevel(): number;
  24677. static set loggingLevel(value: number);
  24678. /**
  24679. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24680. */
  24681. static get CleanBoneMatrixWeights(): boolean;
  24682. static set CleanBoneMatrixWeights(value: boolean);
  24683. }
  24684. }
  24685. declare module BABYLON {
  24686. /**
  24687. * Class used to store geometry data (vertex buffers + index buffer)
  24688. */
  24689. export class Geometry implements IGetSetVerticesData {
  24690. /**
  24691. * Gets or sets the ID of the geometry
  24692. */
  24693. id: string;
  24694. /**
  24695. * Gets or sets the unique ID of the geometry
  24696. */
  24697. uniqueId: number;
  24698. /**
  24699. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24700. */
  24701. delayLoadState: number;
  24702. /**
  24703. * Gets the file containing the data to load when running in delay load state
  24704. */
  24705. delayLoadingFile: Nullable<string>;
  24706. /**
  24707. * Callback called when the geometry is updated
  24708. */
  24709. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24710. private _scene;
  24711. private _engine;
  24712. private _meshes;
  24713. private _totalVertices;
  24714. /** @hidden */
  24715. _indices: IndicesArray;
  24716. /** @hidden */
  24717. _vertexBuffers: {
  24718. [key: string]: VertexBuffer;
  24719. };
  24720. private _isDisposed;
  24721. private _extend;
  24722. private _boundingBias;
  24723. /** @hidden */
  24724. _delayInfo: Array<string>;
  24725. private _indexBuffer;
  24726. private _indexBufferIsUpdatable;
  24727. /** @hidden */
  24728. _boundingInfo: Nullable<BoundingInfo>;
  24729. /** @hidden */
  24730. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24731. /** @hidden */
  24732. _softwareSkinningFrameId: number;
  24733. private _vertexArrayObjects;
  24734. private _updatable;
  24735. /** @hidden */
  24736. _positions: Nullable<Vector3[]>;
  24737. /**
  24738. * 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
  24739. */
  24740. get boundingBias(): Vector2;
  24741. /**
  24742. * 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
  24743. */
  24744. set boundingBias(value: Vector2);
  24745. /**
  24746. * Static function used to attach a new empty geometry to a mesh
  24747. * @param mesh defines the mesh to attach the geometry to
  24748. * @returns the new Geometry
  24749. */
  24750. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24751. /** Get the list of meshes using this geometry */
  24752. get meshes(): Mesh[];
  24753. /**
  24754. * Creates a new geometry
  24755. * @param id defines the unique ID
  24756. * @param scene defines the hosting scene
  24757. * @param vertexData defines the VertexData used to get geometry data
  24758. * @param updatable defines if geometry must be updatable (false by default)
  24759. * @param mesh defines the mesh that will be associated with the geometry
  24760. */
  24761. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24762. /**
  24763. * Gets the current extend of the geometry
  24764. */
  24765. get extend(): {
  24766. minimum: Vector3;
  24767. maximum: Vector3;
  24768. };
  24769. /**
  24770. * Gets the hosting scene
  24771. * @returns the hosting Scene
  24772. */
  24773. getScene(): Scene;
  24774. /**
  24775. * Gets the hosting engine
  24776. * @returns the hosting Engine
  24777. */
  24778. getEngine(): Engine;
  24779. /**
  24780. * Defines if the geometry is ready to use
  24781. * @returns true if the geometry is ready to be used
  24782. */
  24783. isReady(): boolean;
  24784. /**
  24785. * Gets a value indicating that the geometry should not be serialized
  24786. */
  24787. get doNotSerialize(): boolean;
  24788. /** @hidden */
  24789. _rebuild(): void;
  24790. /**
  24791. * Affects all geometry data in one call
  24792. * @param vertexData defines the geometry data
  24793. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24794. */
  24795. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24796. /**
  24797. * Set specific vertex data
  24798. * @param kind defines the data kind (Position, normal, etc...)
  24799. * @param data defines the vertex data to use
  24800. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24801. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24802. */
  24803. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24804. /**
  24805. * Removes a specific vertex data
  24806. * @param kind defines the data kind (Position, normal, etc...)
  24807. */
  24808. removeVerticesData(kind: string): void;
  24809. /**
  24810. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24811. * @param buffer defines the vertex buffer to use
  24812. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24813. */
  24814. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24815. /**
  24816. * Update a specific vertex buffer
  24817. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24818. * It will do nothing if the buffer is not updatable
  24819. * @param kind defines the data kind (Position, normal, etc...)
  24820. * @param data defines the data to use
  24821. * @param offset defines the offset in the target buffer where to store the data
  24822. * @param useBytes set to true if the offset is in bytes
  24823. */
  24824. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24825. /**
  24826. * Update a specific vertex buffer
  24827. * This function will create a new buffer if the current one is not updatable
  24828. * @param kind defines the data kind (Position, normal, etc...)
  24829. * @param data defines the data to use
  24830. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24831. */
  24832. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24833. private _updateBoundingInfo;
  24834. /** @hidden */
  24835. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24836. /**
  24837. * Gets total number of vertices
  24838. * @returns the total number of vertices
  24839. */
  24840. getTotalVertices(): number;
  24841. /**
  24842. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24843. * @param kind defines the data kind (Position, normal, etc...)
  24844. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24845. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24846. * @returns a float array containing vertex data
  24847. */
  24848. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24849. /**
  24850. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24851. * @param kind defines the data kind (Position, normal, etc...)
  24852. * @returns true if the vertex buffer with the specified kind is updatable
  24853. */
  24854. isVertexBufferUpdatable(kind: string): boolean;
  24855. /**
  24856. * Gets a specific vertex buffer
  24857. * @param kind defines the data kind (Position, normal, etc...)
  24858. * @returns a VertexBuffer
  24859. */
  24860. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24861. /**
  24862. * Returns all vertex buffers
  24863. * @return an object holding all vertex buffers indexed by kind
  24864. */
  24865. getVertexBuffers(): Nullable<{
  24866. [key: string]: VertexBuffer;
  24867. }>;
  24868. /**
  24869. * Gets a boolean indicating if specific vertex buffer is present
  24870. * @param kind defines the data kind (Position, normal, etc...)
  24871. * @returns true if data is present
  24872. */
  24873. isVerticesDataPresent(kind: string): boolean;
  24874. /**
  24875. * Gets a list of all attached data kinds (Position, normal, etc...)
  24876. * @returns a list of string containing all kinds
  24877. */
  24878. getVerticesDataKinds(): string[];
  24879. /**
  24880. * Update index buffer
  24881. * @param indices defines the indices to store in the index buffer
  24882. * @param offset defines the offset in the target buffer where to store the data
  24883. * @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)
  24884. */
  24885. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24886. /**
  24887. * Creates a new index buffer
  24888. * @param indices defines the indices to store in the index buffer
  24889. * @param totalVertices defines the total number of vertices (could be null)
  24890. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24891. */
  24892. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24893. /**
  24894. * Return the total number of indices
  24895. * @returns the total number of indices
  24896. */
  24897. getTotalIndices(): number;
  24898. /**
  24899. * Gets the index buffer array
  24900. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24902. * @returns the index buffer array
  24903. */
  24904. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24905. /**
  24906. * Gets the index buffer
  24907. * @return the index buffer
  24908. */
  24909. getIndexBuffer(): Nullable<DataBuffer>;
  24910. /** @hidden */
  24911. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24912. /**
  24913. * Release the associated resources for a specific mesh
  24914. * @param mesh defines the source mesh
  24915. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24916. */
  24917. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24918. /**
  24919. * Apply current geometry to a given mesh
  24920. * @param mesh defines the mesh to apply geometry to
  24921. */
  24922. applyToMesh(mesh: Mesh): void;
  24923. private _updateExtend;
  24924. private _applyToMesh;
  24925. private notifyUpdate;
  24926. /**
  24927. * Load the geometry if it was flagged as delay loaded
  24928. * @param scene defines the hosting scene
  24929. * @param onLoaded defines a callback called when the geometry is loaded
  24930. */
  24931. load(scene: Scene, onLoaded?: () => void): void;
  24932. private _queueLoad;
  24933. /**
  24934. * Invert the geometry to move from a right handed system to a left handed one.
  24935. */
  24936. toLeftHanded(): void;
  24937. /** @hidden */
  24938. _resetPointsArrayCache(): void;
  24939. /** @hidden */
  24940. _generatePointsArray(): boolean;
  24941. /**
  24942. * Gets a value indicating if the geometry is disposed
  24943. * @returns true if the geometry was disposed
  24944. */
  24945. isDisposed(): boolean;
  24946. private _disposeVertexArrayObjects;
  24947. /**
  24948. * Free all associated resources
  24949. */
  24950. dispose(): void;
  24951. /**
  24952. * Clone the current geometry into a new geometry
  24953. * @param id defines the unique ID of the new geometry
  24954. * @returns a new geometry object
  24955. */
  24956. copy(id: string): Geometry;
  24957. /**
  24958. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24959. * @return a JSON representation of the current geometry data (without the vertices data)
  24960. */
  24961. serialize(): any;
  24962. private toNumberArray;
  24963. /**
  24964. * Serialize all vertices data into a JSON oject
  24965. * @returns a JSON representation of the current geometry data
  24966. */
  24967. serializeVerticeData(): any;
  24968. /**
  24969. * Extracts a clone of a mesh geometry
  24970. * @param mesh defines the source mesh
  24971. * @param id defines the unique ID of the new geometry object
  24972. * @returns the new geometry object
  24973. */
  24974. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24975. /**
  24976. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24977. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24978. * Be aware Math.random() could cause collisions, but:
  24979. * "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"
  24980. * @returns a string containing a new GUID
  24981. */
  24982. static RandomId(): string;
  24983. /** @hidden */
  24984. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24985. private static _CleanMatricesWeights;
  24986. /**
  24987. * Create a new geometry from persisted data (Using .babylon file format)
  24988. * @param parsedVertexData defines the persisted data
  24989. * @param scene defines the hosting scene
  24990. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24991. * @returns the new geometry object
  24992. */
  24993. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24994. }
  24995. }
  24996. declare module BABYLON {
  24997. /**
  24998. * Define an interface for all classes that will get and set the data on vertices
  24999. */
  25000. export interface IGetSetVerticesData {
  25001. /**
  25002. * Gets a boolean indicating if specific vertex data is present
  25003. * @param kind defines the vertex data kind to use
  25004. * @returns true is data kind is present
  25005. */
  25006. isVerticesDataPresent(kind: string): boolean;
  25007. /**
  25008. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25009. * @param kind defines the data kind (Position, normal, etc...)
  25010. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25011. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25012. * @returns a float array containing vertex data
  25013. */
  25014. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25015. /**
  25016. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25017. * @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.
  25018. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25019. * @returns the indices array or an empty array if the mesh has no geometry
  25020. */
  25021. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25022. /**
  25023. * Set specific vertex data
  25024. * @param kind defines the data kind (Position, normal, etc...)
  25025. * @param data defines the vertex data to use
  25026. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25027. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25028. */
  25029. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25030. /**
  25031. * Update a specific associated vertex buffer
  25032. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25033. * - VertexBuffer.PositionKind
  25034. * - VertexBuffer.UVKind
  25035. * - VertexBuffer.UV2Kind
  25036. * - VertexBuffer.UV3Kind
  25037. * - VertexBuffer.UV4Kind
  25038. * - VertexBuffer.UV5Kind
  25039. * - VertexBuffer.UV6Kind
  25040. * - VertexBuffer.ColorKind
  25041. * - VertexBuffer.MatricesIndicesKind
  25042. * - VertexBuffer.MatricesIndicesExtraKind
  25043. * - VertexBuffer.MatricesWeightsKind
  25044. * - VertexBuffer.MatricesWeightsExtraKind
  25045. * @param data defines the data source
  25046. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25047. * @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)
  25048. */
  25049. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25050. /**
  25051. * Creates a new index buffer
  25052. * @param indices defines the indices to store in the index buffer
  25053. * @param totalVertices defines the total number of vertices (could be null)
  25054. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25055. */
  25056. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25057. }
  25058. /**
  25059. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25060. */
  25061. export class VertexData {
  25062. /**
  25063. * Mesh side orientation : usually the external or front surface
  25064. */
  25065. static readonly FRONTSIDE: number;
  25066. /**
  25067. * Mesh side orientation : usually the internal or back surface
  25068. */
  25069. static readonly BACKSIDE: number;
  25070. /**
  25071. * Mesh side orientation : both internal and external or front and back surfaces
  25072. */
  25073. static readonly DOUBLESIDE: number;
  25074. /**
  25075. * Mesh side orientation : by default, `FRONTSIDE`
  25076. */
  25077. static readonly DEFAULTSIDE: number;
  25078. /**
  25079. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25080. */
  25081. positions: Nullable<FloatArray>;
  25082. /**
  25083. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25084. */
  25085. normals: Nullable<FloatArray>;
  25086. /**
  25087. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25088. */
  25089. tangents: Nullable<FloatArray>;
  25090. /**
  25091. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25092. */
  25093. uvs: Nullable<FloatArray>;
  25094. /**
  25095. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25096. */
  25097. uvs2: Nullable<FloatArray>;
  25098. /**
  25099. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25100. */
  25101. uvs3: Nullable<FloatArray>;
  25102. /**
  25103. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25104. */
  25105. uvs4: Nullable<FloatArray>;
  25106. /**
  25107. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25108. */
  25109. uvs5: Nullable<FloatArray>;
  25110. /**
  25111. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25112. */
  25113. uvs6: Nullable<FloatArray>;
  25114. /**
  25115. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25116. */
  25117. colors: Nullable<FloatArray>;
  25118. /**
  25119. * 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).
  25120. */
  25121. matricesIndices: Nullable<FloatArray>;
  25122. /**
  25123. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25124. */
  25125. matricesWeights: Nullable<FloatArray>;
  25126. /**
  25127. * An array extending the number of possible indices
  25128. */
  25129. matricesIndicesExtra: Nullable<FloatArray>;
  25130. /**
  25131. * An array extending the number of possible weights when the number of indices is extended
  25132. */
  25133. matricesWeightsExtra: Nullable<FloatArray>;
  25134. /**
  25135. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25136. */
  25137. indices: Nullable<IndicesArray>;
  25138. /**
  25139. * Uses the passed data array to set the set the values for the specified kind of data
  25140. * @param data a linear array of floating numbers
  25141. * @param kind the type of data that is being set, eg positions, colors etc
  25142. */
  25143. set(data: FloatArray, kind: string): void;
  25144. /**
  25145. * Associates the vertexData to the passed Mesh.
  25146. * Sets it as updatable or not (default `false`)
  25147. * @param mesh the mesh the vertexData is applied to
  25148. * @param updatable when used and having the value true allows new data to update the vertexData
  25149. * @returns the VertexData
  25150. */
  25151. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25152. /**
  25153. * Associates the vertexData to the passed Geometry.
  25154. * Sets it as updatable or not (default `false`)
  25155. * @param geometry the geometry the vertexData is applied to
  25156. * @param updatable when used and having the value true allows new data to update the vertexData
  25157. * @returns VertexData
  25158. */
  25159. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25160. /**
  25161. * Updates the associated mesh
  25162. * @param mesh the mesh to be updated
  25163. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25164. * @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
  25165. * @returns VertexData
  25166. */
  25167. updateMesh(mesh: Mesh): VertexData;
  25168. /**
  25169. * Updates the associated geometry
  25170. * @param geometry the geometry to be updated
  25171. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25172. * @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
  25173. * @returns VertexData.
  25174. */
  25175. updateGeometry(geometry: Geometry): VertexData;
  25176. private _applyTo;
  25177. private _update;
  25178. /**
  25179. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25180. * @param matrix the transforming matrix
  25181. * @returns the VertexData
  25182. */
  25183. transform(matrix: Matrix): VertexData;
  25184. /**
  25185. * Merges the passed VertexData into the current one
  25186. * @param other the VertexData to be merged into the current one
  25187. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25188. * @returns the modified VertexData
  25189. */
  25190. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25191. private _mergeElement;
  25192. private _validate;
  25193. /**
  25194. * Serializes the VertexData
  25195. * @returns a serialized object
  25196. */
  25197. serialize(): any;
  25198. /**
  25199. * Extracts the vertexData from a mesh
  25200. * @param mesh the mesh from which to extract the VertexData
  25201. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25202. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25203. * @returns the object VertexData associated to the passed mesh
  25204. */
  25205. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25206. /**
  25207. * Extracts the vertexData from the geometry
  25208. * @param geometry the geometry from which to extract the VertexData
  25209. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25210. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25211. * @returns the object VertexData associated to the passed mesh
  25212. */
  25213. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25214. private static _ExtractFrom;
  25215. /**
  25216. * Creates the VertexData for a Ribbon
  25217. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25218. * * pathArray array of paths, each of which an array of successive Vector3
  25219. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25220. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25221. * * 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
  25222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25223. * * 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)
  25224. * * 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)
  25225. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25226. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25227. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25228. * @returns the VertexData of the ribbon
  25229. */
  25230. static CreateRibbon(options: {
  25231. pathArray: Vector3[][];
  25232. closeArray?: boolean;
  25233. closePath?: boolean;
  25234. offset?: number;
  25235. sideOrientation?: number;
  25236. frontUVs?: Vector4;
  25237. backUVs?: Vector4;
  25238. invertUV?: boolean;
  25239. uvs?: Vector2[];
  25240. colors?: Color4[];
  25241. }): VertexData;
  25242. /**
  25243. * Creates the VertexData for a box
  25244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25245. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25246. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25247. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25248. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25249. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25250. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25252. * * 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)
  25253. * * 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)
  25254. * @returns the VertexData of the box
  25255. */
  25256. static CreateBox(options: {
  25257. size?: number;
  25258. width?: number;
  25259. height?: number;
  25260. depth?: number;
  25261. faceUV?: Vector4[];
  25262. faceColors?: Color4[];
  25263. sideOrientation?: number;
  25264. frontUVs?: Vector4;
  25265. backUVs?: Vector4;
  25266. }): VertexData;
  25267. /**
  25268. * Creates the VertexData for a tiled box
  25269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25270. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25271. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25272. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25274. * @returns the VertexData of the box
  25275. */
  25276. static CreateTiledBox(options: {
  25277. pattern?: number;
  25278. width?: number;
  25279. height?: number;
  25280. depth?: number;
  25281. tileSize?: number;
  25282. tileWidth?: number;
  25283. tileHeight?: number;
  25284. alignHorizontal?: number;
  25285. alignVertical?: number;
  25286. faceUV?: Vector4[];
  25287. faceColors?: Color4[];
  25288. sideOrientation?: number;
  25289. }): VertexData;
  25290. /**
  25291. * Creates the VertexData for a tiled plane
  25292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25293. * * pattern a limited pattern arrangement depending on the number
  25294. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25295. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25296. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25298. * * 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)
  25299. * * 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)
  25300. * @returns the VertexData of the tiled plane
  25301. */
  25302. static CreateTiledPlane(options: {
  25303. pattern?: number;
  25304. tileSize?: number;
  25305. tileWidth?: number;
  25306. tileHeight?: number;
  25307. size?: number;
  25308. width?: number;
  25309. height?: number;
  25310. alignHorizontal?: number;
  25311. alignVertical?: number;
  25312. sideOrientation?: number;
  25313. frontUVs?: Vector4;
  25314. backUVs?: Vector4;
  25315. }): VertexData;
  25316. /**
  25317. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25319. * * segments sets the number of horizontal strips optional, default 32
  25320. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25321. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25322. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25323. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25324. * * 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
  25325. * * 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
  25326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25327. * * 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)
  25328. * * 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)
  25329. * @returns the VertexData of the ellipsoid
  25330. */
  25331. static CreateSphere(options: {
  25332. segments?: number;
  25333. diameter?: number;
  25334. diameterX?: number;
  25335. diameterY?: number;
  25336. diameterZ?: number;
  25337. arc?: number;
  25338. slice?: number;
  25339. sideOrientation?: number;
  25340. frontUVs?: Vector4;
  25341. backUVs?: Vector4;
  25342. }): VertexData;
  25343. /**
  25344. * Creates the VertexData for a cylinder, cone or prism
  25345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25346. * * height sets the height (y direction) of the cylinder, optional, default 2
  25347. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25348. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25349. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25351. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25352. * * 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
  25353. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25354. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25355. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25356. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25358. * * 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)
  25359. * * 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)
  25360. * @returns the VertexData of the cylinder, cone or prism
  25361. */
  25362. static CreateCylinder(options: {
  25363. height?: number;
  25364. diameterTop?: number;
  25365. diameterBottom?: number;
  25366. diameter?: number;
  25367. tessellation?: number;
  25368. subdivisions?: number;
  25369. arc?: number;
  25370. faceColors?: Color4[];
  25371. faceUV?: Vector4[];
  25372. hasRings?: boolean;
  25373. enclose?: boolean;
  25374. sideOrientation?: number;
  25375. frontUVs?: Vector4;
  25376. backUVs?: Vector4;
  25377. }): VertexData;
  25378. /**
  25379. * Creates the VertexData for a torus
  25380. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25381. * * diameter the diameter of the torus, optional default 1
  25382. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25383. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25385. * * 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)
  25386. * * 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)
  25387. * @returns the VertexData of the torus
  25388. */
  25389. static CreateTorus(options: {
  25390. diameter?: number;
  25391. thickness?: number;
  25392. tessellation?: number;
  25393. sideOrientation?: number;
  25394. frontUVs?: Vector4;
  25395. backUVs?: Vector4;
  25396. }): VertexData;
  25397. /**
  25398. * Creates the VertexData of the LineSystem
  25399. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25400. * - lines an array of lines, each line being an array of successive Vector3
  25401. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25402. * @returns the VertexData of the LineSystem
  25403. */
  25404. static CreateLineSystem(options: {
  25405. lines: Vector3[][];
  25406. colors?: Nullable<Color4[][]>;
  25407. }): VertexData;
  25408. /**
  25409. * Create the VertexData for a DashedLines
  25410. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25411. * - points an array successive Vector3
  25412. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25413. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25414. * - dashNb the intended total number of dashes, optional, default 200
  25415. * @returns the VertexData for the DashedLines
  25416. */
  25417. static CreateDashedLines(options: {
  25418. points: Vector3[];
  25419. dashSize?: number;
  25420. gapSize?: number;
  25421. dashNb?: number;
  25422. }): VertexData;
  25423. /**
  25424. * Creates the VertexData for a Ground
  25425. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25426. * - width the width (x direction) of the ground, optional, default 1
  25427. * - height the height (z direction) of the ground, optional, default 1
  25428. * - subdivisions the number of subdivisions per side, optional, default 1
  25429. * @returns the VertexData of the Ground
  25430. */
  25431. static CreateGround(options: {
  25432. width?: number;
  25433. height?: number;
  25434. subdivisions?: number;
  25435. subdivisionsX?: number;
  25436. subdivisionsY?: number;
  25437. }): VertexData;
  25438. /**
  25439. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25440. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25441. * * xmin the ground minimum X coordinate, optional, default -1
  25442. * * zmin the ground minimum Z coordinate, optional, default -1
  25443. * * xmax the ground maximum X coordinate, optional, default 1
  25444. * * zmax the ground maximum Z coordinate, optional, default 1
  25445. * * 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}
  25446. * * 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}
  25447. * @returns the VertexData of the TiledGround
  25448. */
  25449. static CreateTiledGround(options: {
  25450. xmin: number;
  25451. zmin: number;
  25452. xmax: number;
  25453. zmax: number;
  25454. subdivisions?: {
  25455. w: number;
  25456. h: number;
  25457. };
  25458. precision?: {
  25459. w: number;
  25460. h: number;
  25461. };
  25462. }): VertexData;
  25463. /**
  25464. * Creates the VertexData of the Ground designed from a heightmap
  25465. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25466. * * width the width (x direction) of the ground
  25467. * * height the height (z direction) of the ground
  25468. * * subdivisions the number of subdivisions per side
  25469. * * minHeight the minimum altitude on the ground, optional, default 0
  25470. * * maxHeight the maximum altitude on the ground, optional default 1
  25471. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25472. * * buffer the array holding the image color data
  25473. * * bufferWidth the width of image
  25474. * * bufferHeight the height of image
  25475. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25476. * @returns the VertexData of the Ground designed from a heightmap
  25477. */
  25478. static CreateGroundFromHeightMap(options: {
  25479. width: number;
  25480. height: number;
  25481. subdivisions: number;
  25482. minHeight: number;
  25483. maxHeight: number;
  25484. colorFilter: Color3;
  25485. buffer: Uint8Array;
  25486. bufferWidth: number;
  25487. bufferHeight: number;
  25488. alphaFilter: number;
  25489. }): VertexData;
  25490. /**
  25491. * Creates the VertexData for a Plane
  25492. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25493. * * size sets the width and height of the plane to the value of size, optional default 1
  25494. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25495. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25497. * * 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)
  25498. * * 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)
  25499. * @returns the VertexData of the box
  25500. */
  25501. static CreatePlane(options: {
  25502. size?: number;
  25503. width?: number;
  25504. height?: number;
  25505. sideOrientation?: number;
  25506. frontUVs?: Vector4;
  25507. backUVs?: Vector4;
  25508. }): VertexData;
  25509. /**
  25510. * Creates the VertexData of the Disc or regular Polygon
  25511. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25512. * * radius the radius of the disc, optional default 0.5
  25513. * * tessellation the number of polygon sides, optional, default 64
  25514. * * 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
  25515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25516. * * 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)
  25517. * * 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)
  25518. * @returns the VertexData of the box
  25519. */
  25520. static CreateDisc(options: {
  25521. radius?: number;
  25522. tessellation?: number;
  25523. arc?: number;
  25524. sideOrientation?: number;
  25525. frontUVs?: Vector4;
  25526. backUVs?: Vector4;
  25527. }): VertexData;
  25528. /**
  25529. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25530. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25531. * @param polygon a mesh built from polygonTriangulation.build()
  25532. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25533. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25534. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25535. * @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)
  25536. * @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)
  25537. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25538. * @returns the VertexData of the Polygon
  25539. */
  25540. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25541. /**
  25542. * Creates the VertexData of the IcoSphere
  25543. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25544. * * radius the radius of the IcoSphere, optional default 1
  25545. * * radiusX allows stretching in the x direction, optional, default radius
  25546. * * radiusY allows stretching in the y direction, optional, default radius
  25547. * * radiusZ allows stretching in the z direction, optional, default radius
  25548. * * flat when true creates a flat shaded mesh, optional, default true
  25549. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25551. * * 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)
  25552. * * 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)
  25553. * @returns the VertexData of the IcoSphere
  25554. */
  25555. static CreateIcoSphere(options: {
  25556. radius?: number;
  25557. radiusX?: number;
  25558. radiusY?: number;
  25559. radiusZ?: number;
  25560. flat?: boolean;
  25561. subdivisions?: number;
  25562. sideOrientation?: number;
  25563. frontUVs?: Vector4;
  25564. backUVs?: Vector4;
  25565. }): VertexData;
  25566. /**
  25567. * Creates the VertexData for a Polyhedron
  25568. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25569. * * type provided types are:
  25570. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25571. * * 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)
  25572. * * size the size of the IcoSphere, optional default 1
  25573. * * sizeX allows stretching in the x direction, optional, default size
  25574. * * sizeY allows stretching in the y direction, optional, default size
  25575. * * sizeZ allows stretching in the z direction, optional, default size
  25576. * * 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
  25577. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25578. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25579. * * flat when true creates a flat shaded mesh, optional, default true
  25580. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25582. * * 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)
  25583. * * 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)
  25584. * @returns the VertexData of the Polyhedron
  25585. */
  25586. static CreatePolyhedron(options: {
  25587. type?: number;
  25588. size?: number;
  25589. sizeX?: number;
  25590. sizeY?: number;
  25591. sizeZ?: number;
  25592. custom?: any;
  25593. faceUV?: Vector4[];
  25594. faceColors?: Color4[];
  25595. flat?: boolean;
  25596. sideOrientation?: number;
  25597. frontUVs?: Vector4;
  25598. backUVs?: Vector4;
  25599. }): VertexData;
  25600. /**
  25601. * Creates the VertexData for a TorusKnot
  25602. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25603. * * radius the radius of the torus knot, optional, default 2
  25604. * * tube the thickness of the tube, optional, default 0.5
  25605. * * radialSegments the number of sides on each tube segments, optional, default 32
  25606. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25607. * * p the number of windings around the z axis, optional, default 2
  25608. * * q the number of windings around the x axis, optional, default 3
  25609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25610. * * 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)
  25611. * * 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)
  25612. * @returns the VertexData of the Torus Knot
  25613. */
  25614. static CreateTorusKnot(options: {
  25615. radius?: number;
  25616. tube?: number;
  25617. radialSegments?: number;
  25618. tubularSegments?: number;
  25619. p?: number;
  25620. q?: number;
  25621. sideOrientation?: number;
  25622. frontUVs?: Vector4;
  25623. backUVs?: Vector4;
  25624. }): VertexData;
  25625. /**
  25626. * Compute normals for given positions and indices
  25627. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25628. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25629. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25630. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25631. * * facetNormals : optional array of facet normals (vector3)
  25632. * * facetPositions : optional array of facet positions (vector3)
  25633. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25634. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25635. * * bInfo : optional bounding info, required for facetPartitioning computation
  25636. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25637. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25638. * * useRightHandedSystem: optional boolean to for right handed system computation
  25639. * * depthSort : optional boolean to enable the facet depth sort computation
  25640. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25641. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25642. */
  25643. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25644. facetNormals?: any;
  25645. facetPositions?: any;
  25646. facetPartitioning?: any;
  25647. ratio?: number;
  25648. bInfo?: any;
  25649. bbSize?: Vector3;
  25650. subDiv?: any;
  25651. useRightHandedSystem?: boolean;
  25652. depthSort?: boolean;
  25653. distanceTo?: Vector3;
  25654. depthSortedFacets?: any;
  25655. }): void;
  25656. /** @hidden */
  25657. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25658. /**
  25659. * Applies VertexData created from the imported parameters to the geometry
  25660. * @param parsedVertexData the parsed data from an imported file
  25661. * @param geometry the geometry to apply the VertexData to
  25662. */
  25663. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25664. }
  25665. }
  25666. declare module BABYLON {
  25667. /**
  25668. * Defines a target to use with MorphTargetManager
  25669. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25670. */
  25671. export class MorphTarget implements IAnimatable {
  25672. /** defines the name of the target */
  25673. name: string;
  25674. /**
  25675. * Gets or sets the list of animations
  25676. */
  25677. animations: Animation[];
  25678. private _scene;
  25679. private _positions;
  25680. private _normals;
  25681. private _tangents;
  25682. private _uvs;
  25683. private _influence;
  25684. private _uniqueId;
  25685. /**
  25686. * Observable raised when the influence changes
  25687. */
  25688. onInfluenceChanged: Observable<boolean>;
  25689. /** @hidden */
  25690. _onDataLayoutChanged: Observable<void>;
  25691. /**
  25692. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25693. */
  25694. get influence(): number;
  25695. set influence(influence: number);
  25696. /**
  25697. * Gets or sets the id of the morph Target
  25698. */
  25699. id: string;
  25700. private _animationPropertiesOverride;
  25701. /**
  25702. * Gets or sets the animation properties override
  25703. */
  25704. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25705. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25706. /**
  25707. * Creates a new MorphTarget
  25708. * @param name defines the name of the target
  25709. * @param influence defines the influence to use
  25710. * @param scene defines the scene the morphtarget belongs to
  25711. */
  25712. constructor(
  25713. /** defines the name of the target */
  25714. name: string, influence?: number, scene?: Nullable<Scene>);
  25715. /**
  25716. * Gets the unique ID of this manager
  25717. */
  25718. get uniqueId(): number;
  25719. /**
  25720. * Gets a boolean defining if the target contains position data
  25721. */
  25722. get hasPositions(): boolean;
  25723. /**
  25724. * Gets a boolean defining if the target contains normal data
  25725. */
  25726. get hasNormals(): boolean;
  25727. /**
  25728. * Gets a boolean defining if the target contains tangent data
  25729. */
  25730. get hasTangents(): boolean;
  25731. /**
  25732. * Gets a boolean defining if the target contains texture coordinates data
  25733. */
  25734. get hasUVs(): boolean;
  25735. /**
  25736. * Affects position data to this target
  25737. * @param data defines the position data to use
  25738. */
  25739. setPositions(data: Nullable<FloatArray>): void;
  25740. /**
  25741. * Gets the position data stored in this target
  25742. * @returns a FloatArray containing the position data (or null if not present)
  25743. */
  25744. getPositions(): Nullable<FloatArray>;
  25745. /**
  25746. * Affects normal data to this target
  25747. * @param data defines the normal data to use
  25748. */
  25749. setNormals(data: Nullable<FloatArray>): void;
  25750. /**
  25751. * Gets the normal data stored in this target
  25752. * @returns a FloatArray containing the normal data (or null if not present)
  25753. */
  25754. getNormals(): Nullable<FloatArray>;
  25755. /**
  25756. * Affects tangent data to this target
  25757. * @param data defines the tangent data to use
  25758. */
  25759. setTangents(data: Nullable<FloatArray>): void;
  25760. /**
  25761. * Gets the tangent data stored in this target
  25762. * @returns a FloatArray containing the tangent data (or null if not present)
  25763. */
  25764. getTangents(): Nullable<FloatArray>;
  25765. /**
  25766. * Affects texture coordinates data to this target
  25767. * @param data defines the texture coordinates data to use
  25768. */
  25769. setUVs(data: Nullable<FloatArray>): void;
  25770. /**
  25771. * Gets the texture coordinates data stored in this target
  25772. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25773. */
  25774. getUVs(): Nullable<FloatArray>;
  25775. /**
  25776. * Clone the current target
  25777. * @returns a new MorphTarget
  25778. */
  25779. clone(): MorphTarget;
  25780. /**
  25781. * Serializes the current target into a Serialization object
  25782. * @returns the serialized object
  25783. */
  25784. serialize(): any;
  25785. /**
  25786. * Returns the string "MorphTarget"
  25787. * @returns "MorphTarget"
  25788. */
  25789. getClassName(): string;
  25790. /**
  25791. * Creates a new target from serialized data
  25792. * @param serializationObject defines the serialized data to use
  25793. * @returns a new MorphTarget
  25794. */
  25795. static Parse(serializationObject: any): MorphTarget;
  25796. /**
  25797. * Creates a MorphTarget from mesh data
  25798. * @param mesh defines the source mesh
  25799. * @param name defines the name to use for the new target
  25800. * @param influence defines the influence to attach to the target
  25801. * @returns a new MorphTarget
  25802. */
  25803. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25804. }
  25805. }
  25806. declare module BABYLON {
  25807. /**
  25808. * This class is used to deform meshes using morphing between different targets
  25809. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25810. */
  25811. export class MorphTargetManager {
  25812. private _targets;
  25813. private _targetInfluenceChangedObservers;
  25814. private _targetDataLayoutChangedObservers;
  25815. private _activeTargets;
  25816. private _scene;
  25817. private _influences;
  25818. private _supportsNormals;
  25819. private _supportsTangents;
  25820. private _supportsUVs;
  25821. private _vertexCount;
  25822. private _uniqueId;
  25823. private _tempInfluences;
  25824. /**
  25825. * Gets or sets a boolean indicating if normals must be morphed
  25826. */
  25827. enableNormalMorphing: boolean;
  25828. /**
  25829. * Gets or sets a boolean indicating if tangents must be morphed
  25830. */
  25831. enableTangentMorphing: boolean;
  25832. /**
  25833. * Gets or sets a boolean indicating if UV must be morphed
  25834. */
  25835. enableUVMorphing: boolean;
  25836. /**
  25837. * Creates a new MorphTargetManager
  25838. * @param scene defines the current scene
  25839. */
  25840. constructor(scene?: Nullable<Scene>);
  25841. /**
  25842. * Gets the unique ID of this manager
  25843. */
  25844. get uniqueId(): number;
  25845. /**
  25846. * Gets the number of vertices handled by this manager
  25847. */
  25848. get vertexCount(): number;
  25849. /**
  25850. * Gets a boolean indicating if this manager supports morphing of normals
  25851. */
  25852. get supportsNormals(): boolean;
  25853. /**
  25854. * Gets a boolean indicating if this manager supports morphing of tangents
  25855. */
  25856. get supportsTangents(): boolean;
  25857. /**
  25858. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25859. */
  25860. get supportsUVs(): boolean;
  25861. /**
  25862. * Gets the number of targets stored in this manager
  25863. */
  25864. get numTargets(): number;
  25865. /**
  25866. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25867. */
  25868. get numInfluencers(): number;
  25869. /**
  25870. * Gets the list of influences (one per target)
  25871. */
  25872. get influences(): Float32Array;
  25873. /**
  25874. * Gets the active target at specified index. An active target is a target with an influence > 0
  25875. * @param index defines the index to check
  25876. * @returns the requested target
  25877. */
  25878. getActiveTarget(index: number): MorphTarget;
  25879. /**
  25880. * Gets the target at specified index
  25881. * @param index defines the index to check
  25882. * @returns the requested target
  25883. */
  25884. getTarget(index: number): MorphTarget;
  25885. /**
  25886. * Add a new target to this manager
  25887. * @param target defines the target to add
  25888. */
  25889. addTarget(target: MorphTarget): void;
  25890. /**
  25891. * Removes a target from the manager
  25892. * @param target defines the target to remove
  25893. */
  25894. removeTarget(target: MorphTarget): void;
  25895. /**
  25896. * Clone the current manager
  25897. * @returns a new MorphTargetManager
  25898. */
  25899. clone(): MorphTargetManager;
  25900. /**
  25901. * Serializes the current manager into a Serialization object
  25902. * @returns the serialized object
  25903. */
  25904. serialize(): any;
  25905. private _syncActiveTargets;
  25906. /**
  25907. * Syncrhonize the targets with all the meshes using this morph target manager
  25908. */
  25909. synchronize(): void;
  25910. /**
  25911. * Creates a new MorphTargetManager from serialized data
  25912. * @param serializationObject defines the serialized data
  25913. * @param scene defines the hosting scene
  25914. * @returns the new MorphTargetManager
  25915. */
  25916. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25917. }
  25918. }
  25919. declare module BABYLON {
  25920. /**
  25921. * Class used to represent a specific level of detail of a mesh
  25922. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25923. */
  25924. export class MeshLODLevel {
  25925. /** Defines the distance where this level should start being displayed */
  25926. distance: number;
  25927. /** Defines the mesh to use to render this level */
  25928. mesh: Nullable<Mesh>;
  25929. /**
  25930. * Creates a new LOD level
  25931. * @param distance defines the distance where this level should star being displayed
  25932. * @param mesh defines the mesh to use to render this level
  25933. */
  25934. constructor(
  25935. /** Defines the distance where this level should start being displayed */
  25936. distance: number,
  25937. /** Defines the mesh to use to render this level */
  25938. mesh: Nullable<Mesh>);
  25939. }
  25940. }
  25941. declare module BABYLON {
  25942. /**
  25943. * Mesh representing the gorund
  25944. */
  25945. export class GroundMesh extends Mesh {
  25946. /** If octree should be generated */
  25947. generateOctree: boolean;
  25948. private _heightQuads;
  25949. /** @hidden */
  25950. _subdivisionsX: number;
  25951. /** @hidden */
  25952. _subdivisionsY: number;
  25953. /** @hidden */
  25954. _width: number;
  25955. /** @hidden */
  25956. _height: number;
  25957. /** @hidden */
  25958. _minX: number;
  25959. /** @hidden */
  25960. _maxX: number;
  25961. /** @hidden */
  25962. _minZ: number;
  25963. /** @hidden */
  25964. _maxZ: number;
  25965. constructor(name: string, scene: Scene);
  25966. /**
  25967. * "GroundMesh"
  25968. * @returns "GroundMesh"
  25969. */
  25970. getClassName(): string;
  25971. /**
  25972. * The minimum of x and y subdivisions
  25973. */
  25974. get subdivisions(): number;
  25975. /**
  25976. * X subdivisions
  25977. */
  25978. get subdivisionsX(): number;
  25979. /**
  25980. * Y subdivisions
  25981. */
  25982. get subdivisionsY(): number;
  25983. /**
  25984. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25985. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25986. * @param chunksCount the number of subdivisions for x and y
  25987. * @param octreeBlocksSize (Default: 32)
  25988. */
  25989. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25990. /**
  25991. * Returns a height (y) value in the Worl system :
  25992. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25993. * @param x x coordinate
  25994. * @param z z coordinate
  25995. * @returns the ground y position if (x, z) are outside the ground surface.
  25996. */
  25997. getHeightAtCoordinates(x: number, z: number): number;
  25998. /**
  25999. * Returns a normalized vector (Vector3) orthogonal to the ground
  26000. * at the ground coordinates (x, z) expressed in the World system.
  26001. * @param x x coordinate
  26002. * @param z z coordinate
  26003. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26004. */
  26005. getNormalAtCoordinates(x: number, z: number): Vector3;
  26006. /**
  26007. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26008. * at the ground coordinates (x, z) expressed in the World system.
  26009. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26010. * @param x x coordinate
  26011. * @param z z coordinate
  26012. * @param ref vector to store the result
  26013. * @returns the GroundMesh.
  26014. */
  26015. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26016. /**
  26017. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26018. * if the ground has been updated.
  26019. * This can be used in the render loop.
  26020. * @returns the GroundMesh.
  26021. */
  26022. updateCoordinateHeights(): GroundMesh;
  26023. private _getFacetAt;
  26024. private _initHeightQuads;
  26025. private _computeHeightQuads;
  26026. /**
  26027. * Serializes this ground mesh
  26028. * @param serializationObject object to write serialization to
  26029. */
  26030. serialize(serializationObject: any): void;
  26031. /**
  26032. * Parses a serialized ground mesh
  26033. * @param parsedMesh the serialized mesh
  26034. * @param scene the scene to create the ground mesh in
  26035. * @returns the created ground mesh
  26036. */
  26037. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26038. }
  26039. }
  26040. declare module BABYLON {
  26041. /**
  26042. * Interface for Physics-Joint data
  26043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26044. */
  26045. export interface PhysicsJointData {
  26046. /**
  26047. * The main pivot of the joint
  26048. */
  26049. mainPivot?: Vector3;
  26050. /**
  26051. * The connected pivot of the joint
  26052. */
  26053. connectedPivot?: Vector3;
  26054. /**
  26055. * The main axis of the joint
  26056. */
  26057. mainAxis?: Vector3;
  26058. /**
  26059. * The connected axis of the joint
  26060. */
  26061. connectedAxis?: Vector3;
  26062. /**
  26063. * The collision of the joint
  26064. */
  26065. collision?: boolean;
  26066. /**
  26067. * Native Oimo/Cannon/Energy data
  26068. */
  26069. nativeParams?: any;
  26070. }
  26071. /**
  26072. * This is a holder class for the physics joint created by the physics plugin
  26073. * It holds a set of functions to control the underlying joint
  26074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26075. */
  26076. export class PhysicsJoint {
  26077. /**
  26078. * The type of the physics joint
  26079. */
  26080. type: number;
  26081. /**
  26082. * The data for the physics joint
  26083. */
  26084. jointData: PhysicsJointData;
  26085. private _physicsJoint;
  26086. protected _physicsPlugin: IPhysicsEnginePlugin;
  26087. /**
  26088. * Initializes the physics joint
  26089. * @param type The type of the physics joint
  26090. * @param jointData The data for the physics joint
  26091. */
  26092. constructor(
  26093. /**
  26094. * The type of the physics joint
  26095. */
  26096. type: number,
  26097. /**
  26098. * The data for the physics joint
  26099. */
  26100. jointData: PhysicsJointData);
  26101. /**
  26102. * Gets the physics joint
  26103. */
  26104. get physicsJoint(): any;
  26105. /**
  26106. * Sets the physics joint
  26107. */
  26108. set physicsJoint(newJoint: any);
  26109. /**
  26110. * Sets the physics plugin
  26111. */
  26112. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26113. /**
  26114. * Execute a function that is physics-plugin specific.
  26115. * @param {Function} func the function that will be executed.
  26116. * It accepts two parameters: the physics world and the physics joint
  26117. */
  26118. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26119. /**
  26120. * Distance-Joint type
  26121. */
  26122. static DistanceJoint: number;
  26123. /**
  26124. * Hinge-Joint type
  26125. */
  26126. static HingeJoint: number;
  26127. /**
  26128. * Ball-and-Socket joint type
  26129. */
  26130. static BallAndSocketJoint: number;
  26131. /**
  26132. * Wheel-Joint type
  26133. */
  26134. static WheelJoint: number;
  26135. /**
  26136. * Slider-Joint type
  26137. */
  26138. static SliderJoint: number;
  26139. /**
  26140. * Prismatic-Joint type
  26141. */
  26142. static PrismaticJoint: number;
  26143. /**
  26144. * Universal-Joint type
  26145. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26146. */
  26147. static UniversalJoint: number;
  26148. /**
  26149. * Hinge-Joint 2 type
  26150. */
  26151. static Hinge2Joint: number;
  26152. /**
  26153. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26154. */
  26155. static PointToPointJoint: number;
  26156. /**
  26157. * Spring-Joint type
  26158. */
  26159. static SpringJoint: number;
  26160. /**
  26161. * Lock-Joint type
  26162. */
  26163. static LockJoint: number;
  26164. }
  26165. /**
  26166. * A class representing a physics distance joint
  26167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26168. */
  26169. export class DistanceJoint extends PhysicsJoint {
  26170. /**
  26171. *
  26172. * @param jointData The data for the Distance-Joint
  26173. */
  26174. constructor(jointData: DistanceJointData);
  26175. /**
  26176. * Update the predefined distance.
  26177. * @param maxDistance The maximum preferred distance
  26178. * @param minDistance The minimum preferred distance
  26179. */
  26180. updateDistance(maxDistance: number, minDistance?: number): void;
  26181. }
  26182. /**
  26183. * Represents a Motor-Enabled Joint
  26184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26185. */
  26186. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26187. /**
  26188. * Initializes the Motor-Enabled Joint
  26189. * @param type The type of the joint
  26190. * @param jointData The physica joint data for the joint
  26191. */
  26192. constructor(type: number, jointData: PhysicsJointData);
  26193. /**
  26194. * Set the motor values.
  26195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26196. * @param force the force to apply
  26197. * @param maxForce max force for this motor.
  26198. */
  26199. setMotor(force?: number, maxForce?: number): void;
  26200. /**
  26201. * Set the motor's limits.
  26202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26203. * @param upperLimit The upper limit of the motor
  26204. * @param lowerLimit The lower limit of the motor
  26205. */
  26206. setLimit(upperLimit: number, lowerLimit?: number): void;
  26207. }
  26208. /**
  26209. * This class represents a single physics Hinge-Joint
  26210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26211. */
  26212. export class HingeJoint extends MotorEnabledJoint {
  26213. /**
  26214. * Initializes the Hinge-Joint
  26215. * @param jointData The joint data for the Hinge-Joint
  26216. */
  26217. constructor(jointData: PhysicsJointData);
  26218. /**
  26219. * Set the motor values.
  26220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26221. * @param {number} force the force to apply
  26222. * @param {number} maxForce max force for this motor.
  26223. */
  26224. setMotor(force?: number, maxForce?: number): void;
  26225. /**
  26226. * Set the motor's limits.
  26227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26228. * @param upperLimit The upper limit of the motor
  26229. * @param lowerLimit The lower limit of the motor
  26230. */
  26231. setLimit(upperLimit: number, lowerLimit?: number): void;
  26232. }
  26233. /**
  26234. * This class represents a dual hinge physics joint (same as wheel joint)
  26235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26236. */
  26237. export class Hinge2Joint extends MotorEnabledJoint {
  26238. /**
  26239. * Initializes the Hinge2-Joint
  26240. * @param jointData The joint data for the Hinge2-Joint
  26241. */
  26242. constructor(jointData: PhysicsJointData);
  26243. /**
  26244. * Set the motor values.
  26245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26246. * @param {number} targetSpeed the speed the motor is to reach
  26247. * @param {number} maxForce max force for this motor.
  26248. * @param {motorIndex} the motor's index, 0 or 1.
  26249. */
  26250. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26251. /**
  26252. * Set the motor limits.
  26253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26254. * @param {number} upperLimit the upper limit
  26255. * @param {number} lowerLimit lower limit
  26256. * @param {motorIndex} the motor's index, 0 or 1.
  26257. */
  26258. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26259. }
  26260. /**
  26261. * Interface for a motor enabled joint
  26262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26263. */
  26264. export interface IMotorEnabledJoint {
  26265. /**
  26266. * Physics joint
  26267. */
  26268. physicsJoint: any;
  26269. /**
  26270. * Sets the motor of the motor-enabled joint
  26271. * @param force The force of the motor
  26272. * @param maxForce The maximum force of the motor
  26273. * @param motorIndex The index of the motor
  26274. */
  26275. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26276. /**
  26277. * Sets the limit of the motor
  26278. * @param upperLimit The upper limit of the motor
  26279. * @param lowerLimit The lower limit of the motor
  26280. * @param motorIndex The index of the motor
  26281. */
  26282. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26283. }
  26284. /**
  26285. * Joint data for a Distance-Joint
  26286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26287. */
  26288. export interface DistanceJointData extends PhysicsJointData {
  26289. /**
  26290. * Max distance the 2 joint objects can be apart
  26291. */
  26292. maxDistance: number;
  26293. }
  26294. /**
  26295. * Joint data from a spring joint
  26296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26297. */
  26298. export interface SpringJointData extends PhysicsJointData {
  26299. /**
  26300. * Length of the spring
  26301. */
  26302. length: number;
  26303. /**
  26304. * Stiffness of the spring
  26305. */
  26306. stiffness: number;
  26307. /**
  26308. * Damping of the spring
  26309. */
  26310. damping: number;
  26311. /** this callback will be called when applying the force to the impostors. */
  26312. forceApplicationCallback: () => void;
  26313. }
  26314. }
  26315. declare module BABYLON {
  26316. /**
  26317. * Holds the data for the raycast result
  26318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26319. */
  26320. export class PhysicsRaycastResult {
  26321. private _hasHit;
  26322. private _hitDistance;
  26323. private _hitNormalWorld;
  26324. private _hitPointWorld;
  26325. private _rayFromWorld;
  26326. private _rayToWorld;
  26327. /**
  26328. * Gets if there was a hit
  26329. */
  26330. get hasHit(): boolean;
  26331. /**
  26332. * Gets the distance from the hit
  26333. */
  26334. get hitDistance(): number;
  26335. /**
  26336. * Gets the hit normal/direction in the world
  26337. */
  26338. get hitNormalWorld(): Vector3;
  26339. /**
  26340. * Gets the hit point in the world
  26341. */
  26342. get hitPointWorld(): Vector3;
  26343. /**
  26344. * Gets the ray "start point" of the ray in the world
  26345. */
  26346. get rayFromWorld(): Vector3;
  26347. /**
  26348. * Gets the ray "end point" of the ray in the world
  26349. */
  26350. get rayToWorld(): Vector3;
  26351. /**
  26352. * Sets the hit data (normal & point in world space)
  26353. * @param hitNormalWorld defines the normal in world space
  26354. * @param hitPointWorld defines the point in world space
  26355. */
  26356. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26357. /**
  26358. * Sets the distance from the start point to the hit point
  26359. * @param distance
  26360. */
  26361. setHitDistance(distance: number): void;
  26362. /**
  26363. * Calculates the distance manually
  26364. */
  26365. calculateHitDistance(): void;
  26366. /**
  26367. * Resets all the values to default
  26368. * @param from The from point on world space
  26369. * @param to The to point on world space
  26370. */
  26371. reset(from?: Vector3, to?: Vector3): void;
  26372. }
  26373. /**
  26374. * Interface for the size containing width and height
  26375. */
  26376. interface IXYZ {
  26377. /**
  26378. * X
  26379. */
  26380. x: number;
  26381. /**
  26382. * Y
  26383. */
  26384. y: number;
  26385. /**
  26386. * Z
  26387. */
  26388. z: number;
  26389. }
  26390. }
  26391. declare module BABYLON {
  26392. /**
  26393. * Interface used to describe a physics joint
  26394. */
  26395. export interface PhysicsImpostorJoint {
  26396. /** Defines the main impostor to which the joint is linked */
  26397. mainImpostor: PhysicsImpostor;
  26398. /** Defines the impostor that is connected to the main impostor using this joint */
  26399. connectedImpostor: PhysicsImpostor;
  26400. /** Defines the joint itself */
  26401. joint: PhysicsJoint;
  26402. }
  26403. /** @hidden */
  26404. export interface IPhysicsEnginePlugin {
  26405. world: any;
  26406. name: string;
  26407. setGravity(gravity: Vector3): void;
  26408. setTimeStep(timeStep: number): void;
  26409. getTimeStep(): number;
  26410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26414. removePhysicsBody(impostor: PhysicsImpostor): void;
  26415. generateJoint(joint: PhysicsImpostorJoint): void;
  26416. removeJoint(joint: PhysicsImpostorJoint): void;
  26417. isSupported(): boolean;
  26418. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26419. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26420. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26421. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26422. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26423. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26424. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26425. getBodyMass(impostor: PhysicsImpostor): number;
  26426. getBodyFriction(impostor: PhysicsImpostor): number;
  26427. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26428. getBodyRestitution(impostor: PhysicsImpostor): number;
  26429. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26430. getBodyPressure?(impostor: PhysicsImpostor): number;
  26431. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26432. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26433. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26434. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26435. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26436. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26437. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26438. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26439. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26440. sleepBody(impostor: PhysicsImpostor): void;
  26441. wakeUpBody(impostor: PhysicsImpostor): void;
  26442. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26443. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26444. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26445. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26446. getRadius(impostor: PhysicsImpostor): number;
  26447. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26448. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26449. dispose(): void;
  26450. }
  26451. /**
  26452. * Interface used to define a physics engine
  26453. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26454. */
  26455. export interface IPhysicsEngine {
  26456. /**
  26457. * Gets the gravity vector used by the simulation
  26458. */
  26459. gravity: Vector3;
  26460. /**
  26461. * Sets the gravity vector used by the simulation
  26462. * @param gravity defines the gravity vector to use
  26463. */
  26464. setGravity(gravity: Vector3): void;
  26465. /**
  26466. * Set the time step of the physics engine.
  26467. * Default is 1/60.
  26468. * To slow it down, enter 1/600 for example.
  26469. * To speed it up, 1/30
  26470. * @param newTimeStep the new timestep to apply to this world.
  26471. */
  26472. setTimeStep(newTimeStep: number): void;
  26473. /**
  26474. * Get the time step of the physics engine.
  26475. * @returns the current time step
  26476. */
  26477. getTimeStep(): number;
  26478. /**
  26479. * Set the sub time step of the physics engine.
  26480. * Default is 0 meaning there is no sub steps
  26481. * To increase physics resolution precision, set a small value (like 1 ms)
  26482. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26483. */
  26484. setSubTimeStep(subTimeStep: number): void;
  26485. /**
  26486. * Get the sub time step of the physics engine.
  26487. * @returns the current sub time step
  26488. */
  26489. getSubTimeStep(): number;
  26490. /**
  26491. * Release all resources
  26492. */
  26493. dispose(): void;
  26494. /**
  26495. * Gets the name of the current physics plugin
  26496. * @returns the name of the plugin
  26497. */
  26498. getPhysicsPluginName(): string;
  26499. /**
  26500. * Adding a new impostor for the impostor tracking.
  26501. * This will be done by the impostor itself.
  26502. * @param impostor the impostor to add
  26503. */
  26504. addImpostor(impostor: PhysicsImpostor): void;
  26505. /**
  26506. * Remove an impostor from the engine.
  26507. * This impostor and its mesh will not longer be updated by the physics engine.
  26508. * @param impostor the impostor to remove
  26509. */
  26510. removeImpostor(impostor: PhysicsImpostor): void;
  26511. /**
  26512. * Add a joint to the physics engine
  26513. * @param mainImpostor defines the main impostor to which the joint is added.
  26514. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26515. * @param joint defines the joint that will connect both impostors.
  26516. */
  26517. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26518. /**
  26519. * Removes a joint from the simulation
  26520. * @param mainImpostor defines the impostor used with the joint
  26521. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26522. * @param joint defines the joint to remove
  26523. */
  26524. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26525. /**
  26526. * Gets the current plugin used to run the simulation
  26527. * @returns current plugin
  26528. */
  26529. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26530. /**
  26531. * Gets the list of physic impostors
  26532. * @returns an array of PhysicsImpostor
  26533. */
  26534. getImpostors(): Array<PhysicsImpostor>;
  26535. /**
  26536. * Gets the impostor for a physics enabled object
  26537. * @param object defines the object impersonated by the impostor
  26538. * @returns the PhysicsImpostor or null if not found
  26539. */
  26540. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26541. /**
  26542. * Gets the impostor for a physics body object
  26543. * @param body defines physics body used by the impostor
  26544. * @returns the PhysicsImpostor or null if not found
  26545. */
  26546. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26547. /**
  26548. * Does a raycast in the physics world
  26549. * @param from when should the ray start?
  26550. * @param to when should the ray end?
  26551. * @returns PhysicsRaycastResult
  26552. */
  26553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26554. /**
  26555. * Called by the scene. No need to call it.
  26556. * @param delta defines the timespam between frames
  26557. */
  26558. _step(delta: number): void;
  26559. }
  26560. }
  26561. declare module BABYLON {
  26562. /**
  26563. * The interface for the physics imposter parameters
  26564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26565. */
  26566. export interface PhysicsImpostorParameters {
  26567. /**
  26568. * The mass of the physics imposter
  26569. */
  26570. mass: number;
  26571. /**
  26572. * The friction of the physics imposter
  26573. */
  26574. friction?: number;
  26575. /**
  26576. * The coefficient of restitution of the physics imposter
  26577. */
  26578. restitution?: number;
  26579. /**
  26580. * The native options of the physics imposter
  26581. */
  26582. nativeOptions?: any;
  26583. /**
  26584. * Specifies if the parent should be ignored
  26585. */
  26586. ignoreParent?: boolean;
  26587. /**
  26588. * Specifies if bi-directional transformations should be disabled
  26589. */
  26590. disableBidirectionalTransformation?: boolean;
  26591. /**
  26592. * The pressure inside the physics imposter, soft object only
  26593. */
  26594. pressure?: number;
  26595. /**
  26596. * The stiffness the physics imposter, soft object only
  26597. */
  26598. stiffness?: number;
  26599. /**
  26600. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26601. */
  26602. velocityIterations?: number;
  26603. /**
  26604. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26605. */
  26606. positionIterations?: number;
  26607. /**
  26608. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26609. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26610. * Add to fix multiple points
  26611. */
  26612. fixedPoints?: number;
  26613. /**
  26614. * The collision margin around a soft object
  26615. */
  26616. margin?: number;
  26617. /**
  26618. * The collision margin around a soft object
  26619. */
  26620. damping?: number;
  26621. /**
  26622. * The path for a rope based on an extrusion
  26623. */
  26624. path?: any;
  26625. /**
  26626. * The shape of an extrusion used for a rope based on an extrusion
  26627. */
  26628. shape?: any;
  26629. }
  26630. /**
  26631. * Interface for a physics-enabled object
  26632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26633. */
  26634. export interface IPhysicsEnabledObject {
  26635. /**
  26636. * The position of the physics-enabled object
  26637. */
  26638. position: Vector3;
  26639. /**
  26640. * The rotation of the physics-enabled object
  26641. */
  26642. rotationQuaternion: Nullable<Quaternion>;
  26643. /**
  26644. * The scale of the physics-enabled object
  26645. */
  26646. scaling: Vector3;
  26647. /**
  26648. * The rotation of the physics-enabled object
  26649. */
  26650. rotation?: Vector3;
  26651. /**
  26652. * The parent of the physics-enabled object
  26653. */
  26654. parent?: any;
  26655. /**
  26656. * The bounding info of the physics-enabled object
  26657. * @returns The bounding info of the physics-enabled object
  26658. */
  26659. getBoundingInfo(): BoundingInfo;
  26660. /**
  26661. * Computes the world matrix
  26662. * @param force Specifies if the world matrix should be computed by force
  26663. * @returns A world matrix
  26664. */
  26665. computeWorldMatrix(force: boolean): Matrix;
  26666. /**
  26667. * Gets the world matrix
  26668. * @returns A world matrix
  26669. */
  26670. getWorldMatrix?(): Matrix;
  26671. /**
  26672. * Gets the child meshes
  26673. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26674. * @returns An array of abstract meshes
  26675. */
  26676. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26677. /**
  26678. * Gets the vertex data
  26679. * @param kind The type of vertex data
  26680. * @returns A nullable array of numbers, or a float32 array
  26681. */
  26682. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26683. /**
  26684. * Gets the indices from the mesh
  26685. * @returns A nullable array of index arrays
  26686. */
  26687. getIndices?(): Nullable<IndicesArray>;
  26688. /**
  26689. * Gets the scene from the mesh
  26690. * @returns the indices array or null
  26691. */
  26692. getScene?(): Scene;
  26693. /**
  26694. * Gets the absolute position from the mesh
  26695. * @returns the absolute position
  26696. */
  26697. getAbsolutePosition(): Vector3;
  26698. /**
  26699. * Gets the absolute pivot point from the mesh
  26700. * @returns the absolute pivot point
  26701. */
  26702. getAbsolutePivotPoint(): Vector3;
  26703. /**
  26704. * Rotates the mesh
  26705. * @param axis The axis of rotation
  26706. * @param amount The amount of rotation
  26707. * @param space The space of the rotation
  26708. * @returns The rotation transform node
  26709. */
  26710. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26711. /**
  26712. * Translates the mesh
  26713. * @param axis The axis of translation
  26714. * @param distance The distance of translation
  26715. * @param space The space of the translation
  26716. * @returns The transform node
  26717. */
  26718. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26719. /**
  26720. * Sets the absolute position of the mesh
  26721. * @param absolutePosition The absolute position of the mesh
  26722. * @returns The transform node
  26723. */
  26724. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26725. /**
  26726. * Gets the class name of the mesh
  26727. * @returns The class name
  26728. */
  26729. getClassName(): string;
  26730. }
  26731. /**
  26732. * Represents a physics imposter
  26733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26734. */
  26735. export class PhysicsImpostor {
  26736. /**
  26737. * The physics-enabled object used as the physics imposter
  26738. */
  26739. object: IPhysicsEnabledObject;
  26740. /**
  26741. * The type of the physics imposter
  26742. */
  26743. type: number;
  26744. private _options;
  26745. private _scene?;
  26746. /**
  26747. * The default object size of the imposter
  26748. */
  26749. static DEFAULT_OBJECT_SIZE: Vector3;
  26750. /**
  26751. * The identity quaternion of the imposter
  26752. */
  26753. static IDENTITY_QUATERNION: Quaternion;
  26754. /** @hidden */
  26755. _pluginData: any;
  26756. private _physicsEngine;
  26757. private _physicsBody;
  26758. private _bodyUpdateRequired;
  26759. private _onBeforePhysicsStepCallbacks;
  26760. private _onAfterPhysicsStepCallbacks;
  26761. /** @hidden */
  26762. _onPhysicsCollideCallbacks: Array<{
  26763. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26764. otherImpostors: Array<PhysicsImpostor>;
  26765. }>;
  26766. private _deltaPosition;
  26767. private _deltaRotation;
  26768. private _deltaRotationConjugated;
  26769. /** @hidden */
  26770. _isFromLine: boolean;
  26771. private _parent;
  26772. private _isDisposed;
  26773. private static _tmpVecs;
  26774. private static _tmpQuat;
  26775. /**
  26776. * Specifies if the physics imposter is disposed
  26777. */
  26778. get isDisposed(): boolean;
  26779. /**
  26780. * Gets the mass of the physics imposter
  26781. */
  26782. get mass(): number;
  26783. set mass(value: number);
  26784. /**
  26785. * Gets the coefficient of friction
  26786. */
  26787. get friction(): number;
  26788. /**
  26789. * Sets the coefficient of friction
  26790. */
  26791. set friction(value: number);
  26792. /**
  26793. * Gets the coefficient of restitution
  26794. */
  26795. get restitution(): number;
  26796. /**
  26797. * Sets the coefficient of restitution
  26798. */
  26799. set restitution(value: number);
  26800. /**
  26801. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26802. */
  26803. get pressure(): number;
  26804. /**
  26805. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26806. */
  26807. set pressure(value: number);
  26808. /**
  26809. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26810. */
  26811. get stiffness(): number;
  26812. /**
  26813. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26814. */
  26815. set stiffness(value: number);
  26816. /**
  26817. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26818. */
  26819. get velocityIterations(): number;
  26820. /**
  26821. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26822. */
  26823. set velocityIterations(value: number);
  26824. /**
  26825. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26826. */
  26827. get positionIterations(): number;
  26828. /**
  26829. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26830. */
  26831. set positionIterations(value: number);
  26832. /**
  26833. * The unique id of the physics imposter
  26834. * set by the physics engine when adding this impostor to the array
  26835. */
  26836. uniqueId: number;
  26837. /**
  26838. * @hidden
  26839. */
  26840. soft: boolean;
  26841. /**
  26842. * @hidden
  26843. */
  26844. segments: number;
  26845. private _joints;
  26846. /**
  26847. * Initializes the physics imposter
  26848. * @param object The physics-enabled object used as the physics imposter
  26849. * @param type The type of the physics imposter
  26850. * @param _options The options for the physics imposter
  26851. * @param _scene The Babylon scene
  26852. */
  26853. constructor(
  26854. /**
  26855. * The physics-enabled object used as the physics imposter
  26856. */
  26857. object: IPhysicsEnabledObject,
  26858. /**
  26859. * The type of the physics imposter
  26860. */
  26861. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26862. /**
  26863. * This function will completly initialize this impostor.
  26864. * It will create a new body - but only if this mesh has no parent.
  26865. * If it has, this impostor will not be used other than to define the impostor
  26866. * of the child mesh.
  26867. * @hidden
  26868. */
  26869. _init(): void;
  26870. private _getPhysicsParent;
  26871. /**
  26872. * Should a new body be generated.
  26873. * @returns boolean specifying if body initialization is required
  26874. */
  26875. isBodyInitRequired(): boolean;
  26876. /**
  26877. * Sets the updated scaling
  26878. * @param updated Specifies if the scaling is updated
  26879. */
  26880. setScalingUpdated(): void;
  26881. /**
  26882. * Force a regeneration of this or the parent's impostor's body.
  26883. * Use under cautious - This will remove all joints already implemented.
  26884. */
  26885. forceUpdate(): void;
  26886. /**
  26887. * Gets the body that holds this impostor. Either its own, or its parent.
  26888. */
  26889. get physicsBody(): any;
  26890. /**
  26891. * Get the parent of the physics imposter
  26892. * @returns Physics imposter or null
  26893. */
  26894. get parent(): Nullable<PhysicsImpostor>;
  26895. /**
  26896. * Sets the parent of the physics imposter
  26897. */
  26898. set parent(value: Nullable<PhysicsImpostor>);
  26899. /**
  26900. * Set the physics body. Used mainly by the physics engine/plugin
  26901. */
  26902. set physicsBody(physicsBody: any);
  26903. /**
  26904. * Resets the update flags
  26905. */
  26906. resetUpdateFlags(): void;
  26907. /**
  26908. * Gets the object extend size
  26909. * @returns the object extend size
  26910. */
  26911. getObjectExtendSize(): Vector3;
  26912. /**
  26913. * Gets the object center
  26914. * @returns The object center
  26915. */
  26916. getObjectCenter(): Vector3;
  26917. /**
  26918. * Get a specific parameter from the options parameters
  26919. * @param paramName The object parameter name
  26920. * @returns The object parameter
  26921. */
  26922. getParam(paramName: string): any;
  26923. /**
  26924. * Sets a specific parameter in the options given to the physics plugin
  26925. * @param paramName The parameter name
  26926. * @param value The value of the parameter
  26927. */
  26928. setParam(paramName: string, value: number): void;
  26929. /**
  26930. * Specifically change the body's mass option. Won't recreate the physics body object
  26931. * @param mass The mass of the physics imposter
  26932. */
  26933. setMass(mass: number): void;
  26934. /**
  26935. * Gets the linear velocity
  26936. * @returns linear velocity or null
  26937. */
  26938. getLinearVelocity(): Nullable<Vector3>;
  26939. /**
  26940. * Sets the linear velocity
  26941. * @param velocity linear velocity or null
  26942. */
  26943. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26944. /**
  26945. * Gets the angular velocity
  26946. * @returns angular velocity or null
  26947. */
  26948. getAngularVelocity(): Nullable<Vector3>;
  26949. /**
  26950. * Sets the angular velocity
  26951. * @param velocity The velocity or null
  26952. */
  26953. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26954. /**
  26955. * Execute a function with the physics plugin native code
  26956. * Provide a function the will have two variables - the world object and the physics body object
  26957. * @param func The function to execute with the physics plugin native code
  26958. */
  26959. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26960. /**
  26961. * Register a function that will be executed before the physics world is stepping forward
  26962. * @param func The function to execute before the physics world is stepped forward
  26963. */
  26964. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26965. /**
  26966. * Unregister a function that will be executed before the physics world is stepping forward
  26967. * @param func The function to execute before the physics world is stepped forward
  26968. */
  26969. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26970. /**
  26971. * Register a function that will be executed after the physics step
  26972. * @param func The function to execute after physics step
  26973. */
  26974. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26975. /**
  26976. * Unregisters a function that will be executed after the physics step
  26977. * @param func The function to execute after physics step
  26978. */
  26979. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26980. /**
  26981. * register a function that will be executed when this impostor collides against a different body
  26982. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26983. * @param func Callback that is executed on collision
  26984. */
  26985. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26986. /**
  26987. * Unregisters the physics imposter on contact
  26988. * @param collideAgainst The physics object to collide against
  26989. * @param func Callback to execute on collision
  26990. */
  26991. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26992. private _tmpQuat;
  26993. private _tmpQuat2;
  26994. /**
  26995. * Get the parent rotation
  26996. * @returns The parent rotation
  26997. */
  26998. getParentsRotation(): Quaternion;
  26999. /**
  27000. * this function is executed by the physics engine.
  27001. */
  27002. beforeStep: () => void;
  27003. /**
  27004. * this function is executed by the physics engine
  27005. */
  27006. afterStep: () => void;
  27007. /**
  27008. * Legacy collision detection event support
  27009. */
  27010. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27011. /**
  27012. * event and body object due to cannon's event-based architecture.
  27013. */
  27014. onCollide: (e: {
  27015. body: any;
  27016. }) => void;
  27017. /**
  27018. * Apply a force
  27019. * @param force The force to apply
  27020. * @param contactPoint The contact point for the force
  27021. * @returns The physics imposter
  27022. */
  27023. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27024. /**
  27025. * Apply an impulse
  27026. * @param force The impulse force
  27027. * @param contactPoint The contact point for the impulse force
  27028. * @returns The physics imposter
  27029. */
  27030. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27031. /**
  27032. * A help function to create a joint
  27033. * @param otherImpostor A physics imposter used to create a joint
  27034. * @param jointType The type of joint
  27035. * @param jointData The data for the joint
  27036. * @returns The physics imposter
  27037. */
  27038. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27039. /**
  27040. * Add a joint to this impostor with a different impostor
  27041. * @param otherImpostor A physics imposter used to add a joint
  27042. * @param joint The joint to add
  27043. * @returns The physics imposter
  27044. */
  27045. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27046. /**
  27047. * Add an anchor to a cloth impostor
  27048. * @param otherImpostor rigid impostor to anchor to
  27049. * @param width ratio across width from 0 to 1
  27050. * @param height ratio up height from 0 to 1
  27051. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27052. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27053. * @returns impostor the soft imposter
  27054. */
  27055. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27056. /**
  27057. * Add a hook to a rope impostor
  27058. * @param otherImpostor rigid impostor to anchor to
  27059. * @param length ratio across rope from 0 to 1
  27060. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27061. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27062. * @returns impostor the rope imposter
  27063. */
  27064. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27065. /**
  27066. * Will keep this body still, in a sleep mode.
  27067. * @returns the physics imposter
  27068. */
  27069. sleep(): PhysicsImpostor;
  27070. /**
  27071. * Wake the body up.
  27072. * @returns The physics imposter
  27073. */
  27074. wakeUp(): PhysicsImpostor;
  27075. /**
  27076. * Clones the physics imposter
  27077. * @param newObject The physics imposter clones to this physics-enabled object
  27078. * @returns A nullable physics imposter
  27079. */
  27080. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27081. /**
  27082. * Disposes the physics imposter
  27083. */
  27084. dispose(): void;
  27085. /**
  27086. * Sets the delta position
  27087. * @param position The delta position amount
  27088. */
  27089. setDeltaPosition(position: Vector3): void;
  27090. /**
  27091. * Sets the delta rotation
  27092. * @param rotation The delta rotation amount
  27093. */
  27094. setDeltaRotation(rotation: Quaternion): void;
  27095. /**
  27096. * Gets the box size of the physics imposter and stores the result in the input parameter
  27097. * @param result Stores the box size
  27098. * @returns The physics imposter
  27099. */
  27100. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27101. /**
  27102. * Gets the radius of the physics imposter
  27103. * @returns Radius of the physics imposter
  27104. */
  27105. getRadius(): number;
  27106. /**
  27107. * Sync a bone with this impostor
  27108. * @param bone The bone to sync to the impostor.
  27109. * @param boneMesh The mesh that the bone is influencing.
  27110. * @param jointPivot The pivot of the joint / bone in local space.
  27111. * @param distToJoint Optional distance from the impostor to the joint.
  27112. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27113. */
  27114. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27115. /**
  27116. * Sync impostor to a bone
  27117. * @param bone The bone that the impostor will be synced to.
  27118. * @param boneMesh The mesh that the bone is influencing.
  27119. * @param jointPivot The pivot of the joint / bone in local space.
  27120. * @param distToJoint Optional distance from the impostor to the joint.
  27121. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27122. * @param boneAxis Optional vector3 axis the bone is aligned with
  27123. */
  27124. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27125. /**
  27126. * No-Imposter type
  27127. */
  27128. static NoImpostor: number;
  27129. /**
  27130. * Sphere-Imposter type
  27131. */
  27132. static SphereImpostor: number;
  27133. /**
  27134. * Box-Imposter type
  27135. */
  27136. static BoxImpostor: number;
  27137. /**
  27138. * Plane-Imposter type
  27139. */
  27140. static PlaneImpostor: number;
  27141. /**
  27142. * Mesh-imposter type
  27143. */
  27144. static MeshImpostor: number;
  27145. /**
  27146. * Capsule-Impostor type (Ammo.js plugin only)
  27147. */
  27148. static CapsuleImpostor: number;
  27149. /**
  27150. * Cylinder-Imposter type
  27151. */
  27152. static CylinderImpostor: number;
  27153. /**
  27154. * Particle-Imposter type
  27155. */
  27156. static ParticleImpostor: number;
  27157. /**
  27158. * Heightmap-Imposter type
  27159. */
  27160. static HeightmapImpostor: number;
  27161. /**
  27162. * ConvexHull-Impostor type (Ammo.js plugin only)
  27163. */
  27164. static ConvexHullImpostor: number;
  27165. /**
  27166. * Custom-Imposter type (Ammo.js plugin only)
  27167. */
  27168. static CustomImpostor: number;
  27169. /**
  27170. * Rope-Imposter type
  27171. */
  27172. static RopeImpostor: number;
  27173. /**
  27174. * Cloth-Imposter type
  27175. */
  27176. static ClothImpostor: number;
  27177. /**
  27178. * Softbody-Imposter type
  27179. */
  27180. static SoftbodyImpostor: number;
  27181. }
  27182. }
  27183. declare module BABYLON {
  27184. /**
  27185. * @hidden
  27186. **/
  27187. export class _CreationDataStorage {
  27188. closePath?: boolean;
  27189. closeArray?: boolean;
  27190. idx: number[];
  27191. dashSize: number;
  27192. gapSize: number;
  27193. path3D: Path3D;
  27194. pathArray: Vector3[][];
  27195. arc: number;
  27196. radius: number;
  27197. cap: number;
  27198. tessellation: number;
  27199. }
  27200. /**
  27201. * @hidden
  27202. **/
  27203. class _InstanceDataStorage {
  27204. visibleInstances: any;
  27205. batchCache: _InstancesBatch;
  27206. instancesBufferSize: number;
  27207. instancesBuffer: Nullable<Buffer>;
  27208. instancesData: Float32Array;
  27209. overridenInstanceCount: number;
  27210. isFrozen: boolean;
  27211. previousBatch: Nullable<_InstancesBatch>;
  27212. hardwareInstancedRendering: boolean;
  27213. sideOrientation: number;
  27214. manualUpdate: boolean;
  27215. }
  27216. /**
  27217. * @hidden
  27218. **/
  27219. export class _InstancesBatch {
  27220. mustReturn: boolean;
  27221. visibleInstances: Nullable<InstancedMesh[]>[];
  27222. renderSelf: boolean[];
  27223. hardwareInstancedRendering: boolean[];
  27224. }
  27225. /**
  27226. * @hidden
  27227. **/
  27228. class _ThinInstanceDataStorage {
  27229. instancesCount: number;
  27230. matrixBuffer: Nullable<Buffer>;
  27231. matrixBufferSize: number;
  27232. matrixData: Nullable<Float32Array>;
  27233. boundingVectors: Array<Vector3>;
  27234. }
  27235. /**
  27236. * Class used to represent renderable models
  27237. */
  27238. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27239. /**
  27240. * Mesh side orientation : usually the external or front surface
  27241. */
  27242. static readonly FRONTSIDE: number;
  27243. /**
  27244. * Mesh side orientation : usually the internal or back surface
  27245. */
  27246. static readonly BACKSIDE: number;
  27247. /**
  27248. * Mesh side orientation : both internal and external or front and back surfaces
  27249. */
  27250. static readonly DOUBLESIDE: number;
  27251. /**
  27252. * Mesh side orientation : by default, `FRONTSIDE`
  27253. */
  27254. static readonly DEFAULTSIDE: number;
  27255. /**
  27256. * Mesh cap setting : no cap
  27257. */
  27258. static readonly NO_CAP: number;
  27259. /**
  27260. * Mesh cap setting : one cap at the beginning of the mesh
  27261. */
  27262. static readonly CAP_START: number;
  27263. /**
  27264. * Mesh cap setting : one cap at the end of the mesh
  27265. */
  27266. static readonly CAP_END: number;
  27267. /**
  27268. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27269. */
  27270. static readonly CAP_ALL: number;
  27271. /**
  27272. * Mesh pattern setting : no flip or rotate
  27273. */
  27274. static readonly NO_FLIP: number;
  27275. /**
  27276. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27277. */
  27278. static readonly FLIP_TILE: number;
  27279. /**
  27280. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27281. */
  27282. static readonly ROTATE_TILE: number;
  27283. /**
  27284. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27285. */
  27286. static readonly FLIP_ROW: number;
  27287. /**
  27288. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27289. */
  27290. static readonly ROTATE_ROW: number;
  27291. /**
  27292. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27293. */
  27294. static readonly FLIP_N_ROTATE_TILE: number;
  27295. /**
  27296. * Mesh pattern setting : rotate pattern and rotate
  27297. */
  27298. static readonly FLIP_N_ROTATE_ROW: number;
  27299. /**
  27300. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27301. */
  27302. static readonly CENTER: number;
  27303. /**
  27304. * Mesh tile positioning : part tiles on left
  27305. */
  27306. static readonly LEFT: number;
  27307. /**
  27308. * Mesh tile positioning : part tiles on right
  27309. */
  27310. static readonly RIGHT: number;
  27311. /**
  27312. * Mesh tile positioning : part tiles on top
  27313. */
  27314. static readonly TOP: number;
  27315. /**
  27316. * Mesh tile positioning : part tiles on bottom
  27317. */
  27318. static readonly BOTTOM: number;
  27319. /**
  27320. * Gets the default side orientation.
  27321. * @param orientation the orientation to value to attempt to get
  27322. * @returns the default orientation
  27323. * @hidden
  27324. */
  27325. static _GetDefaultSideOrientation(orientation?: number): number;
  27326. private _internalMeshDataInfo;
  27327. /**
  27328. * An event triggered before rendering the mesh
  27329. */
  27330. get onBeforeRenderObservable(): Observable<Mesh>;
  27331. /**
  27332. * An event triggered before binding the mesh
  27333. */
  27334. get onBeforeBindObservable(): Observable<Mesh>;
  27335. /**
  27336. * An event triggered after rendering the mesh
  27337. */
  27338. get onAfterRenderObservable(): Observable<Mesh>;
  27339. /**
  27340. * An event triggered before drawing the mesh
  27341. */
  27342. get onBeforeDrawObservable(): Observable<Mesh>;
  27343. private _onBeforeDrawObserver;
  27344. /**
  27345. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27346. */
  27347. set onBeforeDraw(callback: () => void);
  27348. get hasInstances(): boolean;
  27349. get hasThinInstances(): boolean;
  27350. /**
  27351. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27352. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27353. */
  27354. delayLoadState: number;
  27355. /**
  27356. * Gets the list of instances created from this mesh
  27357. * it is not supposed to be modified manually.
  27358. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27359. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27360. */
  27361. instances: InstancedMesh[];
  27362. /**
  27363. * Gets the file containing delay loading data for this mesh
  27364. */
  27365. delayLoadingFile: string;
  27366. /** @hidden */
  27367. _binaryInfo: any;
  27368. /**
  27369. * User defined function used to change how LOD level selection is done
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27371. */
  27372. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27373. /**
  27374. * Gets or sets the morph target manager
  27375. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27376. */
  27377. get morphTargetManager(): Nullable<MorphTargetManager>;
  27378. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27379. /** @hidden */
  27380. _creationDataStorage: Nullable<_CreationDataStorage>;
  27381. /** @hidden */
  27382. _geometry: Nullable<Geometry>;
  27383. /** @hidden */
  27384. _delayInfo: Array<string>;
  27385. /** @hidden */
  27386. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27387. /** @hidden */
  27388. _instanceDataStorage: _InstanceDataStorage;
  27389. /** @hidden */
  27390. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27391. private _effectiveMaterial;
  27392. /** @hidden */
  27393. _shouldGenerateFlatShading: boolean;
  27394. /** @hidden */
  27395. _originalBuilderSideOrientation: number;
  27396. /**
  27397. * Use this property to change the original side orientation defined at construction time
  27398. */
  27399. overrideMaterialSideOrientation: Nullable<number>;
  27400. /**
  27401. * Gets the source mesh (the one used to clone this one from)
  27402. */
  27403. get source(): Nullable<Mesh>;
  27404. /**
  27405. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27406. */
  27407. get isUnIndexed(): boolean;
  27408. set isUnIndexed(value: boolean);
  27409. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27410. get worldMatrixInstancedBuffer(): Float32Array;
  27411. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27412. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27413. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27414. /**
  27415. * @constructor
  27416. * @param name The value used by scene.getMeshByName() to do a lookup.
  27417. * @param scene The scene to add this mesh to.
  27418. * @param parent The parent of this mesh, if it has one
  27419. * @param source An optional Mesh from which geometry is shared, cloned.
  27420. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27421. * When false, achieved by calling a clone(), also passing False.
  27422. * This will make creation of children, recursive.
  27423. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27424. */
  27425. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27426. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27427. doNotInstantiate: boolean;
  27428. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27429. /**
  27430. * Gets the class name
  27431. * @returns the string "Mesh".
  27432. */
  27433. getClassName(): string;
  27434. /** @hidden */
  27435. get _isMesh(): boolean;
  27436. /**
  27437. * Returns a description of this mesh
  27438. * @param fullDetails define if full details about this mesh must be used
  27439. * @returns a descriptive string representing this mesh
  27440. */
  27441. toString(fullDetails?: boolean): string;
  27442. /** @hidden */
  27443. _unBindEffect(): void;
  27444. /**
  27445. * Gets a boolean indicating if this mesh has LOD
  27446. */
  27447. get hasLODLevels(): boolean;
  27448. /**
  27449. * Gets the list of MeshLODLevel associated with the current mesh
  27450. * @returns an array of MeshLODLevel
  27451. */
  27452. getLODLevels(): MeshLODLevel[];
  27453. private _sortLODLevels;
  27454. /**
  27455. * Add a mesh as LOD level triggered at the given distance.
  27456. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27457. * @param distance The distance from the center of the object to show this level
  27458. * @param mesh The mesh to be added as LOD level (can be null)
  27459. * @return This mesh (for chaining)
  27460. */
  27461. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27462. /**
  27463. * Returns the LOD level mesh at the passed distance or null if not found.
  27464. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27465. * @param distance The distance from the center of the object to show this level
  27466. * @returns a Mesh or `null`
  27467. */
  27468. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27469. /**
  27470. * Remove a mesh from the LOD array
  27471. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27472. * @param mesh defines the mesh to be removed
  27473. * @return This mesh (for chaining)
  27474. */
  27475. removeLODLevel(mesh: Mesh): Mesh;
  27476. /**
  27477. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27478. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27479. * @param camera defines the camera to use to compute distance
  27480. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27481. * @return This mesh (for chaining)
  27482. */
  27483. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27484. /**
  27485. * Gets the mesh internal Geometry object
  27486. */
  27487. get geometry(): Nullable<Geometry>;
  27488. /**
  27489. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27490. * @returns the total number of vertices
  27491. */
  27492. getTotalVertices(): number;
  27493. /**
  27494. * Returns the content of an associated vertex buffer
  27495. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27496. * - VertexBuffer.PositionKind
  27497. * - VertexBuffer.UVKind
  27498. * - VertexBuffer.UV2Kind
  27499. * - VertexBuffer.UV3Kind
  27500. * - VertexBuffer.UV4Kind
  27501. * - VertexBuffer.UV5Kind
  27502. * - VertexBuffer.UV6Kind
  27503. * - VertexBuffer.ColorKind
  27504. * - VertexBuffer.MatricesIndicesKind
  27505. * - VertexBuffer.MatricesIndicesExtraKind
  27506. * - VertexBuffer.MatricesWeightsKind
  27507. * - VertexBuffer.MatricesWeightsExtraKind
  27508. * @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
  27509. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27510. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27511. */
  27512. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27513. /**
  27514. * Returns the mesh VertexBuffer object from the requested `kind`
  27515. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27516. * - VertexBuffer.PositionKind
  27517. * - VertexBuffer.NormalKind
  27518. * - VertexBuffer.UVKind
  27519. * - VertexBuffer.UV2Kind
  27520. * - VertexBuffer.UV3Kind
  27521. * - VertexBuffer.UV4Kind
  27522. * - VertexBuffer.UV5Kind
  27523. * - VertexBuffer.UV6Kind
  27524. * - VertexBuffer.ColorKind
  27525. * - VertexBuffer.MatricesIndicesKind
  27526. * - VertexBuffer.MatricesIndicesExtraKind
  27527. * - VertexBuffer.MatricesWeightsKind
  27528. * - VertexBuffer.MatricesWeightsExtraKind
  27529. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27530. */
  27531. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27532. /**
  27533. * Tests if a specific vertex buffer is associated with this mesh
  27534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27535. * - VertexBuffer.PositionKind
  27536. * - VertexBuffer.NormalKind
  27537. * - VertexBuffer.UVKind
  27538. * - VertexBuffer.UV2Kind
  27539. * - VertexBuffer.UV3Kind
  27540. * - VertexBuffer.UV4Kind
  27541. * - VertexBuffer.UV5Kind
  27542. * - VertexBuffer.UV6Kind
  27543. * - VertexBuffer.ColorKind
  27544. * - VertexBuffer.MatricesIndicesKind
  27545. * - VertexBuffer.MatricesIndicesExtraKind
  27546. * - VertexBuffer.MatricesWeightsKind
  27547. * - VertexBuffer.MatricesWeightsExtraKind
  27548. * @returns a boolean
  27549. */
  27550. isVerticesDataPresent(kind: string): boolean;
  27551. /**
  27552. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27553. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27554. * - VertexBuffer.PositionKind
  27555. * - VertexBuffer.UVKind
  27556. * - VertexBuffer.UV2Kind
  27557. * - VertexBuffer.UV3Kind
  27558. * - VertexBuffer.UV4Kind
  27559. * - VertexBuffer.UV5Kind
  27560. * - VertexBuffer.UV6Kind
  27561. * - VertexBuffer.ColorKind
  27562. * - VertexBuffer.MatricesIndicesKind
  27563. * - VertexBuffer.MatricesIndicesExtraKind
  27564. * - VertexBuffer.MatricesWeightsKind
  27565. * - VertexBuffer.MatricesWeightsExtraKind
  27566. * @returns a boolean
  27567. */
  27568. isVertexBufferUpdatable(kind: string): boolean;
  27569. /**
  27570. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27571. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27572. * - VertexBuffer.PositionKind
  27573. * - VertexBuffer.NormalKind
  27574. * - VertexBuffer.UVKind
  27575. * - VertexBuffer.UV2Kind
  27576. * - VertexBuffer.UV3Kind
  27577. * - VertexBuffer.UV4Kind
  27578. * - VertexBuffer.UV5Kind
  27579. * - VertexBuffer.UV6Kind
  27580. * - VertexBuffer.ColorKind
  27581. * - VertexBuffer.MatricesIndicesKind
  27582. * - VertexBuffer.MatricesIndicesExtraKind
  27583. * - VertexBuffer.MatricesWeightsKind
  27584. * - VertexBuffer.MatricesWeightsExtraKind
  27585. * @returns an array of strings
  27586. */
  27587. getVerticesDataKinds(): string[];
  27588. /**
  27589. * Returns a positive integer : the total number of indices in this mesh geometry.
  27590. * @returns the numner of indices or zero if the mesh has no geometry.
  27591. */
  27592. getTotalIndices(): number;
  27593. /**
  27594. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27595. * @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.
  27596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27597. * @returns the indices array or an empty array if the mesh has no geometry
  27598. */
  27599. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27600. get isBlocked(): boolean;
  27601. /**
  27602. * Determine if the current mesh is ready to be rendered
  27603. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27604. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27605. * @returns true if all associated assets are ready (material, textures, shaders)
  27606. */
  27607. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27608. /**
  27609. * 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.
  27610. */
  27611. get areNormalsFrozen(): boolean;
  27612. /**
  27613. * 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.
  27614. * @returns the current mesh
  27615. */
  27616. freezeNormals(): Mesh;
  27617. /**
  27618. * 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
  27619. * @returns the current mesh
  27620. */
  27621. unfreezeNormals(): Mesh;
  27622. /**
  27623. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27624. */
  27625. set overridenInstanceCount(count: number);
  27626. /** @hidden */
  27627. _preActivate(): Mesh;
  27628. /** @hidden */
  27629. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27630. /** @hidden */
  27631. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27632. protected _afterComputeWorldMatrix(): void;
  27633. /** @hidden */
  27634. _postActivate(): void;
  27635. /**
  27636. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27637. * This means the mesh underlying bounding box and sphere are recomputed.
  27638. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27639. * @returns the current mesh
  27640. */
  27641. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27642. /** @hidden */
  27643. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27644. /**
  27645. * This function will subdivide the mesh into multiple submeshes
  27646. * @param count defines the expected number of submeshes
  27647. */
  27648. subdivide(count: number): void;
  27649. /**
  27650. * Copy a FloatArray into a specific associated vertex buffer
  27651. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27652. * - VertexBuffer.PositionKind
  27653. * - VertexBuffer.UVKind
  27654. * - VertexBuffer.UV2Kind
  27655. * - VertexBuffer.UV3Kind
  27656. * - VertexBuffer.UV4Kind
  27657. * - VertexBuffer.UV5Kind
  27658. * - VertexBuffer.UV6Kind
  27659. * - VertexBuffer.ColorKind
  27660. * - VertexBuffer.MatricesIndicesKind
  27661. * - VertexBuffer.MatricesIndicesExtraKind
  27662. * - VertexBuffer.MatricesWeightsKind
  27663. * - VertexBuffer.MatricesWeightsExtraKind
  27664. * @param data defines the data source
  27665. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27666. * @param stride defines the data stride size (can be null)
  27667. * @returns the current mesh
  27668. */
  27669. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27670. /**
  27671. * Delete a vertex buffer associated with this mesh
  27672. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27673. * - VertexBuffer.PositionKind
  27674. * - VertexBuffer.UVKind
  27675. * - VertexBuffer.UV2Kind
  27676. * - VertexBuffer.UV3Kind
  27677. * - VertexBuffer.UV4Kind
  27678. * - VertexBuffer.UV5Kind
  27679. * - VertexBuffer.UV6Kind
  27680. * - VertexBuffer.ColorKind
  27681. * - VertexBuffer.MatricesIndicesKind
  27682. * - VertexBuffer.MatricesIndicesExtraKind
  27683. * - VertexBuffer.MatricesWeightsKind
  27684. * - VertexBuffer.MatricesWeightsExtraKind
  27685. */
  27686. removeVerticesData(kind: string): void;
  27687. /**
  27688. * Flags an associated vertex buffer as updatable
  27689. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27690. * - VertexBuffer.PositionKind
  27691. * - VertexBuffer.UVKind
  27692. * - VertexBuffer.UV2Kind
  27693. * - VertexBuffer.UV3Kind
  27694. * - VertexBuffer.UV4Kind
  27695. * - VertexBuffer.UV5Kind
  27696. * - VertexBuffer.UV6Kind
  27697. * - VertexBuffer.ColorKind
  27698. * - VertexBuffer.MatricesIndicesKind
  27699. * - VertexBuffer.MatricesIndicesExtraKind
  27700. * - VertexBuffer.MatricesWeightsKind
  27701. * - VertexBuffer.MatricesWeightsExtraKind
  27702. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27703. */
  27704. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27705. /**
  27706. * Sets the mesh global Vertex Buffer
  27707. * @param buffer defines the buffer to use
  27708. * @returns the current mesh
  27709. */
  27710. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27711. /**
  27712. * Update a specific associated vertex buffer
  27713. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27714. * - VertexBuffer.PositionKind
  27715. * - VertexBuffer.UVKind
  27716. * - VertexBuffer.UV2Kind
  27717. * - VertexBuffer.UV3Kind
  27718. * - VertexBuffer.UV4Kind
  27719. * - VertexBuffer.UV5Kind
  27720. * - VertexBuffer.UV6Kind
  27721. * - VertexBuffer.ColorKind
  27722. * - VertexBuffer.MatricesIndicesKind
  27723. * - VertexBuffer.MatricesIndicesExtraKind
  27724. * - VertexBuffer.MatricesWeightsKind
  27725. * - VertexBuffer.MatricesWeightsExtraKind
  27726. * @param data defines the data source
  27727. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27728. * @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)
  27729. * @returns the current mesh
  27730. */
  27731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27732. /**
  27733. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27734. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27735. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27736. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27737. * @returns the current mesh
  27738. */
  27739. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27740. /**
  27741. * Creates a un-shared specific occurence of the geometry for the mesh.
  27742. * @returns the current mesh
  27743. */
  27744. makeGeometryUnique(): Mesh;
  27745. /**
  27746. * Set the index buffer of this mesh
  27747. * @param indices defines the source data
  27748. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27749. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27750. * @returns the current mesh
  27751. */
  27752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27753. /**
  27754. * Update the current index buffer
  27755. * @param indices defines the source data
  27756. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27757. * @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)
  27758. * @returns the current mesh
  27759. */
  27760. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27761. /**
  27762. * Invert the geometry to move from a right handed system to a left handed one.
  27763. * @returns the current mesh
  27764. */
  27765. toLeftHanded(): Mesh;
  27766. /** @hidden */
  27767. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27768. /** @hidden */
  27769. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27770. /**
  27771. * Registers for this mesh a javascript function called just before the rendering process
  27772. * @param func defines the function to call before rendering this mesh
  27773. * @returns the current mesh
  27774. */
  27775. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27776. /**
  27777. * Disposes a previously registered javascript function called before the rendering
  27778. * @param func defines the function to remove
  27779. * @returns the current mesh
  27780. */
  27781. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27782. /**
  27783. * Registers for this mesh a javascript function called just after the rendering is complete
  27784. * @param func defines the function to call after rendering this mesh
  27785. * @returns the current mesh
  27786. */
  27787. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27788. /**
  27789. * Disposes a previously registered javascript function called after the rendering.
  27790. * @param func defines the function to remove
  27791. * @returns the current mesh
  27792. */
  27793. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27794. /** @hidden */
  27795. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27796. /** @hidden */
  27797. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27798. /** @hidden */
  27799. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27800. /** @hidden */
  27801. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27802. /** @hidden */
  27803. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27804. /** @hidden */
  27805. _rebuild(): void;
  27806. /** @hidden */
  27807. _freeze(): void;
  27808. /** @hidden */
  27809. _unFreeze(): void;
  27810. /**
  27811. * 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
  27812. * @param subMesh defines the subMesh to render
  27813. * @param enableAlphaMode defines if alpha mode can be changed
  27814. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27815. * @returns the current mesh
  27816. */
  27817. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27818. private _onBeforeDraw;
  27819. /**
  27820. * Renormalize the mesh and patch it up if there are no weights
  27821. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27822. * However in the case of zero weights then we set just a single influence to 1.
  27823. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27824. */
  27825. cleanMatrixWeights(): void;
  27826. private normalizeSkinFourWeights;
  27827. private normalizeSkinWeightsAndExtra;
  27828. /**
  27829. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27830. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27831. * the user know there was an issue with importing the mesh
  27832. * @returns a validation object with skinned, valid and report string
  27833. */
  27834. validateSkinning(): {
  27835. skinned: boolean;
  27836. valid: boolean;
  27837. report: string;
  27838. };
  27839. /** @hidden */
  27840. _checkDelayState(): Mesh;
  27841. private _queueLoad;
  27842. /**
  27843. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27844. * A mesh is in the frustum if its bounding box intersects the frustum
  27845. * @param frustumPlanes defines the frustum to test
  27846. * @returns true if the mesh is in the frustum planes
  27847. */
  27848. isInFrustum(frustumPlanes: Plane[]): boolean;
  27849. /**
  27850. * Sets the mesh material by the material or multiMaterial `id` property
  27851. * @param id is a string identifying the material or the multiMaterial
  27852. * @returns the current mesh
  27853. */
  27854. setMaterialByID(id: string): Mesh;
  27855. /**
  27856. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27857. * @returns an array of IAnimatable
  27858. */
  27859. getAnimatables(): IAnimatable[];
  27860. /**
  27861. * Modifies the mesh geometry according to the passed transformation matrix.
  27862. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27863. * The mesh normals are modified using the same transformation.
  27864. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27865. * @param transform defines the transform matrix to use
  27866. * @see http://doc.babylonjs.com/resources/baking_transformations
  27867. * @returns the current mesh
  27868. */
  27869. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27870. /**
  27871. * Modifies the mesh geometry according to its own current World Matrix.
  27872. * The mesh World Matrix is then reset.
  27873. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27874. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27875. * @see http://doc.babylonjs.com/resources/baking_transformations
  27876. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27877. * @returns the current mesh
  27878. */
  27879. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27880. /** @hidden */
  27881. get _positions(): Nullable<Vector3[]>;
  27882. /** @hidden */
  27883. _resetPointsArrayCache(): Mesh;
  27884. /** @hidden */
  27885. _generatePointsArray(): boolean;
  27886. /**
  27887. * Returns a new Mesh object generated from the current mesh properties.
  27888. * This method must not get confused with createInstance()
  27889. * @param name is a string, the name given to the new mesh
  27890. * @param newParent can be any Node object (default `null`)
  27891. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27892. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27893. * @returns a new mesh
  27894. */
  27895. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27896. /**
  27897. * Releases resources associated with this mesh.
  27898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27900. */
  27901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27902. /** @hidden */
  27903. _disposeInstanceSpecificData(): void;
  27904. /** @hidden */
  27905. _disposeThinInstanceSpecificData(): void;
  27906. /**
  27907. * Modifies the mesh geometry according to a displacement map.
  27908. * 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.
  27909. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27910. * @param url is a string, the URL from the image file is to be downloaded.
  27911. * @param minHeight is the lower limit of the displacement.
  27912. * @param maxHeight is the upper limit of the displacement.
  27913. * @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.
  27914. * @param uvOffset is an optional vector2 used to offset UV.
  27915. * @param uvScale is an optional vector2 used to scale UV.
  27916. * @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.
  27917. * @returns the Mesh.
  27918. */
  27919. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27920. /**
  27921. * Modifies the mesh geometry according to a displacementMap buffer.
  27922. * 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.
  27923. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27924. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27925. * @param heightMapWidth is the width of the buffer image.
  27926. * @param heightMapHeight is the height of the buffer image.
  27927. * @param minHeight is the lower limit of the displacement.
  27928. * @param maxHeight is the upper limit of the displacement.
  27929. * @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.
  27930. * @param uvOffset is an optional vector2 used to offset UV.
  27931. * @param uvScale is an optional vector2 used to scale UV.
  27932. * @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.
  27933. * @returns the Mesh.
  27934. */
  27935. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27936. /**
  27937. * Modify the mesh to get a flat shading rendering.
  27938. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27939. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27940. * @returns current mesh
  27941. */
  27942. convertToFlatShadedMesh(): Mesh;
  27943. /**
  27944. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27945. * In other words, more vertices, no more indices and a single bigger VBO.
  27946. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27947. * @returns current mesh
  27948. */
  27949. convertToUnIndexedMesh(): Mesh;
  27950. /**
  27951. * Inverses facet orientations.
  27952. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27953. * @param flipNormals will also inverts the normals
  27954. * @returns current mesh
  27955. */
  27956. flipFaces(flipNormals?: boolean): Mesh;
  27957. /**
  27958. * Increase the number of facets and hence vertices in a mesh
  27959. * Vertex normals are interpolated from existing vertex normals
  27960. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27961. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27962. */
  27963. increaseVertices(numberPerEdge: number): void;
  27964. /**
  27965. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27966. * This will undo any application of covertToFlatShadedMesh
  27967. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27968. */
  27969. forceSharedVertices(): void;
  27970. /** @hidden */
  27971. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27972. /** @hidden */
  27973. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27974. /**
  27975. * Creates a new InstancedMesh object from the mesh model.
  27976. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27977. * @param name defines the name of the new instance
  27978. * @returns a new InstancedMesh
  27979. */
  27980. createInstance(name: string): InstancedMesh;
  27981. /**
  27982. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27983. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27984. * @returns the current mesh
  27985. */
  27986. synchronizeInstances(): Mesh;
  27987. /**
  27988. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27989. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27990. * This should be used together with the simplification to avoid disappearing triangles.
  27991. * @param successCallback an optional success callback to be called after the optimization finished.
  27992. * @returns the current mesh
  27993. */
  27994. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27995. /**
  27996. * Serialize current mesh
  27997. * @param serializationObject defines the object which will receive the serialization data
  27998. */
  27999. serialize(serializationObject: any): void;
  28000. /** @hidden */
  28001. _syncGeometryWithMorphTargetManager(): void;
  28002. /** @hidden */
  28003. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28004. /**
  28005. * Returns a new Mesh object parsed from the source provided.
  28006. * @param parsedMesh is the source
  28007. * @param scene defines the hosting scene
  28008. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28009. * @returns a new Mesh
  28010. */
  28011. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28012. /**
  28013. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28014. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28015. * @param name defines the name of the mesh to create
  28016. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28017. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28018. * @param closePath creates a seam between the first and the last points of each path of the path array
  28019. * @param offset is taken in account only if the `pathArray` is containing a single path
  28020. * @param scene defines the hosting scene
  28021. * @param updatable defines if the mesh must be flagged as updatable
  28022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28023. * @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)
  28024. * @returns a new Mesh
  28025. */
  28026. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28027. /**
  28028. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28029. * @param name defines the name of the mesh to create
  28030. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28031. * @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
  28032. * @param scene defines the hosting scene
  28033. * @param updatable defines if the mesh must be flagged as updatable
  28034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28035. * @returns a new Mesh
  28036. */
  28037. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28038. /**
  28039. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28040. * @param name defines the name of the mesh to create
  28041. * @param size sets the size (float) of each box side (default 1)
  28042. * @param scene defines the hosting scene
  28043. * @param updatable defines if the mesh must be flagged as updatable
  28044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28048. /**
  28049. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28050. * @param name defines the name of the mesh to create
  28051. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28052. * @param diameter sets the diameter size (float) of the sphere (default 1)
  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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28059. /**
  28060. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28063. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28064. * @param scene defines the hosting scene
  28065. * @returns a new Mesh
  28066. */
  28067. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28068. /**
  28069. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28070. * @param name defines the name of the mesh to create
  28071. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28072. * @param diameterTop set the top cap diameter (floats, default 1)
  28073. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28074. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28075. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28076. * @param scene defines the hosting scene
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28079. * @returns a new Mesh
  28080. */
  28081. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28082. /**
  28083. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28084. * @param name defines the name of the mesh to create
  28085. * @param diameter sets the diameter size (float) of the torus (default 1)
  28086. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28087. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28088. * @param scene defines the hosting scene
  28089. * @param updatable defines if the mesh must be flagged as updatable
  28090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28091. * @returns a new Mesh
  28092. */
  28093. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28094. /**
  28095. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28096. * @param name defines the name of the mesh to create
  28097. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28098. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28099. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28100. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28101. * @param p the number of windings on X axis (positive integers, default 2)
  28102. * @param q the number of windings on Y axis (positive integers, default 3)
  28103. * @param scene defines the hosting scene
  28104. * @param updatable defines if the mesh must be flagged as updatable
  28105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28106. * @returns a new Mesh
  28107. */
  28108. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28109. /**
  28110. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28111. * @param name defines the name of the mesh to create
  28112. * @param points is an array successive Vector3
  28113. * @param scene defines the hosting scene
  28114. * @param updatable defines if the mesh must be flagged as updatable
  28115. * @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).
  28116. * @returns a new Mesh
  28117. */
  28118. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28119. /**
  28120. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28121. * @param name defines the name of the mesh to create
  28122. * @param points is an array successive Vector3
  28123. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28124. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28125. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28126. * @param scene defines the hosting scene
  28127. * @param updatable defines if the mesh must be flagged as updatable
  28128. * @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)
  28129. * @returns a new Mesh
  28130. */
  28131. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28132. /**
  28133. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28134. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28135. * 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.
  28136. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28137. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28138. * Remember you can only change the shape positions, not their number when updating a polygon.
  28139. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28140. * @param name defines the name of the mesh to create
  28141. * @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
  28142. * @param scene defines the hosting scene
  28143. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28144. * @param updatable defines if the mesh must be flagged as updatable
  28145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28146. * @param earcutInjection can be used to inject your own earcut reference
  28147. * @returns a new Mesh
  28148. */
  28149. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28150. /**
  28151. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28152. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28153. * @param name defines the name of the mesh to create
  28154. * @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
  28155. * @param depth defines the height of extrusion
  28156. * @param scene defines the hosting scene
  28157. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28158. * @param updatable defines if the mesh must be flagged as updatable
  28159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28160. * @param earcutInjection can be used to inject your own earcut reference
  28161. * @returns a new Mesh
  28162. */
  28163. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28164. /**
  28165. * Creates an extruded shape mesh.
  28166. * 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
  28167. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28168. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28169. * @param name defines the name of the mesh to create
  28170. * @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
  28171. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28172. * @param scale is the value to scale the shape
  28173. * @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
  28174. * @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
  28175. * @param scene defines the hosting scene
  28176. * @param updatable defines if the mesh must be flagged as updatable
  28177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28178. * @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)
  28179. * @returns a new Mesh
  28180. */
  28181. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28182. /**
  28183. * Creates an custom extruded shape mesh.
  28184. * The custom extrusion is a parametric shape.
  28185. * It has no predefined shape. Its final shape will depend on the input parameters.
  28186. * Please consider using the same method from the MeshBuilder class instead
  28187. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28188. * @param name defines the name of the mesh to create
  28189. * @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
  28190. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28191. * @param scaleFunction is a custom Javascript function called on each path point
  28192. * @param rotationFunction is a custom Javascript function called on each path point
  28193. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28194. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28195. * @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
  28196. * @param scene defines the hosting scene
  28197. * @param updatable defines if the mesh must be flagged as updatable
  28198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28199. * @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)
  28200. * @returns a new Mesh
  28201. */
  28202. 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;
  28203. /**
  28204. * Creates lathe mesh.
  28205. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28206. * Please consider using the same method from the MeshBuilder class instead
  28207. * @param name defines the name of the mesh to create
  28208. * @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
  28209. * @param radius is the radius value of the lathe
  28210. * @param tessellation is the side number of the lathe.
  28211. * @param scene defines the hosting scene
  28212. * @param updatable defines if the mesh must be flagged as updatable
  28213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28214. * @returns a new Mesh
  28215. */
  28216. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28217. /**
  28218. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28219. * @param name defines the name of the mesh to create
  28220. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28221. * @param scene defines the hosting scene
  28222. * @param updatable defines if the mesh must be flagged as updatable
  28223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28224. * @returns a new Mesh
  28225. */
  28226. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28227. /**
  28228. * Creates a ground mesh.
  28229. * Please consider using the same method from the MeshBuilder class instead
  28230. * @param name defines the name of the mesh to create
  28231. * @param width set the width of the ground
  28232. * @param height set the height of the ground
  28233. * @param subdivisions sets the number of subdivisions per side
  28234. * @param scene defines the hosting scene
  28235. * @param updatable defines if the mesh must be flagged as updatable
  28236. * @returns a new Mesh
  28237. */
  28238. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28239. /**
  28240. * Creates a tiled ground mesh.
  28241. * Please consider using the same method from the MeshBuilder class instead
  28242. * @param name defines the name of the mesh to create
  28243. * @param xmin set the ground minimum X coordinate
  28244. * @param zmin set the ground minimum Y coordinate
  28245. * @param xmax set the ground maximum X coordinate
  28246. * @param zmax set the ground maximum Z coordinate
  28247. * @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
  28248. * @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
  28249. * @param scene defines the hosting scene
  28250. * @param updatable defines if the mesh must be flagged as updatable
  28251. * @returns a new Mesh
  28252. */
  28253. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28254. w: number;
  28255. h: number;
  28256. }, precision: {
  28257. w: number;
  28258. h: number;
  28259. }, scene: Scene, updatable?: boolean): Mesh;
  28260. /**
  28261. * Creates a ground mesh from a height map.
  28262. * Please consider using the same method from the MeshBuilder class instead
  28263. * @see http://doc.babylonjs.com/babylon101/height_map
  28264. * @param name defines the name of the mesh to create
  28265. * @param url sets the URL of the height map image resource
  28266. * @param width set the ground width size
  28267. * @param height set the ground height size
  28268. * @param subdivisions sets the number of subdivision per side
  28269. * @param minHeight is the minimum altitude on the ground
  28270. * @param maxHeight is the maximum altitude on the ground
  28271. * @param scene defines the hosting scene
  28272. * @param updatable defines if the mesh must be flagged as updatable
  28273. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28274. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28275. * @returns a new Mesh
  28276. */
  28277. 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;
  28278. /**
  28279. * Creates a tube mesh.
  28280. * The tube is a parametric shape.
  28281. * It has no predefined shape. Its final shape will depend on the input parameters.
  28282. * Please consider using the same method from the MeshBuilder class instead
  28283. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28284. * @param name defines the name of the mesh to create
  28285. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28286. * @param radius sets the tube radius size
  28287. * @param tessellation is the number of sides on the tubular surface
  28288. * @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
  28289. * @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
  28290. * @param scene defines the hosting scene
  28291. * @param updatable defines if the mesh must be flagged as updatable
  28292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28293. * @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)
  28294. * @returns a new Mesh
  28295. */
  28296. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28297. (i: number, distance: number): number;
  28298. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28299. /**
  28300. * Creates a polyhedron mesh.
  28301. * Please consider using the same method from the MeshBuilder class instead.
  28302. * * 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
  28303. * * The parameter `size` (positive float, default 1) sets the polygon size
  28304. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28305. * * 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`
  28306. * * 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
  28307. * * 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)`)
  28308. * * 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
  28309. * * 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
  28310. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28311. * * 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
  28312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28313. * @param name defines the name of the mesh to create
  28314. * @param options defines the options used to create the mesh
  28315. * @param scene defines the hosting scene
  28316. * @returns a new Mesh
  28317. */
  28318. static CreatePolyhedron(name: string, options: {
  28319. type?: number;
  28320. size?: number;
  28321. sizeX?: number;
  28322. sizeY?: number;
  28323. sizeZ?: number;
  28324. custom?: any;
  28325. faceUV?: Vector4[];
  28326. faceColors?: Color4[];
  28327. updatable?: boolean;
  28328. sideOrientation?: number;
  28329. }, scene: Scene): Mesh;
  28330. /**
  28331. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28332. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28333. * * 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`)
  28334. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28335. * * 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
  28336. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28337. * * 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
  28338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28339. * @param name defines the name of the mesh
  28340. * @param options defines the options used to create the mesh
  28341. * @param scene defines the hosting scene
  28342. * @returns a new Mesh
  28343. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28344. */
  28345. static CreateIcoSphere(name: string, options: {
  28346. radius?: number;
  28347. flat?: boolean;
  28348. subdivisions?: number;
  28349. sideOrientation?: number;
  28350. updatable?: boolean;
  28351. }, scene: Scene): Mesh;
  28352. /**
  28353. * Creates a decal mesh.
  28354. * Please consider using the same method from the MeshBuilder class instead.
  28355. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28356. * @param name defines the name of the mesh
  28357. * @param sourceMesh defines the mesh receiving the decal
  28358. * @param position sets the position of the decal in world coordinates
  28359. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28360. * @param size sets the decal scaling
  28361. * @param angle sets the angle to rotate the decal
  28362. * @returns a new Mesh
  28363. */
  28364. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28365. /**
  28366. * Prepare internal position array for software CPU skinning
  28367. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28368. */
  28369. setPositionsForCPUSkinning(): Float32Array;
  28370. /**
  28371. * Prepare internal normal array for software CPU skinning
  28372. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28373. */
  28374. setNormalsForCPUSkinning(): Float32Array;
  28375. /**
  28376. * Updates the vertex buffer by applying transformation from the bones
  28377. * @param skeleton defines the skeleton to apply to current mesh
  28378. * @returns the current mesh
  28379. */
  28380. applySkeleton(skeleton: Skeleton): Mesh;
  28381. /**
  28382. * 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
  28383. * @param meshes defines the list of meshes to scan
  28384. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28385. */
  28386. static MinMax(meshes: AbstractMesh[]): {
  28387. min: Vector3;
  28388. max: Vector3;
  28389. };
  28390. /**
  28391. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28392. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28393. * @returns a vector3
  28394. */
  28395. static Center(meshesOrMinMaxVector: {
  28396. min: Vector3;
  28397. max: Vector3;
  28398. } | AbstractMesh[]): Vector3;
  28399. /**
  28400. * Merge the array of meshes into a single mesh for performance reasons.
  28401. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28402. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28403. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28404. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28405. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28406. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28407. * @returns a new mesh
  28408. */
  28409. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28410. /** @hidden */
  28411. addInstance(instance: InstancedMesh): void;
  28412. /** @hidden */
  28413. removeInstance(instance: InstancedMesh): void;
  28414. }
  28415. }
  28416. declare module BABYLON {
  28417. /**
  28418. * This is the base class of all the camera used in the application.
  28419. * @see http://doc.babylonjs.com/features/cameras
  28420. */
  28421. export class Camera extends Node {
  28422. /** @hidden */
  28423. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28424. /**
  28425. * This is the default projection mode used by the cameras.
  28426. * It helps recreating a feeling of perspective and better appreciate depth.
  28427. * This is the best way to simulate real life cameras.
  28428. */
  28429. static readonly PERSPECTIVE_CAMERA: number;
  28430. /**
  28431. * This helps creating camera with an orthographic mode.
  28432. * 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.
  28433. */
  28434. static readonly ORTHOGRAPHIC_CAMERA: number;
  28435. /**
  28436. * This is the default FOV mode for perspective cameras.
  28437. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28438. */
  28439. static readonly FOVMODE_VERTICAL_FIXED: number;
  28440. /**
  28441. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28442. */
  28443. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28444. /**
  28445. * This specifies ther is no need for a camera rig.
  28446. * Basically only one eye is rendered corresponding to the camera.
  28447. */
  28448. static readonly RIG_MODE_NONE: number;
  28449. /**
  28450. * Simulates a camera Rig with one blue eye and one red eye.
  28451. * This can be use with 3d blue and red glasses.
  28452. */
  28453. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28454. /**
  28455. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28456. */
  28457. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28458. /**
  28459. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28460. */
  28461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28462. /**
  28463. * Defines that both eyes of the camera will be rendered over under each other.
  28464. */
  28465. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28466. /**
  28467. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28468. */
  28469. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28470. /**
  28471. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28472. */
  28473. static readonly RIG_MODE_VR: number;
  28474. /**
  28475. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28476. */
  28477. static readonly RIG_MODE_WEBVR: number;
  28478. /**
  28479. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28480. */
  28481. static readonly RIG_MODE_CUSTOM: number;
  28482. /**
  28483. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28484. */
  28485. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28486. /**
  28487. * Define the input manager associated with the camera.
  28488. */
  28489. inputs: CameraInputsManager<Camera>;
  28490. /** @hidden */
  28491. _position: Vector3;
  28492. /**
  28493. * Define the current local position of the camera in the scene
  28494. */
  28495. get position(): Vector3;
  28496. set position(newPosition: Vector3);
  28497. /**
  28498. * The vector the camera should consider as up.
  28499. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28500. */
  28501. upVector: Vector3;
  28502. /**
  28503. * Define the current limit on the left side for an orthographic camera
  28504. * In scene unit
  28505. */
  28506. orthoLeft: Nullable<number>;
  28507. /**
  28508. * Define the current limit on the right side for an orthographic camera
  28509. * In scene unit
  28510. */
  28511. orthoRight: Nullable<number>;
  28512. /**
  28513. * Define the current limit on the bottom side for an orthographic camera
  28514. * In scene unit
  28515. */
  28516. orthoBottom: Nullable<number>;
  28517. /**
  28518. * Define the current limit on the top side for an orthographic camera
  28519. * In scene unit
  28520. */
  28521. orthoTop: Nullable<number>;
  28522. /**
  28523. * Field Of View is set in Radians. (default is 0.8)
  28524. */
  28525. fov: number;
  28526. /**
  28527. * Define the minimum distance the camera can see from.
  28528. * This is important to note that the depth buffer are not infinite and the closer it starts
  28529. * the more your scene might encounter depth fighting issue.
  28530. */
  28531. minZ: number;
  28532. /**
  28533. * Define the maximum distance the camera can see to.
  28534. * This is important to note that the depth buffer are not infinite and the further it end
  28535. * the more your scene might encounter depth fighting issue.
  28536. */
  28537. maxZ: number;
  28538. /**
  28539. * Define the default inertia of the camera.
  28540. * This helps giving a smooth feeling to the camera movement.
  28541. */
  28542. inertia: number;
  28543. /**
  28544. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28545. */
  28546. mode: number;
  28547. /**
  28548. * Define whether the camera is intermediate.
  28549. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28550. */
  28551. isIntermediate: boolean;
  28552. /**
  28553. * Define the viewport of the camera.
  28554. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28555. */
  28556. viewport: Viewport;
  28557. /**
  28558. * Restricts the camera to viewing objects with the same layerMask.
  28559. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28560. */
  28561. layerMask: number;
  28562. /**
  28563. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28564. */
  28565. fovMode: number;
  28566. /**
  28567. * Rig mode of the camera.
  28568. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28569. * This is normally controlled byt the camera themselves as internal use.
  28570. */
  28571. cameraRigMode: number;
  28572. /**
  28573. * Defines the distance between both "eyes" in case of a RIG
  28574. */
  28575. interaxialDistance: number;
  28576. /**
  28577. * Defines if stereoscopic rendering is done side by side or over under.
  28578. */
  28579. isStereoscopicSideBySide: boolean;
  28580. /**
  28581. * 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
  28582. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28583. * else in the scene. (Eg. security camera)
  28584. *
  28585. * 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)
  28586. */
  28587. customRenderTargets: RenderTargetTexture[];
  28588. /**
  28589. * When set, the camera will render to this render target instead of the default canvas
  28590. *
  28591. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28592. */
  28593. outputRenderTarget: Nullable<RenderTargetTexture>;
  28594. /**
  28595. * Observable triggered when the camera view matrix has changed.
  28596. */
  28597. onViewMatrixChangedObservable: Observable<Camera>;
  28598. /**
  28599. * Observable triggered when the camera Projection matrix has changed.
  28600. */
  28601. onProjectionMatrixChangedObservable: Observable<Camera>;
  28602. /**
  28603. * Observable triggered when the inputs have been processed.
  28604. */
  28605. onAfterCheckInputsObservable: Observable<Camera>;
  28606. /**
  28607. * Observable triggered when reset has been called and applied to the camera.
  28608. */
  28609. onRestoreStateObservable: Observable<Camera>;
  28610. /**
  28611. * Is this camera a part of a rig system?
  28612. */
  28613. isRigCamera: boolean;
  28614. /**
  28615. * If isRigCamera set to true this will be set with the parent camera.
  28616. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28617. */
  28618. rigParent?: Camera;
  28619. /** @hidden */
  28620. _cameraRigParams: any;
  28621. /** @hidden */
  28622. _rigCameras: Camera[];
  28623. /** @hidden */
  28624. _rigPostProcess: Nullable<PostProcess>;
  28625. protected _webvrViewMatrix: Matrix;
  28626. /** @hidden */
  28627. _skipRendering: boolean;
  28628. /** @hidden */
  28629. _projectionMatrix: Matrix;
  28630. /** @hidden */
  28631. _postProcesses: Nullable<PostProcess>[];
  28632. /** @hidden */
  28633. _activeMeshes: SmartArray<AbstractMesh>;
  28634. protected _globalPosition: Vector3;
  28635. /** @hidden */
  28636. _computedViewMatrix: Matrix;
  28637. private _doNotComputeProjectionMatrix;
  28638. private _transformMatrix;
  28639. private _frustumPlanes;
  28640. private _refreshFrustumPlanes;
  28641. private _storedFov;
  28642. private _stateStored;
  28643. /**
  28644. * Instantiates a new camera object.
  28645. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28646. * @see http://doc.babylonjs.com/features/cameras
  28647. * @param name Defines the name of the camera in the scene
  28648. * @param position Defines the position of the camera
  28649. * @param scene Defines the scene the camera belongs too
  28650. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28651. */
  28652. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28653. /**
  28654. * Store current camera state (fov, position, etc..)
  28655. * @returns the camera
  28656. */
  28657. storeState(): Camera;
  28658. /**
  28659. * Restores the camera state values if it has been stored. You must call storeState() first
  28660. */
  28661. protected _restoreStateValues(): boolean;
  28662. /**
  28663. * Restored camera state. You must call storeState() first.
  28664. * @returns true if restored and false otherwise
  28665. */
  28666. restoreState(): boolean;
  28667. /**
  28668. * Gets the class name of the camera.
  28669. * @returns the class name
  28670. */
  28671. getClassName(): string;
  28672. /** @hidden */
  28673. readonly _isCamera: boolean;
  28674. /**
  28675. * Gets a string representation of the camera useful for debug purpose.
  28676. * @param fullDetails Defines that a more verboe level of logging is required
  28677. * @returns the string representation
  28678. */
  28679. toString(fullDetails?: boolean): string;
  28680. /**
  28681. * Gets the current world space position of the camera.
  28682. */
  28683. get globalPosition(): Vector3;
  28684. /**
  28685. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28686. * @returns the active meshe list
  28687. */
  28688. getActiveMeshes(): SmartArray<AbstractMesh>;
  28689. /**
  28690. * Check whether a mesh is part of the current active mesh list of the camera
  28691. * @param mesh Defines the mesh to check
  28692. * @returns true if active, false otherwise
  28693. */
  28694. isActiveMesh(mesh: Mesh): boolean;
  28695. /**
  28696. * Is this camera ready to be used/rendered
  28697. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28698. * @return true if the camera is ready
  28699. */
  28700. isReady(completeCheck?: boolean): boolean;
  28701. /** @hidden */
  28702. _initCache(): void;
  28703. /** @hidden */
  28704. _updateCache(ignoreParentClass?: boolean): void;
  28705. /** @hidden */
  28706. _isSynchronized(): boolean;
  28707. /** @hidden */
  28708. _isSynchronizedViewMatrix(): boolean;
  28709. /** @hidden */
  28710. _isSynchronizedProjectionMatrix(): boolean;
  28711. /**
  28712. * Attach the input controls to a specific dom element to get the input from.
  28713. * @param element Defines the element the controls should be listened from
  28714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28715. */
  28716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28717. /**
  28718. * Detach the current controls from the specified dom element.
  28719. * @param element Defines the element to stop listening the inputs from
  28720. */
  28721. detachControl(element: HTMLElement): void;
  28722. /**
  28723. * Update the camera state according to the different inputs gathered during the frame.
  28724. */
  28725. update(): void;
  28726. /** @hidden */
  28727. _checkInputs(): void;
  28728. /** @hidden */
  28729. get rigCameras(): Camera[];
  28730. /**
  28731. * Gets the post process used by the rig cameras
  28732. */
  28733. get rigPostProcess(): Nullable<PostProcess>;
  28734. /**
  28735. * Internal, gets the first post proces.
  28736. * @returns the first post process to be run on this camera.
  28737. */
  28738. _getFirstPostProcess(): Nullable<PostProcess>;
  28739. private _cascadePostProcessesToRigCams;
  28740. /**
  28741. * Attach a post process to the camera.
  28742. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28743. * @param postProcess The post process to attach to the camera
  28744. * @param insertAt The position of the post process in case several of them are in use in the scene
  28745. * @returns the position the post process has been inserted at
  28746. */
  28747. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28748. /**
  28749. * Detach a post process to the camera.
  28750. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28751. * @param postProcess The post process to detach from the camera
  28752. */
  28753. detachPostProcess(postProcess: PostProcess): void;
  28754. /**
  28755. * Gets the current world matrix of the camera
  28756. */
  28757. getWorldMatrix(): Matrix;
  28758. /** @hidden */
  28759. _getViewMatrix(): Matrix;
  28760. /**
  28761. * Gets the current view matrix of the camera.
  28762. * @param force forces the camera to recompute the matrix without looking at the cached state
  28763. * @returns the view matrix
  28764. */
  28765. getViewMatrix(force?: boolean): Matrix;
  28766. /**
  28767. * Freeze the projection matrix.
  28768. * It will prevent the cache check of the camera projection compute and can speed up perf
  28769. * if no parameter of the camera are meant to change
  28770. * @param projection Defines manually a projection if necessary
  28771. */
  28772. freezeProjectionMatrix(projection?: Matrix): void;
  28773. /**
  28774. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28775. */
  28776. unfreezeProjectionMatrix(): void;
  28777. /**
  28778. * Gets the current projection matrix of the camera.
  28779. * @param force forces the camera to recompute the matrix without looking at the cached state
  28780. * @returns the projection matrix
  28781. */
  28782. getProjectionMatrix(force?: boolean): Matrix;
  28783. /**
  28784. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28785. * @returns a Matrix
  28786. */
  28787. getTransformationMatrix(): Matrix;
  28788. private _updateFrustumPlanes;
  28789. /**
  28790. * Checks if a cullable object (mesh...) is in the camera frustum
  28791. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28792. * @param target The object to check
  28793. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28794. * @returns true if the object is in frustum otherwise false
  28795. */
  28796. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28797. /**
  28798. * Checks if a cullable object (mesh...) is in the camera frustum
  28799. * Unlike isInFrustum this cheks the full bounding box
  28800. * @param target The object to check
  28801. * @returns true if the object is in frustum otherwise false
  28802. */
  28803. isCompletelyInFrustum(target: ICullable): boolean;
  28804. /**
  28805. * Gets a ray in the forward direction from the camera.
  28806. * @param length Defines the length of the ray to create
  28807. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28808. * @param origin Defines the start point of the ray which defaults to the camera position
  28809. * @returns the forward ray
  28810. */
  28811. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28812. /**
  28813. * Releases resources associated with this node.
  28814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28816. */
  28817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28818. /** @hidden */
  28819. _isLeftCamera: boolean;
  28820. /**
  28821. * Gets the left camera of a rig setup in case of Rigged Camera
  28822. */
  28823. get isLeftCamera(): boolean;
  28824. /** @hidden */
  28825. _isRightCamera: boolean;
  28826. /**
  28827. * Gets the right camera of a rig setup in case of Rigged Camera
  28828. */
  28829. get isRightCamera(): boolean;
  28830. /**
  28831. * Gets the left camera of a rig setup in case of Rigged Camera
  28832. */
  28833. get leftCamera(): Nullable<FreeCamera>;
  28834. /**
  28835. * Gets the right camera of a rig setup in case of Rigged Camera
  28836. */
  28837. get rightCamera(): Nullable<FreeCamera>;
  28838. /**
  28839. * Gets the left camera target of a rig setup in case of Rigged Camera
  28840. * @returns the target position
  28841. */
  28842. getLeftTarget(): Nullable<Vector3>;
  28843. /**
  28844. * Gets the right camera target of a rig setup in case of Rigged Camera
  28845. * @returns the target position
  28846. */
  28847. getRightTarget(): Nullable<Vector3>;
  28848. /**
  28849. * @hidden
  28850. */
  28851. setCameraRigMode(mode: number, rigParams: any): void;
  28852. /** @hidden */
  28853. static _setStereoscopicRigMode(camera: Camera): void;
  28854. /** @hidden */
  28855. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28856. /** @hidden */
  28857. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28858. /** @hidden */
  28859. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28860. /** @hidden */
  28861. _getVRProjectionMatrix(): Matrix;
  28862. protected _updateCameraRotationMatrix(): void;
  28863. protected _updateWebVRCameraRotationMatrix(): void;
  28864. /**
  28865. * This function MUST be overwritten by the different WebVR cameras available.
  28866. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28867. * @hidden
  28868. */
  28869. _getWebVRProjectionMatrix(): Matrix;
  28870. /**
  28871. * This function MUST be overwritten by the different WebVR cameras available.
  28872. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28873. * @hidden
  28874. */
  28875. _getWebVRViewMatrix(): Matrix;
  28876. /** @hidden */
  28877. setCameraRigParameter(name: string, value: any): void;
  28878. /**
  28879. * needs to be overridden by children so sub has required properties to be copied
  28880. * @hidden
  28881. */
  28882. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28883. /**
  28884. * May need to be overridden by children
  28885. * @hidden
  28886. */
  28887. _updateRigCameras(): void;
  28888. /** @hidden */
  28889. _setupInputs(): void;
  28890. /**
  28891. * Serialiaze the camera setup to a json represention
  28892. * @returns the JSON representation
  28893. */
  28894. serialize(): any;
  28895. /**
  28896. * Clones the current camera.
  28897. * @param name The cloned camera name
  28898. * @returns the cloned camera
  28899. */
  28900. clone(name: string): Camera;
  28901. /**
  28902. * Gets the direction of the camera relative to a given local axis.
  28903. * @param localAxis Defines the reference axis to provide a relative direction.
  28904. * @return the direction
  28905. */
  28906. getDirection(localAxis: Vector3): Vector3;
  28907. /**
  28908. * Returns the current camera absolute rotation
  28909. */
  28910. get absoluteRotation(): Quaternion;
  28911. /**
  28912. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28913. * @param localAxis Defines the reference axis to provide a relative direction.
  28914. * @param result Defines the vector to store the result in
  28915. */
  28916. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28917. /**
  28918. * Gets a camera constructor for a given camera type
  28919. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28920. * @param name The name of the camera the result will be able to instantiate
  28921. * @param scene The scene the result will construct the camera in
  28922. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28923. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28924. * @returns a factory method to construc the camera
  28925. */
  28926. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28927. /**
  28928. * Compute the world matrix of the camera.
  28929. * @returns the camera world matrix
  28930. */
  28931. computeWorldMatrix(): Matrix;
  28932. /**
  28933. * Parse a JSON and creates the camera from the parsed information
  28934. * @param parsedCamera The JSON to parse
  28935. * @param scene The scene to instantiate the camera in
  28936. * @returns the newly constructed camera
  28937. */
  28938. static Parse(parsedCamera: any, scene: Scene): Camera;
  28939. }
  28940. }
  28941. declare module BABYLON {
  28942. /**
  28943. * Class containing static functions to help procedurally build meshes
  28944. */
  28945. export class DiscBuilder {
  28946. /**
  28947. * Creates a plane polygonal mesh. By default, this is a disc
  28948. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28949. * * 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
  28950. * * 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
  28951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28952. * * 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
  28953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28954. * @param name defines the name of the mesh
  28955. * @param options defines the options used to create the mesh
  28956. * @param scene defines the hosting scene
  28957. * @returns the plane polygonal mesh
  28958. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28959. */
  28960. static CreateDisc(name: string, options: {
  28961. radius?: number;
  28962. tessellation?: number;
  28963. arc?: number;
  28964. updatable?: boolean;
  28965. sideOrientation?: number;
  28966. frontUVs?: Vector4;
  28967. backUVs?: Vector4;
  28968. }, scene?: Nullable<Scene>): Mesh;
  28969. }
  28970. }
  28971. declare module BABYLON {
  28972. /**
  28973. * Options to be used when creating a FresnelParameters.
  28974. */
  28975. export type IFresnelParametersCreationOptions = {
  28976. /**
  28977. * Define the color used on edges (grazing angle)
  28978. */
  28979. leftColor?: Color3;
  28980. /**
  28981. * Define the color used on center
  28982. */
  28983. rightColor?: Color3;
  28984. /**
  28985. * Define bias applied to computed fresnel term
  28986. */
  28987. bias?: number;
  28988. /**
  28989. * Defined the power exponent applied to fresnel term
  28990. */
  28991. power?: number;
  28992. /**
  28993. * Define if the fresnel effect is enable or not.
  28994. */
  28995. isEnabled?: boolean;
  28996. };
  28997. /**
  28998. * Serialized format for FresnelParameters.
  28999. */
  29000. export type IFresnelParametersSerialized = {
  29001. /**
  29002. * Define the color used on edges (grazing angle) [as an array]
  29003. */
  29004. leftColor: number[];
  29005. /**
  29006. * Define the color used on center [as an array]
  29007. */
  29008. rightColor: number[];
  29009. /**
  29010. * Define bias applied to computed fresnel term
  29011. */
  29012. bias: number;
  29013. /**
  29014. * Defined the power exponent applied to fresnel term
  29015. */
  29016. power?: number;
  29017. /**
  29018. * Define if the fresnel effect is enable or not.
  29019. */
  29020. isEnabled: boolean;
  29021. };
  29022. /**
  29023. * This represents all the required information to add a fresnel effect on a material:
  29024. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29025. */
  29026. export class FresnelParameters {
  29027. private _isEnabled;
  29028. /**
  29029. * Define if the fresnel effect is enable or not.
  29030. */
  29031. get isEnabled(): boolean;
  29032. set isEnabled(value: boolean);
  29033. /**
  29034. * Define the color used on edges (grazing angle)
  29035. */
  29036. leftColor: Color3;
  29037. /**
  29038. * Define the color used on center
  29039. */
  29040. rightColor: Color3;
  29041. /**
  29042. * Define bias applied to computed fresnel term
  29043. */
  29044. bias: number;
  29045. /**
  29046. * Defined the power exponent applied to fresnel term
  29047. */
  29048. power: number;
  29049. /**
  29050. * Creates a new FresnelParameters object.
  29051. *
  29052. * @param options provide your own settings to optionally to override defaults
  29053. */
  29054. constructor(options?: IFresnelParametersCreationOptions);
  29055. /**
  29056. * Clones the current fresnel and its valuues
  29057. * @returns a clone fresnel configuration
  29058. */
  29059. clone(): FresnelParameters;
  29060. /**
  29061. * Determines equality between FresnelParameters objects
  29062. * @param otherFresnelParameters defines the second operand
  29063. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29064. */
  29065. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29066. /**
  29067. * Serializes the current fresnel parameters to a JSON representation.
  29068. * @return the JSON serialization
  29069. */
  29070. serialize(): IFresnelParametersSerialized;
  29071. /**
  29072. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29073. * @param parsedFresnelParameters Define the JSON representation
  29074. * @returns the parsed parameters
  29075. */
  29076. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29077. }
  29078. }
  29079. declare module BABYLON {
  29080. /**
  29081. * This groups all the flags used to control the materials channel.
  29082. */
  29083. export class MaterialFlags {
  29084. private static _DiffuseTextureEnabled;
  29085. /**
  29086. * Are diffuse textures enabled in the application.
  29087. */
  29088. static get DiffuseTextureEnabled(): boolean;
  29089. static set DiffuseTextureEnabled(value: boolean);
  29090. private static _AmbientTextureEnabled;
  29091. /**
  29092. * Are ambient textures enabled in the application.
  29093. */
  29094. static get AmbientTextureEnabled(): boolean;
  29095. static set AmbientTextureEnabled(value: boolean);
  29096. private static _OpacityTextureEnabled;
  29097. /**
  29098. * Are opacity textures enabled in the application.
  29099. */
  29100. static get OpacityTextureEnabled(): boolean;
  29101. static set OpacityTextureEnabled(value: boolean);
  29102. private static _ReflectionTextureEnabled;
  29103. /**
  29104. * Are reflection textures enabled in the application.
  29105. */
  29106. static get ReflectionTextureEnabled(): boolean;
  29107. static set ReflectionTextureEnabled(value: boolean);
  29108. private static _EmissiveTextureEnabled;
  29109. /**
  29110. * Are emissive textures enabled in the application.
  29111. */
  29112. static get EmissiveTextureEnabled(): boolean;
  29113. static set EmissiveTextureEnabled(value: boolean);
  29114. private static _SpecularTextureEnabled;
  29115. /**
  29116. * Are specular textures enabled in the application.
  29117. */
  29118. static get SpecularTextureEnabled(): boolean;
  29119. static set SpecularTextureEnabled(value: boolean);
  29120. private static _BumpTextureEnabled;
  29121. /**
  29122. * Are bump textures enabled in the application.
  29123. */
  29124. static get BumpTextureEnabled(): boolean;
  29125. static set BumpTextureEnabled(value: boolean);
  29126. private static _LightmapTextureEnabled;
  29127. /**
  29128. * Are lightmap textures enabled in the application.
  29129. */
  29130. static get LightmapTextureEnabled(): boolean;
  29131. static set LightmapTextureEnabled(value: boolean);
  29132. private static _RefractionTextureEnabled;
  29133. /**
  29134. * Are refraction textures enabled in the application.
  29135. */
  29136. static get RefractionTextureEnabled(): boolean;
  29137. static set RefractionTextureEnabled(value: boolean);
  29138. private static _ColorGradingTextureEnabled;
  29139. /**
  29140. * Are color grading textures enabled in the application.
  29141. */
  29142. static get ColorGradingTextureEnabled(): boolean;
  29143. static set ColorGradingTextureEnabled(value: boolean);
  29144. private static _FresnelEnabled;
  29145. /**
  29146. * Are fresnels enabled in the application.
  29147. */
  29148. static get FresnelEnabled(): boolean;
  29149. static set FresnelEnabled(value: boolean);
  29150. private static _ClearCoatTextureEnabled;
  29151. /**
  29152. * Are clear coat textures enabled in the application.
  29153. */
  29154. static get ClearCoatTextureEnabled(): boolean;
  29155. static set ClearCoatTextureEnabled(value: boolean);
  29156. private static _ClearCoatBumpTextureEnabled;
  29157. /**
  29158. * Are clear coat bump textures enabled in the application.
  29159. */
  29160. static get ClearCoatBumpTextureEnabled(): boolean;
  29161. static set ClearCoatBumpTextureEnabled(value: boolean);
  29162. private static _ClearCoatTintTextureEnabled;
  29163. /**
  29164. * Are clear coat tint textures enabled in the application.
  29165. */
  29166. static get ClearCoatTintTextureEnabled(): boolean;
  29167. static set ClearCoatTintTextureEnabled(value: boolean);
  29168. private static _SheenTextureEnabled;
  29169. /**
  29170. * Are sheen textures enabled in the application.
  29171. */
  29172. static get SheenTextureEnabled(): boolean;
  29173. static set SheenTextureEnabled(value: boolean);
  29174. private static _AnisotropicTextureEnabled;
  29175. /**
  29176. * Are anisotropic textures enabled in the application.
  29177. */
  29178. static get AnisotropicTextureEnabled(): boolean;
  29179. static set AnisotropicTextureEnabled(value: boolean);
  29180. private static _ThicknessTextureEnabled;
  29181. /**
  29182. * Are thickness textures enabled in the application.
  29183. */
  29184. static get ThicknessTextureEnabled(): boolean;
  29185. static set ThicknessTextureEnabled(value: boolean);
  29186. }
  29187. }
  29188. declare module BABYLON {
  29189. /** @hidden */
  29190. export var defaultFragmentDeclaration: {
  29191. name: string;
  29192. shader: string;
  29193. };
  29194. }
  29195. declare module BABYLON {
  29196. /** @hidden */
  29197. export var defaultUboDeclaration: {
  29198. name: string;
  29199. shader: string;
  29200. };
  29201. }
  29202. declare module BABYLON {
  29203. /** @hidden */
  29204. export var lightFragmentDeclaration: {
  29205. name: string;
  29206. shader: string;
  29207. };
  29208. }
  29209. declare module BABYLON {
  29210. /** @hidden */
  29211. export var lightUboDeclaration: {
  29212. name: string;
  29213. shader: string;
  29214. };
  29215. }
  29216. declare module BABYLON {
  29217. /** @hidden */
  29218. export var lightsFragmentFunctions: {
  29219. name: string;
  29220. shader: string;
  29221. };
  29222. }
  29223. declare module BABYLON {
  29224. /** @hidden */
  29225. export var shadowsFragmentFunctions: {
  29226. name: string;
  29227. shader: string;
  29228. };
  29229. }
  29230. declare module BABYLON {
  29231. /** @hidden */
  29232. export var fresnelFunction: {
  29233. name: string;
  29234. shader: string;
  29235. };
  29236. }
  29237. declare module BABYLON {
  29238. /** @hidden */
  29239. export var bumpFragmentMainFunctions: {
  29240. name: string;
  29241. shader: string;
  29242. };
  29243. }
  29244. declare module BABYLON {
  29245. /** @hidden */
  29246. export var bumpFragmentFunctions: {
  29247. name: string;
  29248. shader: string;
  29249. };
  29250. }
  29251. declare module BABYLON {
  29252. /** @hidden */
  29253. export var logDepthDeclaration: {
  29254. name: string;
  29255. shader: string;
  29256. };
  29257. }
  29258. declare module BABYLON {
  29259. /** @hidden */
  29260. export var bumpFragment: {
  29261. name: string;
  29262. shader: string;
  29263. };
  29264. }
  29265. declare module BABYLON {
  29266. /** @hidden */
  29267. export var depthPrePass: {
  29268. name: string;
  29269. shader: string;
  29270. };
  29271. }
  29272. declare module BABYLON {
  29273. /** @hidden */
  29274. export var lightFragment: {
  29275. name: string;
  29276. shader: string;
  29277. };
  29278. }
  29279. declare module BABYLON {
  29280. /** @hidden */
  29281. export var logDepthFragment: {
  29282. name: string;
  29283. shader: string;
  29284. };
  29285. }
  29286. declare module BABYLON {
  29287. /** @hidden */
  29288. export var defaultPixelShader: {
  29289. name: string;
  29290. shader: string;
  29291. };
  29292. }
  29293. declare module BABYLON {
  29294. /** @hidden */
  29295. export var defaultVertexDeclaration: {
  29296. name: string;
  29297. shader: string;
  29298. };
  29299. }
  29300. declare module BABYLON {
  29301. /** @hidden */
  29302. export var bumpVertexDeclaration: {
  29303. name: string;
  29304. shader: string;
  29305. };
  29306. }
  29307. declare module BABYLON {
  29308. /** @hidden */
  29309. export var bumpVertex: {
  29310. name: string;
  29311. shader: string;
  29312. };
  29313. }
  29314. declare module BABYLON {
  29315. /** @hidden */
  29316. export var fogVertex: {
  29317. name: string;
  29318. shader: string;
  29319. };
  29320. }
  29321. declare module BABYLON {
  29322. /** @hidden */
  29323. export var shadowsVertex: {
  29324. name: string;
  29325. shader: string;
  29326. };
  29327. }
  29328. declare module BABYLON {
  29329. /** @hidden */
  29330. export var pointCloudVertex: {
  29331. name: string;
  29332. shader: string;
  29333. };
  29334. }
  29335. declare module BABYLON {
  29336. /** @hidden */
  29337. export var logDepthVertex: {
  29338. name: string;
  29339. shader: string;
  29340. };
  29341. }
  29342. declare module BABYLON {
  29343. /** @hidden */
  29344. export var defaultVertexShader: {
  29345. name: string;
  29346. shader: string;
  29347. };
  29348. }
  29349. declare module BABYLON {
  29350. /** @hidden */
  29351. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29352. MAINUV1: boolean;
  29353. MAINUV2: boolean;
  29354. DIFFUSE: boolean;
  29355. DIFFUSEDIRECTUV: number;
  29356. AMBIENT: boolean;
  29357. AMBIENTDIRECTUV: number;
  29358. OPACITY: boolean;
  29359. OPACITYDIRECTUV: number;
  29360. OPACITYRGB: boolean;
  29361. REFLECTION: boolean;
  29362. EMISSIVE: boolean;
  29363. EMISSIVEDIRECTUV: number;
  29364. SPECULAR: boolean;
  29365. SPECULARDIRECTUV: number;
  29366. BUMP: boolean;
  29367. BUMPDIRECTUV: number;
  29368. PARALLAX: boolean;
  29369. PARALLAXOCCLUSION: boolean;
  29370. SPECULAROVERALPHA: boolean;
  29371. CLIPPLANE: boolean;
  29372. CLIPPLANE2: boolean;
  29373. CLIPPLANE3: boolean;
  29374. CLIPPLANE4: boolean;
  29375. CLIPPLANE5: boolean;
  29376. CLIPPLANE6: boolean;
  29377. ALPHATEST: boolean;
  29378. DEPTHPREPASS: boolean;
  29379. ALPHAFROMDIFFUSE: boolean;
  29380. POINTSIZE: boolean;
  29381. FOG: boolean;
  29382. SPECULARTERM: boolean;
  29383. DIFFUSEFRESNEL: boolean;
  29384. OPACITYFRESNEL: boolean;
  29385. REFLECTIONFRESNEL: boolean;
  29386. REFRACTIONFRESNEL: boolean;
  29387. EMISSIVEFRESNEL: boolean;
  29388. FRESNEL: boolean;
  29389. NORMAL: boolean;
  29390. UV1: boolean;
  29391. UV2: boolean;
  29392. VERTEXCOLOR: boolean;
  29393. VERTEXALPHA: boolean;
  29394. NUM_BONE_INFLUENCERS: number;
  29395. BonesPerMesh: number;
  29396. BONETEXTURE: boolean;
  29397. INSTANCES: boolean;
  29398. THIN_INSTANCES: boolean;
  29399. GLOSSINESS: boolean;
  29400. ROUGHNESS: boolean;
  29401. EMISSIVEASILLUMINATION: boolean;
  29402. LINKEMISSIVEWITHDIFFUSE: boolean;
  29403. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29404. LIGHTMAP: boolean;
  29405. LIGHTMAPDIRECTUV: number;
  29406. OBJECTSPACE_NORMALMAP: boolean;
  29407. USELIGHTMAPASSHADOWMAP: boolean;
  29408. REFLECTIONMAP_3D: boolean;
  29409. REFLECTIONMAP_SPHERICAL: boolean;
  29410. REFLECTIONMAP_PLANAR: boolean;
  29411. REFLECTIONMAP_CUBIC: boolean;
  29412. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29413. REFLECTIONMAP_PROJECTION: boolean;
  29414. REFLECTIONMAP_SKYBOX: boolean;
  29415. REFLECTIONMAP_EXPLICIT: boolean;
  29416. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29417. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29418. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29419. INVERTCUBICMAP: boolean;
  29420. LOGARITHMICDEPTH: boolean;
  29421. REFRACTION: boolean;
  29422. REFRACTIONMAP_3D: boolean;
  29423. REFLECTIONOVERALPHA: boolean;
  29424. TWOSIDEDLIGHTING: boolean;
  29425. SHADOWFLOAT: boolean;
  29426. MORPHTARGETS: boolean;
  29427. MORPHTARGETS_NORMAL: boolean;
  29428. MORPHTARGETS_TANGENT: boolean;
  29429. MORPHTARGETS_UV: boolean;
  29430. NUM_MORPH_INFLUENCERS: number;
  29431. NONUNIFORMSCALING: boolean;
  29432. PREMULTIPLYALPHA: boolean;
  29433. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29434. ALPHABLEND: boolean;
  29435. RGBDLIGHTMAP: boolean;
  29436. RGBDREFLECTION: boolean;
  29437. RGBDREFRACTION: boolean;
  29438. IMAGEPROCESSING: boolean;
  29439. VIGNETTE: boolean;
  29440. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29441. VIGNETTEBLENDMODEOPAQUE: boolean;
  29442. TONEMAPPING: boolean;
  29443. TONEMAPPING_ACES: boolean;
  29444. CONTRAST: boolean;
  29445. COLORCURVES: boolean;
  29446. COLORGRADING: boolean;
  29447. COLORGRADING3D: boolean;
  29448. SAMPLER3DGREENDEPTH: boolean;
  29449. SAMPLER3DBGRMAP: boolean;
  29450. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29451. MULTIVIEW: boolean;
  29452. /**
  29453. * If the reflection texture on this material is in linear color space
  29454. * @hidden
  29455. */
  29456. IS_REFLECTION_LINEAR: boolean;
  29457. /**
  29458. * If the refraction texture on this material is in linear color space
  29459. * @hidden
  29460. */
  29461. IS_REFRACTION_LINEAR: boolean;
  29462. EXPOSURE: boolean;
  29463. constructor();
  29464. setReflectionMode(modeToEnable: string): void;
  29465. }
  29466. /**
  29467. * This is the default material used in Babylon. It is the best trade off between quality
  29468. * and performances.
  29469. * @see http://doc.babylonjs.com/babylon101/materials
  29470. */
  29471. export class StandardMaterial extends PushMaterial {
  29472. private _diffuseTexture;
  29473. /**
  29474. * The basic texture of the material as viewed under a light.
  29475. */
  29476. diffuseTexture: Nullable<BaseTexture>;
  29477. private _ambientTexture;
  29478. /**
  29479. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29480. */
  29481. ambientTexture: Nullable<BaseTexture>;
  29482. private _opacityTexture;
  29483. /**
  29484. * Define the transparency of the material from a texture.
  29485. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29486. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29487. */
  29488. opacityTexture: Nullable<BaseTexture>;
  29489. private _reflectionTexture;
  29490. /**
  29491. * Define the texture used to display the reflection.
  29492. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29493. */
  29494. reflectionTexture: Nullable<BaseTexture>;
  29495. private _emissiveTexture;
  29496. /**
  29497. * Define texture of the material as if self lit.
  29498. * This will be mixed in the final result even in the absence of light.
  29499. */
  29500. emissiveTexture: Nullable<BaseTexture>;
  29501. private _specularTexture;
  29502. /**
  29503. * Define how the color and intensity of the highlight given by the light in the material.
  29504. */
  29505. specularTexture: Nullable<BaseTexture>;
  29506. private _bumpTexture;
  29507. /**
  29508. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29509. * 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.
  29510. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29511. */
  29512. bumpTexture: Nullable<BaseTexture>;
  29513. private _lightmapTexture;
  29514. /**
  29515. * Complex lighting can be computationally expensive to compute at runtime.
  29516. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29517. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29518. */
  29519. lightmapTexture: Nullable<BaseTexture>;
  29520. private _refractionTexture;
  29521. /**
  29522. * Define the texture used to display the refraction.
  29523. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29524. */
  29525. refractionTexture: Nullable<BaseTexture>;
  29526. /**
  29527. * The color of the material lit by the environmental background lighting.
  29528. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29529. */
  29530. ambientColor: Color3;
  29531. /**
  29532. * The basic color of the material as viewed under a light.
  29533. */
  29534. diffuseColor: Color3;
  29535. /**
  29536. * Define how the color and intensity of the highlight given by the light in the material.
  29537. */
  29538. specularColor: Color3;
  29539. /**
  29540. * Define the color of the material as if self lit.
  29541. * This will be mixed in the final result even in the absence of light.
  29542. */
  29543. emissiveColor: Color3;
  29544. /**
  29545. * Defines how sharp are the highlights in the material.
  29546. * The bigger the value the sharper giving a more glossy feeling to the result.
  29547. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29548. */
  29549. specularPower: number;
  29550. private _useAlphaFromDiffuseTexture;
  29551. /**
  29552. * Does the transparency come from the diffuse texture alpha channel.
  29553. */
  29554. useAlphaFromDiffuseTexture: boolean;
  29555. private _useEmissiveAsIllumination;
  29556. /**
  29557. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29558. */
  29559. useEmissiveAsIllumination: boolean;
  29560. private _linkEmissiveWithDiffuse;
  29561. /**
  29562. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29563. * the emissive level when the final color is close to one.
  29564. */
  29565. linkEmissiveWithDiffuse: boolean;
  29566. private _useSpecularOverAlpha;
  29567. /**
  29568. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29569. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29570. */
  29571. useSpecularOverAlpha: boolean;
  29572. private _useReflectionOverAlpha;
  29573. /**
  29574. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29575. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29576. */
  29577. useReflectionOverAlpha: boolean;
  29578. private _disableLighting;
  29579. /**
  29580. * Does lights from the scene impacts this material.
  29581. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29582. */
  29583. disableLighting: boolean;
  29584. private _useObjectSpaceNormalMap;
  29585. /**
  29586. * Allows using an object space normal map (instead of tangent space).
  29587. */
  29588. useObjectSpaceNormalMap: boolean;
  29589. private _useParallax;
  29590. /**
  29591. * Is parallax enabled or not.
  29592. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29593. */
  29594. useParallax: boolean;
  29595. private _useParallaxOcclusion;
  29596. /**
  29597. * Is parallax occlusion enabled or not.
  29598. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29599. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29600. */
  29601. useParallaxOcclusion: boolean;
  29602. /**
  29603. * 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.
  29604. */
  29605. parallaxScaleBias: number;
  29606. private _roughness;
  29607. /**
  29608. * Helps to define how blurry the reflections should appears in the material.
  29609. */
  29610. roughness: number;
  29611. /**
  29612. * In case of refraction, define the value of the index of refraction.
  29613. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29614. */
  29615. indexOfRefraction: number;
  29616. /**
  29617. * Invert the refraction texture alongside the y axis.
  29618. * It can be useful with procedural textures or probe for instance.
  29619. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29620. */
  29621. invertRefractionY: boolean;
  29622. /**
  29623. * Defines the alpha limits in alpha test mode.
  29624. */
  29625. alphaCutOff: number;
  29626. private _useLightmapAsShadowmap;
  29627. /**
  29628. * In case of light mapping, define whether the map contains light or shadow informations.
  29629. */
  29630. useLightmapAsShadowmap: boolean;
  29631. private _diffuseFresnelParameters;
  29632. /**
  29633. * Define the diffuse fresnel parameters of the material.
  29634. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29635. */
  29636. diffuseFresnelParameters: FresnelParameters;
  29637. private _opacityFresnelParameters;
  29638. /**
  29639. * Define the opacity fresnel parameters of the material.
  29640. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29641. */
  29642. opacityFresnelParameters: FresnelParameters;
  29643. private _reflectionFresnelParameters;
  29644. /**
  29645. * Define the reflection fresnel parameters of the material.
  29646. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29647. */
  29648. reflectionFresnelParameters: FresnelParameters;
  29649. private _refractionFresnelParameters;
  29650. /**
  29651. * Define the refraction fresnel parameters of the material.
  29652. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29653. */
  29654. refractionFresnelParameters: FresnelParameters;
  29655. private _emissiveFresnelParameters;
  29656. /**
  29657. * Define the emissive fresnel parameters of the material.
  29658. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29659. */
  29660. emissiveFresnelParameters: FresnelParameters;
  29661. private _useReflectionFresnelFromSpecular;
  29662. /**
  29663. * If true automatically deducts the fresnels values from the material specularity.
  29664. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29665. */
  29666. useReflectionFresnelFromSpecular: boolean;
  29667. private _useGlossinessFromSpecularMapAlpha;
  29668. /**
  29669. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29670. */
  29671. useGlossinessFromSpecularMapAlpha: boolean;
  29672. private _maxSimultaneousLights;
  29673. /**
  29674. * Defines the maximum number of lights that can be used in the material
  29675. */
  29676. maxSimultaneousLights: number;
  29677. private _invertNormalMapX;
  29678. /**
  29679. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29680. */
  29681. invertNormalMapX: boolean;
  29682. private _invertNormalMapY;
  29683. /**
  29684. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29685. */
  29686. invertNormalMapY: boolean;
  29687. private _twoSidedLighting;
  29688. /**
  29689. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29690. */
  29691. twoSidedLighting: boolean;
  29692. /**
  29693. * Default configuration related to image processing available in the standard Material.
  29694. */
  29695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29696. /**
  29697. * Gets the image processing configuration used either in this material.
  29698. */
  29699. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29700. /**
  29701. * Sets the Default image processing configuration used either in the this material.
  29702. *
  29703. * If sets to null, the scene one is in use.
  29704. */
  29705. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29706. /**
  29707. * Keep track of the image processing observer to allow dispose and replace.
  29708. */
  29709. private _imageProcessingObserver;
  29710. /**
  29711. * Attaches a new image processing configuration to the Standard Material.
  29712. * @param configuration
  29713. */
  29714. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29715. /**
  29716. * Gets wether the color curves effect is enabled.
  29717. */
  29718. get cameraColorCurvesEnabled(): boolean;
  29719. /**
  29720. * Sets wether the color curves effect is enabled.
  29721. */
  29722. set cameraColorCurvesEnabled(value: boolean);
  29723. /**
  29724. * Gets wether the color grading effect is enabled.
  29725. */
  29726. get cameraColorGradingEnabled(): boolean;
  29727. /**
  29728. * Gets wether the color grading effect is enabled.
  29729. */
  29730. set cameraColorGradingEnabled(value: boolean);
  29731. /**
  29732. * Gets wether tonemapping is enabled or not.
  29733. */
  29734. get cameraToneMappingEnabled(): boolean;
  29735. /**
  29736. * Sets wether tonemapping is enabled or not
  29737. */
  29738. set cameraToneMappingEnabled(value: boolean);
  29739. /**
  29740. * The camera exposure used on this material.
  29741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29742. * This corresponds to a photographic exposure.
  29743. */
  29744. get cameraExposure(): number;
  29745. /**
  29746. * The camera exposure used on this material.
  29747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29748. * This corresponds to a photographic exposure.
  29749. */
  29750. set cameraExposure(value: number);
  29751. /**
  29752. * Gets The camera contrast used on this material.
  29753. */
  29754. get cameraContrast(): number;
  29755. /**
  29756. * Sets The camera contrast used on this material.
  29757. */
  29758. set cameraContrast(value: number);
  29759. /**
  29760. * Gets the Color Grading 2D Lookup Texture.
  29761. */
  29762. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29763. /**
  29764. * Sets the Color Grading 2D Lookup Texture.
  29765. */
  29766. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29767. /**
  29768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29770. * 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;
  29771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29772. */
  29773. get cameraColorCurves(): Nullable<ColorCurves>;
  29774. /**
  29775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29777. * 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;
  29778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29779. */
  29780. set cameraColorCurves(value: Nullable<ColorCurves>);
  29781. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29782. protected _worldViewProjectionMatrix: Matrix;
  29783. protected _globalAmbientColor: Color3;
  29784. protected _useLogarithmicDepth: boolean;
  29785. protected _rebuildInParallel: boolean;
  29786. /**
  29787. * Instantiates a new standard material.
  29788. * This is the default material used in Babylon. It is the best trade off between quality
  29789. * and performances.
  29790. * @see http://doc.babylonjs.com/babylon101/materials
  29791. * @param name Define the name of the material in the scene
  29792. * @param scene Define the scene the material belong to
  29793. */
  29794. constructor(name: string, scene: Scene);
  29795. /**
  29796. * Gets a boolean indicating that current material needs to register RTT
  29797. */
  29798. get hasRenderTargetTextures(): boolean;
  29799. /**
  29800. * Gets the current class name of the material e.g. "StandardMaterial"
  29801. * Mainly use in serialization.
  29802. * @returns the class name
  29803. */
  29804. getClassName(): string;
  29805. /**
  29806. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29807. * You can try switching to logarithmic depth.
  29808. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29809. */
  29810. get useLogarithmicDepth(): boolean;
  29811. set useLogarithmicDepth(value: boolean);
  29812. /**
  29813. * Specifies if the material will require alpha blending
  29814. * @returns a boolean specifying if alpha blending is needed
  29815. */
  29816. needAlphaBlending(): boolean;
  29817. /**
  29818. * Specifies if this material should be rendered in alpha test mode
  29819. * @returns a boolean specifying if an alpha test is needed.
  29820. */
  29821. needAlphaTesting(): boolean;
  29822. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29823. /**
  29824. * Get the texture used for alpha test purpose.
  29825. * @returns the diffuse texture in case of the standard material.
  29826. */
  29827. getAlphaTestTexture(): Nullable<BaseTexture>;
  29828. /**
  29829. * Get if the submesh is ready to be used and all its information available.
  29830. * Child classes can use it to update shaders
  29831. * @param mesh defines the mesh to check
  29832. * @param subMesh defines which submesh to check
  29833. * @param useInstances specifies that instances should be used
  29834. * @returns a boolean indicating that the submesh is ready or not
  29835. */
  29836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29837. /**
  29838. * Builds the material UBO layouts.
  29839. * Used internally during the effect preparation.
  29840. */
  29841. buildUniformLayout(): void;
  29842. /**
  29843. * Unbinds the material from the mesh
  29844. */
  29845. unbind(): void;
  29846. /**
  29847. * Binds the submesh to this material by preparing the effect and shader to draw
  29848. * @param world defines the world transformation matrix
  29849. * @param mesh defines the mesh containing the submesh
  29850. * @param subMesh defines the submesh to bind the material to
  29851. */
  29852. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29853. /**
  29854. * Get the list of animatables in the material.
  29855. * @returns the list of animatables object used in the material
  29856. */
  29857. getAnimatables(): IAnimatable[];
  29858. /**
  29859. * Gets the active textures from the material
  29860. * @returns an array of textures
  29861. */
  29862. getActiveTextures(): BaseTexture[];
  29863. /**
  29864. * Specifies if the material uses a texture
  29865. * @param texture defines the texture to check against the material
  29866. * @returns a boolean specifying if the material uses the texture
  29867. */
  29868. hasTexture(texture: BaseTexture): boolean;
  29869. /**
  29870. * Disposes the material
  29871. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29872. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29873. */
  29874. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29875. /**
  29876. * Makes a duplicate of the material, and gives it a new name
  29877. * @param name defines the new name for the duplicated material
  29878. * @returns the cloned material
  29879. */
  29880. clone(name: string): StandardMaterial;
  29881. /**
  29882. * Serializes this material in a JSON representation
  29883. * @returns the serialized material object
  29884. */
  29885. serialize(): any;
  29886. /**
  29887. * Creates a standard material from parsed material data
  29888. * @param source defines the JSON representation of the material
  29889. * @param scene defines the hosting scene
  29890. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29891. * @returns a new standard material
  29892. */
  29893. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29894. /**
  29895. * Are diffuse textures enabled in the application.
  29896. */
  29897. static get DiffuseTextureEnabled(): boolean;
  29898. static set DiffuseTextureEnabled(value: boolean);
  29899. /**
  29900. * Are ambient textures enabled in the application.
  29901. */
  29902. static get AmbientTextureEnabled(): boolean;
  29903. static set AmbientTextureEnabled(value: boolean);
  29904. /**
  29905. * Are opacity textures enabled in the application.
  29906. */
  29907. static get OpacityTextureEnabled(): boolean;
  29908. static set OpacityTextureEnabled(value: boolean);
  29909. /**
  29910. * Are reflection textures enabled in the application.
  29911. */
  29912. static get ReflectionTextureEnabled(): boolean;
  29913. static set ReflectionTextureEnabled(value: boolean);
  29914. /**
  29915. * Are emissive textures enabled in the application.
  29916. */
  29917. static get EmissiveTextureEnabled(): boolean;
  29918. static set EmissiveTextureEnabled(value: boolean);
  29919. /**
  29920. * Are specular textures enabled in the application.
  29921. */
  29922. static get SpecularTextureEnabled(): boolean;
  29923. static set SpecularTextureEnabled(value: boolean);
  29924. /**
  29925. * Are bump textures enabled in the application.
  29926. */
  29927. static get BumpTextureEnabled(): boolean;
  29928. static set BumpTextureEnabled(value: boolean);
  29929. /**
  29930. * Are lightmap textures enabled in the application.
  29931. */
  29932. static get LightmapTextureEnabled(): boolean;
  29933. static set LightmapTextureEnabled(value: boolean);
  29934. /**
  29935. * Are refraction textures enabled in the application.
  29936. */
  29937. static get RefractionTextureEnabled(): boolean;
  29938. static set RefractionTextureEnabled(value: boolean);
  29939. /**
  29940. * Are color grading textures enabled in the application.
  29941. */
  29942. static get ColorGradingTextureEnabled(): boolean;
  29943. static set ColorGradingTextureEnabled(value: boolean);
  29944. /**
  29945. * Are fresnels enabled in the application.
  29946. */
  29947. static get FresnelEnabled(): boolean;
  29948. static set FresnelEnabled(value: boolean);
  29949. }
  29950. }
  29951. declare module BABYLON {
  29952. /**
  29953. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29954. *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.
  29955. * The SPS is also a particle system. It provides some methods to manage the particles.
  29956. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29957. *
  29958. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29959. */
  29960. export class SolidParticleSystem implements IDisposable {
  29961. /**
  29962. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29963. * Example : var p = SPS.particles[i];
  29964. */
  29965. particles: SolidParticle[];
  29966. /**
  29967. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29968. */
  29969. nbParticles: number;
  29970. /**
  29971. * If the particles must ever face the camera (default false). Useful for planar particles.
  29972. */
  29973. billboard: boolean;
  29974. /**
  29975. * Recompute normals when adding a shape
  29976. */
  29977. recomputeNormals: boolean;
  29978. /**
  29979. * This a counter ofr your own usage. It's not set by any SPS functions.
  29980. */
  29981. counter: number;
  29982. /**
  29983. * The SPS name. This name is also given to the underlying mesh.
  29984. */
  29985. name: string;
  29986. /**
  29987. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29988. */
  29989. mesh: Mesh;
  29990. /**
  29991. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29992. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29993. */
  29994. vars: any;
  29995. /**
  29996. * This array is populated when the SPS is set as 'pickable'.
  29997. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29998. * Each element of this array is an object `{idx: int, faceId: int}`.
  29999. * `idx` is the picked particle index in the `SPS.particles` array
  30000. * `faceId` is the picked face index counted within this particle.
  30001. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30002. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30003. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30004. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30005. */
  30006. pickedParticles: {
  30007. idx: number;
  30008. faceId: number;
  30009. }[];
  30010. /**
  30011. * This array is populated when the SPS is set as 'pickable'
  30012. * Each key of this array is a submesh index.
  30013. * Each element of this array is a second array defined like this :
  30014. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30015. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30016. * `idx` is the picked particle index in the `SPS.particles` array
  30017. * `faceId` is the picked face index counted within this particle.
  30018. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30019. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30020. */
  30021. pickedBySubMesh: {
  30022. idx: number;
  30023. faceId: number;
  30024. }[][];
  30025. /**
  30026. * This array is populated when `enableDepthSort` is set to true.
  30027. * Each element of this array is an instance of the class DepthSortedParticle.
  30028. */
  30029. depthSortedParticles: DepthSortedParticle[];
  30030. /**
  30031. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30032. * @hidden
  30033. */
  30034. _bSphereOnly: boolean;
  30035. /**
  30036. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30037. * @hidden
  30038. */
  30039. _bSphereRadiusFactor: number;
  30040. private _scene;
  30041. private _positions;
  30042. private _indices;
  30043. private _normals;
  30044. private _colors;
  30045. private _uvs;
  30046. private _indices32;
  30047. private _positions32;
  30048. private _normals32;
  30049. private _fixedNormal32;
  30050. private _colors32;
  30051. private _uvs32;
  30052. private _index;
  30053. private _updatable;
  30054. private _pickable;
  30055. private _isVisibilityBoxLocked;
  30056. private _alwaysVisible;
  30057. private _depthSort;
  30058. private _expandable;
  30059. private _shapeCounter;
  30060. private _copy;
  30061. private _color;
  30062. private _computeParticleColor;
  30063. private _computeParticleTexture;
  30064. private _computeParticleRotation;
  30065. private _computeParticleVertex;
  30066. private _computeBoundingBox;
  30067. private _depthSortParticles;
  30068. private _camera;
  30069. private _mustUnrotateFixedNormals;
  30070. private _particlesIntersect;
  30071. private _needs32Bits;
  30072. private _isNotBuilt;
  30073. private _lastParticleId;
  30074. private _idxOfId;
  30075. private _multimaterialEnabled;
  30076. private _useModelMaterial;
  30077. private _indicesByMaterial;
  30078. private _materialIndexes;
  30079. private _depthSortFunction;
  30080. private _materialSortFunction;
  30081. private _materials;
  30082. private _multimaterial;
  30083. private _materialIndexesById;
  30084. private _defaultMaterial;
  30085. private _autoUpdateSubMeshes;
  30086. private _tmpVertex;
  30087. /**
  30088. * Creates a SPS (Solid Particle System) object.
  30089. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30090. * @param scene (Scene) is the scene in which the SPS is added.
  30091. * @param options defines the options of the sps e.g.
  30092. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30093. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30094. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30095. * * 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.
  30096. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30097. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30098. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30099. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30100. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30101. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30102. */
  30103. constructor(name: string, scene: Scene, options?: {
  30104. updatable?: boolean;
  30105. isPickable?: boolean;
  30106. enableDepthSort?: boolean;
  30107. particleIntersection?: boolean;
  30108. boundingSphereOnly?: boolean;
  30109. bSphereRadiusFactor?: number;
  30110. expandable?: boolean;
  30111. useModelMaterial?: boolean;
  30112. enableMultiMaterial?: boolean;
  30113. });
  30114. /**
  30115. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30116. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30117. * @returns the created mesh
  30118. */
  30119. buildMesh(): Mesh;
  30120. /**
  30121. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30122. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30123. * Thus the particles generated from `digest()` have their property `position` set yet.
  30124. * @param mesh ( Mesh ) is the mesh to be digested
  30125. * @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
  30126. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30127. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30128. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30129. * @returns the current SPS
  30130. */
  30131. digest(mesh: Mesh, options?: {
  30132. facetNb?: number;
  30133. number?: number;
  30134. delta?: number;
  30135. storage?: [];
  30136. }): SolidParticleSystem;
  30137. /**
  30138. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30139. * @hidden
  30140. */
  30141. private _unrotateFixedNormals;
  30142. /**
  30143. * Resets the temporary working copy particle
  30144. * @hidden
  30145. */
  30146. private _resetCopy;
  30147. /**
  30148. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30149. * @param p the current index in the positions array to be updated
  30150. * @param ind the current index in the indices array
  30151. * @param shape a Vector3 array, the shape geometry
  30152. * @param positions the positions array to be updated
  30153. * @param meshInd the shape indices array
  30154. * @param indices the indices array to be updated
  30155. * @param meshUV the shape uv array
  30156. * @param uvs the uv array to be updated
  30157. * @param meshCol the shape color array
  30158. * @param colors the color array to be updated
  30159. * @param meshNor the shape normals array
  30160. * @param normals the normals array to be updated
  30161. * @param idx the particle index
  30162. * @param idxInShape the particle index in its shape
  30163. * @param options the addShape() method passed options
  30164. * @model the particle model
  30165. * @hidden
  30166. */
  30167. private _meshBuilder;
  30168. /**
  30169. * Returns a shape Vector3 array from positions float array
  30170. * @param positions float array
  30171. * @returns a vector3 array
  30172. * @hidden
  30173. */
  30174. private _posToShape;
  30175. /**
  30176. * Returns a shapeUV array from a float uvs (array deep copy)
  30177. * @param uvs as a float array
  30178. * @returns a shapeUV array
  30179. * @hidden
  30180. */
  30181. private _uvsToShapeUV;
  30182. /**
  30183. * Adds a new particle object in the particles array
  30184. * @param idx particle index in particles array
  30185. * @param id particle id
  30186. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30187. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30188. * @param model particle ModelShape object
  30189. * @param shapeId model shape identifier
  30190. * @param idxInShape index of the particle in the current model
  30191. * @param bInfo model bounding info object
  30192. * @param storage target storage array, if any
  30193. * @hidden
  30194. */
  30195. private _addParticle;
  30196. /**
  30197. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30198. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30199. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30200. * @param nb (positive integer) the number of particles to be created from this model
  30201. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30202. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30203. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30204. * @returns the number of shapes in the system
  30205. */
  30206. addShape(mesh: Mesh, nb: number, options?: {
  30207. positionFunction?: any;
  30208. vertexFunction?: any;
  30209. storage?: [];
  30210. }): number;
  30211. /**
  30212. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30213. * @hidden
  30214. */
  30215. private _rebuildParticle;
  30216. /**
  30217. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30218. * @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.
  30219. * @returns the SPS.
  30220. */
  30221. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30222. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30223. * Returns an array with the removed particles.
  30224. * 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.
  30225. * The SPS can't be empty so at least one particle needs to remain in place.
  30226. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30227. * @param start index of the first particle to remove
  30228. * @param end index of the last particle to remove (included)
  30229. * @returns an array populated with the removed particles
  30230. */
  30231. removeParticles(start: number, end: number): SolidParticle[];
  30232. /**
  30233. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30234. * @param solidParticleArray an array populated with Solid Particles objects
  30235. * @returns the SPS
  30236. */
  30237. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30238. /**
  30239. * Creates a new particle and modifies the SPS mesh geometry :
  30240. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30241. * - calls _addParticle() to populate the particle array
  30242. * factorized code from addShape() and insertParticlesFromArray()
  30243. * @param idx particle index in the particles array
  30244. * @param i particle index in its shape
  30245. * @param modelShape particle ModelShape object
  30246. * @param shape shape vertex array
  30247. * @param meshInd shape indices array
  30248. * @param meshUV shape uv array
  30249. * @param meshCol shape color array
  30250. * @param meshNor shape normals array
  30251. * @param bbInfo shape bounding info
  30252. * @param storage target particle storage
  30253. * @options addShape() passed options
  30254. * @hidden
  30255. */
  30256. private _insertNewParticle;
  30257. /**
  30258. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30259. * This method calls `updateParticle()` for each particle of the SPS.
  30260. * For an animated SPS, it is usually called within the render loop.
  30261. * 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.
  30262. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30263. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30264. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30265. * @returns the SPS.
  30266. */
  30267. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30268. /**
  30269. * Disposes the SPS.
  30270. */
  30271. dispose(): void;
  30272. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30273. * idx is the particle index in the SPS
  30274. * faceId is the picked face index counted within this particle.
  30275. * Returns null if the pickInfo can't identify a picked particle.
  30276. * @param pickingInfo (PickingInfo object)
  30277. * @returns {idx: number, faceId: number} or null
  30278. */
  30279. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30280. idx: number;
  30281. faceId: number;
  30282. }>;
  30283. /**
  30284. * Returns a SolidParticle object from its identifier : particle.id
  30285. * @param id (integer) the particle Id
  30286. * @returns the searched particle or null if not found in the SPS.
  30287. */
  30288. getParticleById(id: number): Nullable<SolidParticle>;
  30289. /**
  30290. * Returns a new array populated with the particles having the passed shapeId.
  30291. * @param shapeId (integer) the shape identifier
  30292. * @returns a new solid particle array
  30293. */
  30294. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30295. /**
  30296. * Populates the passed array "ref" with the particles having the passed shapeId.
  30297. * @param shapeId the shape identifier
  30298. * @returns the SPS
  30299. * @param ref
  30300. */
  30301. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30302. /**
  30303. * Computes the required SubMeshes according the materials assigned to the particles.
  30304. * @returns the solid particle system.
  30305. * Does nothing if called before the SPS mesh is built.
  30306. */
  30307. computeSubMeshes(): SolidParticleSystem;
  30308. /**
  30309. * Sorts the solid particles by material when MultiMaterial is enabled.
  30310. * Updates the indices32 array.
  30311. * Updates the indicesByMaterial array.
  30312. * Updates the mesh indices array.
  30313. * @returns the SPS
  30314. * @hidden
  30315. */
  30316. private _sortParticlesByMaterial;
  30317. /**
  30318. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30319. * @hidden
  30320. */
  30321. private _setMaterialIndexesById;
  30322. /**
  30323. * Returns an array with unique values of Materials from the passed array
  30324. * @param array the material array to be checked and filtered
  30325. * @hidden
  30326. */
  30327. private _filterUniqueMaterialId;
  30328. /**
  30329. * Sets a new Standard Material as _defaultMaterial if not already set.
  30330. * @hidden
  30331. */
  30332. private _setDefaultMaterial;
  30333. /**
  30334. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30335. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30336. * @returns the SPS.
  30337. */
  30338. refreshVisibleSize(): SolidParticleSystem;
  30339. /**
  30340. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30341. * @param size the size (float) of the visibility box
  30342. * note : this doesn't lock the SPS mesh bounding box.
  30343. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30344. */
  30345. setVisibilityBox(size: number): void;
  30346. /**
  30347. * Gets whether the SPS as always visible or not
  30348. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30349. */
  30350. get isAlwaysVisible(): boolean;
  30351. /**
  30352. * Sets the SPS as always visible or not
  30353. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30354. */
  30355. set isAlwaysVisible(val: boolean);
  30356. /**
  30357. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30358. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30359. */
  30360. set isVisibilityBoxLocked(val: boolean);
  30361. /**
  30362. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30363. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30364. */
  30365. get isVisibilityBoxLocked(): boolean;
  30366. /**
  30367. * Tells to `setParticles()` to compute the particle rotations or not.
  30368. * Default value : true. The SPS is faster when it's set to false.
  30369. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30370. */
  30371. set computeParticleRotation(val: boolean);
  30372. /**
  30373. * Tells to `setParticles()` to compute the particle colors or not.
  30374. * Default value : true. The SPS is faster when it's set to false.
  30375. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30376. */
  30377. set computeParticleColor(val: boolean);
  30378. set computeParticleTexture(val: boolean);
  30379. /**
  30380. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30381. * Default value : false. The SPS is faster when it's set to false.
  30382. * Note : the particle custom vertex positions aren't stored values.
  30383. */
  30384. set computeParticleVertex(val: boolean);
  30385. /**
  30386. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30387. */
  30388. set computeBoundingBox(val: boolean);
  30389. /**
  30390. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30391. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30392. * Default : `true`
  30393. */
  30394. set depthSortParticles(val: boolean);
  30395. /**
  30396. * Gets if `setParticles()` computes the particle rotations or not.
  30397. * Default value : true. The SPS is faster when it's set to false.
  30398. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30399. */
  30400. get computeParticleRotation(): boolean;
  30401. /**
  30402. * Gets if `setParticles()` computes the particle colors or not.
  30403. * Default value : true. The SPS is faster when it's set to false.
  30404. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30405. */
  30406. get computeParticleColor(): boolean;
  30407. /**
  30408. * Gets if `setParticles()` computes the particle textures or not.
  30409. * Default value : true. The SPS is faster when it's set to false.
  30410. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30411. */
  30412. get computeParticleTexture(): boolean;
  30413. /**
  30414. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30415. * Default value : false. The SPS is faster when it's set to false.
  30416. * Note : the particle custom vertex positions aren't stored values.
  30417. */
  30418. get computeParticleVertex(): boolean;
  30419. /**
  30420. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30421. */
  30422. get computeBoundingBox(): boolean;
  30423. /**
  30424. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30425. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30426. * Default : `true`
  30427. */
  30428. get depthSortParticles(): boolean;
  30429. /**
  30430. * Gets if the SPS is created as expandable at construction time.
  30431. * Default : `false`
  30432. */
  30433. get expandable(): boolean;
  30434. /**
  30435. * Gets if the SPS supports the Multi Materials
  30436. */
  30437. get multimaterialEnabled(): boolean;
  30438. /**
  30439. * Gets if the SPS uses the model materials for its own multimaterial.
  30440. */
  30441. get useModelMaterial(): boolean;
  30442. /**
  30443. * The SPS used material array.
  30444. */
  30445. get materials(): Material[];
  30446. /**
  30447. * Sets the SPS MultiMaterial from the passed materials.
  30448. * Note : the passed array is internally copied and not used then by reference.
  30449. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30450. */
  30451. setMultiMaterial(materials: Material[]): void;
  30452. /**
  30453. * The SPS computed multimaterial object
  30454. */
  30455. get multimaterial(): MultiMaterial;
  30456. set multimaterial(mm: MultiMaterial);
  30457. /**
  30458. * If the subMeshes must be updated on the next call to setParticles()
  30459. */
  30460. get autoUpdateSubMeshes(): boolean;
  30461. set autoUpdateSubMeshes(val: boolean);
  30462. /**
  30463. * This function does nothing. It may be overwritten to set all the particle first values.
  30464. * The SPS doesn't call this function, you may have to call it by your own.
  30465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30466. */
  30467. initParticles(): void;
  30468. /**
  30469. * This function does nothing. It may be overwritten to recycle a particle.
  30470. * The SPS doesn't call this function, you may have to call it by your own.
  30471. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30472. * @param particle The particle to recycle
  30473. * @returns the recycled particle
  30474. */
  30475. recycleParticle(particle: SolidParticle): SolidParticle;
  30476. /**
  30477. * Updates a particle : this function should be overwritten by the user.
  30478. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30480. * @example : just set a particle position or velocity and recycle conditions
  30481. * @param particle The particle to update
  30482. * @returns the updated particle
  30483. */
  30484. updateParticle(particle: SolidParticle): SolidParticle;
  30485. /**
  30486. * Updates a vertex of a particle : it can be overwritten by the user.
  30487. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30488. * @param particle the current particle
  30489. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30490. * @param pt the index of the current vertex in the particle shape
  30491. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30492. * @example : just set a vertex particle position or color
  30493. * @returns the sps
  30494. */
  30495. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30496. /**
  30497. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30498. * This does nothing and may be overwritten by the user.
  30499. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30500. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30501. * @param update the boolean update value actually passed to setParticles()
  30502. */
  30503. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30504. /**
  30505. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30506. * This will be passed three parameters.
  30507. * This does nothing and may be overwritten by the user.
  30508. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30509. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30510. * @param update the boolean update value actually passed to setParticles()
  30511. */
  30512. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30513. }
  30514. }
  30515. declare module BABYLON {
  30516. /**
  30517. * Represents one particle of a solid particle system.
  30518. */
  30519. export class SolidParticle {
  30520. /**
  30521. * particle global index
  30522. */
  30523. idx: number;
  30524. /**
  30525. * particle identifier
  30526. */
  30527. id: number;
  30528. /**
  30529. * The color of the particle
  30530. */
  30531. color: Nullable<Color4>;
  30532. /**
  30533. * The world space position of the particle.
  30534. */
  30535. position: Vector3;
  30536. /**
  30537. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30538. */
  30539. rotation: Vector3;
  30540. /**
  30541. * The world space rotation quaternion of the particle.
  30542. */
  30543. rotationQuaternion: Nullable<Quaternion>;
  30544. /**
  30545. * The scaling of the particle.
  30546. */
  30547. scaling: Vector3;
  30548. /**
  30549. * The uvs of the particle.
  30550. */
  30551. uvs: Vector4;
  30552. /**
  30553. * The current speed of the particle.
  30554. */
  30555. velocity: Vector3;
  30556. /**
  30557. * The pivot point in the particle local space.
  30558. */
  30559. pivot: Vector3;
  30560. /**
  30561. * Must the particle be translated from its pivot point in its local space ?
  30562. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30563. * Default : false
  30564. */
  30565. translateFromPivot: boolean;
  30566. /**
  30567. * Is the particle active or not ?
  30568. */
  30569. alive: boolean;
  30570. /**
  30571. * Is the particle visible or not ?
  30572. */
  30573. isVisible: boolean;
  30574. /**
  30575. * Index of this particle in the global "positions" array (Internal use)
  30576. * @hidden
  30577. */
  30578. _pos: number;
  30579. /**
  30580. * @hidden Index of this particle in the global "indices" array (Internal use)
  30581. */
  30582. _ind: number;
  30583. /**
  30584. * @hidden ModelShape of this particle (Internal use)
  30585. */
  30586. _model: ModelShape;
  30587. /**
  30588. * ModelShape id of this particle
  30589. */
  30590. shapeId: number;
  30591. /**
  30592. * Index of the particle in its shape id
  30593. */
  30594. idxInShape: number;
  30595. /**
  30596. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30597. */
  30598. _modelBoundingInfo: BoundingInfo;
  30599. /**
  30600. * @hidden Particle BoundingInfo object (Internal use)
  30601. */
  30602. _boundingInfo: BoundingInfo;
  30603. /**
  30604. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30605. */
  30606. _sps: SolidParticleSystem;
  30607. /**
  30608. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30609. */
  30610. _stillInvisible: boolean;
  30611. /**
  30612. * @hidden Last computed particle rotation matrix
  30613. */
  30614. _rotationMatrix: number[];
  30615. /**
  30616. * Parent particle Id, if any.
  30617. * Default null.
  30618. */
  30619. parentId: Nullable<number>;
  30620. /**
  30621. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30622. */
  30623. materialIndex: Nullable<number>;
  30624. /**
  30625. * Custom object or properties.
  30626. */
  30627. props: Nullable<any>;
  30628. /**
  30629. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30630. * The possible values are :
  30631. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30632. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30633. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30634. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30635. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30636. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30637. * */
  30638. cullingStrategy: number;
  30639. /**
  30640. * @hidden Internal global position in the SPS.
  30641. */
  30642. _globalPosition: Vector3;
  30643. /**
  30644. * Creates a Solid Particle object.
  30645. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30646. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30647. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30648. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30649. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30650. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30651. * @param shapeId (integer) is the model shape identifier in the SPS.
  30652. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30653. * @param sps defines the sps it is associated to
  30654. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30655. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30656. */
  30657. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30658. /**
  30659. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30660. * @param target the particle target
  30661. * @returns the current particle
  30662. */
  30663. copyToRef(target: SolidParticle): SolidParticle;
  30664. /**
  30665. * Legacy support, changed scale to scaling
  30666. */
  30667. get scale(): Vector3;
  30668. /**
  30669. * Legacy support, changed scale to scaling
  30670. */
  30671. set scale(scale: Vector3);
  30672. /**
  30673. * Legacy support, changed quaternion to rotationQuaternion
  30674. */
  30675. get quaternion(): Nullable<Quaternion>;
  30676. /**
  30677. * Legacy support, changed quaternion to rotationQuaternion
  30678. */
  30679. set quaternion(q: Nullable<Quaternion>);
  30680. /**
  30681. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30682. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30683. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30684. * @returns true if it intersects
  30685. */
  30686. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30687. /**
  30688. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30689. * A particle is in the frustum if its bounding box intersects the frustum
  30690. * @param frustumPlanes defines the frustum to test
  30691. * @returns true if the particle is in the frustum planes
  30692. */
  30693. isInFrustum(frustumPlanes: Plane[]): boolean;
  30694. /**
  30695. * get the rotation matrix of the particle
  30696. * @hidden
  30697. */
  30698. getRotationMatrix(m: Matrix): void;
  30699. }
  30700. /**
  30701. * Represents the shape of the model used by one particle of a solid particle system.
  30702. * SPS internal tool, don't use it manually.
  30703. */
  30704. export class ModelShape {
  30705. /**
  30706. * The shape id
  30707. * @hidden
  30708. */
  30709. shapeID: number;
  30710. /**
  30711. * flat array of model positions (internal use)
  30712. * @hidden
  30713. */
  30714. _shape: Vector3[];
  30715. /**
  30716. * flat array of model UVs (internal use)
  30717. * @hidden
  30718. */
  30719. _shapeUV: number[];
  30720. /**
  30721. * color array of the model
  30722. * @hidden
  30723. */
  30724. _shapeColors: number[];
  30725. /**
  30726. * indices array of the model
  30727. * @hidden
  30728. */
  30729. _indices: number[];
  30730. /**
  30731. * normals array of the model
  30732. * @hidden
  30733. */
  30734. _normals: number[];
  30735. /**
  30736. * length of the shape in the model indices array (internal use)
  30737. * @hidden
  30738. */
  30739. _indicesLength: number;
  30740. /**
  30741. * Custom position function (internal use)
  30742. * @hidden
  30743. */
  30744. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30745. /**
  30746. * Custom vertex function (internal use)
  30747. * @hidden
  30748. */
  30749. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30750. /**
  30751. * Model material (internal use)
  30752. * @hidden
  30753. */
  30754. _material: Nullable<Material>;
  30755. /**
  30756. * 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.
  30757. * SPS internal tool, don't use it manually.
  30758. * @hidden
  30759. */
  30760. 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>);
  30761. }
  30762. /**
  30763. * Represents a Depth Sorted Particle in the solid particle system.
  30764. * @hidden
  30765. */
  30766. export class DepthSortedParticle {
  30767. /**
  30768. * Particle index
  30769. */
  30770. idx: number;
  30771. /**
  30772. * Index of the particle in the "indices" array
  30773. */
  30774. ind: number;
  30775. /**
  30776. * Length of the particle shape in the "indices" array
  30777. */
  30778. indicesLength: number;
  30779. /**
  30780. * Squared distance from the particle to the camera
  30781. */
  30782. sqDistance: number;
  30783. /**
  30784. * Material index when used with MultiMaterials
  30785. */
  30786. materialIndex: number;
  30787. /**
  30788. * Creates a new sorted particle
  30789. * @param materialIndex
  30790. */
  30791. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30792. }
  30793. /**
  30794. * Represents a solid particle vertex
  30795. */
  30796. export class SolidParticleVertex {
  30797. /**
  30798. * Vertex position
  30799. */
  30800. position: Vector3;
  30801. /**
  30802. * Vertex color
  30803. */
  30804. color: Color4;
  30805. /**
  30806. * Vertex UV
  30807. */
  30808. uv: Vector2;
  30809. /**
  30810. * Creates a new solid particle vertex
  30811. */
  30812. constructor();
  30813. /** Vertex x coordinate */
  30814. get x(): number;
  30815. set x(val: number);
  30816. /** Vertex y coordinate */
  30817. get y(): number;
  30818. set y(val: number);
  30819. /** Vertex z coordinate */
  30820. get z(): number;
  30821. set z(val: number);
  30822. }
  30823. }
  30824. declare module BABYLON {
  30825. /**
  30826. * @hidden
  30827. */
  30828. export class _MeshCollisionData {
  30829. _checkCollisions: boolean;
  30830. _collisionMask: number;
  30831. _collisionGroup: number;
  30832. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30833. _collider: Nullable<Collider>;
  30834. _oldPositionForCollisions: Vector3;
  30835. _diffPositionForCollisions: Vector3;
  30836. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30837. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30838. }
  30839. }
  30840. declare module BABYLON {
  30841. /** @hidden */
  30842. class _FacetDataStorage {
  30843. facetPositions: Vector3[];
  30844. facetNormals: Vector3[];
  30845. facetPartitioning: number[][];
  30846. facetNb: number;
  30847. partitioningSubdivisions: number;
  30848. partitioningBBoxRatio: number;
  30849. facetDataEnabled: boolean;
  30850. facetParameters: any;
  30851. bbSize: Vector3;
  30852. subDiv: {
  30853. max: number;
  30854. X: number;
  30855. Y: number;
  30856. Z: number;
  30857. };
  30858. facetDepthSort: boolean;
  30859. facetDepthSortEnabled: boolean;
  30860. depthSortedIndices: IndicesArray;
  30861. depthSortedFacets: {
  30862. ind: number;
  30863. sqDistance: number;
  30864. }[];
  30865. facetDepthSortFunction: (f1: {
  30866. ind: number;
  30867. sqDistance: number;
  30868. }, f2: {
  30869. ind: number;
  30870. sqDistance: number;
  30871. }) => number;
  30872. facetDepthSortFrom: Vector3;
  30873. facetDepthSortOrigin: Vector3;
  30874. invertedMatrix: Matrix;
  30875. }
  30876. /**
  30877. * @hidden
  30878. **/
  30879. class _InternalAbstractMeshDataInfo {
  30880. _hasVertexAlpha: boolean;
  30881. _useVertexColors: boolean;
  30882. _numBoneInfluencers: number;
  30883. _applyFog: boolean;
  30884. _receiveShadows: boolean;
  30885. _facetData: _FacetDataStorage;
  30886. _visibility: number;
  30887. _skeleton: Nullable<Skeleton>;
  30888. _layerMask: number;
  30889. _computeBonesUsingShaders: boolean;
  30890. _isActive: boolean;
  30891. _onlyForInstances: boolean;
  30892. _isActiveIntermediate: boolean;
  30893. _onlyForInstancesIntermediate: boolean;
  30894. _actAsRegularMesh: boolean;
  30895. }
  30896. /**
  30897. * Class used to store all common mesh properties
  30898. */
  30899. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30900. /** No occlusion */
  30901. static OCCLUSION_TYPE_NONE: number;
  30902. /** Occlusion set to optimisitic */
  30903. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30904. /** Occlusion set to strict */
  30905. static OCCLUSION_TYPE_STRICT: number;
  30906. /** Use an accurante occlusion algorithm */
  30907. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30908. /** Use a conservative occlusion algorithm */
  30909. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30910. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30911. * Test order :
  30912. * Is the bounding sphere outside the frustum ?
  30913. * If not, are the bounding box vertices outside the frustum ?
  30914. * It not, then the cullable object is in the frustum.
  30915. */
  30916. static readonly CULLINGSTRATEGY_STANDARD: number;
  30917. /** Culling strategy : Bounding Sphere Only.
  30918. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30919. * It's also less accurate than the standard because some not visible objects can still be selected.
  30920. * Test : is the bounding sphere outside the frustum ?
  30921. * If not, then the cullable object is in the frustum.
  30922. */
  30923. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30924. /** Culling strategy : Optimistic Inclusion.
  30925. * This in an inclusion test first, then the standard exclusion test.
  30926. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30927. * 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.
  30928. * Anyway, it's as accurate as the standard strategy.
  30929. * Test :
  30930. * Is the cullable object bounding sphere center in the frustum ?
  30931. * If not, apply the default culling strategy.
  30932. */
  30933. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30934. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30935. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30936. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30937. * 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.
  30938. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30939. * Test :
  30940. * Is the cullable object bounding sphere center in the frustum ?
  30941. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30942. */
  30943. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30944. /**
  30945. * No billboard
  30946. */
  30947. static get BILLBOARDMODE_NONE(): number;
  30948. /** Billboard on X axis */
  30949. static get BILLBOARDMODE_X(): number;
  30950. /** Billboard on Y axis */
  30951. static get BILLBOARDMODE_Y(): number;
  30952. /** Billboard on Z axis */
  30953. static get BILLBOARDMODE_Z(): number;
  30954. /** Billboard on all axes */
  30955. static get BILLBOARDMODE_ALL(): number;
  30956. /** Billboard on using position instead of orientation */
  30957. static get BILLBOARDMODE_USE_POSITION(): number;
  30958. /** @hidden */
  30959. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30960. /**
  30961. * The culling strategy to use to check whether the mesh must be rendered or not.
  30962. * This value can be changed at any time and will be used on the next render mesh selection.
  30963. * The possible values are :
  30964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30968. * Please read each static variable documentation to get details about the culling process.
  30969. * */
  30970. cullingStrategy: number;
  30971. /**
  30972. * Gets the number of facets in the mesh
  30973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30974. */
  30975. get facetNb(): number;
  30976. /**
  30977. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30979. */
  30980. get partitioningSubdivisions(): number;
  30981. set partitioningSubdivisions(nb: number);
  30982. /**
  30983. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30984. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30986. */
  30987. get partitioningBBoxRatio(): number;
  30988. set partitioningBBoxRatio(ratio: number);
  30989. /**
  30990. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30991. * Works only for updatable meshes.
  30992. * Doesn't work with multi-materials
  30993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30994. */
  30995. get mustDepthSortFacets(): boolean;
  30996. set mustDepthSortFacets(sort: boolean);
  30997. /**
  30998. * The location (Vector3) where the facet depth sort must be computed from.
  30999. * By default, the active camera position.
  31000. * Used only when facet depth sort is enabled
  31001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31002. */
  31003. get facetDepthSortFrom(): Vector3;
  31004. set facetDepthSortFrom(location: Vector3);
  31005. /**
  31006. * gets a boolean indicating if facetData is enabled
  31007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31008. */
  31009. get isFacetDataEnabled(): boolean;
  31010. /** @hidden */
  31011. _updateNonUniformScalingState(value: boolean): boolean;
  31012. /**
  31013. * An event triggered when this mesh collides with another one
  31014. */
  31015. onCollideObservable: Observable<AbstractMesh>;
  31016. /** Set a function to call when this mesh collides with another one */
  31017. set onCollide(callback: () => void);
  31018. /**
  31019. * An event triggered when the collision's position changes
  31020. */
  31021. onCollisionPositionChangeObservable: Observable<Vector3>;
  31022. /** Set a function to call when the collision's position changes */
  31023. set onCollisionPositionChange(callback: () => void);
  31024. /**
  31025. * An event triggered when material is changed
  31026. */
  31027. onMaterialChangedObservable: Observable<AbstractMesh>;
  31028. /**
  31029. * Gets or sets the orientation for POV movement & rotation
  31030. */
  31031. definedFacingForward: boolean;
  31032. /** @hidden */
  31033. _occlusionQuery: Nullable<WebGLQuery>;
  31034. /** @hidden */
  31035. _renderingGroup: Nullable<RenderingGroup>;
  31036. /**
  31037. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31038. */
  31039. get visibility(): number;
  31040. /**
  31041. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31042. */
  31043. set visibility(value: number);
  31044. /** Gets or sets the alpha index used to sort transparent meshes
  31045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31046. */
  31047. alphaIndex: number;
  31048. /**
  31049. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31050. */
  31051. isVisible: boolean;
  31052. /**
  31053. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31054. */
  31055. isPickable: boolean;
  31056. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31057. showSubMeshesBoundingBox: boolean;
  31058. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31060. */
  31061. isBlocker: boolean;
  31062. /**
  31063. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31064. */
  31065. enablePointerMoveEvents: boolean;
  31066. /**
  31067. * Specifies the rendering group id for this mesh (0 by default)
  31068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31069. */
  31070. renderingGroupId: number;
  31071. private _material;
  31072. /** Gets or sets current material */
  31073. get material(): Nullable<Material>;
  31074. set material(value: Nullable<Material>);
  31075. /**
  31076. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31077. * @see http://doc.babylonjs.com/babylon101/shadows
  31078. */
  31079. get receiveShadows(): boolean;
  31080. set receiveShadows(value: boolean);
  31081. /** Defines color to use when rendering outline */
  31082. outlineColor: Color3;
  31083. /** Define width to use when rendering outline */
  31084. outlineWidth: number;
  31085. /** Defines color to use when rendering overlay */
  31086. overlayColor: Color3;
  31087. /** Defines alpha to use when rendering overlay */
  31088. overlayAlpha: number;
  31089. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31090. get hasVertexAlpha(): boolean;
  31091. set hasVertexAlpha(value: boolean);
  31092. /** 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) */
  31093. get useVertexColors(): boolean;
  31094. set useVertexColors(value: boolean);
  31095. /**
  31096. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31097. */
  31098. get computeBonesUsingShaders(): boolean;
  31099. set computeBonesUsingShaders(value: boolean);
  31100. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31101. get numBoneInfluencers(): number;
  31102. set numBoneInfluencers(value: number);
  31103. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31104. get applyFog(): boolean;
  31105. set applyFog(value: boolean);
  31106. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31107. useOctreeForRenderingSelection: boolean;
  31108. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31109. useOctreeForPicking: boolean;
  31110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31111. useOctreeForCollisions: boolean;
  31112. /**
  31113. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31114. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31115. */
  31116. get layerMask(): number;
  31117. set layerMask(value: number);
  31118. /**
  31119. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31120. */
  31121. alwaysSelectAsActiveMesh: boolean;
  31122. /**
  31123. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31124. */
  31125. doNotSyncBoundingInfo: boolean;
  31126. /**
  31127. * Gets or sets the current action manager
  31128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31129. */
  31130. actionManager: Nullable<AbstractActionManager>;
  31131. private _meshCollisionData;
  31132. /**
  31133. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31134. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31135. */
  31136. ellipsoid: Vector3;
  31137. /**
  31138. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31140. */
  31141. ellipsoidOffset: Vector3;
  31142. /**
  31143. * Gets or sets a collision mask used to mask collisions (default is -1).
  31144. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31145. */
  31146. get collisionMask(): number;
  31147. set collisionMask(mask: number);
  31148. /**
  31149. * Gets or sets the current collision group mask (-1 by default).
  31150. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31151. */
  31152. get collisionGroup(): number;
  31153. set collisionGroup(mask: number);
  31154. /**
  31155. * Gets or sets current surrounding meshes (null by default).
  31156. *
  31157. * By default collision detection is tested against every mesh in the scene.
  31158. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31159. * meshes will be tested for the collision.
  31160. *
  31161. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31162. */
  31163. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31164. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31165. /**
  31166. * Defines edge width used when edgesRenderer is enabled
  31167. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31168. */
  31169. edgesWidth: number;
  31170. /**
  31171. * Defines edge color used when edgesRenderer is enabled
  31172. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31173. */
  31174. edgesColor: Color4;
  31175. /** @hidden */
  31176. _edgesRenderer: Nullable<IEdgesRenderer>;
  31177. /** @hidden */
  31178. _masterMesh: Nullable<AbstractMesh>;
  31179. /** @hidden */
  31180. _boundingInfo: Nullable<BoundingInfo>;
  31181. /** @hidden */
  31182. _renderId: number;
  31183. /**
  31184. * Gets or sets the list of subMeshes
  31185. * @see http://doc.babylonjs.com/how_to/multi_materials
  31186. */
  31187. subMeshes: SubMesh[];
  31188. /** @hidden */
  31189. _intersectionsInProgress: AbstractMesh[];
  31190. /** @hidden */
  31191. _unIndexed: boolean;
  31192. /** @hidden */
  31193. _lightSources: Light[];
  31194. /** Gets the list of lights affecting that mesh */
  31195. get lightSources(): Light[];
  31196. /** @hidden */
  31197. get _positions(): Nullable<Vector3[]>;
  31198. /** @hidden */
  31199. _waitingData: {
  31200. lods: Nullable<any>;
  31201. actions: Nullable<any>;
  31202. freezeWorldMatrix: Nullable<boolean>;
  31203. };
  31204. /** @hidden */
  31205. _bonesTransformMatrices: Nullable<Float32Array>;
  31206. /** @hidden */
  31207. _transformMatrixTexture: Nullable<RawTexture>;
  31208. /**
  31209. * Gets or sets a skeleton to apply skining transformations
  31210. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31211. */
  31212. set skeleton(value: Nullable<Skeleton>);
  31213. get skeleton(): Nullable<Skeleton>;
  31214. /**
  31215. * An event triggered when the mesh is rebuilt.
  31216. */
  31217. onRebuildObservable: Observable<AbstractMesh>;
  31218. /**
  31219. * Creates a new AbstractMesh
  31220. * @param name defines the name of the mesh
  31221. * @param scene defines the hosting scene
  31222. */
  31223. constructor(name: string, scene?: Nullable<Scene>);
  31224. /**
  31225. * Returns the string "AbstractMesh"
  31226. * @returns "AbstractMesh"
  31227. */
  31228. getClassName(): string;
  31229. /**
  31230. * Gets a string representation of the current mesh
  31231. * @param fullDetails defines a boolean indicating if full details must be included
  31232. * @returns a string representation of the current mesh
  31233. */
  31234. toString(fullDetails?: boolean): string;
  31235. /**
  31236. * @hidden
  31237. */
  31238. protected _getEffectiveParent(): Nullable<Node>;
  31239. /** @hidden */
  31240. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31241. /** @hidden */
  31242. _rebuild(): void;
  31243. /** @hidden */
  31244. _resyncLightSources(): void;
  31245. /** @hidden */
  31246. _resyncLightSource(light: Light): void;
  31247. /** @hidden */
  31248. _unBindEffect(): void;
  31249. /** @hidden */
  31250. _removeLightSource(light: Light, dispose: boolean): void;
  31251. private _markSubMeshesAsDirty;
  31252. /** @hidden */
  31253. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31254. /** @hidden */
  31255. _markSubMeshesAsAttributesDirty(): void;
  31256. /** @hidden */
  31257. _markSubMeshesAsMiscDirty(): void;
  31258. /**
  31259. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31260. */
  31261. get scaling(): Vector3;
  31262. set scaling(newScaling: Vector3);
  31263. /**
  31264. * Returns true if the mesh is blocked. Implemented by child classes
  31265. */
  31266. get isBlocked(): boolean;
  31267. /**
  31268. * Returns the mesh itself by default. Implemented by child classes
  31269. * @param camera defines the camera to use to pick the right LOD level
  31270. * @returns the currentAbstractMesh
  31271. */
  31272. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31273. /**
  31274. * Returns 0 by default. Implemented by child classes
  31275. * @returns an integer
  31276. */
  31277. getTotalVertices(): number;
  31278. /**
  31279. * Returns a positive integer : the total number of indices in this mesh geometry.
  31280. * @returns the numner of indices or zero if the mesh has no geometry.
  31281. */
  31282. getTotalIndices(): number;
  31283. /**
  31284. * Returns null by default. Implemented by child classes
  31285. * @returns null
  31286. */
  31287. getIndices(): Nullable<IndicesArray>;
  31288. /**
  31289. * Returns the array of the requested vertex data kind. Implemented by child classes
  31290. * @param kind defines the vertex data kind to use
  31291. * @returns null
  31292. */
  31293. getVerticesData(kind: string): Nullable<FloatArray>;
  31294. /**
  31295. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31296. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31297. * Note that a new underlying VertexBuffer object is created each call.
  31298. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31299. * @param kind defines vertex data kind:
  31300. * * VertexBuffer.PositionKind
  31301. * * VertexBuffer.UVKind
  31302. * * VertexBuffer.UV2Kind
  31303. * * VertexBuffer.UV3Kind
  31304. * * VertexBuffer.UV4Kind
  31305. * * VertexBuffer.UV5Kind
  31306. * * VertexBuffer.UV6Kind
  31307. * * VertexBuffer.ColorKind
  31308. * * VertexBuffer.MatricesIndicesKind
  31309. * * VertexBuffer.MatricesIndicesExtraKind
  31310. * * VertexBuffer.MatricesWeightsKind
  31311. * * VertexBuffer.MatricesWeightsExtraKind
  31312. * @param data defines the data source
  31313. * @param updatable defines if the data must be flagged as updatable (or static)
  31314. * @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
  31315. * @returns the current mesh
  31316. */
  31317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31318. /**
  31319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31320. * If the mesh has no geometry, it is simply returned as it is.
  31321. * @param kind defines vertex data kind:
  31322. * * VertexBuffer.PositionKind
  31323. * * VertexBuffer.UVKind
  31324. * * VertexBuffer.UV2Kind
  31325. * * VertexBuffer.UV3Kind
  31326. * * VertexBuffer.UV4Kind
  31327. * * VertexBuffer.UV5Kind
  31328. * * VertexBuffer.UV6Kind
  31329. * * VertexBuffer.ColorKind
  31330. * * VertexBuffer.MatricesIndicesKind
  31331. * * VertexBuffer.MatricesIndicesExtraKind
  31332. * * VertexBuffer.MatricesWeightsKind
  31333. * * VertexBuffer.MatricesWeightsExtraKind
  31334. * @param data defines the data source
  31335. * @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
  31336. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31337. * @returns the current mesh
  31338. */
  31339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31340. /**
  31341. * Sets the mesh indices,
  31342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31343. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31344. * @param totalVertices Defines the total number of vertices
  31345. * @returns the current mesh
  31346. */
  31347. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31348. /**
  31349. * Gets a boolean indicating if specific vertex data is present
  31350. * @param kind defines the vertex data kind to use
  31351. * @returns true is data kind is present
  31352. */
  31353. isVerticesDataPresent(kind: string): boolean;
  31354. /**
  31355. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31356. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31357. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31358. * @returns a BoundingInfo
  31359. */
  31360. getBoundingInfo(): BoundingInfo;
  31361. /**
  31362. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31363. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31364. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31365. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31366. * @returns the current mesh
  31367. */
  31368. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31369. /**
  31370. * Overwrite the current bounding info
  31371. * @param boundingInfo defines the new bounding info
  31372. * @returns the current mesh
  31373. */
  31374. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31375. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31376. get useBones(): boolean;
  31377. /** @hidden */
  31378. _preActivate(): void;
  31379. /** @hidden */
  31380. _preActivateForIntermediateRendering(renderId: number): void;
  31381. /** @hidden */
  31382. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31383. /** @hidden */
  31384. _postActivate(): void;
  31385. /** @hidden */
  31386. _freeze(): void;
  31387. /** @hidden */
  31388. _unFreeze(): void;
  31389. /**
  31390. * Gets the current world matrix
  31391. * @returns a Matrix
  31392. */
  31393. getWorldMatrix(): Matrix;
  31394. /** @hidden */
  31395. _getWorldMatrixDeterminant(): number;
  31396. /**
  31397. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31398. */
  31399. get isAnInstance(): boolean;
  31400. /**
  31401. * Gets a boolean indicating if this mesh has instances
  31402. */
  31403. get hasInstances(): boolean;
  31404. /**
  31405. * Gets a boolean indicating if this mesh has thin instances
  31406. */
  31407. get hasThinInstances(): boolean;
  31408. /**
  31409. * Perform relative position change from the point of view of behind the front of the mesh.
  31410. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31411. * Supports definition of mesh facing forward or backward
  31412. * @param amountRight defines the distance on the right axis
  31413. * @param amountUp defines the distance on the up axis
  31414. * @param amountForward defines the distance on the forward axis
  31415. * @returns the current mesh
  31416. */
  31417. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31418. /**
  31419. * Calculate relative position change from the point of view of behind the front of the mesh.
  31420. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31421. * Supports definition of mesh facing forward or backward
  31422. * @param amountRight defines the distance on the right axis
  31423. * @param amountUp defines the distance on the up axis
  31424. * @param amountForward defines the distance on the forward axis
  31425. * @returns the new displacement vector
  31426. */
  31427. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31428. /**
  31429. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31430. * Supports definition of mesh facing forward or backward
  31431. * @param flipBack defines the flip
  31432. * @param twirlClockwise defines the twirl
  31433. * @param tiltRight defines the tilt
  31434. * @returns the current mesh
  31435. */
  31436. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31437. /**
  31438. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31439. * Supports definition of mesh facing forward or backward.
  31440. * @param flipBack defines the flip
  31441. * @param twirlClockwise defines the twirl
  31442. * @param tiltRight defines the tilt
  31443. * @returns the new rotation vector
  31444. */
  31445. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31446. /**
  31447. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31448. * This means the mesh underlying bounding box and sphere are recomputed.
  31449. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31450. * @returns the current mesh
  31451. */
  31452. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31453. /** @hidden */
  31454. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31455. /** @hidden */
  31456. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31457. /** @hidden */
  31458. _updateBoundingInfo(): AbstractMesh;
  31459. /** @hidden */
  31460. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31461. /** @hidden */
  31462. protected _afterComputeWorldMatrix(): void;
  31463. /** @hidden */
  31464. get _effectiveMesh(): AbstractMesh;
  31465. /**
  31466. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31467. * A mesh is in the frustum if its bounding box intersects the frustum
  31468. * @param frustumPlanes defines the frustum to test
  31469. * @returns true if the mesh is in the frustum planes
  31470. */
  31471. isInFrustum(frustumPlanes: Plane[]): boolean;
  31472. /**
  31473. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31474. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31475. * @param frustumPlanes defines the frustum to test
  31476. * @returns true if the mesh is completely in the frustum planes
  31477. */
  31478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31479. /**
  31480. * True if the mesh intersects another mesh or a SolidParticle object
  31481. * @param mesh defines a target mesh or SolidParticle to test
  31482. * @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)
  31483. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31484. * @returns true if there is an intersection
  31485. */
  31486. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31487. /**
  31488. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31489. * @param point defines the point to test
  31490. * @returns true if there is an intersection
  31491. */
  31492. intersectsPoint(point: Vector3): boolean;
  31493. /**
  31494. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31495. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31496. */
  31497. get checkCollisions(): boolean;
  31498. set checkCollisions(collisionEnabled: boolean);
  31499. /**
  31500. * Gets Collider object used to compute collisions (not physics)
  31501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31502. */
  31503. get collider(): Nullable<Collider>;
  31504. /**
  31505. * Move the mesh using collision engine
  31506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31507. * @param displacement defines the requested displacement vector
  31508. * @returns the current mesh
  31509. */
  31510. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31511. private _onCollisionPositionChange;
  31512. /** @hidden */
  31513. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31514. /** @hidden */
  31515. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31516. /** @hidden */
  31517. _checkCollision(collider: Collider): AbstractMesh;
  31518. /** @hidden */
  31519. _generatePointsArray(): boolean;
  31520. /**
  31521. * Checks if the passed Ray intersects with the mesh
  31522. * @param ray defines the ray to use
  31523. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31525. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31526. * @returns the picking info
  31527. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31528. */
  31529. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31530. /**
  31531. * Clones the current mesh
  31532. * @param name defines the mesh name
  31533. * @param newParent defines the new mesh parent
  31534. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31535. * @returns the new mesh
  31536. */
  31537. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31538. /**
  31539. * Disposes all the submeshes of the current meshnp
  31540. * @returns the current mesh
  31541. */
  31542. releaseSubMeshes(): AbstractMesh;
  31543. /**
  31544. * Releases resources associated with this abstract mesh.
  31545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31547. */
  31548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31549. /**
  31550. * Adds the passed mesh as a child to the current mesh
  31551. * @param mesh defines the child mesh
  31552. * @returns the current mesh
  31553. */
  31554. addChild(mesh: AbstractMesh): AbstractMesh;
  31555. /**
  31556. * Removes the passed mesh from the current mesh children list
  31557. * @param mesh defines the child mesh
  31558. * @returns the current mesh
  31559. */
  31560. removeChild(mesh: AbstractMesh): AbstractMesh;
  31561. /** @hidden */
  31562. private _initFacetData;
  31563. /**
  31564. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31565. * This method can be called within the render loop.
  31566. * 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
  31567. * @returns the current mesh
  31568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31569. */
  31570. updateFacetData(): AbstractMesh;
  31571. /**
  31572. * Returns the facetLocalNormals array.
  31573. * The normals are expressed in the mesh local spac
  31574. * @returns an array of Vector3
  31575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31576. */
  31577. getFacetLocalNormals(): Vector3[];
  31578. /**
  31579. * Returns the facetLocalPositions array.
  31580. * The facet positions are expressed in the mesh local space
  31581. * @returns an array of Vector3
  31582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31583. */
  31584. getFacetLocalPositions(): Vector3[];
  31585. /**
  31586. * Returns the facetLocalPartioning array
  31587. * @returns an array of array of numbers
  31588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31589. */
  31590. getFacetLocalPartitioning(): number[][];
  31591. /**
  31592. * Returns the i-th facet position in the world system.
  31593. * This method allocates a new Vector3 per call
  31594. * @param i defines the facet index
  31595. * @returns a new Vector3
  31596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31597. */
  31598. getFacetPosition(i: number): Vector3;
  31599. /**
  31600. * Sets the reference Vector3 with the i-th facet position in the world system
  31601. * @param i defines the facet index
  31602. * @param ref defines the target vector
  31603. * @returns the current mesh
  31604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31605. */
  31606. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31607. /**
  31608. * Returns the i-th facet normal in the world system.
  31609. * This method allocates a new Vector3 per call
  31610. * @param i defines the facet index
  31611. * @returns a new Vector3
  31612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31613. */
  31614. getFacetNormal(i: number): Vector3;
  31615. /**
  31616. * Sets the reference Vector3 with the i-th facet normal in the world system
  31617. * @param i defines the facet index
  31618. * @param ref defines the target vector
  31619. * @returns the current mesh
  31620. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31621. */
  31622. getFacetNormalToRef(i: number, ref: Vector3): this;
  31623. /**
  31624. * 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)
  31625. * @param x defines x coordinate
  31626. * @param y defines y coordinate
  31627. * @param z defines z coordinate
  31628. * @returns the array of facet indexes
  31629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31630. */
  31631. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31632. /**
  31633. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31634. * @param projected sets as the (x,y,z) world projection on the facet
  31635. * @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
  31636. * @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
  31637. * @param x defines x coordinate
  31638. * @param y defines y coordinate
  31639. * @param z defines z coordinate
  31640. * @returns the face index if found (or null instead)
  31641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31642. */
  31643. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31644. /**
  31645. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31646. * @param projected sets as the (x,y,z) local projection on the facet
  31647. * @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
  31648. * @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
  31649. * @param x defines x coordinate
  31650. * @param y defines y coordinate
  31651. * @param z defines z coordinate
  31652. * @returns the face index if found (or null instead)
  31653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31654. */
  31655. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31656. /**
  31657. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31658. * @returns the parameters
  31659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31660. */
  31661. getFacetDataParameters(): any;
  31662. /**
  31663. * Disables the feature FacetData and frees the related memory
  31664. * @returns the current mesh
  31665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31666. */
  31667. disableFacetData(): AbstractMesh;
  31668. /**
  31669. * Updates the AbstractMesh indices array
  31670. * @param indices defines the data source
  31671. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31672. * @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)
  31673. * @returns the current mesh
  31674. */
  31675. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31676. /**
  31677. * Creates new normals data for the mesh
  31678. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31679. * @returns the current mesh
  31680. */
  31681. createNormals(updatable: boolean): AbstractMesh;
  31682. /**
  31683. * Align the mesh with a normal
  31684. * @param normal defines the normal to use
  31685. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31686. * @returns the current mesh
  31687. */
  31688. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31689. /** @hidden */
  31690. _checkOcclusionQuery(): boolean;
  31691. /**
  31692. * Disables the mesh edge rendering mode
  31693. * @returns the currentAbstractMesh
  31694. */
  31695. disableEdgesRendering(): AbstractMesh;
  31696. /**
  31697. * Enables the edge rendering mode on the mesh.
  31698. * This mode makes the mesh edges visible
  31699. * @param epsilon defines the maximal distance between two angles to detect a face
  31700. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31701. * @returns the currentAbstractMesh
  31702. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31703. */
  31704. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31705. }
  31706. }
  31707. declare module BABYLON {
  31708. /**
  31709. * Interface used to define ActionEvent
  31710. */
  31711. export interface IActionEvent {
  31712. /** The mesh or sprite that triggered the action */
  31713. source: any;
  31714. /** The X mouse cursor position at the time of the event */
  31715. pointerX: number;
  31716. /** The Y mouse cursor position at the time of the event */
  31717. pointerY: number;
  31718. /** The mesh that is currently pointed at (can be null) */
  31719. meshUnderPointer: Nullable<AbstractMesh>;
  31720. /** the original (browser) event that triggered the ActionEvent */
  31721. sourceEvent?: any;
  31722. /** additional data for the event */
  31723. additionalData?: any;
  31724. }
  31725. /**
  31726. * ActionEvent is the event being sent when an action is triggered.
  31727. */
  31728. export class ActionEvent implements IActionEvent {
  31729. /** The mesh or sprite that triggered the action */
  31730. source: any;
  31731. /** The X mouse cursor position at the time of the event */
  31732. pointerX: number;
  31733. /** The Y mouse cursor position at the time of the event */
  31734. pointerY: number;
  31735. /** The mesh that is currently pointed at (can be null) */
  31736. meshUnderPointer: Nullable<AbstractMesh>;
  31737. /** the original (browser) event that triggered the ActionEvent */
  31738. sourceEvent?: any;
  31739. /** additional data for the event */
  31740. additionalData?: any;
  31741. /**
  31742. * Creates a new ActionEvent
  31743. * @param source The mesh or sprite that triggered the action
  31744. * @param pointerX The X mouse cursor position at the time of the event
  31745. * @param pointerY The Y mouse cursor position at the time of the event
  31746. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31747. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31748. * @param additionalData additional data for the event
  31749. */
  31750. constructor(
  31751. /** The mesh or sprite that triggered the action */
  31752. source: any,
  31753. /** The X mouse cursor position at the time of the event */
  31754. pointerX: number,
  31755. /** The Y mouse cursor position at the time of the event */
  31756. pointerY: number,
  31757. /** The mesh that is currently pointed at (can be null) */
  31758. meshUnderPointer: Nullable<AbstractMesh>,
  31759. /** the original (browser) event that triggered the ActionEvent */
  31760. sourceEvent?: any,
  31761. /** additional data for the event */
  31762. additionalData?: any);
  31763. /**
  31764. * Helper function to auto-create an ActionEvent from a source mesh.
  31765. * @param source The source mesh that triggered the event
  31766. * @param evt The original (browser) event
  31767. * @param additionalData additional data for the event
  31768. * @returns the new ActionEvent
  31769. */
  31770. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31771. /**
  31772. * Helper function to auto-create an ActionEvent from a source sprite
  31773. * @param source The source sprite that triggered the event
  31774. * @param scene Scene associated with the sprite
  31775. * @param evt The original (browser) event
  31776. * @param additionalData additional data for the event
  31777. * @returns the new ActionEvent
  31778. */
  31779. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31780. /**
  31781. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31782. * @param scene the scene where the event occurred
  31783. * @param evt The original (browser) event
  31784. * @returns the new ActionEvent
  31785. */
  31786. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31787. /**
  31788. * Helper function to auto-create an ActionEvent from a primitive
  31789. * @param prim defines the target primitive
  31790. * @param pointerPos defines the pointer position
  31791. * @param evt The original (browser) event
  31792. * @param additionalData additional data for the event
  31793. * @returns the new ActionEvent
  31794. */
  31795. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31796. }
  31797. }
  31798. declare module BABYLON {
  31799. /**
  31800. * Abstract class used to decouple action Manager from scene and meshes.
  31801. * Do not instantiate.
  31802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31803. */
  31804. export abstract class AbstractActionManager implements IDisposable {
  31805. /** Gets the list of active triggers */
  31806. static Triggers: {
  31807. [key: string]: number;
  31808. };
  31809. /** Gets the cursor to use when hovering items */
  31810. hoverCursor: string;
  31811. /** Gets the list of actions */
  31812. actions: IAction[];
  31813. /**
  31814. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31815. */
  31816. isRecursive: boolean;
  31817. /**
  31818. * Releases all associated resources
  31819. */
  31820. abstract dispose(): void;
  31821. /**
  31822. * Does this action manager has pointer triggers
  31823. */
  31824. abstract get hasPointerTriggers(): boolean;
  31825. /**
  31826. * Does this action manager has pick triggers
  31827. */
  31828. abstract get hasPickTriggers(): boolean;
  31829. /**
  31830. * Process a specific trigger
  31831. * @param trigger defines the trigger to process
  31832. * @param evt defines the event details to be processed
  31833. */
  31834. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31835. /**
  31836. * Does this action manager handles actions of any of the given triggers
  31837. * @param triggers defines the triggers to be tested
  31838. * @return a boolean indicating whether one (or more) of the triggers is handled
  31839. */
  31840. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31841. /**
  31842. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31843. * speed.
  31844. * @param triggerA defines the trigger to be tested
  31845. * @param triggerB defines the trigger to be tested
  31846. * @return a boolean indicating whether one (or more) of the triggers is handled
  31847. */
  31848. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31849. /**
  31850. * Does this action manager handles actions of a given trigger
  31851. * @param trigger defines the trigger to be tested
  31852. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31853. * @return whether the trigger is handled
  31854. */
  31855. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31856. /**
  31857. * Serialize this manager to a JSON object
  31858. * @param name defines the property name to store this manager
  31859. * @returns a JSON representation of this manager
  31860. */
  31861. abstract serialize(name: string): any;
  31862. /**
  31863. * Registers an action to this action manager
  31864. * @param action defines the action to be registered
  31865. * @return the action amended (prepared) after registration
  31866. */
  31867. abstract registerAction(action: IAction): Nullable<IAction>;
  31868. /**
  31869. * Unregisters an action to this action manager
  31870. * @param action defines the action to be unregistered
  31871. * @return a boolean indicating whether the action has been unregistered
  31872. */
  31873. abstract unregisterAction(action: IAction): Boolean;
  31874. /**
  31875. * Does exist one action manager with at least one trigger
  31876. **/
  31877. static get HasTriggers(): boolean;
  31878. /**
  31879. * Does exist one action manager with at least one pick trigger
  31880. **/
  31881. static get HasPickTriggers(): boolean;
  31882. /**
  31883. * Does exist one action manager that handles actions of a given trigger
  31884. * @param trigger defines the trigger to be tested
  31885. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31886. **/
  31887. static HasSpecificTrigger(trigger: number): boolean;
  31888. }
  31889. }
  31890. declare module BABYLON {
  31891. /**
  31892. * Defines how a node can be built from a string name.
  31893. */
  31894. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31895. /**
  31896. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31897. */
  31898. export class Node implements IBehaviorAware<Node> {
  31899. /** @hidden */
  31900. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31901. private static _NodeConstructors;
  31902. /**
  31903. * Add a new node constructor
  31904. * @param type defines the type name of the node to construct
  31905. * @param constructorFunc defines the constructor function
  31906. */
  31907. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31908. /**
  31909. * Returns a node constructor based on type name
  31910. * @param type defines the type name
  31911. * @param name defines the new node name
  31912. * @param scene defines the hosting scene
  31913. * @param options defines optional options to transmit to constructors
  31914. * @returns the new constructor or null
  31915. */
  31916. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31917. /**
  31918. * Gets or sets the name of the node
  31919. */
  31920. name: string;
  31921. /**
  31922. * Gets or sets the id of the node
  31923. */
  31924. id: string;
  31925. /**
  31926. * Gets or sets the unique id of the node
  31927. */
  31928. uniqueId: number;
  31929. /**
  31930. * Gets or sets a string used to store user defined state for the node
  31931. */
  31932. state: string;
  31933. /**
  31934. * Gets or sets an object used to store user defined information for the node
  31935. */
  31936. metadata: any;
  31937. /**
  31938. * For internal use only. Please do not use.
  31939. */
  31940. reservedDataStore: any;
  31941. /**
  31942. * List of inspectable custom properties (used by the Inspector)
  31943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31944. */
  31945. inspectableCustomProperties: IInspectable[];
  31946. private _doNotSerialize;
  31947. /**
  31948. * Gets or sets a boolean used to define if the node must be serialized
  31949. */
  31950. get doNotSerialize(): boolean;
  31951. set doNotSerialize(value: boolean);
  31952. /** @hidden */
  31953. _isDisposed: boolean;
  31954. /**
  31955. * Gets a list of Animations associated with the node
  31956. */
  31957. animations: Animation[];
  31958. protected _ranges: {
  31959. [name: string]: Nullable<AnimationRange>;
  31960. };
  31961. /**
  31962. * Callback raised when the node is ready to be used
  31963. */
  31964. onReady: Nullable<(node: Node) => void>;
  31965. private _isEnabled;
  31966. private _isParentEnabled;
  31967. private _isReady;
  31968. /** @hidden */
  31969. _currentRenderId: number;
  31970. private _parentUpdateId;
  31971. /** @hidden */
  31972. _childUpdateId: number;
  31973. /** @hidden */
  31974. _waitingParentId: Nullable<string>;
  31975. /** @hidden */
  31976. _scene: Scene;
  31977. /** @hidden */
  31978. _cache: any;
  31979. private _parentNode;
  31980. private _children;
  31981. /** @hidden */
  31982. _worldMatrix: Matrix;
  31983. /** @hidden */
  31984. _worldMatrixDeterminant: number;
  31985. /** @hidden */
  31986. _worldMatrixDeterminantIsDirty: boolean;
  31987. /** @hidden */
  31988. private _sceneRootNodesIndex;
  31989. /**
  31990. * Gets a boolean indicating if the node has been disposed
  31991. * @returns true if the node was disposed
  31992. */
  31993. isDisposed(): boolean;
  31994. /**
  31995. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31996. * @see https://doc.babylonjs.com/how_to/parenting
  31997. */
  31998. set parent(parent: Nullable<Node>);
  31999. get parent(): Nullable<Node>;
  32000. /** @hidden */
  32001. _addToSceneRootNodes(): void;
  32002. /** @hidden */
  32003. _removeFromSceneRootNodes(): void;
  32004. private _animationPropertiesOverride;
  32005. /**
  32006. * Gets or sets the animation properties override
  32007. */
  32008. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32009. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32010. /**
  32011. * Gets a string idenfifying the name of the class
  32012. * @returns "Node" string
  32013. */
  32014. getClassName(): string;
  32015. /** @hidden */
  32016. readonly _isNode: boolean;
  32017. /**
  32018. * An event triggered when the mesh is disposed
  32019. */
  32020. onDisposeObservable: Observable<Node>;
  32021. private _onDisposeObserver;
  32022. /**
  32023. * Sets a callback that will be raised when the node will be disposed
  32024. */
  32025. set onDispose(callback: () => void);
  32026. /**
  32027. * Creates a new Node
  32028. * @param name the name and id to be given to this node
  32029. * @param scene the scene this node will be added to
  32030. */
  32031. constructor(name: string, scene?: Nullable<Scene>);
  32032. /**
  32033. * Gets the scene of the node
  32034. * @returns a scene
  32035. */
  32036. getScene(): Scene;
  32037. /**
  32038. * Gets the engine of the node
  32039. * @returns a Engine
  32040. */
  32041. getEngine(): Engine;
  32042. private _behaviors;
  32043. /**
  32044. * Attach a behavior to the node
  32045. * @see http://doc.babylonjs.com/features/behaviour
  32046. * @param behavior defines the behavior to attach
  32047. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32048. * @returns the current Node
  32049. */
  32050. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32051. /**
  32052. * Remove an attached behavior
  32053. * @see http://doc.babylonjs.com/features/behaviour
  32054. * @param behavior defines the behavior to attach
  32055. * @returns the current Node
  32056. */
  32057. removeBehavior(behavior: Behavior<Node>): Node;
  32058. /**
  32059. * Gets the list of attached behaviors
  32060. * @see http://doc.babylonjs.com/features/behaviour
  32061. */
  32062. get behaviors(): Behavior<Node>[];
  32063. /**
  32064. * Gets an attached behavior by name
  32065. * @param name defines the name of the behavior to look for
  32066. * @see http://doc.babylonjs.com/features/behaviour
  32067. * @returns null if behavior was not found else the requested behavior
  32068. */
  32069. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32070. /**
  32071. * Returns the latest update of the World matrix
  32072. * @returns a Matrix
  32073. */
  32074. getWorldMatrix(): Matrix;
  32075. /** @hidden */
  32076. _getWorldMatrixDeterminant(): number;
  32077. /**
  32078. * Returns directly the latest state of the mesh World matrix.
  32079. * A Matrix is returned.
  32080. */
  32081. get worldMatrixFromCache(): Matrix;
  32082. /** @hidden */
  32083. _initCache(): void;
  32084. /** @hidden */
  32085. updateCache(force?: boolean): void;
  32086. /** @hidden */
  32087. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32088. /** @hidden */
  32089. _updateCache(ignoreParentClass?: boolean): void;
  32090. /** @hidden */
  32091. _isSynchronized(): boolean;
  32092. /** @hidden */
  32093. _markSyncedWithParent(): void;
  32094. /** @hidden */
  32095. isSynchronizedWithParent(): boolean;
  32096. /** @hidden */
  32097. isSynchronized(): boolean;
  32098. /**
  32099. * Is this node ready to be used/rendered
  32100. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32101. * @return true if the node is ready
  32102. */
  32103. isReady(completeCheck?: boolean): boolean;
  32104. /**
  32105. * Is this node enabled?
  32106. * 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
  32107. * @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
  32108. * @return whether this node (and its parent) is enabled
  32109. */
  32110. isEnabled(checkAncestors?: boolean): boolean;
  32111. /** @hidden */
  32112. protected _syncParentEnabledState(): void;
  32113. /**
  32114. * Set the enabled state of this node
  32115. * @param value defines the new enabled state
  32116. */
  32117. setEnabled(value: boolean): void;
  32118. /**
  32119. * Is this node a descendant of the given node?
  32120. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32121. * @param ancestor defines the parent node to inspect
  32122. * @returns a boolean indicating if this node is a descendant of the given node
  32123. */
  32124. isDescendantOf(ancestor: Node): boolean;
  32125. /** @hidden */
  32126. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32127. /**
  32128. * Will return all nodes that have this node as ascendant
  32129. * @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
  32130. * @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
  32131. * @return all children nodes of all types
  32132. */
  32133. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32134. /**
  32135. * Get all child-meshes of this node
  32136. * @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)
  32137. * @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
  32138. * @returns an array of AbstractMesh
  32139. */
  32140. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32141. /**
  32142. * Get all direct children of this node
  32143. * @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
  32144. * @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)
  32145. * @returns an array of Node
  32146. */
  32147. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32148. /** @hidden */
  32149. _setReady(state: boolean): void;
  32150. /**
  32151. * Get an animation by name
  32152. * @param name defines the name of the animation to look for
  32153. * @returns null if not found else the requested animation
  32154. */
  32155. getAnimationByName(name: string): Nullable<Animation>;
  32156. /**
  32157. * Creates an animation range for this node
  32158. * @param name defines the name of the range
  32159. * @param from defines the starting key
  32160. * @param to defines the end key
  32161. */
  32162. createAnimationRange(name: string, from: number, to: number): void;
  32163. /**
  32164. * Delete a specific animation range
  32165. * @param name defines the name of the range to delete
  32166. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32167. */
  32168. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32169. /**
  32170. * Get an animation range by name
  32171. * @param name defines the name of the animation range to look for
  32172. * @returns null if not found else the requested animation range
  32173. */
  32174. getAnimationRange(name: string): Nullable<AnimationRange>;
  32175. /**
  32176. * Gets the list of all animation ranges defined on this node
  32177. * @returns an array
  32178. */
  32179. getAnimationRanges(): Nullable<AnimationRange>[];
  32180. /**
  32181. * Will start the animation sequence
  32182. * @param name defines the range frames for animation sequence
  32183. * @param loop defines if the animation should loop (false by default)
  32184. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32185. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32186. * @returns the object created for this animation. If range does not exist, it will return null
  32187. */
  32188. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32189. /**
  32190. * Serialize animation ranges into a JSON compatible object
  32191. * @returns serialization object
  32192. */
  32193. serializeAnimationRanges(): any;
  32194. /**
  32195. * Computes the world matrix of the node
  32196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32197. * @returns the world matrix
  32198. */
  32199. computeWorldMatrix(force?: boolean): Matrix;
  32200. /**
  32201. * Releases resources associated with this node.
  32202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32204. */
  32205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32206. /**
  32207. * Parse animation range data from a serialization object and store them into a given node
  32208. * @param node defines where to store the animation ranges
  32209. * @param parsedNode defines the serialization object to read data from
  32210. * @param scene defines the hosting scene
  32211. */
  32212. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32213. /**
  32214. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32215. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32216. * @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
  32217. * @returns the new bounding vectors
  32218. */
  32219. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32220. min: Vector3;
  32221. max: Vector3;
  32222. };
  32223. }
  32224. }
  32225. declare module BABYLON {
  32226. /**
  32227. * @hidden
  32228. */
  32229. export class _IAnimationState {
  32230. key: number;
  32231. repeatCount: number;
  32232. workValue?: any;
  32233. loopMode?: number;
  32234. offsetValue?: any;
  32235. highLimitValue?: any;
  32236. }
  32237. /**
  32238. * Class used to store any kind of animation
  32239. */
  32240. export class Animation {
  32241. /**Name of the animation */
  32242. name: string;
  32243. /**Property to animate */
  32244. targetProperty: string;
  32245. /**The frames per second of the animation */
  32246. framePerSecond: number;
  32247. /**The data type of the animation */
  32248. dataType: number;
  32249. /**The loop mode of the animation */
  32250. loopMode?: number | undefined;
  32251. /**Specifies if blending should be enabled */
  32252. enableBlending?: boolean | undefined;
  32253. /**
  32254. * Use matrix interpolation instead of using direct key value when animating matrices
  32255. */
  32256. static AllowMatricesInterpolation: boolean;
  32257. /**
  32258. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32259. */
  32260. static AllowMatrixDecomposeForInterpolation: boolean;
  32261. /** Define the Url to load snippets */
  32262. static SnippetUrl: string;
  32263. /** Snippet ID if the animation was created from the snippet server */
  32264. snippetId: string;
  32265. /**
  32266. * Stores the key frames of the animation
  32267. */
  32268. private _keys;
  32269. /**
  32270. * Stores the easing function of the animation
  32271. */
  32272. private _easingFunction;
  32273. /**
  32274. * @hidden Internal use only
  32275. */
  32276. _runtimeAnimations: RuntimeAnimation[];
  32277. /**
  32278. * The set of event that will be linked to this animation
  32279. */
  32280. private _events;
  32281. /**
  32282. * Stores an array of target property paths
  32283. */
  32284. targetPropertyPath: string[];
  32285. /**
  32286. * Stores the blending speed of the animation
  32287. */
  32288. blendingSpeed: number;
  32289. /**
  32290. * Stores the animation ranges for the animation
  32291. */
  32292. private _ranges;
  32293. /**
  32294. * @hidden Internal use
  32295. */
  32296. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32297. /**
  32298. * Sets up an animation
  32299. * @param property The property to animate
  32300. * @param animationType The animation type to apply
  32301. * @param framePerSecond The frames per second of the animation
  32302. * @param easingFunction The easing function used in the animation
  32303. * @returns The created animation
  32304. */
  32305. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32306. /**
  32307. * Create and start an animation on a node
  32308. * @param name defines the name of the global animation that will be run on all nodes
  32309. * @param node defines the root node where the animation will take place
  32310. * @param targetProperty defines property to animate
  32311. * @param framePerSecond defines the number of frame per second yo use
  32312. * @param totalFrame defines the number of frames in total
  32313. * @param from defines the initial value
  32314. * @param to defines the final value
  32315. * @param loopMode defines which loop mode you want to use (off by default)
  32316. * @param easingFunction defines the easing function to use (linear by default)
  32317. * @param onAnimationEnd defines the callback to call when animation end
  32318. * @returns the animatable created for this animation
  32319. */
  32320. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32321. /**
  32322. * Create and start an animation on a node and its descendants
  32323. * @param name defines the name of the global animation that will be run on all nodes
  32324. * @param node defines the root node where the animation will take place
  32325. * @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
  32326. * @param targetProperty defines property to animate
  32327. * @param framePerSecond defines the number of frame per second to use
  32328. * @param totalFrame defines the number of frames in total
  32329. * @param from defines the initial value
  32330. * @param to defines the final value
  32331. * @param loopMode defines which loop mode you want to use (off by default)
  32332. * @param easingFunction defines the easing function to use (linear by default)
  32333. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32334. * @returns the list of animatables created for all nodes
  32335. * @example https://www.babylonjs-playground.com/#MH0VLI
  32336. */
  32337. 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[]>;
  32338. /**
  32339. * Creates a new animation, merges it with the existing animations and starts it
  32340. * @param name Name of the animation
  32341. * @param node Node which contains the scene that begins the animations
  32342. * @param targetProperty Specifies which property to animate
  32343. * @param framePerSecond The frames per second of the animation
  32344. * @param totalFrame The total number of frames
  32345. * @param from The frame at the beginning of the animation
  32346. * @param to The frame at the end of the animation
  32347. * @param loopMode Specifies the loop mode of the animation
  32348. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32349. * @param onAnimationEnd Callback to run once the animation is complete
  32350. * @returns Nullable animation
  32351. */
  32352. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32353. /**
  32354. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32355. * @param sourceAnimation defines the Animation containing keyframes to convert
  32356. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32357. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32358. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32359. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32360. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32361. */
  32362. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32363. /**
  32364. * Transition property of an host to the target Value
  32365. * @param property The property to transition
  32366. * @param targetValue The target Value of the property
  32367. * @param host The object where the property to animate belongs
  32368. * @param scene Scene used to run the animation
  32369. * @param frameRate Framerate (in frame/s) to use
  32370. * @param transition The transition type we want to use
  32371. * @param duration The duration of the animation, in milliseconds
  32372. * @param onAnimationEnd Callback trigger at the end of the animation
  32373. * @returns Nullable animation
  32374. */
  32375. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32376. /**
  32377. * Return the array of runtime animations currently using this animation
  32378. */
  32379. get runtimeAnimations(): RuntimeAnimation[];
  32380. /**
  32381. * Specifies if any of the runtime animations are currently running
  32382. */
  32383. get hasRunningRuntimeAnimations(): boolean;
  32384. /**
  32385. * Initializes the animation
  32386. * @param name Name of the animation
  32387. * @param targetProperty Property to animate
  32388. * @param framePerSecond The frames per second of the animation
  32389. * @param dataType The data type of the animation
  32390. * @param loopMode The loop mode of the animation
  32391. * @param enableBlending Specifies if blending should be enabled
  32392. */
  32393. constructor(
  32394. /**Name of the animation */
  32395. name: string,
  32396. /**Property to animate */
  32397. targetProperty: string,
  32398. /**The frames per second of the animation */
  32399. framePerSecond: number,
  32400. /**The data type of the animation */
  32401. dataType: number,
  32402. /**The loop mode of the animation */
  32403. loopMode?: number | undefined,
  32404. /**Specifies if blending should be enabled */
  32405. enableBlending?: boolean | undefined);
  32406. /**
  32407. * Converts the animation to a string
  32408. * @param fullDetails support for multiple levels of logging within scene loading
  32409. * @returns String form of the animation
  32410. */
  32411. toString(fullDetails?: boolean): string;
  32412. /**
  32413. * Add an event to this animation
  32414. * @param event Event to add
  32415. */
  32416. addEvent(event: AnimationEvent): void;
  32417. /**
  32418. * Remove all events found at the given frame
  32419. * @param frame The frame to remove events from
  32420. */
  32421. removeEvents(frame: number): void;
  32422. /**
  32423. * Retrieves all the events from the animation
  32424. * @returns Events from the animation
  32425. */
  32426. getEvents(): AnimationEvent[];
  32427. /**
  32428. * Creates an animation range
  32429. * @param name Name of the animation range
  32430. * @param from Starting frame of the animation range
  32431. * @param to Ending frame of the animation
  32432. */
  32433. createRange(name: string, from: number, to: number): void;
  32434. /**
  32435. * Deletes an animation range by name
  32436. * @param name Name of the animation range to delete
  32437. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32438. */
  32439. deleteRange(name: string, deleteFrames?: boolean): void;
  32440. /**
  32441. * Gets the animation range by name, or null if not defined
  32442. * @param name Name of the animation range
  32443. * @returns Nullable animation range
  32444. */
  32445. getRange(name: string): Nullable<AnimationRange>;
  32446. /**
  32447. * Gets the key frames from the animation
  32448. * @returns The key frames of the animation
  32449. */
  32450. getKeys(): Array<IAnimationKey>;
  32451. /**
  32452. * Gets the highest frame rate of the animation
  32453. * @returns Highest frame rate of the animation
  32454. */
  32455. getHighestFrame(): number;
  32456. /**
  32457. * Gets the easing function of the animation
  32458. * @returns Easing function of the animation
  32459. */
  32460. getEasingFunction(): IEasingFunction;
  32461. /**
  32462. * Sets the easing function of the animation
  32463. * @param easingFunction A custom mathematical formula for animation
  32464. */
  32465. setEasingFunction(easingFunction: EasingFunction): void;
  32466. /**
  32467. * Interpolates a scalar 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 scalar value
  32472. */
  32473. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32474. /**
  32475. * Interpolates a scalar 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 scalar value
  32482. */
  32483. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32484. /**
  32485. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  32490. */
  32491. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32492. /**
  32493. * Interpolates a quaternion cubically
  32494. * @param startValue Start value of the animation curve
  32495. * @param outTangent End tangent of the animation curve
  32496. * @param endValue End value of the animation curve
  32497. * @param inTangent Start tangent of the animation curve
  32498. * @param gradient Scalar amount to interpolate
  32499. * @returns Interpolated quaternion value
  32500. */
  32501. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32502. /**
  32503. * Interpolates a Vector3 linearl
  32504. * @param startValue Start value of the animation curve
  32505. * @param endValue End value of the animation curve
  32506. * @param gradient Scalar amount to interpolate
  32507. * @returns Interpolated scalar value
  32508. */
  32509. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32510. /**
  32511. * Interpolates a Vector3 cubically
  32512. * @param startValue Start value of the animation curve
  32513. * @param outTangent End tangent of the animation
  32514. * @param endValue End value of the animation curve
  32515. * @param inTangent Start tangent of the animation curve
  32516. * @param gradient Scalar amount to interpolate
  32517. * @returns InterpolatedVector3 value
  32518. */
  32519. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32520. /**
  32521. * Interpolates a Vector2 linearly
  32522. * @param startValue Start value of the animation curve
  32523. * @param endValue End value of the animation curve
  32524. * @param gradient Scalar amount to interpolate
  32525. * @returns Interpolated Vector2 value
  32526. */
  32527. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32528. /**
  32529. * Interpolates a Vector2 cubically
  32530. * @param startValue Start value of the animation curve
  32531. * @param outTangent End tangent of the animation
  32532. * @param endValue End value of the animation curve
  32533. * @param inTangent Start tangent of the animation curve
  32534. * @param gradient Scalar amount to interpolate
  32535. * @returns Interpolated Vector2 value
  32536. */
  32537. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32538. /**
  32539. * Interpolates a size linearly
  32540. * @param startValue Start value of the animation curve
  32541. * @param endValue End value of the animation curve
  32542. * @param gradient Scalar amount to interpolate
  32543. * @returns Interpolated Size value
  32544. */
  32545. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32546. /**
  32547. * Interpolates a Color3 linearly
  32548. * @param startValue Start value of the animation curve
  32549. * @param endValue End value of the animation curve
  32550. * @param gradient Scalar amount to interpolate
  32551. * @returns Interpolated Color3 value
  32552. */
  32553. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32554. /**
  32555. * Interpolates a Color4 linearly
  32556. * @param startValue Start value of the animation curve
  32557. * @param endValue End value of the animation curve
  32558. * @param gradient Scalar amount to interpolate
  32559. * @returns Interpolated Color3 value
  32560. */
  32561. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32562. /**
  32563. * @hidden Internal use only
  32564. */
  32565. _getKeyValue(value: any): any;
  32566. /**
  32567. * @hidden Internal use only
  32568. */
  32569. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32570. /**
  32571. * Defines the function to use to interpolate matrices
  32572. * @param startValue defines the start matrix
  32573. * @param endValue defines the end matrix
  32574. * @param gradient defines the gradient between both matrices
  32575. * @param result defines an optional target matrix where to store the interpolation
  32576. * @returns the interpolated matrix
  32577. */
  32578. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32579. /**
  32580. * Makes a copy of the animation
  32581. * @returns Cloned animation
  32582. */
  32583. clone(): Animation;
  32584. /**
  32585. * Sets the key frames of the animation
  32586. * @param values The animation key frames to set
  32587. */
  32588. setKeys(values: Array<IAnimationKey>): void;
  32589. /**
  32590. * Serializes the animation to an object
  32591. * @returns Serialized object
  32592. */
  32593. serialize(): any;
  32594. /**
  32595. * Float animation type
  32596. */
  32597. static readonly ANIMATIONTYPE_FLOAT: number;
  32598. /**
  32599. * Vector3 animation type
  32600. */
  32601. static readonly ANIMATIONTYPE_VECTOR3: number;
  32602. /**
  32603. * Quaternion animation type
  32604. */
  32605. static readonly ANIMATIONTYPE_QUATERNION: number;
  32606. /**
  32607. * Matrix animation type
  32608. */
  32609. static readonly ANIMATIONTYPE_MATRIX: number;
  32610. /**
  32611. * Color3 animation type
  32612. */
  32613. static readonly ANIMATIONTYPE_COLOR3: number;
  32614. /**
  32615. * Color3 animation type
  32616. */
  32617. static readonly ANIMATIONTYPE_COLOR4: number;
  32618. /**
  32619. * Vector2 animation type
  32620. */
  32621. static readonly ANIMATIONTYPE_VECTOR2: number;
  32622. /**
  32623. * Size animation type
  32624. */
  32625. static readonly ANIMATIONTYPE_SIZE: number;
  32626. /**
  32627. * Relative Loop Mode
  32628. */
  32629. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32630. /**
  32631. * Cycle Loop Mode
  32632. */
  32633. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32634. /**
  32635. * Constant Loop Mode
  32636. */
  32637. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32638. /** @hidden */
  32639. static _UniversalLerp(left: any, right: any, amount: number): any;
  32640. /**
  32641. * Parses an animation object and creates an animation
  32642. * @param parsedAnimation Parsed animation object
  32643. * @returns Animation object
  32644. */
  32645. static Parse(parsedAnimation: any): Animation;
  32646. /**
  32647. * Appends the serialized animations from the source animations
  32648. * @param source Source containing the animations
  32649. * @param destination Target to store the animations
  32650. */
  32651. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32652. /**
  32653. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32654. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32655. * @param url defines the url to load from
  32656. * @returns a promise that will resolve to the new animation or an array of animations
  32657. */
  32658. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32659. /**
  32660. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32661. * @param snippetId defines the snippet to load
  32662. * @returns a promise that will resolve to the new animation or a new array of animations
  32663. */
  32664. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32665. }
  32666. }
  32667. declare module BABYLON {
  32668. /**
  32669. * Interface containing an array of animations
  32670. */
  32671. export interface IAnimatable {
  32672. /**
  32673. * Array of animations
  32674. */
  32675. animations: Nullable<Array<Animation>>;
  32676. }
  32677. }
  32678. declare module BABYLON {
  32679. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32680. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32681. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32682. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32683. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32684. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32685. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32686. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32687. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32688. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32689. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32690. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32691. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32692. /**
  32693. * Decorator used to define property that can be serialized as reference to a camera
  32694. * @param sourceName defines the name of the property to decorate
  32695. */
  32696. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32697. /**
  32698. * Class used to help serialization objects
  32699. */
  32700. export class SerializationHelper {
  32701. /** @hidden */
  32702. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32703. /** @hidden */
  32704. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32705. /** @hidden */
  32706. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32707. /** @hidden */
  32708. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32709. /**
  32710. * Appends the serialized animations from the source animations
  32711. * @param source Source containing the animations
  32712. * @param destination Target to store the animations
  32713. */
  32714. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32715. /**
  32716. * Static function used to serialized a specific entity
  32717. * @param entity defines the entity to serialize
  32718. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32719. * @returns a JSON compatible object representing the serialization of the entity
  32720. */
  32721. static Serialize<T>(entity: T, serializationObject?: any): any;
  32722. /**
  32723. * Creates a new entity from a serialization data object
  32724. * @param creationFunction defines a function used to instanciated the new entity
  32725. * @param source defines the source serialization data
  32726. * @param scene defines the hosting scene
  32727. * @param rootUrl defines the root url for resources
  32728. * @returns a new entity
  32729. */
  32730. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32731. /**
  32732. * Clones an object
  32733. * @param creationFunction defines the function used to instanciate the new object
  32734. * @param source defines the source object
  32735. * @returns the cloned object
  32736. */
  32737. static Clone<T>(creationFunction: () => T, source: T): T;
  32738. /**
  32739. * Instanciates a new object based on a source one (some data will be shared between both object)
  32740. * @param creationFunction defines the function used to instanciate the new object
  32741. * @param source defines the source object
  32742. * @returns the new object
  32743. */
  32744. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32745. }
  32746. }
  32747. declare module BABYLON {
  32748. /**
  32749. * Base class of all the textures in babylon.
  32750. * It groups all the common properties the materials, post process, lights... might need
  32751. * in order to make a correct use of the texture.
  32752. */
  32753. export class BaseTexture implements IAnimatable {
  32754. /**
  32755. * Default anisotropic filtering level for the application.
  32756. * It is set to 4 as a good tradeoff between perf and quality.
  32757. */
  32758. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32759. /**
  32760. * Gets or sets the unique id of the texture
  32761. */
  32762. uniqueId: number;
  32763. /**
  32764. * Define the name of the texture.
  32765. */
  32766. name: string;
  32767. /**
  32768. * Gets or sets an object used to store user defined information.
  32769. */
  32770. metadata: any;
  32771. /**
  32772. * For internal use only. Please do not use.
  32773. */
  32774. reservedDataStore: any;
  32775. private _hasAlpha;
  32776. /**
  32777. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32778. */
  32779. set hasAlpha(value: boolean);
  32780. get hasAlpha(): boolean;
  32781. /**
  32782. * Defines if the alpha value should be determined via the rgb values.
  32783. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32784. */
  32785. getAlphaFromRGB: boolean;
  32786. /**
  32787. * Intensity or strength of the texture.
  32788. * It is commonly used by materials to fine tune the intensity of the texture
  32789. */
  32790. level: number;
  32791. /**
  32792. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32793. * This is part of the texture as textures usually maps to one uv set.
  32794. */
  32795. coordinatesIndex: number;
  32796. private _coordinatesMode;
  32797. /**
  32798. * How a texture is mapped.
  32799. *
  32800. * | Value | Type | Description |
  32801. * | ----- | ----------------------------------- | ----------- |
  32802. * | 0 | EXPLICIT_MODE | |
  32803. * | 1 | SPHERICAL_MODE | |
  32804. * | 2 | PLANAR_MODE | |
  32805. * | 3 | CUBIC_MODE | |
  32806. * | 4 | PROJECTION_MODE | |
  32807. * | 5 | SKYBOX_MODE | |
  32808. * | 6 | INVCUBIC_MODE | |
  32809. * | 7 | EQUIRECTANGULAR_MODE | |
  32810. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32811. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32812. */
  32813. set coordinatesMode(value: number);
  32814. get coordinatesMode(): number;
  32815. /**
  32816. * | Value | Type | Description |
  32817. * | ----- | ------------------ | ----------- |
  32818. * | 0 | CLAMP_ADDRESSMODE | |
  32819. * | 1 | WRAP_ADDRESSMODE | |
  32820. * | 2 | MIRROR_ADDRESSMODE | |
  32821. */
  32822. wrapU: number;
  32823. /**
  32824. * | Value | Type | Description |
  32825. * | ----- | ------------------ | ----------- |
  32826. * | 0 | CLAMP_ADDRESSMODE | |
  32827. * | 1 | WRAP_ADDRESSMODE | |
  32828. * | 2 | MIRROR_ADDRESSMODE | |
  32829. */
  32830. wrapV: number;
  32831. /**
  32832. * | Value | Type | Description |
  32833. * | ----- | ------------------ | ----------- |
  32834. * | 0 | CLAMP_ADDRESSMODE | |
  32835. * | 1 | WRAP_ADDRESSMODE | |
  32836. * | 2 | MIRROR_ADDRESSMODE | |
  32837. */
  32838. wrapR: number;
  32839. /**
  32840. * With compliant hardware and browser (supporting anisotropic filtering)
  32841. * this defines the level of anisotropic filtering in the texture.
  32842. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32843. */
  32844. anisotropicFilteringLevel: number;
  32845. /**
  32846. * Define if the texture is a cube texture or if false a 2d texture.
  32847. */
  32848. get isCube(): boolean;
  32849. set isCube(value: boolean);
  32850. /**
  32851. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32852. */
  32853. get is3D(): boolean;
  32854. set is3D(value: boolean);
  32855. /**
  32856. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32857. */
  32858. get is2DArray(): boolean;
  32859. set is2DArray(value: boolean);
  32860. /**
  32861. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32862. * HDR texture are usually stored in linear space.
  32863. * This only impacts the PBR and Background materials
  32864. */
  32865. gammaSpace: boolean;
  32866. /**
  32867. * Gets or sets whether or not the texture contains RGBD data.
  32868. */
  32869. get isRGBD(): boolean;
  32870. set isRGBD(value: boolean);
  32871. /**
  32872. * Is Z inverted in the texture (useful in a cube texture).
  32873. */
  32874. invertZ: boolean;
  32875. /**
  32876. * Are mip maps generated for this texture or not.
  32877. */
  32878. get noMipmap(): boolean;
  32879. /**
  32880. * @hidden
  32881. */
  32882. lodLevelInAlpha: boolean;
  32883. /**
  32884. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32885. */
  32886. get lodGenerationOffset(): number;
  32887. set lodGenerationOffset(value: number);
  32888. /**
  32889. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32890. */
  32891. get lodGenerationScale(): number;
  32892. set lodGenerationScale(value: number);
  32893. /**
  32894. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32895. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32896. * average roughness values.
  32897. */
  32898. get linearSpecularLOD(): boolean;
  32899. set linearSpecularLOD(value: boolean);
  32900. /**
  32901. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32902. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32903. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32904. */
  32905. get irradianceTexture(): Nullable<BaseTexture>;
  32906. set irradianceTexture(value: Nullable<BaseTexture>);
  32907. /**
  32908. * Define if the texture is a render target.
  32909. */
  32910. isRenderTarget: boolean;
  32911. /**
  32912. * Define the unique id of the texture in the scene.
  32913. */
  32914. get uid(): string;
  32915. /** @hidden */
  32916. _prefiltered: boolean;
  32917. /**
  32918. * Return a string representation of the texture.
  32919. * @returns the texture as a string
  32920. */
  32921. toString(): string;
  32922. /**
  32923. * Get the class name of the texture.
  32924. * @returns "BaseTexture"
  32925. */
  32926. getClassName(): string;
  32927. /**
  32928. * Define the list of animation attached to the texture.
  32929. */
  32930. animations: Animation[];
  32931. /**
  32932. * An event triggered when the texture is disposed.
  32933. */
  32934. onDisposeObservable: Observable<BaseTexture>;
  32935. private _onDisposeObserver;
  32936. /**
  32937. * Callback triggered when the texture has been disposed.
  32938. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32939. */
  32940. set onDispose(callback: () => void);
  32941. /**
  32942. * Define the current state of the loading sequence when in delayed load mode.
  32943. */
  32944. delayLoadState: number;
  32945. private _scene;
  32946. private _engine;
  32947. /** @hidden */
  32948. _texture: Nullable<InternalTexture>;
  32949. private _uid;
  32950. /**
  32951. * Define if the texture is preventinga material to render or not.
  32952. * If not and the texture is not ready, the engine will use a default black texture instead.
  32953. */
  32954. get isBlocking(): boolean;
  32955. /**
  32956. * Instantiates a new BaseTexture.
  32957. * Base class of all the textures in babylon.
  32958. * It groups all the common properties the materials, post process, lights... might need
  32959. * in order to make a correct use of the texture.
  32960. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32961. */
  32962. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32963. /**
  32964. * Get the scene the texture belongs to.
  32965. * @returns the scene or null if undefined
  32966. */
  32967. getScene(): Nullable<Scene>;
  32968. /** @hidden */
  32969. protected _getEngine(): Nullable<ThinEngine>;
  32970. /**
  32971. * Get the texture transform matrix used to offset tile the texture for istance.
  32972. * @returns the transformation matrix
  32973. */
  32974. getTextureMatrix(): Matrix;
  32975. /**
  32976. * Get the texture reflection matrix used to rotate/transform the reflection.
  32977. * @returns the reflection matrix
  32978. */
  32979. getReflectionTextureMatrix(): Matrix;
  32980. /**
  32981. * Get the underlying lower level texture from Babylon.
  32982. * @returns the insternal texture
  32983. */
  32984. getInternalTexture(): Nullable<InternalTexture>;
  32985. /**
  32986. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32987. * @returns true if ready or not blocking
  32988. */
  32989. isReadyOrNotBlocking(): boolean;
  32990. /**
  32991. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32992. * @returns true if fully ready
  32993. */
  32994. isReady(): boolean;
  32995. private _cachedSize;
  32996. /**
  32997. * Get the size of the texture.
  32998. * @returns the texture size.
  32999. */
  33000. getSize(): ISize;
  33001. /**
  33002. * Get the base size of the texture.
  33003. * It can be different from the size if the texture has been resized for POT for instance
  33004. * @returns the base size
  33005. */
  33006. getBaseSize(): ISize;
  33007. /**
  33008. * Update the sampling mode of the texture.
  33009. * Default is Trilinear mode.
  33010. *
  33011. * | Value | Type | Description |
  33012. * | ----- | ------------------ | ----------- |
  33013. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33014. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33015. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33016. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33017. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33018. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33019. * | 7 | NEAREST_LINEAR | |
  33020. * | 8 | NEAREST_NEAREST | |
  33021. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33022. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33023. * | 11 | LINEAR_LINEAR | |
  33024. * | 12 | LINEAR_NEAREST | |
  33025. *
  33026. * > _mag_: magnification filter (close to the viewer)
  33027. * > _min_: minification filter (far from the viewer)
  33028. * > _mip_: filter used between mip map levels
  33029. *@param samplingMode Define the new sampling mode of the texture
  33030. */
  33031. updateSamplingMode(samplingMode: number): void;
  33032. /**
  33033. * Scales the texture if is `canRescale()`
  33034. * @param ratio the resize factor we want to use to rescale
  33035. */
  33036. scale(ratio: number): void;
  33037. /**
  33038. * Get if the texture can rescale.
  33039. */
  33040. get canRescale(): boolean;
  33041. /** @hidden */
  33042. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33043. /** @hidden */
  33044. _rebuild(): void;
  33045. /**
  33046. * Triggers the load sequence in delayed load mode.
  33047. */
  33048. delayLoad(): void;
  33049. /**
  33050. * Clones the texture.
  33051. * @returns the cloned texture
  33052. */
  33053. clone(): Nullable<BaseTexture>;
  33054. /**
  33055. * Get the texture underlying type (INT, FLOAT...)
  33056. */
  33057. get textureType(): number;
  33058. /**
  33059. * Get the texture underlying format (RGB, RGBA...)
  33060. */
  33061. get textureFormat(): number;
  33062. /**
  33063. * Indicates that textures need to be re-calculated for all materials
  33064. */
  33065. protected _markAllSubMeshesAsTexturesDirty(): void;
  33066. /**
  33067. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33068. * This will returns an RGBA array buffer containing either in values (0-255) or
  33069. * float values (0-1) depending of the underlying buffer type.
  33070. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33071. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33072. * @param buffer defines a user defined buffer to fill with data (can be null)
  33073. * @returns The Array buffer containing the pixels data.
  33074. */
  33075. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33076. /**
  33077. * Release and destroy the underlying lower level texture aka internalTexture.
  33078. */
  33079. releaseInternalTexture(): void;
  33080. /** @hidden */
  33081. get _lodTextureHigh(): Nullable<BaseTexture>;
  33082. /** @hidden */
  33083. get _lodTextureMid(): Nullable<BaseTexture>;
  33084. /** @hidden */
  33085. get _lodTextureLow(): Nullable<BaseTexture>;
  33086. /**
  33087. * Dispose the texture and release its associated resources.
  33088. */
  33089. dispose(): void;
  33090. /**
  33091. * Serialize the texture into a JSON representation that can be parsed later on.
  33092. * @returns the JSON representation of the texture
  33093. */
  33094. serialize(): any;
  33095. /**
  33096. * Helper function to be called back once a list of texture contains only ready textures.
  33097. * @param textures Define the list of textures to wait for
  33098. * @param callback Define the callback triggered once the entire list will be ready
  33099. */
  33100. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33101. private static _isScene;
  33102. }
  33103. }
  33104. declare module BABYLON {
  33105. /**
  33106. * Options to be used when creating an effect.
  33107. */
  33108. export interface IEffectCreationOptions {
  33109. /**
  33110. * Atrributes that will be used in the shader.
  33111. */
  33112. attributes: string[];
  33113. /**
  33114. * Uniform varible names that will be set in the shader.
  33115. */
  33116. uniformsNames: string[];
  33117. /**
  33118. * Uniform buffer variable names that will be set in the shader.
  33119. */
  33120. uniformBuffersNames: string[];
  33121. /**
  33122. * Sampler texture variable names that will be set in the shader.
  33123. */
  33124. samplers: string[];
  33125. /**
  33126. * Define statements that will be set in the shader.
  33127. */
  33128. defines: any;
  33129. /**
  33130. * Possible fallbacks for this effect to improve performance when needed.
  33131. */
  33132. fallbacks: Nullable<IEffectFallbacks>;
  33133. /**
  33134. * Callback that will be called when the shader is compiled.
  33135. */
  33136. onCompiled: Nullable<(effect: Effect) => void>;
  33137. /**
  33138. * Callback that will be called if an error occurs during shader compilation.
  33139. */
  33140. onError: Nullable<(effect: Effect, errors: string) => void>;
  33141. /**
  33142. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33143. */
  33144. indexParameters?: any;
  33145. /**
  33146. * Max number of lights that can be used in the shader.
  33147. */
  33148. maxSimultaneousLights?: number;
  33149. /**
  33150. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33151. */
  33152. transformFeedbackVaryings?: Nullable<string[]>;
  33153. /**
  33154. * 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
  33155. */
  33156. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33157. }
  33158. /**
  33159. * Effect containing vertex and fragment shader that can be executed on an object.
  33160. */
  33161. export class Effect implements IDisposable {
  33162. /**
  33163. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33164. */
  33165. static ShadersRepository: string;
  33166. /**
  33167. * Enable logging of the shader code when a compilation error occurs
  33168. */
  33169. static LogShaderCodeOnCompilationError: boolean;
  33170. /**
  33171. * Name of the effect.
  33172. */
  33173. name: any;
  33174. /**
  33175. * String container all the define statements that should be set on the shader.
  33176. */
  33177. defines: string;
  33178. /**
  33179. * Callback that will be called when the shader is compiled.
  33180. */
  33181. onCompiled: Nullable<(effect: Effect) => void>;
  33182. /**
  33183. * Callback that will be called if an error occurs during shader compilation.
  33184. */
  33185. onError: Nullable<(effect: Effect, errors: string) => void>;
  33186. /**
  33187. * Callback that will be called when effect is bound.
  33188. */
  33189. onBind: Nullable<(effect: Effect) => void>;
  33190. /**
  33191. * Unique ID of the effect.
  33192. */
  33193. uniqueId: number;
  33194. /**
  33195. * Observable that will be called when the shader is compiled.
  33196. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33197. */
  33198. onCompileObservable: Observable<Effect>;
  33199. /**
  33200. * Observable that will be called if an error occurs during shader compilation.
  33201. */
  33202. onErrorObservable: Observable<Effect>;
  33203. /** @hidden */
  33204. _onBindObservable: Nullable<Observable<Effect>>;
  33205. /**
  33206. * @hidden
  33207. * Specifies if the effect was previously ready
  33208. */
  33209. _wasPreviouslyReady: boolean;
  33210. /**
  33211. * Observable that will be called when effect is bound.
  33212. */
  33213. get onBindObservable(): Observable<Effect>;
  33214. /** @hidden */
  33215. _bonesComputationForcedToCPU: boolean;
  33216. private static _uniqueIdSeed;
  33217. private _engine;
  33218. private _uniformBuffersNames;
  33219. private _uniformBuffersNamesList;
  33220. private _uniformsNames;
  33221. private _samplerList;
  33222. private _samplers;
  33223. private _isReady;
  33224. private _compilationError;
  33225. private _allFallbacksProcessed;
  33226. private _attributesNames;
  33227. private _attributes;
  33228. private _attributeLocationByName;
  33229. private _uniforms;
  33230. /**
  33231. * Key for the effect.
  33232. * @hidden
  33233. */
  33234. _key: string;
  33235. private _indexParameters;
  33236. private _fallbacks;
  33237. private _vertexSourceCode;
  33238. private _fragmentSourceCode;
  33239. private _vertexSourceCodeOverride;
  33240. private _fragmentSourceCodeOverride;
  33241. private _transformFeedbackVaryings;
  33242. /**
  33243. * Compiled shader to webGL program.
  33244. * @hidden
  33245. */
  33246. _pipelineContext: Nullable<IPipelineContext>;
  33247. private _valueCache;
  33248. private static _baseCache;
  33249. /**
  33250. * Instantiates an effect.
  33251. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33252. * @param baseName Name of the effect.
  33253. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33254. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33255. * @param samplers List of sampler variables that will be passed to the shader.
  33256. * @param engine Engine to be used to render the effect
  33257. * @param defines Define statements to be added to the shader.
  33258. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33259. * @param onCompiled Callback that will be called when the shader is compiled.
  33260. * @param onError Callback that will be called if an error occurs during shader compilation.
  33261. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33262. */
  33263. 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);
  33264. private _useFinalCode;
  33265. /**
  33266. * Unique key for this effect
  33267. */
  33268. get key(): string;
  33269. /**
  33270. * If the effect has been compiled and prepared.
  33271. * @returns if the effect is compiled and prepared.
  33272. */
  33273. isReady(): boolean;
  33274. private _isReadyInternal;
  33275. /**
  33276. * The engine the effect was initialized with.
  33277. * @returns the engine.
  33278. */
  33279. getEngine(): Engine;
  33280. /**
  33281. * The pipeline context for this effect
  33282. * @returns the associated pipeline context
  33283. */
  33284. getPipelineContext(): Nullable<IPipelineContext>;
  33285. /**
  33286. * The set of names of attribute variables for the shader.
  33287. * @returns An array of attribute names.
  33288. */
  33289. getAttributesNames(): string[];
  33290. /**
  33291. * Returns the attribute at the given index.
  33292. * @param index The index of the attribute.
  33293. * @returns The location of the attribute.
  33294. */
  33295. getAttributeLocation(index: number): number;
  33296. /**
  33297. * Returns the attribute based on the name of the variable.
  33298. * @param name of the attribute to look up.
  33299. * @returns the attribute location.
  33300. */
  33301. getAttributeLocationByName(name: string): number;
  33302. /**
  33303. * The number of attributes.
  33304. * @returns the numnber of attributes.
  33305. */
  33306. getAttributesCount(): number;
  33307. /**
  33308. * Gets the index of a uniform variable.
  33309. * @param uniformName of the uniform to look up.
  33310. * @returns the index.
  33311. */
  33312. getUniformIndex(uniformName: string): number;
  33313. /**
  33314. * Returns the attribute based on the name of the variable.
  33315. * @param uniformName of the uniform to look up.
  33316. * @returns the location of the uniform.
  33317. */
  33318. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33319. /**
  33320. * Returns an array of sampler variable names
  33321. * @returns The array of sampler variable names.
  33322. */
  33323. getSamplers(): string[];
  33324. /**
  33325. * Returns an array of uniform variable names
  33326. * @returns The array of uniform variable names.
  33327. */
  33328. getUniformNames(): string[];
  33329. /**
  33330. * Returns an array of uniform buffer variable names
  33331. * @returns The array of uniform buffer variable names.
  33332. */
  33333. getUniformBuffersNames(): string[];
  33334. /**
  33335. * Returns the index parameters used to create the effect
  33336. * @returns The index parameters object
  33337. */
  33338. getIndexParameters(): any;
  33339. /**
  33340. * The error from the last compilation.
  33341. * @returns the error string.
  33342. */
  33343. getCompilationError(): string;
  33344. /**
  33345. * Gets a boolean indicating that all fallbacks were used during compilation
  33346. * @returns true if all fallbacks were used
  33347. */
  33348. allFallbacksProcessed(): boolean;
  33349. /**
  33350. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33351. * @param func The callback to be used.
  33352. */
  33353. executeWhenCompiled(func: (effect: Effect) => void): void;
  33354. private _checkIsReady;
  33355. private _loadShader;
  33356. /**
  33357. * Gets the vertex shader source code of this effect
  33358. */
  33359. get vertexSourceCode(): string;
  33360. /**
  33361. * Gets the fragment shader source code of this effect
  33362. */
  33363. get fragmentSourceCode(): string;
  33364. /**
  33365. * Recompiles the webGL program
  33366. * @param vertexSourceCode The source code for the vertex shader.
  33367. * @param fragmentSourceCode The source code for the fragment shader.
  33368. * @param onCompiled Callback called when completed.
  33369. * @param onError Callback called on error.
  33370. * @hidden
  33371. */
  33372. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33373. /**
  33374. * Prepares the effect
  33375. * @hidden
  33376. */
  33377. _prepareEffect(): void;
  33378. private _getShaderCodeAndErrorLine;
  33379. private _processCompilationErrors;
  33380. /**
  33381. * Checks if the effect is supported. (Must be called after compilation)
  33382. */
  33383. get isSupported(): boolean;
  33384. /**
  33385. * Binds a texture to the engine to be used as output of the shader.
  33386. * @param channel Name of the output variable.
  33387. * @param texture Texture to bind.
  33388. * @hidden
  33389. */
  33390. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33391. /**
  33392. * Sets a texture on the engine to be used in the shader.
  33393. * @param channel Name of the sampler variable.
  33394. * @param texture Texture to set.
  33395. */
  33396. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33397. /**
  33398. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33399. * @param channel Name of the sampler variable.
  33400. * @param texture Texture to set.
  33401. */
  33402. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33403. /**
  33404. * Sets an array of textures on the engine to be used in the shader.
  33405. * @param channel Name of the variable.
  33406. * @param textures Textures to set.
  33407. */
  33408. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33409. /**
  33410. * 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)
  33411. * @param channel Name of the sampler variable.
  33412. * @param postProcess Post process to get the input texture from.
  33413. */
  33414. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33415. /**
  33416. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33417. * 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)
  33418. * @param channel Name of the sampler variable.
  33419. * @param postProcess Post process to get the output texture from.
  33420. */
  33421. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33422. /** @hidden */
  33423. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33424. /** @hidden */
  33425. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33426. /** @hidden */
  33427. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33428. /** @hidden */
  33429. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33430. /**
  33431. * Binds a buffer to a uniform.
  33432. * @param buffer Buffer to bind.
  33433. * @param name Name of the uniform variable to bind to.
  33434. */
  33435. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33436. /**
  33437. * Binds block to a uniform.
  33438. * @param blockName Name of the block to bind.
  33439. * @param index Index to bind.
  33440. */
  33441. bindUniformBlock(blockName: string, index: number): void;
  33442. /**
  33443. * Sets an interger value on a uniform variable.
  33444. * @param uniformName Name of the variable.
  33445. * @param value Value to be set.
  33446. * @returns this effect.
  33447. */
  33448. setInt(uniformName: string, value: number): Effect;
  33449. /**
  33450. * Sets an int array on a uniform variable.
  33451. * @param uniformName Name of the variable.
  33452. * @param array array to be set.
  33453. * @returns this effect.
  33454. */
  33455. setIntArray(uniformName: string, array: Int32Array): Effect;
  33456. /**
  33457. * 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)
  33458. * @param uniformName Name of the variable.
  33459. * @param array array to be set.
  33460. * @returns this effect.
  33461. */
  33462. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33463. /**
  33464. * 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)
  33465. * @param uniformName Name of the variable.
  33466. * @param array array to be set.
  33467. * @returns this effect.
  33468. */
  33469. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33470. /**
  33471. * 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)
  33472. * @param uniformName Name of the variable.
  33473. * @param array array to be set.
  33474. * @returns this effect.
  33475. */
  33476. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33477. /**
  33478. * Sets an float array on a uniform variable.
  33479. * @param uniformName Name of the variable.
  33480. * @param array array to be set.
  33481. * @returns this effect.
  33482. */
  33483. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33484. /**
  33485. * 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)
  33486. * @param uniformName Name of the variable.
  33487. * @param array array to be set.
  33488. * @returns this effect.
  33489. */
  33490. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33491. /**
  33492. * 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)
  33493. * @param uniformName Name of the variable.
  33494. * @param array array to be set.
  33495. * @returns this effect.
  33496. */
  33497. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33498. /**
  33499. * 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)
  33500. * @param uniformName Name of the variable.
  33501. * @param array array to be set.
  33502. * @returns this effect.
  33503. */
  33504. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33505. /**
  33506. * Sets an array on a uniform variable.
  33507. * @param uniformName Name of the variable.
  33508. * @param array array to be set.
  33509. * @returns this effect.
  33510. */
  33511. setArray(uniformName: string, array: number[]): Effect;
  33512. /**
  33513. * 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)
  33514. * @param uniformName Name of the variable.
  33515. * @param array array to be set.
  33516. * @returns this effect.
  33517. */
  33518. setArray2(uniformName: string, array: number[]): Effect;
  33519. /**
  33520. * 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)
  33521. * @param uniformName Name of the variable.
  33522. * @param array array to be set.
  33523. * @returns this effect.
  33524. */
  33525. setArray3(uniformName: string, array: number[]): Effect;
  33526. /**
  33527. * 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)
  33528. * @param uniformName Name of the variable.
  33529. * @param array array to be set.
  33530. * @returns this effect.
  33531. */
  33532. setArray4(uniformName: string, array: number[]): Effect;
  33533. /**
  33534. * Sets matrices on a uniform variable.
  33535. * @param uniformName Name of the variable.
  33536. * @param matrices matrices to be set.
  33537. * @returns this effect.
  33538. */
  33539. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33540. /**
  33541. * Sets matrix on a uniform variable.
  33542. * @param uniformName Name of the variable.
  33543. * @param matrix matrix to be set.
  33544. * @returns this effect.
  33545. */
  33546. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33547. /**
  33548. * 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)
  33549. * @param uniformName Name of the variable.
  33550. * @param matrix matrix to be set.
  33551. * @returns this effect.
  33552. */
  33553. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33554. /**
  33555. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33556. * @param uniformName Name of the variable.
  33557. * @param matrix matrix to be set.
  33558. * @returns this effect.
  33559. */
  33560. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33561. /**
  33562. * Sets a float on a uniform variable.
  33563. * @param uniformName Name of the variable.
  33564. * @param value value to be set.
  33565. * @returns this effect.
  33566. */
  33567. setFloat(uniformName: string, value: number): Effect;
  33568. /**
  33569. * Sets a boolean on a uniform variable.
  33570. * @param uniformName Name of the variable.
  33571. * @param bool value to be set.
  33572. * @returns this effect.
  33573. */
  33574. setBool(uniformName: string, bool: boolean): Effect;
  33575. /**
  33576. * Sets a Vector2 on a uniform variable.
  33577. * @param uniformName Name of the variable.
  33578. * @param vector2 vector2 to be set.
  33579. * @returns this effect.
  33580. */
  33581. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33582. /**
  33583. * Sets a float2 on a uniform variable.
  33584. * @param uniformName Name of the variable.
  33585. * @param x First float in float2.
  33586. * @param y Second float in float2.
  33587. * @returns this effect.
  33588. */
  33589. setFloat2(uniformName: string, x: number, y: number): Effect;
  33590. /**
  33591. * Sets a Vector3 on a uniform variable.
  33592. * @param uniformName Name of the variable.
  33593. * @param vector3 Value to be set.
  33594. * @returns this effect.
  33595. */
  33596. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33597. /**
  33598. * Sets a float3 on a uniform variable.
  33599. * @param uniformName Name of the variable.
  33600. * @param x First float in float3.
  33601. * @param y Second float in float3.
  33602. * @param z Third float in float3.
  33603. * @returns this effect.
  33604. */
  33605. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33606. /**
  33607. * Sets a Vector4 on a uniform variable.
  33608. * @param uniformName Name of the variable.
  33609. * @param vector4 Value to be set.
  33610. * @returns this effect.
  33611. */
  33612. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33613. /**
  33614. * Sets a float4 on a uniform variable.
  33615. * @param uniformName Name of the variable.
  33616. * @param x First float in float4.
  33617. * @param y Second float in float4.
  33618. * @param z Third float in float4.
  33619. * @param w Fourth float in float4.
  33620. * @returns this effect.
  33621. */
  33622. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33623. /**
  33624. * Sets a Color3 on a uniform variable.
  33625. * @param uniformName Name of the variable.
  33626. * @param color3 Value to be set.
  33627. * @returns this effect.
  33628. */
  33629. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33630. /**
  33631. * Sets a Color4 on a uniform variable.
  33632. * @param uniformName Name of the variable.
  33633. * @param color3 Value to be set.
  33634. * @param alpha Alpha value to be set.
  33635. * @returns this effect.
  33636. */
  33637. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33638. /**
  33639. * Sets a Color4 on a uniform variable
  33640. * @param uniformName defines the name of the variable
  33641. * @param color4 defines the value to be set
  33642. * @returns this effect.
  33643. */
  33644. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33645. /** Release all associated resources */
  33646. dispose(): void;
  33647. /**
  33648. * This function will add a new shader to the shader store
  33649. * @param name the name of the shader
  33650. * @param pixelShader optional pixel shader content
  33651. * @param vertexShader optional vertex shader content
  33652. */
  33653. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33654. /**
  33655. * Store of each shader (The can be looked up using effect.key)
  33656. */
  33657. static ShadersStore: {
  33658. [key: string]: string;
  33659. };
  33660. /**
  33661. * Store of each included file for a shader (The can be looked up using effect.key)
  33662. */
  33663. static IncludesShadersStore: {
  33664. [key: string]: string;
  33665. };
  33666. /**
  33667. * Resets the cache of effects.
  33668. */
  33669. static ResetCache(): void;
  33670. }
  33671. }
  33672. declare module BABYLON {
  33673. /**
  33674. * Interface used to describe the capabilities of the engine relatively to the current browser
  33675. */
  33676. export interface EngineCapabilities {
  33677. /** Maximum textures units per fragment shader */
  33678. maxTexturesImageUnits: number;
  33679. /** Maximum texture units per vertex shader */
  33680. maxVertexTextureImageUnits: number;
  33681. /** Maximum textures units in the entire pipeline */
  33682. maxCombinedTexturesImageUnits: number;
  33683. /** Maximum texture size */
  33684. maxTextureSize: number;
  33685. /** Maximum texture samples */
  33686. maxSamples?: number;
  33687. /** Maximum cube texture size */
  33688. maxCubemapTextureSize: number;
  33689. /** Maximum render texture size */
  33690. maxRenderTextureSize: number;
  33691. /** Maximum number of vertex attributes */
  33692. maxVertexAttribs: number;
  33693. /** Maximum number of varyings */
  33694. maxVaryingVectors: number;
  33695. /** Maximum number of uniforms per vertex shader */
  33696. maxVertexUniformVectors: number;
  33697. /** Maximum number of uniforms per fragment shader */
  33698. maxFragmentUniformVectors: number;
  33699. /** Defines if standard derivates (dx/dy) are supported */
  33700. standardDerivatives: boolean;
  33701. /** Defines if s3tc texture compression is supported */
  33702. s3tc?: WEBGL_compressed_texture_s3tc;
  33703. /** Defines if pvrtc texture compression is supported */
  33704. pvrtc: any;
  33705. /** Defines if etc1 texture compression is supported */
  33706. etc1: any;
  33707. /** Defines if etc2 texture compression is supported */
  33708. etc2: any;
  33709. /** Defines if astc texture compression is supported */
  33710. astc: any;
  33711. /** Defines if float textures are supported */
  33712. textureFloat: boolean;
  33713. /** Defines if vertex array objects are supported */
  33714. vertexArrayObject: boolean;
  33715. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33716. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33717. /** Gets the maximum level of anisotropy supported */
  33718. maxAnisotropy: number;
  33719. /** Defines if instancing is supported */
  33720. instancedArrays: boolean;
  33721. /** Defines if 32 bits indices are supported */
  33722. uintIndices: boolean;
  33723. /** Defines if high precision shaders are supported */
  33724. highPrecisionShaderSupported: boolean;
  33725. /** Defines if depth reading in the fragment shader is supported */
  33726. fragmentDepthSupported: boolean;
  33727. /** Defines if float texture linear filtering is supported*/
  33728. textureFloatLinearFiltering: boolean;
  33729. /** Defines if rendering to float textures is supported */
  33730. textureFloatRender: boolean;
  33731. /** Defines if half float textures are supported*/
  33732. textureHalfFloat: boolean;
  33733. /** Defines if half float texture linear filtering is supported*/
  33734. textureHalfFloatLinearFiltering: boolean;
  33735. /** Defines if rendering to half float textures is supported */
  33736. textureHalfFloatRender: boolean;
  33737. /** Defines if textureLOD shader command is supported */
  33738. textureLOD: boolean;
  33739. /** Defines if draw buffers extension is supported */
  33740. drawBuffersExtension: boolean;
  33741. /** Defines if depth textures are supported */
  33742. depthTextureExtension: boolean;
  33743. /** Defines if float color buffer are supported */
  33744. colorBufferFloat: boolean;
  33745. /** Gets disjoint timer query extension (null if not supported) */
  33746. timerQuery?: EXT_disjoint_timer_query;
  33747. /** Defines if timestamp can be used with timer query */
  33748. canUseTimestampForTimerQuery: boolean;
  33749. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33750. multiview?: any;
  33751. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33752. oculusMultiview?: any;
  33753. /** Function used to let the system compiles shaders in background */
  33754. parallelShaderCompile?: {
  33755. COMPLETION_STATUS_KHR: number;
  33756. };
  33757. /** Max number of texture samples for MSAA */
  33758. maxMSAASamples: number;
  33759. /** Defines if the blend min max extension is supported */
  33760. blendMinMax: boolean;
  33761. }
  33762. }
  33763. declare module BABYLON {
  33764. /**
  33765. * @hidden
  33766. **/
  33767. export class DepthCullingState {
  33768. private _isDepthTestDirty;
  33769. private _isDepthMaskDirty;
  33770. private _isDepthFuncDirty;
  33771. private _isCullFaceDirty;
  33772. private _isCullDirty;
  33773. private _isZOffsetDirty;
  33774. private _isFrontFaceDirty;
  33775. private _depthTest;
  33776. private _depthMask;
  33777. private _depthFunc;
  33778. private _cull;
  33779. private _cullFace;
  33780. private _zOffset;
  33781. private _frontFace;
  33782. /**
  33783. * Initializes the state.
  33784. */
  33785. constructor();
  33786. get isDirty(): boolean;
  33787. get zOffset(): number;
  33788. set zOffset(value: number);
  33789. get cullFace(): Nullable<number>;
  33790. set cullFace(value: Nullable<number>);
  33791. get cull(): Nullable<boolean>;
  33792. set cull(value: Nullable<boolean>);
  33793. get depthFunc(): Nullable<number>;
  33794. set depthFunc(value: Nullable<number>);
  33795. get depthMask(): boolean;
  33796. set depthMask(value: boolean);
  33797. get depthTest(): boolean;
  33798. set depthTest(value: boolean);
  33799. get frontFace(): Nullable<number>;
  33800. set frontFace(value: Nullable<number>);
  33801. reset(): void;
  33802. apply(gl: WebGLRenderingContext): void;
  33803. }
  33804. }
  33805. declare module BABYLON {
  33806. /**
  33807. * @hidden
  33808. **/
  33809. export class StencilState {
  33810. /** 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 */
  33811. static readonly ALWAYS: number;
  33812. /** Passed to stencilOperation to specify that stencil value must be kept */
  33813. static readonly KEEP: number;
  33814. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33815. static readonly REPLACE: number;
  33816. private _isStencilTestDirty;
  33817. private _isStencilMaskDirty;
  33818. private _isStencilFuncDirty;
  33819. private _isStencilOpDirty;
  33820. private _stencilTest;
  33821. private _stencilMask;
  33822. private _stencilFunc;
  33823. private _stencilFuncRef;
  33824. private _stencilFuncMask;
  33825. private _stencilOpStencilFail;
  33826. private _stencilOpDepthFail;
  33827. private _stencilOpStencilDepthPass;
  33828. get isDirty(): boolean;
  33829. get stencilFunc(): number;
  33830. set stencilFunc(value: number);
  33831. get stencilFuncRef(): number;
  33832. set stencilFuncRef(value: number);
  33833. get stencilFuncMask(): number;
  33834. set stencilFuncMask(value: number);
  33835. get stencilOpStencilFail(): number;
  33836. set stencilOpStencilFail(value: number);
  33837. get stencilOpDepthFail(): number;
  33838. set stencilOpDepthFail(value: number);
  33839. get stencilOpStencilDepthPass(): number;
  33840. set stencilOpStencilDepthPass(value: number);
  33841. get stencilMask(): number;
  33842. set stencilMask(value: number);
  33843. get stencilTest(): boolean;
  33844. set stencilTest(value: boolean);
  33845. constructor();
  33846. reset(): void;
  33847. apply(gl: WebGLRenderingContext): void;
  33848. }
  33849. }
  33850. declare module BABYLON {
  33851. /**
  33852. * @hidden
  33853. **/
  33854. export class AlphaState {
  33855. private _isAlphaBlendDirty;
  33856. private _isBlendFunctionParametersDirty;
  33857. private _isBlendEquationParametersDirty;
  33858. private _isBlendConstantsDirty;
  33859. private _alphaBlend;
  33860. private _blendFunctionParameters;
  33861. private _blendEquationParameters;
  33862. private _blendConstants;
  33863. /**
  33864. * Initializes the state.
  33865. */
  33866. constructor();
  33867. get isDirty(): boolean;
  33868. get alphaBlend(): boolean;
  33869. set alphaBlend(value: boolean);
  33870. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33871. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33872. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33873. reset(): void;
  33874. apply(gl: WebGLRenderingContext): void;
  33875. }
  33876. }
  33877. declare module BABYLON {
  33878. /** @hidden */
  33879. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33880. attributeProcessor(attribute: string): string;
  33881. varyingProcessor(varying: string, isFragment: boolean): string;
  33882. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33883. }
  33884. }
  33885. declare module BABYLON {
  33886. /**
  33887. * Interface for attribute information associated with buffer instanciation
  33888. */
  33889. export interface InstancingAttributeInfo {
  33890. /**
  33891. * Name of the GLSL attribute
  33892. * if attribute index is not specified, this is used to retrieve the index from the effect
  33893. */
  33894. attributeName: string;
  33895. /**
  33896. * Index/offset of the attribute in the vertex shader
  33897. * if not specified, this will be computes from the name.
  33898. */
  33899. index?: number;
  33900. /**
  33901. * size of the attribute, 1, 2, 3 or 4
  33902. */
  33903. attributeSize: number;
  33904. /**
  33905. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33906. */
  33907. offset: number;
  33908. /**
  33909. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33910. * default to 1
  33911. */
  33912. divisor?: number;
  33913. /**
  33914. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33915. * default is FLOAT
  33916. */
  33917. attributeType?: number;
  33918. /**
  33919. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33920. */
  33921. normalized?: boolean;
  33922. }
  33923. }
  33924. declare module BABYLON {
  33925. interface ThinEngine {
  33926. /**
  33927. * Update a video texture
  33928. * @param texture defines the texture to update
  33929. * @param video defines the video element to use
  33930. * @param invertY defines if data must be stored with Y axis inverted
  33931. */
  33932. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33933. }
  33934. }
  33935. declare module BABYLON {
  33936. /**
  33937. * Settings for finer control over video usage
  33938. */
  33939. export interface VideoTextureSettings {
  33940. /**
  33941. * Applies `autoplay` to video, if specified
  33942. */
  33943. autoPlay?: boolean;
  33944. /**
  33945. * Applies `loop` to video, if specified
  33946. */
  33947. loop?: boolean;
  33948. /**
  33949. * Automatically updates internal texture from video at every frame in the render loop
  33950. */
  33951. autoUpdateTexture: boolean;
  33952. /**
  33953. * Image src displayed during the video loading or until the user interacts with the video.
  33954. */
  33955. poster?: string;
  33956. }
  33957. /**
  33958. * If you want to display a video in your scene, this is the special texture for that.
  33959. * This special texture works similar to other textures, with the exception of a few parameters.
  33960. * @see https://doc.babylonjs.com/how_to/video_texture
  33961. */
  33962. export class VideoTexture extends Texture {
  33963. /**
  33964. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33965. */
  33966. readonly autoUpdateTexture: boolean;
  33967. /**
  33968. * The video instance used by the texture internally
  33969. */
  33970. readonly video: HTMLVideoElement;
  33971. private _onUserActionRequestedObservable;
  33972. /**
  33973. * Event triggerd when a dom action is required by the user to play the video.
  33974. * This happens due to recent changes in browser policies preventing video to auto start.
  33975. */
  33976. get onUserActionRequestedObservable(): Observable<Texture>;
  33977. private _generateMipMaps;
  33978. private _stillImageCaptured;
  33979. private _displayingPosterTexture;
  33980. private _settings;
  33981. private _createInternalTextureOnEvent;
  33982. private _frameId;
  33983. private _currentSrc;
  33984. /**
  33985. * Creates a video texture.
  33986. * If you want to display a video in your scene, this is the special texture for that.
  33987. * This special texture works similar to other textures, with the exception of a few parameters.
  33988. * @see https://doc.babylonjs.com/how_to/video_texture
  33989. * @param name optional name, will detect from video source, if not defined
  33990. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33991. * @param scene is obviously the current scene.
  33992. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33993. * @param invertY is false by default but can be used to invert video on Y axis
  33994. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33995. * @param settings allows finer control over video usage
  33996. */
  33997. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33998. private _getName;
  33999. private _getVideo;
  34000. private _createInternalTexture;
  34001. private reset;
  34002. /**
  34003. * @hidden Internal method to initiate `update`.
  34004. */
  34005. _rebuild(): void;
  34006. /**
  34007. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34008. */
  34009. update(): void;
  34010. /**
  34011. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34012. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34013. */
  34014. updateTexture(isVisible: boolean): void;
  34015. protected _updateInternalTexture: () => void;
  34016. /**
  34017. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34018. * @param url New url.
  34019. */
  34020. updateURL(url: string): void;
  34021. /**
  34022. * Clones the texture.
  34023. * @returns the cloned texture
  34024. */
  34025. clone(): VideoTexture;
  34026. /**
  34027. * Dispose the texture and release its associated resources.
  34028. */
  34029. dispose(): void;
  34030. /**
  34031. * Creates a video texture straight from a stream.
  34032. * @param scene Define the scene the texture should be created in
  34033. * @param stream Define the stream the texture should be created from
  34034. * @returns The created video texture as a promise
  34035. */
  34036. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34037. /**
  34038. * Creates a video texture straight from your WebCam video feed.
  34039. * @param scene Define the scene the texture should be created in
  34040. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34041. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34042. * @returns The created video texture as a promise
  34043. */
  34044. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34045. minWidth: number;
  34046. maxWidth: number;
  34047. minHeight: number;
  34048. maxHeight: number;
  34049. deviceId: string;
  34050. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34051. /**
  34052. * Creates a video texture straight from your WebCam video feed.
  34053. * @param scene Define the scene the texture should be created in
  34054. * @param onReady Define a callback to triggered once the texture will be ready
  34055. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34056. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34057. */
  34058. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34059. minWidth: number;
  34060. maxWidth: number;
  34061. minHeight: number;
  34062. maxHeight: number;
  34063. deviceId: string;
  34064. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34065. }
  34066. }
  34067. declare module BABYLON {
  34068. /**
  34069. * Defines the interface used by objects working like Scene
  34070. * @hidden
  34071. */
  34072. export interface ISceneLike {
  34073. _addPendingData(data: any): void;
  34074. _removePendingData(data: any): void;
  34075. offlineProvider: IOfflineProvider;
  34076. }
  34077. /** Interface defining initialization parameters for Engine class */
  34078. export interface EngineOptions extends WebGLContextAttributes {
  34079. /**
  34080. * Defines if the engine should no exceed a specified device ratio
  34081. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34082. */
  34083. limitDeviceRatio?: number;
  34084. /**
  34085. * Defines if webvr should be enabled automatically
  34086. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34087. */
  34088. autoEnableWebVR?: boolean;
  34089. /**
  34090. * Defines if webgl2 should be turned off even if supported
  34091. * @see http://doc.babylonjs.com/features/webgl2
  34092. */
  34093. disableWebGL2Support?: boolean;
  34094. /**
  34095. * Defines if webaudio should be initialized as well
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34097. */
  34098. audioEngine?: boolean;
  34099. /**
  34100. * Defines if animations should run using a deterministic lock step
  34101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34102. */
  34103. deterministicLockstep?: boolean;
  34104. /** Defines the maximum steps to use with deterministic lock step mode */
  34105. lockstepMaxSteps?: number;
  34106. /** Defines the seconds between each deterministic lock step */
  34107. timeStep?: number;
  34108. /**
  34109. * Defines that engine should ignore context lost events
  34110. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34111. */
  34112. doNotHandleContextLost?: boolean;
  34113. /**
  34114. * Defines that engine should ignore modifying touch action attribute and style
  34115. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34116. */
  34117. doNotHandleTouchAction?: boolean;
  34118. /**
  34119. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34120. */
  34121. useHighPrecisionFloats?: boolean;
  34122. /**
  34123. * Make the canvas XR Compatible for XR sessions
  34124. */
  34125. xrCompatible?: boolean;
  34126. }
  34127. /**
  34128. * The base engine class (root of all engines)
  34129. */
  34130. export class ThinEngine {
  34131. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34132. static ExceptionList: ({
  34133. key: string;
  34134. capture: string;
  34135. captureConstraint: number;
  34136. targets: string[];
  34137. } | {
  34138. key: string;
  34139. capture: null;
  34140. captureConstraint: null;
  34141. targets: string[];
  34142. })[];
  34143. /** @hidden */
  34144. static _TextureLoaders: IInternalTextureLoader[];
  34145. /**
  34146. * Returns the current npm package of the sdk
  34147. */
  34148. static get NpmPackage(): string;
  34149. /**
  34150. * Returns the current version of the framework
  34151. */
  34152. static get Version(): string;
  34153. /**
  34154. * Returns a string describing the current engine
  34155. */
  34156. get description(): string;
  34157. /**
  34158. * Gets or sets the epsilon value used by collision engine
  34159. */
  34160. static CollisionsEpsilon: number;
  34161. /**
  34162. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34163. */
  34164. static get ShadersRepository(): string;
  34165. static set ShadersRepository(value: string);
  34166. /** @hidden */
  34167. _shaderProcessor: IShaderProcessor;
  34168. /**
  34169. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34170. */
  34171. forcePOTTextures: boolean;
  34172. /**
  34173. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34174. */
  34175. isFullscreen: boolean;
  34176. /**
  34177. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34178. */
  34179. cullBackFaces: boolean;
  34180. /**
  34181. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34182. */
  34183. renderEvenInBackground: boolean;
  34184. /**
  34185. * Gets or sets a boolean indicating that cache can be kept between frames
  34186. */
  34187. preventCacheWipeBetweenFrames: boolean;
  34188. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34189. validateShaderPrograms: boolean;
  34190. /**
  34191. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34192. * This can provide greater z depth for distant objects.
  34193. */
  34194. useReverseDepthBuffer: boolean;
  34195. /**
  34196. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34197. */
  34198. disableUniformBuffers: boolean;
  34199. /** @hidden */
  34200. _uniformBuffers: UniformBuffer[];
  34201. /**
  34202. * Gets a boolean indicating that the engine supports uniform buffers
  34203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34204. */
  34205. get supportsUniformBuffers(): boolean;
  34206. /** @hidden */
  34207. _gl: WebGLRenderingContext;
  34208. /** @hidden */
  34209. _webGLVersion: number;
  34210. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34211. protected _windowIsBackground: boolean;
  34212. protected _creationOptions: EngineOptions;
  34213. protected _highPrecisionShadersAllowed: boolean;
  34214. /** @hidden */
  34215. get _shouldUseHighPrecisionShader(): boolean;
  34216. /**
  34217. * Gets a boolean indicating that only power of 2 textures are supported
  34218. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34219. */
  34220. get needPOTTextures(): boolean;
  34221. /** @hidden */
  34222. _badOS: boolean;
  34223. /** @hidden */
  34224. _badDesktopOS: boolean;
  34225. private _hardwareScalingLevel;
  34226. /** @hidden */
  34227. _caps: EngineCapabilities;
  34228. private _isStencilEnable;
  34229. private _glVersion;
  34230. private _glRenderer;
  34231. private _glVendor;
  34232. /** @hidden */
  34233. _videoTextureSupported: boolean;
  34234. protected _renderingQueueLaunched: boolean;
  34235. protected _activeRenderLoops: (() => void)[];
  34236. /**
  34237. * Observable signaled when a context lost event is raised
  34238. */
  34239. onContextLostObservable: Observable<ThinEngine>;
  34240. /**
  34241. * Observable signaled when a context restored event is raised
  34242. */
  34243. onContextRestoredObservable: Observable<ThinEngine>;
  34244. private _onContextLost;
  34245. private _onContextRestored;
  34246. protected _contextWasLost: boolean;
  34247. /** @hidden */
  34248. _doNotHandleContextLost: boolean;
  34249. /**
  34250. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34252. */
  34253. get doNotHandleContextLost(): boolean;
  34254. set doNotHandleContextLost(value: boolean);
  34255. /**
  34256. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34257. */
  34258. disableVertexArrayObjects: boolean;
  34259. /** @hidden */
  34260. protected _colorWrite: boolean;
  34261. /** @hidden */
  34262. protected _colorWriteChanged: boolean;
  34263. /** @hidden */
  34264. protected _depthCullingState: DepthCullingState;
  34265. /** @hidden */
  34266. protected _stencilState: StencilState;
  34267. /** @hidden */
  34268. _alphaState: AlphaState;
  34269. /** @hidden */
  34270. _alphaMode: number;
  34271. /** @hidden */
  34272. _alphaEquation: number;
  34273. /** @hidden */
  34274. _internalTexturesCache: InternalTexture[];
  34275. /** @hidden */
  34276. protected _activeChannel: number;
  34277. private _currentTextureChannel;
  34278. /** @hidden */
  34279. protected _boundTexturesCache: {
  34280. [key: string]: Nullable<InternalTexture>;
  34281. };
  34282. /** @hidden */
  34283. protected _currentEffect: Nullable<Effect>;
  34284. /** @hidden */
  34285. protected _currentProgram: Nullable<WebGLProgram>;
  34286. private _compiledEffects;
  34287. private _vertexAttribArraysEnabled;
  34288. /** @hidden */
  34289. protected _cachedViewport: Nullable<IViewportLike>;
  34290. private _cachedVertexArrayObject;
  34291. /** @hidden */
  34292. protected _cachedVertexBuffers: any;
  34293. /** @hidden */
  34294. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34295. /** @hidden */
  34296. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34297. /** @hidden */
  34298. _currentRenderTarget: Nullable<InternalTexture>;
  34299. private _uintIndicesCurrentlySet;
  34300. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34301. /** @hidden */
  34302. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34303. /** @hidden */
  34304. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34305. private _currentBufferPointers;
  34306. private _currentInstanceLocations;
  34307. private _currentInstanceBuffers;
  34308. private _textureUnits;
  34309. /** @hidden */
  34310. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34311. /** @hidden */
  34312. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34313. /** @hidden */
  34314. _boundRenderFunction: any;
  34315. private _vaoRecordInProgress;
  34316. private _mustWipeVertexAttributes;
  34317. private _emptyTexture;
  34318. private _emptyCubeTexture;
  34319. private _emptyTexture3D;
  34320. private _emptyTexture2DArray;
  34321. /** @hidden */
  34322. _frameHandler: number;
  34323. private _nextFreeTextureSlots;
  34324. private _maxSimultaneousTextures;
  34325. private _activeRequests;
  34326. /** @hidden */
  34327. _transformTextureUrl: Nullable<(url: string) => string>;
  34328. protected get _supportsHardwareTextureRescaling(): boolean;
  34329. private _framebufferDimensionsObject;
  34330. /**
  34331. * sets the object from which width and height will be taken from when getting render width and height
  34332. * Will fallback to the gl object
  34333. * @param dimensions the framebuffer width and height that will be used.
  34334. */
  34335. set framebufferDimensionsObject(dimensions: Nullable<{
  34336. framebufferWidth: number;
  34337. framebufferHeight: number;
  34338. }>);
  34339. /**
  34340. * Gets the current viewport
  34341. */
  34342. get currentViewport(): Nullable<IViewportLike>;
  34343. /**
  34344. * Gets the default empty texture
  34345. */
  34346. get emptyTexture(): InternalTexture;
  34347. /**
  34348. * Gets the default empty 3D texture
  34349. */
  34350. get emptyTexture3D(): InternalTexture;
  34351. /**
  34352. * Gets the default empty 2D array texture
  34353. */
  34354. get emptyTexture2DArray(): InternalTexture;
  34355. /**
  34356. * Gets the default empty cube texture
  34357. */
  34358. get emptyCubeTexture(): InternalTexture;
  34359. /**
  34360. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34361. */
  34362. readonly premultipliedAlpha: boolean;
  34363. /**
  34364. * Observable event triggered before each texture is initialized
  34365. */
  34366. onBeforeTextureInitObservable: Observable<Texture>;
  34367. /**
  34368. * Creates a new engine
  34369. * @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
  34370. * @param antialias defines enable antialiasing (default: false)
  34371. * @param options defines further options to be sent to the getContext() function
  34372. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34373. */
  34374. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34375. private _rebuildInternalTextures;
  34376. private _rebuildEffects;
  34377. /**
  34378. * Gets a boolean indicating if all created effects are ready
  34379. * @returns true if all effects are ready
  34380. */
  34381. areAllEffectsReady(): boolean;
  34382. protected _rebuildBuffers(): void;
  34383. protected _initGLContext(): void;
  34384. /**
  34385. * Gets version of the current webGL context
  34386. */
  34387. get webGLVersion(): number;
  34388. /**
  34389. * Gets a string idenfifying the name of the class
  34390. * @returns "Engine" string
  34391. */
  34392. getClassName(): string;
  34393. /**
  34394. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34395. */
  34396. get isStencilEnable(): boolean;
  34397. /** @hidden */
  34398. _prepareWorkingCanvas(): void;
  34399. /**
  34400. * Reset the texture cache to empty state
  34401. */
  34402. resetTextureCache(): void;
  34403. /**
  34404. * Gets an object containing information about the current webGL context
  34405. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34406. */
  34407. getGlInfo(): {
  34408. vendor: string;
  34409. renderer: string;
  34410. version: string;
  34411. };
  34412. /**
  34413. * Defines the hardware scaling level.
  34414. * By default the hardware scaling level is computed from the window device ratio.
  34415. * 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.
  34416. * @param level defines the level to use
  34417. */
  34418. setHardwareScalingLevel(level: number): void;
  34419. /**
  34420. * Gets the current hardware scaling level.
  34421. * By default the hardware scaling level is computed from the window device ratio.
  34422. * 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.
  34423. * @returns a number indicating the current hardware scaling level
  34424. */
  34425. getHardwareScalingLevel(): number;
  34426. /**
  34427. * Gets the list of loaded textures
  34428. * @returns an array containing all loaded textures
  34429. */
  34430. getLoadedTexturesCache(): InternalTexture[];
  34431. /**
  34432. * Gets the object containing all engine capabilities
  34433. * @returns the EngineCapabilities object
  34434. */
  34435. getCaps(): EngineCapabilities;
  34436. /**
  34437. * stop executing a render loop function and remove it from the execution array
  34438. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34439. */
  34440. stopRenderLoop(renderFunction?: () => void): void;
  34441. /** @hidden */
  34442. _renderLoop(): void;
  34443. /**
  34444. * Gets the HTML canvas attached with the current webGL context
  34445. * @returns a HTML canvas
  34446. */
  34447. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34448. /**
  34449. * Gets host window
  34450. * @returns the host window object
  34451. */
  34452. getHostWindow(): Nullable<Window>;
  34453. /**
  34454. * Gets the current render width
  34455. * @param useScreen defines if screen size must be used (or the current render target if any)
  34456. * @returns a number defining the current render width
  34457. */
  34458. getRenderWidth(useScreen?: boolean): number;
  34459. /**
  34460. * Gets the current render height
  34461. * @param useScreen defines if screen size must be used (or the current render target if any)
  34462. * @returns a number defining the current render height
  34463. */
  34464. getRenderHeight(useScreen?: boolean): number;
  34465. /**
  34466. * Can be used to override the current requestAnimationFrame requester.
  34467. * @hidden
  34468. */
  34469. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34470. /**
  34471. * Register and execute a render loop. The engine can have more than one render function
  34472. * @param renderFunction defines the function to continuously execute
  34473. */
  34474. runRenderLoop(renderFunction: () => void): void;
  34475. /**
  34476. * Clear the current render buffer or the current render target (if any is set up)
  34477. * @param color defines the color to use
  34478. * @param backBuffer defines if the back buffer must be cleared
  34479. * @param depth defines if the depth buffer must be cleared
  34480. * @param stencil defines if the stencil buffer must be cleared
  34481. */
  34482. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34483. private _viewportCached;
  34484. /** @hidden */
  34485. _viewport(x: number, y: number, width: number, height: number): void;
  34486. /**
  34487. * Set the WebGL's viewport
  34488. * @param viewport defines the viewport element to be used
  34489. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34490. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34491. */
  34492. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34493. /**
  34494. * Begin a new frame
  34495. */
  34496. beginFrame(): void;
  34497. /**
  34498. * Enf the current frame
  34499. */
  34500. endFrame(): void;
  34501. /**
  34502. * Resize the view according to the canvas' size
  34503. */
  34504. resize(): void;
  34505. /**
  34506. * Force a specific size of the canvas
  34507. * @param width defines the new canvas' width
  34508. * @param height defines the new canvas' height
  34509. */
  34510. setSize(width: number, height: number): void;
  34511. /**
  34512. * Binds the frame buffer to the specified texture.
  34513. * @param texture The texture to render to or null for the default canvas
  34514. * @param faceIndex The face of the texture to render to in case of cube texture
  34515. * @param requiredWidth The width of the target to render to
  34516. * @param requiredHeight The height of the target to render to
  34517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34518. * @param lodLevel defines the lod level to bind to the frame buffer
  34519. * @param layer defines the 2d array index to bind to frame buffer to
  34520. */
  34521. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34522. /** @hidden */
  34523. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34524. /**
  34525. * Unbind the current render target texture from the webGL context
  34526. * @param texture defines the render target texture to unbind
  34527. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34528. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34529. */
  34530. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34531. /**
  34532. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34533. */
  34534. flushFramebuffer(): void;
  34535. /**
  34536. * Unbind the current render target and bind the default framebuffer
  34537. */
  34538. restoreDefaultFramebuffer(): void;
  34539. /** @hidden */
  34540. protected _resetVertexBufferBinding(): void;
  34541. /**
  34542. * Creates a vertex buffer
  34543. * @param data the data for the vertex buffer
  34544. * @returns the new WebGL static buffer
  34545. */
  34546. createVertexBuffer(data: DataArray): DataBuffer;
  34547. private _createVertexBuffer;
  34548. /**
  34549. * Creates a dynamic vertex buffer
  34550. * @param data the data for the dynamic vertex buffer
  34551. * @returns the new WebGL dynamic buffer
  34552. */
  34553. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34554. protected _resetIndexBufferBinding(): void;
  34555. /**
  34556. * Creates a new index buffer
  34557. * @param indices defines the content of the index buffer
  34558. * @param updatable defines if the index buffer must be updatable
  34559. * @returns a new webGL buffer
  34560. */
  34561. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34562. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34563. /**
  34564. * Bind a webGL buffer to the webGL context
  34565. * @param buffer defines the buffer to bind
  34566. */
  34567. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34568. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34569. private bindBuffer;
  34570. /**
  34571. * update the bound buffer with the given data
  34572. * @param data defines the data to update
  34573. */
  34574. updateArrayBuffer(data: Float32Array): void;
  34575. private _vertexAttribPointer;
  34576. /** @hidden */
  34577. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34578. private _bindVertexBuffersAttributes;
  34579. /**
  34580. * Records a vertex array object
  34581. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34582. * @param vertexBuffers defines the list of vertex buffers to store
  34583. * @param indexBuffer defines the index buffer to store
  34584. * @param effect defines the effect to store
  34585. * @returns the new vertex array object
  34586. */
  34587. recordVertexArrayObject(vertexBuffers: {
  34588. [key: string]: VertexBuffer;
  34589. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34590. /**
  34591. * Bind a specific vertex array object
  34592. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34593. * @param vertexArrayObject defines the vertex array object to bind
  34594. * @param indexBuffer defines the index buffer to bind
  34595. */
  34596. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34597. /**
  34598. * Bind webGl buffers directly to the webGL context
  34599. * @param vertexBuffer defines the vertex buffer to bind
  34600. * @param indexBuffer defines the index buffer to bind
  34601. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34602. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34603. * @param effect defines the effect associated with the vertex buffer
  34604. */
  34605. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34606. private _unbindVertexArrayObject;
  34607. /**
  34608. * Bind a list of vertex buffers to the webGL context
  34609. * @param vertexBuffers defines the list of vertex buffers to bind
  34610. * @param indexBuffer defines the index buffer to bind
  34611. * @param effect defines the effect associated with the vertex buffers
  34612. */
  34613. bindBuffers(vertexBuffers: {
  34614. [key: string]: Nullable<VertexBuffer>;
  34615. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34616. /**
  34617. * Unbind all instance attributes
  34618. */
  34619. unbindInstanceAttributes(): void;
  34620. /**
  34621. * Release and free the memory of a vertex array object
  34622. * @param vao defines the vertex array object to delete
  34623. */
  34624. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34625. /** @hidden */
  34626. _releaseBuffer(buffer: DataBuffer): boolean;
  34627. protected _deleteBuffer(buffer: DataBuffer): void;
  34628. /**
  34629. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34630. * @param instancesBuffer defines the webGL buffer to update and bind
  34631. * @param data defines the data to store in the buffer
  34632. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34633. */
  34634. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34635. /**
  34636. * Bind the content of a webGL buffer used with instantiation
  34637. * @param instancesBuffer defines the webGL buffer to bind
  34638. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34639. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34640. */
  34641. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34642. /**
  34643. * Disable the instance attribute corresponding to the name in parameter
  34644. * @param name defines the name of the attribute to disable
  34645. */
  34646. disableInstanceAttributeByName(name: string): void;
  34647. /**
  34648. * Disable the instance attribute corresponding to the location in parameter
  34649. * @param attributeLocation defines the attribute location of the attribute to disable
  34650. */
  34651. disableInstanceAttribute(attributeLocation: number): void;
  34652. /**
  34653. * Disable the attribute corresponding to the location in parameter
  34654. * @param attributeLocation defines the attribute location of the attribute to disable
  34655. */
  34656. disableAttributeByIndex(attributeLocation: number): void;
  34657. /**
  34658. * Send a draw order
  34659. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34660. * @param indexStart defines the starting index
  34661. * @param indexCount defines the number of index to draw
  34662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34663. */
  34664. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34665. /**
  34666. * Draw a list of points
  34667. * @param verticesStart defines the index of first vertex to draw
  34668. * @param verticesCount defines the count of vertices to draw
  34669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34670. */
  34671. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34672. /**
  34673. * Draw a list of unindexed primitives
  34674. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34675. * @param verticesStart defines the index of first vertex to draw
  34676. * @param verticesCount defines the count of vertices to draw
  34677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34678. */
  34679. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34680. /**
  34681. * Draw a list of indexed primitives
  34682. * @param fillMode defines the primitive to use
  34683. * @param indexStart defines the starting index
  34684. * @param indexCount defines the number of index to draw
  34685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34686. */
  34687. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34688. /**
  34689. * Draw a list of unindexed primitives
  34690. * @param fillMode defines the primitive to use
  34691. * @param verticesStart defines the index of first vertex to draw
  34692. * @param verticesCount defines the count of vertices to draw
  34693. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34694. */
  34695. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34696. private _drawMode;
  34697. /** @hidden */
  34698. protected _reportDrawCall(): void;
  34699. /** @hidden */
  34700. _releaseEffect(effect: Effect): void;
  34701. /** @hidden */
  34702. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34703. /**
  34704. * Create a new effect (used to store vertex/fragment shaders)
  34705. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34706. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34707. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34708. * @param samplers defines an array of string used to represent textures
  34709. * @param defines defines the string containing the defines to use to compile the shaders
  34710. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34711. * @param onCompiled defines a function to call when the effect creation is successful
  34712. * @param onError defines a function to call when the effect creation has failed
  34713. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34714. * @returns the new Effect
  34715. */
  34716. 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;
  34717. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34718. private _compileShader;
  34719. private _compileRawShader;
  34720. /** @hidden */
  34721. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34722. /**
  34723. * Directly creates a webGL program
  34724. * @param pipelineContext defines the pipeline context to attach to
  34725. * @param vertexCode defines the vertex shader code to use
  34726. * @param fragmentCode defines the fragment shader code to use
  34727. * @param context defines the webGL context to use (if not set, the current one will be used)
  34728. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34729. * @returns the new webGL program
  34730. */
  34731. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34732. /**
  34733. * Creates a webGL program
  34734. * @param pipelineContext defines the pipeline context to attach to
  34735. * @param vertexCode defines the vertex shader code to use
  34736. * @param fragmentCode defines the fragment shader code to use
  34737. * @param defines defines the string containing the defines to use to compile the shaders
  34738. * @param context defines the webGL context to use (if not set, the current one will be used)
  34739. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34740. * @returns the new webGL program
  34741. */
  34742. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34743. /**
  34744. * Creates a new pipeline context
  34745. * @returns the new pipeline
  34746. */
  34747. createPipelineContext(): IPipelineContext;
  34748. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34749. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34750. /** @hidden */
  34751. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34752. /** @hidden */
  34753. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34754. /** @hidden */
  34755. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34756. /**
  34757. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34758. * @param pipelineContext defines the pipeline context to use
  34759. * @param uniformsNames defines the list of uniform names
  34760. * @returns an array of webGL uniform locations
  34761. */
  34762. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34763. /**
  34764. * Gets the lsit of active attributes for a given webGL program
  34765. * @param pipelineContext defines the pipeline context to use
  34766. * @param attributesNames defines the list of attribute names to get
  34767. * @returns an array of indices indicating the offset of each attribute
  34768. */
  34769. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34770. /**
  34771. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34772. * @param effect defines the effect to activate
  34773. */
  34774. enableEffect(effect: Nullable<Effect>): void;
  34775. /**
  34776. * Set the value of an uniform to a number (int)
  34777. * @param uniform defines the webGL uniform location where to store the value
  34778. * @param value defines the int number to store
  34779. */
  34780. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34781. /**
  34782. * Set the value of an uniform to an array of int32
  34783. * @param uniform defines the webGL uniform location where to store the value
  34784. * @param array defines the array of int32 to store
  34785. */
  34786. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34787. /**
  34788. * Set the value of an uniform to an array of int32 (stored as vec2)
  34789. * @param uniform defines the webGL uniform location where to store the value
  34790. * @param array defines the array of int32 to store
  34791. */
  34792. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34793. /**
  34794. * Set the value of an uniform to an array of int32 (stored as vec3)
  34795. * @param uniform defines the webGL uniform location where to store the value
  34796. * @param array defines the array of int32 to store
  34797. */
  34798. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34799. /**
  34800. * Set the value of an uniform to an array of int32 (stored as vec4)
  34801. * @param uniform defines the webGL uniform location where to store the value
  34802. * @param array defines the array of int32 to store
  34803. */
  34804. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34805. /**
  34806. * Set the value of an uniform to an array of number
  34807. * @param uniform defines the webGL uniform location where to store the value
  34808. * @param array defines the array of number to store
  34809. */
  34810. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34811. /**
  34812. * Set the value of an uniform to an array of number (stored as vec2)
  34813. * @param uniform defines the webGL uniform location where to store the value
  34814. * @param array defines the array of number to store
  34815. */
  34816. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34817. /**
  34818. * Set the value of an uniform to an array of number (stored as vec3)
  34819. * @param uniform defines the webGL uniform location where to store the value
  34820. * @param array defines the array of number to store
  34821. */
  34822. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34823. /**
  34824. * Set the value of an uniform to an array of number (stored as vec4)
  34825. * @param uniform defines the webGL uniform location where to store the value
  34826. * @param array defines the array of number to store
  34827. */
  34828. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34829. /**
  34830. * Set the value of an uniform to an array of float32 (stored as matrices)
  34831. * @param uniform defines the webGL uniform location where to store the value
  34832. * @param matrices defines the array of float32 to store
  34833. */
  34834. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34835. /**
  34836. * Set the value of an uniform to a matrix (3x3)
  34837. * @param uniform defines the webGL uniform location where to store the value
  34838. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34839. */
  34840. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34841. /**
  34842. * Set the value of an uniform to a matrix (2x2)
  34843. * @param uniform defines the webGL uniform location where to store the value
  34844. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34845. */
  34846. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34847. /**
  34848. * Set the value of an uniform to a number (float)
  34849. * @param uniform defines the webGL uniform location where to store the value
  34850. * @param value defines the float number to store
  34851. */
  34852. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34853. /**
  34854. * Set the value of an uniform to a vec2
  34855. * @param uniform defines the webGL uniform location where to store the value
  34856. * @param x defines the 1st component of the value
  34857. * @param y defines the 2nd component of the value
  34858. */
  34859. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34860. /**
  34861. * Set the value of an uniform to a vec3
  34862. * @param uniform defines the webGL uniform location where to store the value
  34863. * @param x defines the 1st component of the value
  34864. * @param y defines the 2nd component of the value
  34865. * @param z defines the 3rd component of the value
  34866. */
  34867. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34868. /**
  34869. * Set the value of an uniform to a vec4
  34870. * @param uniform defines the webGL uniform location where to store the value
  34871. * @param x defines the 1st component of the value
  34872. * @param y defines the 2nd component of the value
  34873. * @param z defines the 3rd component of the value
  34874. * @param w defines the 4th component of the value
  34875. */
  34876. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34877. /**
  34878. * Apply all cached states (depth, culling, stencil and alpha)
  34879. */
  34880. applyStates(): void;
  34881. /**
  34882. * Enable or disable color writing
  34883. * @param enable defines the state to set
  34884. */
  34885. setColorWrite(enable: boolean): void;
  34886. /**
  34887. * Gets a boolean indicating if color writing is enabled
  34888. * @returns the current color writing state
  34889. */
  34890. getColorWrite(): boolean;
  34891. /**
  34892. * Gets the depth culling state manager
  34893. */
  34894. get depthCullingState(): DepthCullingState;
  34895. /**
  34896. * Gets the alpha state manager
  34897. */
  34898. get alphaState(): AlphaState;
  34899. /**
  34900. * Gets the stencil state manager
  34901. */
  34902. get stencilState(): StencilState;
  34903. /**
  34904. * Clears the list of texture accessible through engine.
  34905. * This can help preventing texture load conflict due to name collision.
  34906. */
  34907. clearInternalTexturesCache(): void;
  34908. /**
  34909. * Force the entire cache to be cleared
  34910. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34911. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34912. */
  34913. wipeCaches(bruteForce?: boolean): void;
  34914. /** @hidden */
  34915. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34916. min: number;
  34917. mag: number;
  34918. };
  34919. /** @hidden */
  34920. _createTexture(): WebGLTexture;
  34921. /**
  34922. * Usually called from Texture.ts.
  34923. * Passed information to create a WebGLTexture
  34924. * @param url defines a value which contains one of the following:
  34925. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34926. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34927. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34929. * @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)
  34930. * @param scene needed for loading to the correct scene
  34931. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34932. * @param onLoad optional callback to be called upon successful completion
  34933. * @param onError optional callback to be called upon failure
  34934. * @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
  34935. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34936. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34937. * @param forcedExtension defines the extension to use to pick the right loader
  34938. * @param mimeType defines an optional mime type
  34939. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34940. */
  34941. 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;
  34942. /**
  34943. * Loads an image as an HTMLImageElement.
  34944. * @param input url string, ArrayBuffer, or Blob to load
  34945. * @param onLoad callback called when the image successfully loads
  34946. * @param onError callback called when the image fails to load
  34947. * @param offlineProvider offline provider for caching
  34948. * @param mimeType optional mime type
  34949. * @returns the HTMLImageElement of the loaded image
  34950. * @hidden
  34951. */
  34952. 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>;
  34953. /**
  34954. * @hidden
  34955. */
  34956. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34957. private _unpackFlipYCached;
  34958. /**
  34959. * In case you are sharing the context with other applications, it might
  34960. * be interested to not cache the unpack flip y state to ensure a consistent
  34961. * value would be set.
  34962. */
  34963. enableUnpackFlipYCached: boolean;
  34964. /** @hidden */
  34965. _unpackFlipY(value: boolean): void;
  34966. /** @hidden */
  34967. _getUnpackAlignement(): number;
  34968. private _getTextureTarget;
  34969. /**
  34970. * Update the sampling mode of a given texture
  34971. * @param samplingMode defines the required sampling mode
  34972. * @param texture defines the texture to update
  34973. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34974. */
  34975. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34976. /**
  34977. * Update the sampling mode of a given texture
  34978. * @param texture defines the texture to update
  34979. * @param wrapU defines the texture wrap mode of the u coordinates
  34980. * @param wrapV defines the texture wrap mode of the v coordinates
  34981. * @param wrapR defines the texture wrap mode of the r coordinates
  34982. */
  34983. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34984. /** @hidden */
  34985. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34986. width: number;
  34987. height: number;
  34988. layers?: number;
  34989. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34990. /** @hidden */
  34991. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34992. /** @hidden */
  34993. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34994. /**
  34995. * Update a portion of an internal texture
  34996. * @param texture defines the texture to update
  34997. * @param imageData defines the data to store into the texture
  34998. * @param xOffset defines the x coordinates of the update rectangle
  34999. * @param yOffset defines the y coordinates of the update rectangle
  35000. * @param width defines the width of the update rectangle
  35001. * @param height defines the height of the update rectangle
  35002. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35003. * @param lod defines the lod level to update (0 by default)
  35004. */
  35005. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35006. /** @hidden */
  35007. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35008. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35009. private _prepareWebGLTexture;
  35010. /** @hidden */
  35011. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35012. private _getDepthStencilBuffer;
  35013. /** @hidden */
  35014. _releaseFramebufferObjects(texture: InternalTexture): void;
  35015. /** @hidden */
  35016. _releaseTexture(texture: InternalTexture): void;
  35017. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35018. protected _setProgram(program: WebGLProgram): void;
  35019. protected _boundUniforms: {
  35020. [key: number]: WebGLUniformLocation;
  35021. };
  35022. /**
  35023. * Binds an effect to the webGL context
  35024. * @param effect defines the effect to bind
  35025. */
  35026. bindSamplers(effect: Effect): void;
  35027. private _activateCurrentTexture;
  35028. /** @hidden */
  35029. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35030. /** @hidden */
  35031. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35032. /**
  35033. * Unbind all textures from the webGL context
  35034. */
  35035. unbindAllTextures(): void;
  35036. /**
  35037. * Sets a texture to the according uniform.
  35038. * @param channel The texture channel
  35039. * @param uniform The uniform to set
  35040. * @param texture The texture to apply
  35041. */
  35042. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35043. private _bindSamplerUniformToChannel;
  35044. private _getTextureWrapMode;
  35045. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35046. /**
  35047. * Sets an array of texture to the webGL context
  35048. * @param channel defines the channel where the texture array must be set
  35049. * @param uniform defines the associated uniform location
  35050. * @param textures defines the array of textures to bind
  35051. */
  35052. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35053. /** @hidden */
  35054. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35055. private _setTextureParameterFloat;
  35056. private _setTextureParameterInteger;
  35057. /**
  35058. * Unbind all vertex attributes from the webGL context
  35059. */
  35060. unbindAllAttributes(): void;
  35061. /**
  35062. * 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
  35063. */
  35064. releaseEffects(): void;
  35065. /**
  35066. * Dispose and release all associated resources
  35067. */
  35068. dispose(): void;
  35069. /**
  35070. * Attach a new callback raised when context lost event is fired
  35071. * @param callback defines the callback to call
  35072. */
  35073. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35074. /**
  35075. * Attach a new callback raised when context restored event is fired
  35076. * @param callback defines the callback to call
  35077. */
  35078. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35079. /**
  35080. * Get the current error code of the webGL context
  35081. * @returns the error code
  35082. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35083. */
  35084. getError(): number;
  35085. private _canRenderToFloatFramebuffer;
  35086. private _canRenderToHalfFloatFramebuffer;
  35087. private _canRenderToFramebuffer;
  35088. /** @hidden */
  35089. _getWebGLTextureType(type: number): number;
  35090. /** @hidden */
  35091. _getInternalFormat(format: number): number;
  35092. /** @hidden */
  35093. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35094. /** @hidden */
  35095. _getRGBAMultiSampleBufferFormat(type: number): number;
  35096. /** @hidden */
  35097. _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;
  35098. /**
  35099. * Loads a file from a url
  35100. * @param url url to load
  35101. * @param onSuccess callback called when the file successfully loads
  35102. * @param onProgress callback called while file is loading (if the server supports this mode)
  35103. * @param offlineProvider defines the offline provider for caching
  35104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35105. * @param onError callback called when the file fails to load
  35106. * @returns a file request object
  35107. * @hidden
  35108. */
  35109. 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;
  35110. /**
  35111. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35112. * @param x defines the x coordinate of the rectangle where pixels must be read
  35113. * @param y defines the y coordinate of the rectangle where pixels must be read
  35114. * @param width defines the width of the rectangle where pixels must be read
  35115. * @param height defines the height of the rectangle where pixels must be read
  35116. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35117. * @returns a Uint8Array containing RGBA colors
  35118. */
  35119. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35120. private static _isSupported;
  35121. /**
  35122. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35123. * @returns true if the engine can be created
  35124. * @ignorenaming
  35125. */
  35126. static isSupported(): boolean;
  35127. /**
  35128. * Find the next highest power of two.
  35129. * @param x Number to start search from.
  35130. * @return Next highest power of two.
  35131. */
  35132. static CeilingPOT(x: number): number;
  35133. /**
  35134. * Find the next lowest power of two.
  35135. * @param x Number to start search from.
  35136. * @return Next lowest power of two.
  35137. */
  35138. static FloorPOT(x: number): number;
  35139. /**
  35140. * Find the nearest power of two.
  35141. * @param x Number to start search from.
  35142. * @return Next nearest power of two.
  35143. */
  35144. static NearestPOT(x: number): number;
  35145. /**
  35146. * Get the closest exponent of two
  35147. * @param value defines the value to approximate
  35148. * @param max defines the maximum value to return
  35149. * @param mode defines how to define the closest value
  35150. * @returns closest exponent of two of the given value
  35151. */
  35152. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35153. /**
  35154. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35155. * @param func - the function to be called
  35156. * @param requester - the object that will request the next frame. Falls back to window.
  35157. * @returns frame number
  35158. */
  35159. static QueueNewFrame(func: () => void, requester?: any): number;
  35160. /**
  35161. * Gets host document
  35162. * @returns the host document object
  35163. */
  35164. getHostDocument(): Nullable<Document>;
  35165. }
  35166. }
  35167. declare module BABYLON {
  35168. /**
  35169. * Class representing spherical harmonics coefficients to the 3rd degree
  35170. */
  35171. export class SphericalHarmonics {
  35172. /**
  35173. * Defines whether or not the harmonics have been prescaled for rendering.
  35174. */
  35175. preScaled: boolean;
  35176. /**
  35177. * The l0,0 coefficients of the spherical harmonics
  35178. */
  35179. l00: Vector3;
  35180. /**
  35181. * The l1,-1 coefficients of the spherical harmonics
  35182. */
  35183. l1_1: Vector3;
  35184. /**
  35185. * The l1,0 coefficients of the spherical harmonics
  35186. */
  35187. l10: Vector3;
  35188. /**
  35189. * The l1,1 coefficients of the spherical harmonics
  35190. */
  35191. l11: Vector3;
  35192. /**
  35193. * The l2,-2 coefficients of the spherical harmonics
  35194. */
  35195. l2_2: Vector3;
  35196. /**
  35197. * The l2,-1 coefficients of the spherical harmonics
  35198. */
  35199. l2_1: Vector3;
  35200. /**
  35201. * The l2,0 coefficients of the spherical harmonics
  35202. */
  35203. l20: Vector3;
  35204. /**
  35205. * The l2,1 coefficients of the spherical harmonics
  35206. */
  35207. l21: Vector3;
  35208. /**
  35209. * The l2,2 coefficients of the spherical harmonics
  35210. */
  35211. l22: Vector3;
  35212. /**
  35213. * Adds a light to the spherical harmonics
  35214. * @param direction the direction of the light
  35215. * @param color the color of the light
  35216. * @param deltaSolidAngle the delta solid angle of the light
  35217. */
  35218. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35219. /**
  35220. * Scales the spherical harmonics by the given amount
  35221. * @param scale the amount to scale
  35222. */
  35223. scaleInPlace(scale: number): void;
  35224. /**
  35225. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35226. *
  35227. * ```
  35228. * E_lm = A_l * L_lm
  35229. * ```
  35230. *
  35231. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35232. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35233. * the scaling factors are given in equation 9.
  35234. */
  35235. convertIncidentRadianceToIrradiance(): void;
  35236. /**
  35237. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35238. *
  35239. * ```
  35240. * L = (1/pi) * E * rho
  35241. * ```
  35242. *
  35243. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35244. */
  35245. convertIrradianceToLambertianRadiance(): void;
  35246. /**
  35247. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35248. * required operations at run time.
  35249. *
  35250. * This is simply done by scaling back the SH with Ylm constants parameter.
  35251. * The trigonometric part being applied by the shader at run time.
  35252. */
  35253. preScaleForRendering(): void;
  35254. /**
  35255. * Constructs a spherical harmonics from an array.
  35256. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35257. * @returns the spherical harmonics
  35258. */
  35259. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35260. /**
  35261. * Gets the spherical harmonics from polynomial
  35262. * @param polynomial the spherical polynomial
  35263. * @returns the spherical harmonics
  35264. */
  35265. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35266. }
  35267. /**
  35268. * Class representing spherical polynomial coefficients to the 3rd degree
  35269. */
  35270. export class SphericalPolynomial {
  35271. private _harmonics;
  35272. /**
  35273. * The spherical harmonics used to create the polynomials.
  35274. */
  35275. get preScaledHarmonics(): SphericalHarmonics;
  35276. /**
  35277. * The x coefficients of the spherical polynomial
  35278. */
  35279. x: Vector3;
  35280. /**
  35281. * The y coefficients of the spherical polynomial
  35282. */
  35283. y: Vector3;
  35284. /**
  35285. * The z coefficients of the spherical polynomial
  35286. */
  35287. z: Vector3;
  35288. /**
  35289. * The xx coefficients of the spherical polynomial
  35290. */
  35291. xx: Vector3;
  35292. /**
  35293. * The yy coefficients of the spherical polynomial
  35294. */
  35295. yy: Vector3;
  35296. /**
  35297. * The zz coefficients of the spherical polynomial
  35298. */
  35299. zz: Vector3;
  35300. /**
  35301. * The xy coefficients of the spherical polynomial
  35302. */
  35303. xy: Vector3;
  35304. /**
  35305. * The yz coefficients of the spherical polynomial
  35306. */
  35307. yz: Vector3;
  35308. /**
  35309. * The zx coefficients of the spherical polynomial
  35310. */
  35311. zx: Vector3;
  35312. /**
  35313. * Adds an ambient color to the spherical polynomial
  35314. * @param color the color to add
  35315. */
  35316. addAmbient(color: Color3): void;
  35317. /**
  35318. * Scales the spherical polynomial by the given amount
  35319. * @param scale the amount to scale
  35320. */
  35321. scaleInPlace(scale: number): void;
  35322. /**
  35323. * Gets the spherical polynomial from harmonics
  35324. * @param harmonics the spherical harmonics
  35325. * @returns the spherical polynomial
  35326. */
  35327. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35328. /**
  35329. * Constructs a spherical polynomial from an array.
  35330. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35331. * @returns the spherical polynomial
  35332. */
  35333. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35334. }
  35335. }
  35336. declare module BABYLON {
  35337. /**
  35338. * Defines the source of the internal texture
  35339. */
  35340. export enum InternalTextureSource {
  35341. /**
  35342. * The source of the texture data is unknown
  35343. */
  35344. Unknown = 0,
  35345. /**
  35346. * Texture data comes from an URL
  35347. */
  35348. Url = 1,
  35349. /**
  35350. * Texture data is only used for temporary storage
  35351. */
  35352. Temp = 2,
  35353. /**
  35354. * Texture data comes from raw data (ArrayBuffer)
  35355. */
  35356. Raw = 3,
  35357. /**
  35358. * Texture content is dynamic (video or dynamic texture)
  35359. */
  35360. Dynamic = 4,
  35361. /**
  35362. * Texture content is generated by rendering to it
  35363. */
  35364. RenderTarget = 5,
  35365. /**
  35366. * Texture content is part of a multi render target process
  35367. */
  35368. MultiRenderTarget = 6,
  35369. /**
  35370. * Texture data comes from a cube data file
  35371. */
  35372. Cube = 7,
  35373. /**
  35374. * Texture data comes from a raw cube data
  35375. */
  35376. CubeRaw = 8,
  35377. /**
  35378. * Texture data come from a prefiltered cube data file
  35379. */
  35380. CubePrefiltered = 9,
  35381. /**
  35382. * Texture content is raw 3D data
  35383. */
  35384. Raw3D = 10,
  35385. /**
  35386. * Texture content is raw 2D array data
  35387. */
  35388. Raw2DArray = 11,
  35389. /**
  35390. * Texture content is a depth texture
  35391. */
  35392. Depth = 12,
  35393. /**
  35394. * Texture data comes from a raw cube data encoded with RGBD
  35395. */
  35396. CubeRawRGBD = 13
  35397. }
  35398. /**
  35399. * Class used to store data associated with WebGL texture data for the engine
  35400. * This class should not be used directly
  35401. */
  35402. export class InternalTexture {
  35403. /** @hidden */
  35404. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35405. /**
  35406. * Defines if the texture is ready
  35407. */
  35408. isReady: boolean;
  35409. /**
  35410. * Defines if the texture is a cube texture
  35411. */
  35412. isCube: boolean;
  35413. /**
  35414. * Defines if the texture contains 3D data
  35415. */
  35416. is3D: boolean;
  35417. /**
  35418. * Defines if the texture contains 2D array data
  35419. */
  35420. is2DArray: boolean;
  35421. /**
  35422. * Defines if the texture contains multiview data
  35423. */
  35424. isMultiview: boolean;
  35425. /**
  35426. * Gets the URL used to load this texture
  35427. */
  35428. url: string;
  35429. /**
  35430. * Gets the sampling mode of the texture
  35431. */
  35432. samplingMode: number;
  35433. /**
  35434. * Gets a boolean indicating if the texture needs mipmaps generation
  35435. */
  35436. generateMipMaps: boolean;
  35437. /**
  35438. * Gets the number of samples used by the texture (WebGL2+ only)
  35439. */
  35440. samples: number;
  35441. /**
  35442. * Gets the type of the texture (int, float...)
  35443. */
  35444. type: number;
  35445. /**
  35446. * Gets the format of the texture (RGB, RGBA...)
  35447. */
  35448. format: number;
  35449. /**
  35450. * Observable called when the texture is loaded
  35451. */
  35452. onLoadedObservable: Observable<InternalTexture>;
  35453. /**
  35454. * Gets the width of the texture
  35455. */
  35456. width: number;
  35457. /**
  35458. * Gets the height of the texture
  35459. */
  35460. height: number;
  35461. /**
  35462. * Gets the depth of the texture
  35463. */
  35464. depth: number;
  35465. /**
  35466. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35467. */
  35468. baseWidth: number;
  35469. /**
  35470. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35471. */
  35472. baseHeight: number;
  35473. /**
  35474. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35475. */
  35476. baseDepth: number;
  35477. /**
  35478. * Gets a boolean indicating if the texture is inverted on Y axis
  35479. */
  35480. invertY: boolean;
  35481. /** @hidden */
  35482. _invertVScale: boolean;
  35483. /** @hidden */
  35484. _associatedChannel: number;
  35485. /** @hidden */
  35486. _source: InternalTextureSource;
  35487. /** @hidden */
  35488. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35489. /** @hidden */
  35490. _bufferView: Nullable<ArrayBufferView>;
  35491. /** @hidden */
  35492. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35493. /** @hidden */
  35494. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35495. /** @hidden */
  35496. _size: number;
  35497. /** @hidden */
  35498. _extension: string;
  35499. /** @hidden */
  35500. _files: Nullable<string[]>;
  35501. /** @hidden */
  35502. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35503. /** @hidden */
  35504. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35505. /** @hidden */
  35506. _framebuffer: Nullable<WebGLFramebuffer>;
  35507. /** @hidden */
  35508. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35509. /** @hidden */
  35510. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35511. /** @hidden */
  35512. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35513. /** @hidden */
  35514. _attachments: Nullable<number[]>;
  35515. /** @hidden */
  35516. _cachedCoordinatesMode: Nullable<number>;
  35517. /** @hidden */
  35518. _cachedWrapU: Nullable<number>;
  35519. /** @hidden */
  35520. _cachedWrapV: Nullable<number>;
  35521. /** @hidden */
  35522. _cachedWrapR: Nullable<number>;
  35523. /** @hidden */
  35524. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35525. /** @hidden */
  35526. _isDisabled: boolean;
  35527. /** @hidden */
  35528. _compression: Nullable<string>;
  35529. /** @hidden */
  35530. _generateStencilBuffer: boolean;
  35531. /** @hidden */
  35532. _generateDepthBuffer: boolean;
  35533. /** @hidden */
  35534. _comparisonFunction: number;
  35535. /** @hidden */
  35536. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35537. /** @hidden */
  35538. _lodGenerationScale: number;
  35539. /** @hidden */
  35540. _lodGenerationOffset: number;
  35541. /** @hidden */
  35542. _depthStencilTexture: Nullable<InternalTexture>;
  35543. /** @hidden */
  35544. _colorTextureArray: Nullable<WebGLTexture>;
  35545. /** @hidden */
  35546. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35547. /** @hidden */
  35548. _lodTextureHigh: Nullable<BaseTexture>;
  35549. /** @hidden */
  35550. _lodTextureMid: Nullable<BaseTexture>;
  35551. /** @hidden */
  35552. _lodTextureLow: Nullable<BaseTexture>;
  35553. /** @hidden */
  35554. _isRGBD: boolean;
  35555. /** @hidden */
  35556. _linearSpecularLOD: boolean;
  35557. /** @hidden */
  35558. _irradianceTexture: Nullable<BaseTexture>;
  35559. /** @hidden */
  35560. _webGLTexture: Nullable<WebGLTexture>;
  35561. /** @hidden */
  35562. _references: number;
  35563. private _engine;
  35564. /**
  35565. * Gets the Engine the texture belongs to.
  35566. * @returns The babylon engine
  35567. */
  35568. getEngine(): ThinEngine;
  35569. /**
  35570. * Gets the data source type of the texture
  35571. */
  35572. get source(): InternalTextureSource;
  35573. /**
  35574. * Creates a new InternalTexture
  35575. * @param engine defines the engine to use
  35576. * @param source defines the type of data that will be used
  35577. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35578. */
  35579. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35580. /**
  35581. * Increments the number of references (ie. the number of Texture that point to it)
  35582. */
  35583. incrementReferences(): void;
  35584. /**
  35585. * Change the size of the texture (not the size of the content)
  35586. * @param width defines the new width
  35587. * @param height defines the new height
  35588. * @param depth defines the new depth (1 by default)
  35589. */
  35590. updateSize(width: int, height: int, depth?: int): void;
  35591. /** @hidden */
  35592. _rebuild(): void;
  35593. /** @hidden */
  35594. _swapAndDie(target: InternalTexture): void;
  35595. /**
  35596. * Dispose the current allocated resources
  35597. */
  35598. dispose(): void;
  35599. }
  35600. }
  35601. declare module BABYLON {
  35602. /**
  35603. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35605. */
  35606. export class Analyser {
  35607. /**
  35608. * Gets or sets the smoothing
  35609. * @ignorenaming
  35610. */
  35611. SMOOTHING: number;
  35612. /**
  35613. * Gets or sets the FFT table size
  35614. * @ignorenaming
  35615. */
  35616. FFT_SIZE: number;
  35617. /**
  35618. * Gets or sets the bar graph amplitude
  35619. * @ignorenaming
  35620. */
  35621. BARGRAPHAMPLITUDE: number;
  35622. /**
  35623. * Gets or sets the position of the debug canvas
  35624. * @ignorenaming
  35625. */
  35626. DEBUGCANVASPOS: {
  35627. x: number;
  35628. y: number;
  35629. };
  35630. /**
  35631. * Gets or sets the debug canvas size
  35632. * @ignorenaming
  35633. */
  35634. DEBUGCANVASSIZE: {
  35635. width: number;
  35636. height: number;
  35637. };
  35638. private _byteFreqs;
  35639. private _byteTime;
  35640. private _floatFreqs;
  35641. private _webAudioAnalyser;
  35642. private _debugCanvas;
  35643. private _debugCanvasContext;
  35644. private _scene;
  35645. private _registerFunc;
  35646. private _audioEngine;
  35647. /**
  35648. * Creates a new analyser
  35649. * @param scene defines hosting scene
  35650. */
  35651. constructor(scene: Scene);
  35652. /**
  35653. * Get the number of data values you will have to play with for the visualization
  35654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35655. * @returns a number
  35656. */
  35657. getFrequencyBinCount(): number;
  35658. /**
  35659. * Gets the current frequency data as a byte array
  35660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35661. * @returns a Uint8Array
  35662. */
  35663. getByteFrequencyData(): Uint8Array;
  35664. /**
  35665. * Gets the current waveform as a byte array
  35666. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35667. * @returns a Uint8Array
  35668. */
  35669. getByteTimeDomainData(): Uint8Array;
  35670. /**
  35671. * Gets the current frequency data as a float array
  35672. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35673. * @returns a Float32Array
  35674. */
  35675. getFloatFrequencyData(): Float32Array;
  35676. /**
  35677. * Renders the debug canvas
  35678. */
  35679. drawDebugCanvas(): void;
  35680. /**
  35681. * Stops rendering the debug canvas and removes it
  35682. */
  35683. stopDebugCanvas(): void;
  35684. /**
  35685. * Connects two audio nodes
  35686. * @param inputAudioNode defines first node to connect
  35687. * @param outputAudioNode defines second node to connect
  35688. */
  35689. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35690. /**
  35691. * Releases all associated resources
  35692. */
  35693. dispose(): void;
  35694. }
  35695. }
  35696. declare module BABYLON {
  35697. /**
  35698. * This represents an audio engine and it is responsible
  35699. * to play, synchronize and analyse sounds throughout the application.
  35700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35701. */
  35702. export interface IAudioEngine extends IDisposable {
  35703. /**
  35704. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35705. */
  35706. readonly canUseWebAudio: boolean;
  35707. /**
  35708. * Gets the current AudioContext if available.
  35709. */
  35710. readonly audioContext: Nullable<AudioContext>;
  35711. /**
  35712. * The master gain node defines the global audio volume of your audio engine.
  35713. */
  35714. readonly masterGain: GainNode;
  35715. /**
  35716. * Gets whether or not mp3 are supported by your browser.
  35717. */
  35718. readonly isMP3supported: boolean;
  35719. /**
  35720. * Gets whether or not ogg are supported by your browser.
  35721. */
  35722. readonly isOGGsupported: boolean;
  35723. /**
  35724. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35725. * @ignoreNaming
  35726. */
  35727. WarnedWebAudioUnsupported: boolean;
  35728. /**
  35729. * Defines if the audio engine relies on a custom unlocked button.
  35730. * In this case, the embedded button will not be displayed.
  35731. */
  35732. useCustomUnlockedButton: boolean;
  35733. /**
  35734. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35735. */
  35736. readonly unlocked: boolean;
  35737. /**
  35738. * Event raised when audio has been unlocked on the browser.
  35739. */
  35740. onAudioUnlockedObservable: Observable<AudioEngine>;
  35741. /**
  35742. * Event raised when audio has been locked on the browser.
  35743. */
  35744. onAudioLockedObservable: Observable<AudioEngine>;
  35745. /**
  35746. * Flags the audio engine in Locked state.
  35747. * This happens due to new browser policies preventing audio to autoplay.
  35748. */
  35749. lock(): void;
  35750. /**
  35751. * Unlocks the audio engine once a user action has been done on the dom.
  35752. * This is helpful to resume play once browser policies have been satisfied.
  35753. */
  35754. unlock(): void;
  35755. /**
  35756. * Gets the global volume sets on the master gain.
  35757. * @returns the global volume if set or -1 otherwise
  35758. */
  35759. getGlobalVolume(): number;
  35760. /**
  35761. * Sets the global volume of your experience (sets on the master gain).
  35762. * @param newVolume Defines the new global volume of the application
  35763. */
  35764. setGlobalVolume(newVolume: number): void;
  35765. /**
  35766. * Connect the audio engine to an audio analyser allowing some amazing
  35767. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35769. * @param analyser The analyser to connect to the engine
  35770. */
  35771. connectToAnalyser(analyser: Analyser): void;
  35772. }
  35773. /**
  35774. * This represents the default audio engine used in babylon.
  35775. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35777. */
  35778. export class AudioEngine implements IAudioEngine {
  35779. private _audioContext;
  35780. private _audioContextInitialized;
  35781. private _muteButton;
  35782. private _hostElement;
  35783. /**
  35784. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35785. */
  35786. canUseWebAudio: boolean;
  35787. /**
  35788. * The master gain node defines the global audio volume of your audio engine.
  35789. */
  35790. masterGain: GainNode;
  35791. /**
  35792. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35793. * @ignoreNaming
  35794. */
  35795. WarnedWebAudioUnsupported: boolean;
  35796. /**
  35797. * Gets whether or not mp3 are supported by your browser.
  35798. */
  35799. isMP3supported: boolean;
  35800. /**
  35801. * Gets whether or not ogg are supported by your browser.
  35802. */
  35803. isOGGsupported: boolean;
  35804. /**
  35805. * Gets whether audio has been unlocked on the device.
  35806. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35807. * a user interaction has happened.
  35808. */
  35809. unlocked: boolean;
  35810. /**
  35811. * Defines if the audio engine relies on a custom unlocked button.
  35812. * In this case, the embedded button will not be displayed.
  35813. */
  35814. useCustomUnlockedButton: boolean;
  35815. /**
  35816. * Event raised when audio has been unlocked on the browser.
  35817. */
  35818. onAudioUnlockedObservable: Observable<AudioEngine>;
  35819. /**
  35820. * Event raised when audio has been locked on the browser.
  35821. */
  35822. onAudioLockedObservable: Observable<AudioEngine>;
  35823. /**
  35824. * Gets the current AudioContext if available.
  35825. */
  35826. get audioContext(): Nullable<AudioContext>;
  35827. private _connectedAnalyser;
  35828. /**
  35829. * Instantiates a new audio engine.
  35830. *
  35831. * There should be only one per page as some browsers restrict the number
  35832. * of audio contexts you can create.
  35833. * @param hostElement defines the host element where to display the mute icon if necessary
  35834. */
  35835. constructor(hostElement?: Nullable<HTMLElement>);
  35836. /**
  35837. * Flags the audio engine in Locked state.
  35838. * This happens due to new browser policies preventing audio to autoplay.
  35839. */
  35840. lock(): void;
  35841. /**
  35842. * Unlocks the audio engine once a user action has been done on the dom.
  35843. * This is helpful to resume play once browser policies have been satisfied.
  35844. */
  35845. unlock(): void;
  35846. private _resumeAudioContext;
  35847. private _initializeAudioContext;
  35848. private _tryToRun;
  35849. private _triggerRunningState;
  35850. private _triggerSuspendedState;
  35851. private _displayMuteButton;
  35852. private _moveButtonToTopLeft;
  35853. private _onResize;
  35854. private _hideMuteButton;
  35855. /**
  35856. * Destroy and release the resources associated with the audio ccontext.
  35857. */
  35858. dispose(): void;
  35859. /**
  35860. * Gets the global volume sets on the master gain.
  35861. * @returns the global volume if set or -1 otherwise
  35862. */
  35863. getGlobalVolume(): number;
  35864. /**
  35865. * Sets the global volume of your experience (sets on the master gain).
  35866. * @param newVolume Defines the new global volume of the application
  35867. */
  35868. setGlobalVolume(newVolume: number): void;
  35869. /**
  35870. * Connect the audio engine to an audio analyser allowing some amazing
  35871. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35873. * @param analyser The analyser to connect to the engine
  35874. */
  35875. connectToAnalyser(analyser: Analyser): void;
  35876. }
  35877. }
  35878. declare module BABYLON {
  35879. /**
  35880. * Interface used to present a loading screen while loading a scene
  35881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35882. */
  35883. export interface ILoadingScreen {
  35884. /**
  35885. * Function called to display the loading screen
  35886. */
  35887. displayLoadingUI: () => void;
  35888. /**
  35889. * Function called to hide the loading screen
  35890. */
  35891. hideLoadingUI: () => void;
  35892. /**
  35893. * Gets or sets the color to use for the background
  35894. */
  35895. loadingUIBackgroundColor: string;
  35896. /**
  35897. * Gets or sets the text to display while loading
  35898. */
  35899. loadingUIText: string;
  35900. }
  35901. /**
  35902. * Class used for the default loading screen
  35903. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35904. */
  35905. export class DefaultLoadingScreen implements ILoadingScreen {
  35906. private _renderingCanvas;
  35907. private _loadingText;
  35908. private _loadingDivBackgroundColor;
  35909. private _loadingDiv;
  35910. private _loadingTextDiv;
  35911. /** Gets or sets the logo url to use for the default loading screen */
  35912. static DefaultLogoUrl: string;
  35913. /** Gets or sets the spinner url to use for the default loading screen */
  35914. static DefaultSpinnerUrl: string;
  35915. /**
  35916. * Creates a new default loading screen
  35917. * @param _renderingCanvas defines the canvas used to render the scene
  35918. * @param _loadingText defines the default text to display
  35919. * @param _loadingDivBackgroundColor defines the default background color
  35920. */
  35921. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35922. /**
  35923. * Function called to display the loading screen
  35924. */
  35925. displayLoadingUI(): void;
  35926. /**
  35927. * Function called to hide the loading screen
  35928. */
  35929. hideLoadingUI(): void;
  35930. /**
  35931. * Gets or sets the text to display while loading
  35932. */
  35933. set loadingUIText(text: string);
  35934. get loadingUIText(): string;
  35935. /**
  35936. * Gets or sets the color to use for the background
  35937. */
  35938. get loadingUIBackgroundColor(): string;
  35939. set loadingUIBackgroundColor(color: string);
  35940. private _resizeLoadingUI;
  35941. }
  35942. }
  35943. declare module BABYLON {
  35944. /**
  35945. * Interface for any object that can request an animation frame
  35946. */
  35947. export interface ICustomAnimationFrameRequester {
  35948. /**
  35949. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35950. */
  35951. renderFunction?: Function;
  35952. /**
  35953. * Called to request the next frame to render to
  35954. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35955. */
  35956. requestAnimationFrame: Function;
  35957. /**
  35958. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35959. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35960. */
  35961. requestID?: number;
  35962. }
  35963. }
  35964. declare module BABYLON {
  35965. /**
  35966. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35967. */
  35968. export class PerformanceMonitor {
  35969. private _enabled;
  35970. private _rollingFrameTime;
  35971. private _lastFrameTimeMs;
  35972. /**
  35973. * constructor
  35974. * @param frameSampleSize The number of samples required to saturate the sliding window
  35975. */
  35976. constructor(frameSampleSize?: number);
  35977. /**
  35978. * Samples current frame
  35979. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35980. */
  35981. sampleFrame(timeMs?: number): void;
  35982. /**
  35983. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35984. */
  35985. get averageFrameTime(): number;
  35986. /**
  35987. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35988. */
  35989. get averageFrameTimeVariance(): number;
  35990. /**
  35991. * Returns the frame time of the most recent frame
  35992. */
  35993. get instantaneousFrameTime(): number;
  35994. /**
  35995. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35996. */
  35997. get averageFPS(): number;
  35998. /**
  35999. * Returns the average framerate in frames per second using the most recent frame time
  36000. */
  36001. get instantaneousFPS(): number;
  36002. /**
  36003. * Returns true if enough samples have been taken to completely fill the sliding window
  36004. */
  36005. get isSaturated(): boolean;
  36006. /**
  36007. * Enables contributions to the sliding window sample set
  36008. */
  36009. enable(): void;
  36010. /**
  36011. * Disables contributions to the sliding window sample set
  36012. * Samples will not be interpolated over the disabled period
  36013. */
  36014. disable(): void;
  36015. /**
  36016. * Returns true if sampling is enabled
  36017. */
  36018. get isEnabled(): boolean;
  36019. /**
  36020. * Resets performance monitor
  36021. */
  36022. reset(): void;
  36023. }
  36024. /**
  36025. * RollingAverage
  36026. *
  36027. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36028. */
  36029. export class RollingAverage {
  36030. /**
  36031. * Current average
  36032. */
  36033. average: number;
  36034. /**
  36035. * Current variance
  36036. */
  36037. variance: number;
  36038. protected _samples: Array<number>;
  36039. protected _sampleCount: number;
  36040. protected _pos: number;
  36041. protected _m2: number;
  36042. /**
  36043. * constructor
  36044. * @param length The number of samples required to saturate the sliding window
  36045. */
  36046. constructor(length: number);
  36047. /**
  36048. * Adds a sample to the sample set
  36049. * @param v The sample value
  36050. */
  36051. add(v: number): void;
  36052. /**
  36053. * Returns previously added values or null if outside of history or outside the sliding window domain
  36054. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36055. * @return Value previously recorded with add() or null if outside of range
  36056. */
  36057. history(i: number): number;
  36058. /**
  36059. * Returns true if enough samples have been taken to completely fill the sliding window
  36060. * @return true if sample-set saturated
  36061. */
  36062. isSaturated(): boolean;
  36063. /**
  36064. * Resets the rolling average (equivalent to 0 samples taken so far)
  36065. */
  36066. reset(): void;
  36067. /**
  36068. * Wraps a value around the sample range boundaries
  36069. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36070. * @return Wrapped position in sample range
  36071. */
  36072. protected _wrapPosition(i: number): number;
  36073. }
  36074. }
  36075. declare module BABYLON {
  36076. /**
  36077. * This class is used to track a performance counter which is number based.
  36078. * The user has access to many properties which give statistics of different nature.
  36079. *
  36080. * The implementer can track two kinds of Performance Counter: time and count.
  36081. * 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.
  36082. * 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.
  36083. */
  36084. export class PerfCounter {
  36085. /**
  36086. * Gets or sets a global boolean to turn on and off all the counters
  36087. */
  36088. static Enabled: boolean;
  36089. /**
  36090. * Returns the smallest value ever
  36091. */
  36092. get min(): number;
  36093. /**
  36094. * Returns the biggest value ever
  36095. */
  36096. get max(): number;
  36097. /**
  36098. * Returns the average value since the performance counter is running
  36099. */
  36100. get average(): number;
  36101. /**
  36102. * Returns the average value of the last second the counter was monitored
  36103. */
  36104. get lastSecAverage(): number;
  36105. /**
  36106. * Returns the current value
  36107. */
  36108. get current(): number;
  36109. /**
  36110. * Gets the accumulated total
  36111. */
  36112. get total(): number;
  36113. /**
  36114. * Gets the total value count
  36115. */
  36116. get count(): number;
  36117. /**
  36118. * Creates a new counter
  36119. */
  36120. constructor();
  36121. /**
  36122. * Call this method to start monitoring a new frame.
  36123. * 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.
  36124. */
  36125. fetchNewFrame(): void;
  36126. /**
  36127. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36128. * @param newCount the count value to add to the monitored count
  36129. * @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.
  36130. */
  36131. addCount(newCount: number, fetchResult: boolean): void;
  36132. /**
  36133. * Start monitoring this performance counter
  36134. */
  36135. beginMonitoring(): void;
  36136. /**
  36137. * Compute the time lapsed since the previous beginMonitoring() call.
  36138. * @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
  36139. */
  36140. endMonitoring(newFrame?: boolean): void;
  36141. private _fetchResult;
  36142. private _startMonitoringTime;
  36143. private _min;
  36144. private _max;
  36145. private _average;
  36146. private _current;
  36147. private _totalValueCount;
  36148. private _totalAccumulated;
  36149. private _lastSecAverage;
  36150. private _lastSecAccumulated;
  36151. private _lastSecTime;
  36152. private _lastSecValueCount;
  36153. }
  36154. }
  36155. declare module BABYLON {
  36156. interface ThinEngine {
  36157. /**
  36158. * Sets alpha constants used by some alpha blending modes
  36159. * @param r defines the red component
  36160. * @param g defines the green component
  36161. * @param b defines the blue component
  36162. * @param a defines the alpha component
  36163. */
  36164. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36165. /**
  36166. * Sets the current alpha mode
  36167. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36168. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36170. */
  36171. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36172. /**
  36173. * Gets the current alpha mode
  36174. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36175. * @returns the current alpha mode
  36176. */
  36177. getAlphaMode(): number;
  36178. /**
  36179. * Sets the current alpha equation
  36180. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36181. */
  36182. setAlphaEquation(equation: number): void;
  36183. /**
  36184. * Gets the current alpha equation.
  36185. * @returns the current alpha equation
  36186. */
  36187. getAlphaEquation(): number;
  36188. }
  36189. }
  36190. declare module BABYLON {
  36191. interface ThinEngine {
  36192. /** @hidden */
  36193. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36194. }
  36195. }
  36196. declare module BABYLON {
  36197. /**
  36198. * Defines the interface used by display changed events
  36199. */
  36200. export interface IDisplayChangedEventArgs {
  36201. /** Gets the vrDisplay object (if any) */
  36202. vrDisplay: Nullable<any>;
  36203. /** Gets a boolean indicating if webVR is supported */
  36204. vrSupported: boolean;
  36205. }
  36206. /**
  36207. * Defines the interface used by objects containing a viewport (like a camera)
  36208. */
  36209. interface IViewportOwnerLike {
  36210. /**
  36211. * Gets or sets the viewport
  36212. */
  36213. viewport: IViewportLike;
  36214. }
  36215. /**
  36216. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36217. */
  36218. export class Engine extends ThinEngine {
  36219. /** Defines that alpha blending is disabled */
  36220. static readonly ALPHA_DISABLE: number;
  36221. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36222. static readonly ALPHA_ADD: number;
  36223. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36224. static readonly ALPHA_COMBINE: number;
  36225. /** Defines that alpha blending to DEST - SRC * DEST */
  36226. static readonly ALPHA_SUBTRACT: number;
  36227. /** Defines that alpha blending to SRC * DEST */
  36228. static readonly ALPHA_MULTIPLY: number;
  36229. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36230. static readonly ALPHA_MAXIMIZED: number;
  36231. /** Defines that alpha blending to SRC + DEST */
  36232. static readonly ALPHA_ONEONE: number;
  36233. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36234. static readonly ALPHA_PREMULTIPLIED: number;
  36235. /**
  36236. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36237. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36238. */
  36239. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36240. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36241. static readonly ALPHA_INTERPOLATE: number;
  36242. /**
  36243. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36244. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36245. */
  36246. static readonly ALPHA_SCREENMODE: number;
  36247. /** Defines that the ressource is not delayed*/
  36248. static readonly DELAYLOADSTATE_NONE: number;
  36249. /** Defines that the ressource was successfully delay loaded */
  36250. static readonly DELAYLOADSTATE_LOADED: number;
  36251. /** Defines that the ressource is currently delay loading */
  36252. static readonly DELAYLOADSTATE_LOADING: number;
  36253. /** Defines that the ressource is delayed and has not started loading */
  36254. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36255. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36256. static readonly NEVER: number;
  36257. /** 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 */
  36258. static readonly ALWAYS: number;
  36259. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36260. static readonly LESS: number;
  36261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36262. static readonly EQUAL: number;
  36263. /** 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 */
  36264. static readonly LEQUAL: number;
  36265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36266. static readonly GREATER: number;
  36267. /** 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 */
  36268. static readonly GEQUAL: number;
  36269. /** 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 */
  36270. static readonly NOTEQUAL: number;
  36271. /** Passed to stencilOperation to specify that stencil value must be kept */
  36272. static readonly KEEP: number;
  36273. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36274. static readonly REPLACE: number;
  36275. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36276. static readonly INCR: number;
  36277. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36278. static readonly DECR: number;
  36279. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36280. static readonly INVERT: number;
  36281. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36282. static readonly INCR_WRAP: number;
  36283. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36284. static readonly DECR_WRAP: number;
  36285. /** Texture is not repeating outside of 0..1 UVs */
  36286. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36287. /** Texture is repeating outside of 0..1 UVs */
  36288. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36289. /** Texture is repeating and mirrored */
  36290. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36291. /** ALPHA */
  36292. static readonly TEXTUREFORMAT_ALPHA: number;
  36293. /** LUMINANCE */
  36294. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36295. /** LUMINANCE_ALPHA */
  36296. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36297. /** RGB */
  36298. static readonly TEXTUREFORMAT_RGB: number;
  36299. /** RGBA */
  36300. static readonly TEXTUREFORMAT_RGBA: number;
  36301. /** RED */
  36302. static readonly TEXTUREFORMAT_RED: number;
  36303. /** RED (2nd reference) */
  36304. static readonly TEXTUREFORMAT_R: number;
  36305. /** RG */
  36306. static readonly TEXTUREFORMAT_RG: number;
  36307. /** RED_INTEGER */
  36308. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36309. /** RED_INTEGER (2nd reference) */
  36310. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36311. /** RG_INTEGER */
  36312. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36313. /** RGB_INTEGER */
  36314. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36315. /** RGBA_INTEGER */
  36316. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36317. /** UNSIGNED_BYTE */
  36318. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36319. /** UNSIGNED_BYTE (2nd reference) */
  36320. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36321. /** FLOAT */
  36322. static readonly TEXTURETYPE_FLOAT: number;
  36323. /** HALF_FLOAT */
  36324. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36325. /** BYTE */
  36326. static readonly TEXTURETYPE_BYTE: number;
  36327. /** SHORT */
  36328. static readonly TEXTURETYPE_SHORT: number;
  36329. /** UNSIGNED_SHORT */
  36330. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36331. /** INT */
  36332. static readonly TEXTURETYPE_INT: number;
  36333. /** UNSIGNED_INT */
  36334. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36335. /** UNSIGNED_SHORT_4_4_4_4 */
  36336. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36337. /** UNSIGNED_SHORT_5_5_5_1 */
  36338. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36339. /** UNSIGNED_SHORT_5_6_5 */
  36340. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36341. /** UNSIGNED_INT_2_10_10_10_REV */
  36342. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36343. /** UNSIGNED_INT_24_8 */
  36344. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36345. /** UNSIGNED_INT_10F_11F_11F_REV */
  36346. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36347. /** UNSIGNED_INT_5_9_9_9_REV */
  36348. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36349. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36350. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36351. /** nearest is mag = nearest and min = nearest and mip = linear */
  36352. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36353. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36354. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36355. /** Trilinear is mag = linear and min = linear and mip = linear */
  36356. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36357. /** nearest is mag = nearest and min = nearest and mip = linear */
  36358. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36360. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36361. /** Trilinear is mag = linear and min = linear and mip = linear */
  36362. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36363. /** mag = nearest and min = nearest and mip = nearest */
  36364. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36365. /** mag = nearest and min = linear and mip = nearest */
  36366. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36367. /** mag = nearest and min = linear and mip = linear */
  36368. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36369. /** mag = nearest and min = linear and mip = none */
  36370. static readonly TEXTURE_NEAREST_LINEAR: number;
  36371. /** mag = nearest and min = nearest and mip = none */
  36372. static readonly TEXTURE_NEAREST_NEAREST: number;
  36373. /** mag = linear and min = nearest and mip = nearest */
  36374. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36375. /** mag = linear and min = nearest and mip = linear */
  36376. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36377. /** mag = linear and min = linear and mip = none */
  36378. static readonly TEXTURE_LINEAR_LINEAR: number;
  36379. /** mag = linear and min = nearest and mip = none */
  36380. static readonly TEXTURE_LINEAR_NEAREST: number;
  36381. /** Explicit coordinates mode */
  36382. static readonly TEXTURE_EXPLICIT_MODE: number;
  36383. /** Spherical coordinates mode */
  36384. static readonly TEXTURE_SPHERICAL_MODE: number;
  36385. /** Planar coordinates mode */
  36386. static readonly TEXTURE_PLANAR_MODE: number;
  36387. /** Cubic coordinates mode */
  36388. static readonly TEXTURE_CUBIC_MODE: number;
  36389. /** Projection coordinates mode */
  36390. static readonly TEXTURE_PROJECTION_MODE: number;
  36391. /** Skybox coordinates mode */
  36392. static readonly TEXTURE_SKYBOX_MODE: number;
  36393. /** Inverse Cubic coordinates mode */
  36394. static readonly TEXTURE_INVCUBIC_MODE: number;
  36395. /** Equirectangular coordinates mode */
  36396. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36397. /** Equirectangular Fixed coordinates mode */
  36398. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36399. /** Equirectangular Fixed Mirrored coordinates mode */
  36400. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36401. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36402. static readonly SCALEMODE_FLOOR: number;
  36403. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36404. static readonly SCALEMODE_NEAREST: number;
  36405. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36406. static readonly SCALEMODE_CEILING: number;
  36407. /**
  36408. * Returns the current npm package of the sdk
  36409. */
  36410. static get NpmPackage(): string;
  36411. /**
  36412. * Returns the current version of the framework
  36413. */
  36414. static get Version(): string;
  36415. /** Gets the list of created engines */
  36416. static get Instances(): Engine[];
  36417. /**
  36418. * Gets the latest created engine
  36419. */
  36420. static get LastCreatedEngine(): Nullable<Engine>;
  36421. /**
  36422. * Gets the latest created scene
  36423. */
  36424. static get LastCreatedScene(): Nullable<Scene>;
  36425. /**
  36426. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36427. * @param flag defines which part of the materials must be marked as dirty
  36428. * @param predicate defines a predicate used to filter which materials should be affected
  36429. */
  36430. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36431. /**
  36432. * Method called to create the default loading screen.
  36433. * This can be overriden in your own app.
  36434. * @param canvas The rendering canvas element
  36435. * @returns The loading screen
  36436. */
  36437. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36438. /**
  36439. * Method called to create the default rescale post process on each engine.
  36440. */
  36441. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36442. /**
  36443. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36444. **/
  36445. enableOfflineSupport: boolean;
  36446. /**
  36447. * 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)
  36448. **/
  36449. disableManifestCheck: boolean;
  36450. /**
  36451. * Gets the list of created scenes
  36452. */
  36453. scenes: Scene[];
  36454. /**
  36455. * Event raised when a new scene is created
  36456. */
  36457. onNewSceneAddedObservable: Observable<Scene>;
  36458. /**
  36459. * Gets the list of created postprocesses
  36460. */
  36461. postProcesses: PostProcess[];
  36462. /**
  36463. * Gets a boolean indicating if the pointer is currently locked
  36464. */
  36465. isPointerLock: boolean;
  36466. /**
  36467. * Observable event triggered each time the rendering canvas is resized
  36468. */
  36469. onResizeObservable: Observable<Engine>;
  36470. /**
  36471. * Observable event triggered each time the canvas loses focus
  36472. */
  36473. onCanvasBlurObservable: Observable<Engine>;
  36474. /**
  36475. * Observable event triggered each time the canvas gains focus
  36476. */
  36477. onCanvasFocusObservable: Observable<Engine>;
  36478. /**
  36479. * Observable event triggered each time the canvas receives pointerout event
  36480. */
  36481. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36482. /**
  36483. * Observable raised when the engine begins a new frame
  36484. */
  36485. onBeginFrameObservable: Observable<Engine>;
  36486. /**
  36487. * If set, will be used to request the next animation frame for the render loop
  36488. */
  36489. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36490. /**
  36491. * Observable raised when the engine ends the current frame
  36492. */
  36493. onEndFrameObservable: Observable<Engine>;
  36494. /**
  36495. * Observable raised when the engine is about to compile a shader
  36496. */
  36497. onBeforeShaderCompilationObservable: Observable<Engine>;
  36498. /**
  36499. * Observable raised when the engine has jsut compiled a shader
  36500. */
  36501. onAfterShaderCompilationObservable: Observable<Engine>;
  36502. /**
  36503. * Gets the audio engine
  36504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36505. * @ignorenaming
  36506. */
  36507. static audioEngine: IAudioEngine;
  36508. /**
  36509. * Default AudioEngine factory responsible of creating the Audio Engine.
  36510. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36511. */
  36512. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36513. /**
  36514. * Default offline support factory responsible of creating a tool used to store data locally.
  36515. * By default, this will create a Database object if the workload has been embedded.
  36516. */
  36517. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36518. private _loadingScreen;
  36519. private _pointerLockRequested;
  36520. private _rescalePostProcess;
  36521. private _deterministicLockstep;
  36522. private _lockstepMaxSteps;
  36523. private _timeStep;
  36524. protected get _supportsHardwareTextureRescaling(): boolean;
  36525. private _fps;
  36526. private _deltaTime;
  36527. /** @hidden */
  36528. _drawCalls: PerfCounter;
  36529. /** 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 */
  36530. canvasTabIndex: number;
  36531. /**
  36532. * Turn this value on if you want to pause FPS computation when in background
  36533. */
  36534. disablePerformanceMonitorInBackground: boolean;
  36535. private _performanceMonitor;
  36536. /**
  36537. * Gets the performance monitor attached to this engine
  36538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36539. */
  36540. get performanceMonitor(): PerformanceMonitor;
  36541. private _onFocus;
  36542. private _onBlur;
  36543. private _onCanvasPointerOut;
  36544. private _onCanvasBlur;
  36545. private _onCanvasFocus;
  36546. private _onFullscreenChange;
  36547. private _onPointerLockChange;
  36548. /**
  36549. * Gets the HTML element used to attach event listeners
  36550. * @returns a HTML element
  36551. */
  36552. getInputElement(): Nullable<HTMLElement>;
  36553. /**
  36554. * Creates a new engine
  36555. * @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
  36556. * @param antialias defines enable antialiasing (default: false)
  36557. * @param options defines further options to be sent to the getContext() function
  36558. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36559. */
  36560. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36561. /**
  36562. * Gets current aspect ratio
  36563. * @param viewportOwner defines the camera to use to get the aspect ratio
  36564. * @param useScreen defines if screen size must be used (or the current render target if any)
  36565. * @returns a number defining the aspect ratio
  36566. */
  36567. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36568. /**
  36569. * Gets current screen aspect ratio
  36570. * @returns a number defining the aspect ratio
  36571. */
  36572. getScreenAspectRatio(): number;
  36573. /**
  36574. * Gets the client rect of the HTML canvas attached with the current webGL context
  36575. * @returns a client rectanglee
  36576. */
  36577. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36578. /**
  36579. * Gets the client rect of the HTML element used for events
  36580. * @returns a client rectanglee
  36581. */
  36582. getInputElementClientRect(): Nullable<ClientRect>;
  36583. /**
  36584. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36585. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36586. * @returns true if engine is in deterministic lock step mode
  36587. */
  36588. isDeterministicLockStep(): boolean;
  36589. /**
  36590. * Gets the max steps when engine is running in deterministic lock step
  36591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36592. * @returns the max steps
  36593. */
  36594. getLockstepMaxSteps(): number;
  36595. /**
  36596. * Returns the time in ms between steps when using deterministic lock step.
  36597. * @returns time step in (ms)
  36598. */
  36599. getTimeStep(): number;
  36600. /**
  36601. * Force the mipmap generation for the given render target texture
  36602. * @param texture defines the render target texture to use
  36603. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36604. */
  36605. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36606. /** States */
  36607. /**
  36608. * Set various states to the webGL context
  36609. * @param culling defines backface culling state
  36610. * @param zOffset defines the value to apply to zOffset (0 by default)
  36611. * @param force defines if states must be applied even if cache is up to date
  36612. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36613. */
  36614. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36615. /**
  36616. * Set the z offset to apply to current rendering
  36617. * @param value defines the offset to apply
  36618. */
  36619. setZOffset(value: number): void;
  36620. /**
  36621. * Gets the current value of the zOffset
  36622. * @returns the current zOffset state
  36623. */
  36624. getZOffset(): number;
  36625. /**
  36626. * Enable or disable depth buffering
  36627. * @param enable defines the state to set
  36628. */
  36629. setDepthBuffer(enable: boolean): void;
  36630. /**
  36631. * Gets a boolean indicating if depth writing is enabled
  36632. * @returns the current depth writing state
  36633. */
  36634. getDepthWrite(): boolean;
  36635. /**
  36636. * Enable or disable depth writing
  36637. * @param enable defines the state to set
  36638. */
  36639. setDepthWrite(enable: boolean): void;
  36640. /**
  36641. * Gets a boolean indicating if stencil buffer is enabled
  36642. * @returns the current stencil buffer state
  36643. */
  36644. getStencilBuffer(): boolean;
  36645. /**
  36646. * Enable or disable the stencil buffer
  36647. * @param enable defines if the stencil buffer must be enabled or disabled
  36648. */
  36649. setStencilBuffer(enable: boolean): void;
  36650. /**
  36651. * Gets the current stencil mask
  36652. * @returns a number defining the new stencil mask to use
  36653. */
  36654. getStencilMask(): number;
  36655. /**
  36656. * Sets the current stencil mask
  36657. * @param mask defines the new stencil mask to use
  36658. */
  36659. setStencilMask(mask: number): void;
  36660. /**
  36661. * Gets the current stencil function
  36662. * @returns a number defining the stencil function to use
  36663. */
  36664. getStencilFunction(): number;
  36665. /**
  36666. * Gets the current stencil reference value
  36667. * @returns a number defining the stencil reference value to use
  36668. */
  36669. getStencilFunctionReference(): number;
  36670. /**
  36671. * Gets the current stencil mask
  36672. * @returns a number defining the stencil mask to use
  36673. */
  36674. getStencilFunctionMask(): number;
  36675. /**
  36676. * Sets the current stencil function
  36677. * @param stencilFunc defines the new stencil function to use
  36678. */
  36679. setStencilFunction(stencilFunc: number): void;
  36680. /**
  36681. * Sets the current stencil reference
  36682. * @param reference defines the new stencil reference to use
  36683. */
  36684. setStencilFunctionReference(reference: number): void;
  36685. /**
  36686. * Sets the current stencil mask
  36687. * @param mask defines the new stencil mask to use
  36688. */
  36689. setStencilFunctionMask(mask: number): void;
  36690. /**
  36691. * Gets the current stencil operation when stencil fails
  36692. * @returns a number defining stencil operation to use when stencil fails
  36693. */
  36694. getStencilOperationFail(): number;
  36695. /**
  36696. * Gets the current stencil operation when depth fails
  36697. * @returns a number defining stencil operation to use when depth fails
  36698. */
  36699. getStencilOperationDepthFail(): number;
  36700. /**
  36701. * Gets the current stencil operation when stencil passes
  36702. * @returns a number defining stencil operation to use when stencil passes
  36703. */
  36704. getStencilOperationPass(): number;
  36705. /**
  36706. * Sets the stencil operation to use when stencil fails
  36707. * @param operation defines the stencil operation to use when stencil fails
  36708. */
  36709. setStencilOperationFail(operation: number): void;
  36710. /**
  36711. * Sets the stencil operation to use when depth fails
  36712. * @param operation defines the stencil operation to use when depth fails
  36713. */
  36714. setStencilOperationDepthFail(operation: number): void;
  36715. /**
  36716. * Sets the stencil operation to use when stencil passes
  36717. * @param operation defines the stencil operation to use when stencil passes
  36718. */
  36719. setStencilOperationPass(operation: number): void;
  36720. /**
  36721. * Sets a boolean indicating if the dithering state is enabled or disabled
  36722. * @param value defines the dithering state
  36723. */
  36724. setDitheringState(value: boolean): void;
  36725. /**
  36726. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36727. * @param value defines the rasterizer state
  36728. */
  36729. setRasterizerState(value: boolean): void;
  36730. /**
  36731. * Gets the current depth function
  36732. * @returns a number defining the depth function
  36733. */
  36734. getDepthFunction(): Nullable<number>;
  36735. /**
  36736. * Sets the current depth function
  36737. * @param depthFunc defines the function to use
  36738. */
  36739. setDepthFunction(depthFunc: number): void;
  36740. /**
  36741. * Sets the current depth function to GREATER
  36742. */
  36743. setDepthFunctionToGreater(): void;
  36744. /**
  36745. * Sets the current depth function to GEQUAL
  36746. */
  36747. setDepthFunctionToGreaterOrEqual(): void;
  36748. /**
  36749. * Sets the current depth function to LESS
  36750. */
  36751. setDepthFunctionToLess(): void;
  36752. /**
  36753. * Sets the current depth function to LEQUAL
  36754. */
  36755. setDepthFunctionToLessOrEqual(): void;
  36756. private _cachedStencilBuffer;
  36757. private _cachedStencilFunction;
  36758. private _cachedStencilMask;
  36759. private _cachedStencilOperationPass;
  36760. private _cachedStencilOperationFail;
  36761. private _cachedStencilOperationDepthFail;
  36762. private _cachedStencilReference;
  36763. /**
  36764. * Caches the the state of the stencil buffer
  36765. */
  36766. cacheStencilState(): void;
  36767. /**
  36768. * Restores the state of the stencil buffer
  36769. */
  36770. restoreStencilState(): void;
  36771. /**
  36772. * Directly set the WebGL Viewport
  36773. * @param x defines the x coordinate of the viewport (in screen space)
  36774. * @param y defines the y coordinate of the viewport (in screen space)
  36775. * @param width defines the width of the viewport (in screen space)
  36776. * @param height defines the height of the viewport (in screen space)
  36777. * @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
  36778. */
  36779. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36780. /**
  36781. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36783. * @param y defines the y-coordinate of the corner of the clear rectangle
  36784. * @param width defines the width of the clear rectangle
  36785. * @param height defines the height of the clear rectangle
  36786. * @param clearColor defines the clear color
  36787. */
  36788. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36789. /**
  36790. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36791. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36792. * @param y defines the y-coordinate of the corner of the clear rectangle
  36793. * @param width defines the width of the clear rectangle
  36794. * @param height defines the height of the clear rectangle
  36795. */
  36796. enableScissor(x: number, y: number, width: number, height: number): void;
  36797. /**
  36798. * Disable previously set scissor test rectangle
  36799. */
  36800. disableScissor(): void;
  36801. protected _reportDrawCall(): void;
  36802. /**
  36803. * Initializes a webVR display and starts listening to display change events
  36804. * The onVRDisplayChangedObservable will be notified upon these changes
  36805. * @returns The onVRDisplayChangedObservable
  36806. */
  36807. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36808. /** @hidden */
  36809. _prepareVRComponent(): void;
  36810. /** @hidden */
  36811. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36812. /** @hidden */
  36813. _submitVRFrame(): void;
  36814. /**
  36815. * Call this function to leave webVR mode
  36816. * Will do nothing if webVR is not supported or if there is no webVR device
  36817. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36818. */
  36819. disableVR(): void;
  36820. /**
  36821. * Gets a boolean indicating that the system is in VR mode and is presenting
  36822. * @returns true if VR mode is engaged
  36823. */
  36824. isVRPresenting(): boolean;
  36825. /** @hidden */
  36826. _requestVRFrame(): void;
  36827. /** @hidden */
  36828. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36829. /**
  36830. * Gets the source code of the vertex shader associated with a specific webGL program
  36831. * @param program defines the program to use
  36832. * @returns a string containing the source code of the vertex shader associated with the program
  36833. */
  36834. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36835. /**
  36836. * Gets the source code of the fragment shader associated with a specific webGL program
  36837. * @param program defines the program to use
  36838. * @returns a string containing the source code of the fragment shader associated with the program
  36839. */
  36840. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36841. /**
  36842. * Sets a depth stencil texture from a render target to the according uniform.
  36843. * @param channel The texture channel
  36844. * @param uniform The uniform to set
  36845. * @param texture The render target texture containing the depth stencil texture to apply
  36846. */
  36847. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36848. /**
  36849. * Sets a texture to the webGL context from a postprocess
  36850. * @param channel defines the channel to use
  36851. * @param postProcess defines the source postprocess
  36852. */
  36853. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36854. /**
  36855. * Binds the output of the passed in post process to the texture channel specified
  36856. * @param channel The channel the texture should be bound to
  36857. * @param postProcess The post process which's output should be bound
  36858. */
  36859. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36860. protected _rebuildBuffers(): void;
  36861. /** @hidden */
  36862. _renderFrame(): void;
  36863. _renderLoop(): void;
  36864. /** @hidden */
  36865. _renderViews(): boolean;
  36866. /**
  36867. * Toggle full screen mode
  36868. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36869. */
  36870. switchFullscreen(requestPointerLock: boolean): void;
  36871. /**
  36872. * Enters full screen mode
  36873. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36874. */
  36875. enterFullscreen(requestPointerLock: boolean): void;
  36876. /**
  36877. * Exits full screen mode
  36878. */
  36879. exitFullscreen(): void;
  36880. /**
  36881. * Enters Pointerlock mode
  36882. */
  36883. enterPointerlock(): void;
  36884. /**
  36885. * Exits Pointerlock mode
  36886. */
  36887. exitPointerlock(): void;
  36888. /**
  36889. * Begin a new frame
  36890. */
  36891. beginFrame(): void;
  36892. /**
  36893. * Enf the current frame
  36894. */
  36895. endFrame(): void;
  36896. resize(): void;
  36897. /**
  36898. * Force a specific size of the canvas
  36899. * @param width defines the new canvas' width
  36900. * @param height defines the new canvas' height
  36901. */
  36902. setSize(width: number, height: number): void;
  36903. /**
  36904. * Updates a dynamic vertex buffer.
  36905. * @param vertexBuffer the vertex buffer to update
  36906. * @param data the data used to update the vertex buffer
  36907. * @param byteOffset the byte offset of the data
  36908. * @param byteLength the byte length of the data
  36909. */
  36910. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36911. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36912. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36913. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36914. _releaseTexture(texture: InternalTexture): void;
  36915. /**
  36916. * @hidden
  36917. * Rescales a texture
  36918. * @param source input texutre
  36919. * @param destination destination texture
  36920. * @param scene scene to use to render the resize
  36921. * @param internalFormat format to use when resizing
  36922. * @param onComplete callback to be called when resize has completed
  36923. */
  36924. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36925. /**
  36926. * Gets the current framerate
  36927. * @returns a number representing the framerate
  36928. */
  36929. getFps(): number;
  36930. /**
  36931. * Gets the time spent between current and previous frame
  36932. * @returns a number representing the delta time in ms
  36933. */
  36934. getDeltaTime(): number;
  36935. private _measureFps;
  36936. /** @hidden */
  36937. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36938. /**
  36939. * Update a dynamic index buffer
  36940. * @param indexBuffer defines the target index buffer
  36941. * @param indices defines the data to update
  36942. * @param offset defines the offset in the target index buffer where update should start
  36943. */
  36944. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36945. /**
  36946. * Updates the sample count of a render target texture
  36947. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36948. * @param texture defines the texture to update
  36949. * @param samples defines the sample count to set
  36950. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36951. */
  36952. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36953. /**
  36954. * Updates a depth texture Comparison Mode and Function.
  36955. * If the comparison Function is equal to 0, the mode will be set to none.
  36956. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36957. * @param texture The texture to set the comparison function for
  36958. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36959. */
  36960. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36961. /**
  36962. * Creates a webGL buffer to use with instanciation
  36963. * @param capacity defines the size of the buffer
  36964. * @returns the webGL buffer
  36965. */
  36966. createInstancesBuffer(capacity: number): DataBuffer;
  36967. /**
  36968. * Delete a webGL buffer used with instanciation
  36969. * @param buffer defines the webGL buffer to delete
  36970. */
  36971. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36972. private _clientWaitAsync;
  36973. /** @hidden */
  36974. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36975. dispose(): void;
  36976. private _disableTouchAction;
  36977. /**
  36978. * Display the loading screen
  36979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36980. */
  36981. displayLoadingUI(): void;
  36982. /**
  36983. * Hide the loading screen
  36984. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36985. */
  36986. hideLoadingUI(): void;
  36987. /**
  36988. * Gets the current loading screen object
  36989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36990. */
  36991. get loadingScreen(): ILoadingScreen;
  36992. /**
  36993. * Sets the current loading screen object
  36994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36995. */
  36996. set loadingScreen(loadingScreen: ILoadingScreen);
  36997. /**
  36998. * Sets the current loading screen text
  36999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37000. */
  37001. set loadingUIText(text: string);
  37002. /**
  37003. * Sets the current loading screen background color
  37004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37005. */
  37006. set loadingUIBackgroundColor(color: string);
  37007. /** Pointerlock and fullscreen */
  37008. /**
  37009. * Ask the browser to promote the current element to pointerlock mode
  37010. * @param element defines the DOM element to promote
  37011. */
  37012. static _RequestPointerlock(element: HTMLElement): void;
  37013. /**
  37014. * Asks the browser to exit pointerlock mode
  37015. */
  37016. static _ExitPointerlock(): void;
  37017. /**
  37018. * Ask the browser to promote the current element to fullscreen rendering mode
  37019. * @param element defines the DOM element to promote
  37020. */
  37021. static _RequestFullscreen(element: HTMLElement): void;
  37022. /**
  37023. * Asks the browser to exit fullscreen mode
  37024. */
  37025. static _ExitFullscreen(): void;
  37026. }
  37027. }
  37028. declare module BABYLON {
  37029. /**
  37030. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37031. * during the life time of the application.
  37032. */
  37033. export class EngineStore {
  37034. /** Gets the list of created engines */
  37035. static Instances: Engine[];
  37036. /** @hidden */
  37037. static _LastCreatedScene: Nullable<Scene>;
  37038. /**
  37039. * Gets the latest created engine
  37040. */
  37041. static get LastCreatedEngine(): Nullable<Engine>;
  37042. /**
  37043. * Gets the latest created scene
  37044. */
  37045. static get LastCreatedScene(): Nullable<Scene>;
  37046. /**
  37047. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37048. * @ignorenaming
  37049. */
  37050. static UseFallbackTexture: boolean;
  37051. /**
  37052. * Texture content used if a texture cannot loaded
  37053. * @ignorenaming
  37054. */
  37055. static FallbackTexture: string;
  37056. }
  37057. }
  37058. declare module BABYLON {
  37059. /**
  37060. * Helper class that provides a small promise polyfill
  37061. */
  37062. export class PromisePolyfill {
  37063. /**
  37064. * Static function used to check if the polyfill is required
  37065. * If this is the case then the function will inject the polyfill to window.Promise
  37066. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37067. */
  37068. static Apply(force?: boolean): void;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * Interface for screenshot methods with describe argument called `size` as object with options
  37074. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37075. */
  37076. export interface IScreenshotSize {
  37077. /**
  37078. * number in pixels for canvas height
  37079. */
  37080. height?: number;
  37081. /**
  37082. * multiplier allowing render at a higher or lower resolution
  37083. * If value is defined then height and width will be ignored and taken from camera
  37084. */
  37085. precision?: number;
  37086. /**
  37087. * number in pixels for canvas width
  37088. */
  37089. width?: number;
  37090. }
  37091. }
  37092. declare module BABYLON {
  37093. interface IColor4Like {
  37094. r: float;
  37095. g: float;
  37096. b: float;
  37097. a: float;
  37098. }
  37099. /**
  37100. * Class containing a set of static utilities functions
  37101. */
  37102. export class Tools {
  37103. /**
  37104. * Gets or sets the base URL to use to load assets
  37105. */
  37106. static get BaseUrl(): string;
  37107. static set BaseUrl(value: string);
  37108. /**
  37109. * Enable/Disable Custom HTTP Request Headers globally.
  37110. * default = false
  37111. * @see CustomRequestHeaders
  37112. */
  37113. static UseCustomRequestHeaders: boolean;
  37114. /**
  37115. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37116. * i.e. when loading files, where the server/service expects an Authorization header
  37117. */
  37118. static CustomRequestHeaders: {
  37119. [key: string]: string;
  37120. };
  37121. /**
  37122. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37123. */
  37124. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37125. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37126. /**
  37127. * Default behaviour for cors in the application.
  37128. * It can be a string if the expected behavior is identical in the entire app.
  37129. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37130. */
  37131. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37132. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37133. /**
  37134. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37135. * @ignorenaming
  37136. */
  37137. static get UseFallbackTexture(): boolean;
  37138. static set UseFallbackTexture(value: boolean);
  37139. /**
  37140. * Use this object to register external classes like custom textures or material
  37141. * to allow the laoders to instantiate them
  37142. */
  37143. static get RegisteredExternalClasses(): {
  37144. [key: string]: Object;
  37145. };
  37146. static set RegisteredExternalClasses(classes: {
  37147. [key: string]: Object;
  37148. });
  37149. /**
  37150. * Texture content used if a texture cannot loaded
  37151. * @ignorenaming
  37152. */
  37153. static get fallbackTexture(): string;
  37154. static set fallbackTexture(value: string);
  37155. /**
  37156. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37157. * @param u defines the coordinate on X axis
  37158. * @param v defines the coordinate on Y axis
  37159. * @param width defines the width of the source data
  37160. * @param height defines the height of the source data
  37161. * @param pixels defines the source byte array
  37162. * @param color defines the output color
  37163. */
  37164. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37165. /**
  37166. * Interpolates between a and b via alpha
  37167. * @param a The lower value (returned when alpha = 0)
  37168. * @param b The upper value (returned when alpha = 1)
  37169. * @param alpha The interpolation-factor
  37170. * @return The mixed value
  37171. */
  37172. static Mix(a: number, b: number, alpha: number): number;
  37173. /**
  37174. * Tries to instantiate a new object from a given class name
  37175. * @param className defines the class name to instantiate
  37176. * @returns the new object or null if the system was not able to do the instantiation
  37177. */
  37178. static Instantiate(className: string): any;
  37179. /**
  37180. * Provides a slice function that will work even on IE
  37181. * @param data defines the array to slice
  37182. * @param start defines the start of the data (optional)
  37183. * @param end defines the end of the data (optional)
  37184. * @returns the new sliced array
  37185. */
  37186. static Slice<T>(data: T, start?: number, end?: number): T;
  37187. /**
  37188. * Polyfill for setImmediate
  37189. * @param action defines the action to execute after the current execution block
  37190. */
  37191. static SetImmediate(action: () => void): void;
  37192. /**
  37193. * Function indicating if a number is an exponent of 2
  37194. * @param value defines the value to test
  37195. * @returns true if the value is an exponent of 2
  37196. */
  37197. static IsExponentOfTwo(value: number): boolean;
  37198. private static _tmpFloatArray;
  37199. /**
  37200. * Returns the nearest 32-bit single precision float representation of a Number
  37201. * @param value A Number. If the parameter is of a different type, it will get converted
  37202. * to a number or to NaN if it cannot be converted
  37203. * @returns number
  37204. */
  37205. static FloatRound(value: number): number;
  37206. /**
  37207. * Extracts the filename from a path
  37208. * @param path defines the path to use
  37209. * @returns the filename
  37210. */
  37211. static GetFilename(path: string): string;
  37212. /**
  37213. * Extracts the "folder" part of a path (everything before the filename).
  37214. * @param uri The URI to extract the info from
  37215. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37216. * @returns The "folder" part of the path
  37217. */
  37218. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37219. /**
  37220. * Extracts text content from a DOM element hierarchy
  37221. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37222. */
  37223. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37224. /**
  37225. * Convert an angle in radians to degrees
  37226. * @param angle defines the angle to convert
  37227. * @returns the angle in degrees
  37228. */
  37229. static ToDegrees(angle: number): number;
  37230. /**
  37231. * Convert an angle in degrees to radians
  37232. * @param angle defines the angle to convert
  37233. * @returns the angle in radians
  37234. */
  37235. static ToRadians(angle: number): number;
  37236. /**
  37237. * Returns an array if obj is not an array
  37238. * @param obj defines the object to evaluate as an array
  37239. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37240. * @returns either obj directly if obj is an array or a new array containing obj
  37241. */
  37242. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37243. /**
  37244. * Gets the pointer prefix to use
  37245. * @param engine defines the engine we are finding the prefix for
  37246. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37247. */
  37248. static GetPointerPrefix(engine: Engine): string;
  37249. /**
  37250. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37251. * @param url define the url we are trying
  37252. * @param element define the dom element where to configure the cors policy
  37253. */
  37254. static SetCorsBehavior(url: string | string[], element: {
  37255. crossOrigin: string | null;
  37256. }): void;
  37257. /**
  37258. * Removes unwanted characters from an url
  37259. * @param url defines the url to clean
  37260. * @returns the cleaned url
  37261. */
  37262. static CleanUrl(url: string): string;
  37263. /**
  37264. * Gets or sets a function used to pre-process url before using them to load assets
  37265. */
  37266. static get PreprocessUrl(): (url: string) => string;
  37267. static set PreprocessUrl(processor: (url: string) => string);
  37268. /**
  37269. * Loads an image as an HTMLImageElement.
  37270. * @param input url string, ArrayBuffer, or Blob to load
  37271. * @param onLoad callback called when the image successfully loads
  37272. * @param onError callback called when the image fails to load
  37273. * @param offlineProvider offline provider for caching
  37274. * @param mimeType optional mime type
  37275. * @returns the HTMLImageElement of the loaded image
  37276. */
  37277. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37278. /**
  37279. * Loads a file from a url
  37280. * @param url url string, ArrayBuffer, or Blob to load
  37281. * @param onSuccess callback called when the file successfully loads
  37282. * @param onProgress callback called while file is loading (if the server supports this mode)
  37283. * @param offlineProvider defines the offline provider for caching
  37284. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37285. * @param onError callback called when the file fails to load
  37286. * @returns a file request object
  37287. */
  37288. 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;
  37289. /**
  37290. * Loads a file from a url
  37291. * @param url the file url to load
  37292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37293. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37294. */
  37295. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37296. /**
  37297. * Load a script (identified by an url). When the url returns, the
  37298. * content of this file is added into a new script element, attached to the DOM (body element)
  37299. * @param scriptUrl defines the url of the script to laod
  37300. * @param onSuccess defines the callback called when the script is loaded
  37301. * @param onError defines the callback to call if an error occurs
  37302. * @param scriptId defines the id of the script element
  37303. */
  37304. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37305. /**
  37306. * Load an asynchronous script (identified by an url). When the url returns, the
  37307. * content of this file is added into a new script element, attached to the DOM (body element)
  37308. * @param scriptUrl defines the url of the script to laod
  37309. * @param scriptId defines the id of the script element
  37310. * @returns a promise request object
  37311. */
  37312. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37313. /**
  37314. * Loads a file from a blob
  37315. * @param fileToLoad defines the blob to use
  37316. * @param callback defines the callback to call when data is loaded
  37317. * @param progressCallback defines the callback to call during loading process
  37318. * @returns a file request object
  37319. */
  37320. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37321. /**
  37322. * Reads a file from a File object
  37323. * @param file defines the file to load
  37324. * @param onSuccess defines the callback to call when data is loaded
  37325. * @param onProgress defines the callback to call during loading process
  37326. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37327. * @param onError defines the callback to call when an error occurs
  37328. * @returns a file request object
  37329. */
  37330. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37331. /**
  37332. * Creates a data url from a given string content
  37333. * @param content defines the content to convert
  37334. * @returns the new data url link
  37335. */
  37336. static FileAsURL(content: string): string;
  37337. /**
  37338. * Format the given number to a specific decimal format
  37339. * @param value defines the number to format
  37340. * @param decimals defines the number of decimals to use
  37341. * @returns the formatted string
  37342. */
  37343. static Format(value: number, decimals?: number): string;
  37344. /**
  37345. * Tries to copy an object by duplicating every property
  37346. * @param source defines the source object
  37347. * @param destination defines the target object
  37348. * @param doNotCopyList defines a list of properties to avoid
  37349. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37350. */
  37351. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37352. /**
  37353. * Gets a boolean indicating if the given object has no own property
  37354. * @param obj defines the object to test
  37355. * @returns true if object has no own property
  37356. */
  37357. static IsEmpty(obj: any): boolean;
  37358. /**
  37359. * Function used to register events at window level
  37360. * @param windowElement defines the Window object to use
  37361. * @param events defines the events to register
  37362. */
  37363. static RegisterTopRootEvents(windowElement: Window, events: {
  37364. name: string;
  37365. handler: Nullable<(e: FocusEvent) => any>;
  37366. }[]): void;
  37367. /**
  37368. * Function used to unregister events from window level
  37369. * @param windowElement defines the Window object to use
  37370. * @param events defines the events to unregister
  37371. */
  37372. static UnregisterTopRootEvents(windowElement: Window, events: {
  37373. name: string;
  37374. handler: Nullable<(e: FocusEvent) => any>;
  37375. }[]): void;
  37376. /**
  37377. * @ignore
  37378. */
  37379. static _ScreenshotCanvas: HTMLCanvasElement;
  37380. /**
  37381. * Dumps the current bound framebuffer
  37382. * @param width defines the rendering width
  37383. * @param height defines the rendering height
  37384. * @param engine defines the hosting engine
  37385. * @param successCallback defines the callback triggered once the data are available
  37386. * @param mimeType defines the mime type of the result
  37387. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37388. */
  37389. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37390. /**
  37391. * Converts the canvas data to blob.
  37392. * This acts as a polyfill for browsers not supporting the to blob function.
  37393. * @param canvas Defines the canvas to extract the data from
  37394. * @param successCallback Defines the callback triggered once the data are available
  37395. * @param mimeType Defines the mime type of the result
  37396. */
  37397. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37398. /**
  37399. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37400. * @param successCallback defines the callback triggered once the data are available
  37401. * @param mimeType defines the mime type of the result
  37402. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37403. */
  37404. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37405. /**
  37406. * Downloads a blob in the browser
  37407. * @param blob defines the blob to download
  37408. * @param fileName defines the name of the downloaded file
  37409. */
  37410. static Download(blob: Blob, fileName: string): void;
  37411. /**
  37412. * Captures a screenshot of the current rendering
  37413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37414. * @param engine defines the rendering engine
  37415. * @param camera defines the source camera
  37416. * @param size This parameter can be set to a single number or to an object with the
  37417. * following (optional) properties: precision, width, height. If a single number is passed,
  37418. * it will be used for both width and height. If an object is passed, the screenshot size
  37419. * will be derived from the parameters. The precision property is a multiplier allowing
  37420. * rendering at a higher or lower resolution
  37421. * @param successCallback defines the callback receives a single parameter which contains the
  37422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37423. * src parameter of an <img> to display it
  37424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37425. * Check your browser for supported MIME types
  37426. */
  37427. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37428. /**
  37429. * Captures a screenshot of the current rendering
  37430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37431. * @param engine defines the rendering engine
  37432. * @param camera defines the source camera
  37433. * @param size This parameter can be set to a single number or to an object with the
  37434. * following (optional) properties: precision, width, height. If a single number is passed,
  37435. * it will be used for both width and height. If an object is passed, the screenshot size
  37436. * will be derived from the parameters. The precision property is a multiplier allowing
  37437. * rendering at a higher or lower resolution
  37438. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37439. * Check your browser for supported MIME types
  37440. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37441. * to the src parameter of an <img> to display it
  37442. */
  37443. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37444. /**
  37445. * Generates an image screenshot from the specified camera.
  37446. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37447. * @param engine The engine to use for rendering
  37448. * @param camera The camera to use for rendering
  37449. * @param size This parameter can be set to a single number or to an object with the
  37450. * following (optional) properties: precision, width, height. If a single number is passed,
  37451. * it will be used for both width and height. If an object is passed, the screenshot size
  37452. * will be derived from the parameters. The precision property is a multiplier allowing
  37453. * rendering at a higher or lower resolution
  37454. * @param successCallback The callback receives a single parameter which contains the
  37455. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37456. * src parameter of an <img> to display it
  37457. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37458. * Check your browser for supported MIME types
  37459. * @param samples Texture samples (default: 1)
  37460. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37461. * @param fileName A name for for the downloaded file.
  37462. */
  37463. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37464. /**
  37465. * Generates an image screenshot from the specified camera.
  37466. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37467. * @param engine The engine to use for rendering
  37468. * @param camera The camera to use for rendering
  37469. * @param size This parameter can be set to a single number or to an object with the
  37470. * following (optional) properties: precision, width, height. If a single number is passed,
  37471. * it will be used for both width and height. If an object is passed, the screenshot size
  37472. * will be derived from the parameters. The precision property is a multiplier allowing
  37473. * rendering at a higher or lower resolution
  37474. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37475. * Check your browser for supported MIME types
  37476. * @param samples Texture samples (default: 1)
  37477. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37478. * @param fileName A name for for the downloaded file.
  37479. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37480. * to the src parameter of an <img> to display it
  37481. */
  37482. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37483. /**
  37484. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37485. * Be aware Math.random() could cause collisions, but:
  37486. * "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"
  37487. * @returns a pseudo random id
  37488. */
  37489. static RandomId(): string;
  37490. /**
  37491. * Test if the given uri is a base64 string
  37492. * @param uri The uri to test
  37493. * @return True if the uri is a base64 string or false otherwise
  37494. */
  37495. static IsBase64(uri: string): boolean;
  37496. /**
  37497. * Decode the given base64 uri.
  37498. * @param uri The uri to decode
  37499. * @return The decoded base64 data.
  37500. */
  37501. static DecodeBase64(uri: string): ArrayBuffer;
  37502. /**
  37503. * Gets the absolute url.
  37504. * @param url the input url
  37505. * @return the absolute url
  37506. */
  37507. static GetAbsoluteUrl(url: string): string;
  37508. /**
  37509. * No log
  37510. */
  37511. static readonly NoneLogLevel: number;
  37512. /**
  37513. * Only message logs
  37514. */
  37515. static readonly MessageLogLevel: number;
  37516. /**
  37517. * Only warning logs
  37518. */
  37519. static readonly WarningLogLevel: number;
  37520. /**
  37521. * Only error logs
  37522. */
  37523. static readonly ErrorLogLevel: number;
  37524. /**
  37525. * All logs
  37526. */
  37527. static readonly AllLogLevel: number;
  37528. /**
  37529. * Gets a value indicating the number of loading errors
  37530. * @ignorenaming
  37531. */
  37532. static get errorsCount(): number;
  37533. /**
  37534. * Callback called when a new log is added
  37535. */
  37536. static OnNewCacheEntry: (entry: string) => void;
  37537. /**
  37538. * Log a message to the console
  37539. * @param message defines the message to log
  37540. */
  37541. static Log(message: string): void;
  37542. /**
  37543. * Write a warning message to the console
  37544. * @param message defines the message to log
  37545. */
  37546. static Warn(message: string): void;
  37547. /**
  37548. * Write an error message to the console
  37549. * @param message defines the message to log
  37550. */
  37551. static Error(message: string): void;
  37552. /**
  37553. * Gets current log cache (list of logs)
  37554. */
  37555. static get LogCache(): string;
  37556. /**
  37557. * Clears the log cache
  37558. */
  37559. static ClearLogCache(): void;
  37560. /**
  37561. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37562. */
  37563. static set LogLevels(level: number);
  37564. /**
  37565. * Checks if the window object exists
  37566. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37567. */
  37568. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37569. /**
  37570. * No performance log
  37571. */
  37572. static readonly PerformanceNoneLogLevel: number;
  37573. /**
  37574. * Use user marks to log performance
  37575. */
  37576. static readonly PerformanceUserMarkLogLevel: number;
  37577. /**
  37578. * Log performance to the console
  37579. */
  37580. static readonly PerformanceConsoleLogLevel: number;
  37581. private static _performance;
  37582. /**
  37583. * Sets the current performance log level
  37584. */
  37585. static set PerformanceLogLevel(level: number);
  37586. private static _StartPerformanceCounterDisabled;
  37587. private static _EndPerformanceCounterDisabled;
  37588. private static _StartUserMark;
  37589. private static _EndUserMark;
  37590. private static _StartPerformanceConsole;
  37591. private static _EndPerformanceConsole;
  37592. /**
  37593. * Starts a performance counter
  37594. */
  37595. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37596. /**
  37597. * Ends a specific performance coutner
  37598. */
  37599. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37600. /**
  37601. * Gets either window.performance.now() if supported or Date.now() else
  37602. */
  37603. static get Now(): number;
  37604. /**
  37605. * This method will return the name of the class used to create the instance of the given object.
  37606. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37607. * @param object the object to get the class name from
  37608. * @param isType defines if the object is actually a type
  37609. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37610. */
  37611. static GetClassName(object: any, isType?: boolean): string;
  37612. /**
  37613. * Gets the first element of an array satisfying a given predicate
  37614. * @param array defines the array to browse
  37615. * @param predicate defines the predicate to use
  37616. * @returns null if not found or the element
  37617. */
  37618. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37619. /**
  37620. * This method will return the name of the full name of the class, including its owning module (if any).
  37621. * 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).
  37622. * @param object the object to get the class name from
  37623. * @param isType defines if the object is actually a type
  37624. * @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.
  37625. * @ignorenaming
  37626. */
  37627. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37628. /**
  37629. * Returns a promise that resolves after the given amount of time.
  37630. * @param delay Number of milliseconds to delay
  37631. * @returns Promise that resolves after the given amount of time
  37632. */
  37633. static DelayAsync(delay: number): Promise<void>;
  37634. /**
  37635. * Utility function to detect if the current user agent is Safari
  37636. * @returns whether or not the current user agent is safari
  37637. */
  37638. static IsSafari(): boolean;
  37639. }
  37640. /**
  37641. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37642. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37643. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37644. * @param name The name of the class, case should be preserved
  37645. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37646. */
  37647. export function className(name: string, module?: string): (target: Object) => void;
  37648. /**
  37649. * An implementation of a loop for asynchronous functions.
  37650. */
  37651. export class AsyncLoop {
  37652. /**
  37653. * Defines the number of iterations for the loop
  37654. */
  37655. iterations: number;
  37656. /**
  37657. * Defines the current index of the loop.
  37658. */
  37659. index: number;
  37660. private _done;
  37661. private _fn;
  37662. private _successCallback;
  37663. /**
  37664. * Constructor.
  37665. * @param iterations the number of iterations.
  37666. * @param func the function to run each iteration
  37667. * @param successCallback the callback that will be called upon succesful execution
  37668. * @param offset starting offset.
  37669. */
  37670. constructor(
  37671. /**
  37672. * Defines the number of iterations for the loop
  37673. */
  37674. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37675. /**
  37676. * Execute the next iteration. Must be called after the last iteration was finished.
  37677. */
  37678. executeNext(): void;
  37679. /**
  37680. * Break the loop and run the success callback.
  37681. */
  37682. breakLoop(): void;
  37683. /**
  37684. * Create and run an async loop.
  37685. * @param iterations the number of iterations.
  37686. * @param fn the function to run each iteration
  37687. * @param successCallback the callback that will be called upon succesful execution
  37688. * @param offset starting offset.
  37689. * @returns the created async loop object
  37690. */
  37691. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37692. /**
  37693. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37694. * @param iterations total number of iterations
  37695. * @param syncedIterations number of synchronous iterations in each async iteration.
  37696. * @param fn the function to call each iteration.
  37697. * @param callback a success call back that will be called when iterating stops.
  37698. * @param breakFunction a break condition (optional)
  37699. * @param timeout timeout settings for the setTimeout function. default - 0.
  37700. * @returns the created async loop object
  37701. */
  37702. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37703. }
  37704. }
  37705. declare module BABYLON {
  37706. /**
  37707. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37708. * The underlying implementation relies on an associative array to ensure the best performances.
  37709. * The value can be anything including 'null' but except 'undefined'
  37710. */
  37711. export class StringDictionary<T> {
  37712. /**
  37713. * This will clear this dictionary and copy the content from the 'source' one.
  37714. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37715. * @param source the dictionary to take the content from and copy to this dictionary
  37716. */
  37717. copyFrom(source: StringDictionary<T>): void;
  37718. /**
  37719. * Get a value based from its key
  37720. * @param key the given key to get the matching value from
  37721. * @return the value if found, otherwise undefined is returned
  37722. */
  37723. get(key: string): T | undefined;
  37724. /**
  37725. * Get a value from its key or add it if it doesn't exist.
  37726. * This method will ensure you that a given key/data will be present in the dictionary.
  37727. * @param key the given key to get the matching value from
  37728. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37729. * The factory will only be invoked if there's no data for the given key.
  37730. * @return the value corresponding to the key.
  37731. */
  37732. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37733. /**
  37734. * Get a value from its key if present in the dictionary otherwise add it
  37735. * @param key the key to get the value from
  37736. * @param val if there's no such key/value pair in the dictionary add it with this value
  37737. * @return the value corresponding to the key
  37738. */
  37739. getOrAdd(key: string, val: T): T;
  37740. /**
  37741. * Check if there's a given key in the dictionary
  37742. * @param key the key to check for
  37743. * @return true if the key is present, false otherwise
  37744. */
  37745. contains(key: string): boolean;
  37746. /**
  37747. * Add a new key and its corresponding value
  37748. * @param key the key to add
  37749. * @param value the value corresponding to the key
  37750. * @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
  37751. */
  37752. add(key: string, value: T): boolean;
  37753. /**
  37754. * Update a specific value associated to a key
  37755. * @param key defines the key to use
  37756. * @param value defines the value to store
  37757. * @returns true if the value was updated (or false if the key was not found)
  37758. */
  37759. set(key: string, value: T): boolean;
  37760. /**
  37761. * Get the element of the given key and remove it from the dictionary
  37762. * @param key defines the key to search
  37763. * @returns the value associated with the key or null if not found
  37764. */
  37765. getAndRemove(key: string): Nullable<T>;
  37766. /**
  37767. * Remove a key/value from the dictionary.
  37768. * @param key the key to remove
  37769. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37770. */
  37771. remove(key: string): boolean;
  37772. /**
  37773. * Clear the whole content of the dictionary
  37774. */
  37775. clear(): void;
  37776. /**
  37777. * Gets the current count
  37778. */
  37779. get count(): number;
  37780. /**
  37781. * Execute a callback on each key/val of the dictionary.
  37782. * Note that you can remove any element in this dictionary in the callback implementation
  37783. * @param callback the callback to execute on a given key/value pair
  37784. */
  37785. forEach(callback: (key: string, val: T) => void): void;
  37786. /**
  37787. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37788. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37789. * Note that you can remove any element in this dictionary in the callback implementation
  37790. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37791. * @returns the first item
  37792. */
  37793. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37794. private _count;
  37795. private _data;
  37796. }
  37797. }
  37798. declare module BABYLON {
  37799. /** @hidden */
  37800. export interface ICollisionCoordinator {
  37801. createCollider(): Collider;
  37802. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37803. init(scene: Scene): void;
  37804. }
  37805. /** @hidden */
  37806. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37807. private _scene;
  37808. private _scaledPosition;
  37809. private _scaledVelocity;
  37810. private _finalPosition;
  37811. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37812. createCollider(): Collider;
  37813. init(scene: Scene): void;
  37814. private _collideWithWorld;
  37815. }
  37816. }
  37817. declare module BABYLON {
  37818. /**
  37819. * Class used to manage all inputs for the scene.
  37820. */
  37821. export class InputManager {
  37822. /** The distance in pixel that you have to move to prevent some events */
  37823. static DragMovementThreshold: number;
  37824. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37825. static LongPressDelay: number;
  37826. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37827. static DoubleClickDelay: number;
  37828. /** If you need to check double click without raising a single click at first click, enable this flag */
  37829. static ExclusiveDoubleClickMode: boolean;
  37830. private _wheelEventName;
  37831. private _onPointerMove;
  37832. private _onPointerDown;
  37833. private _onPointerUp;
  37834. private _initClickEvent;
  37835. private _initActionManager;
  37836. private _delayedSimpleClick;
  37837. private _delayedSimpleClickTimeout;
  37838. private _previousDelayedSimpleClickTimeout;
  37839. private _meshPickProceed;
  37840. private _previousButtonPressed;
  37841. private _currentPickResult;
  37842. private _previousPickResult;
  37843. private _totalPointersPressed;
  37844. private _doubleClickOccured;
  37845. private _pointerOverMesh;
  37846. private _pickedDownMesh;
  37847. private _pickedUpMesh;
  37848. private _pointerX;
  37849. private _pointerY;
  37850. private _unTranslatedPointerX;
  37851. private _unTranslatedPointerY;
  37852. private _startingPointerPosition;
  37853. private _previousStartingPointerPosition;
  37854. private _startingPointerTime;
  37855. private _previousStartingPointerTime;
  37856. private _pointerCaptures;
  37857. private _onKeyDown;
  37858. private _onKeyUp;
  37859. private _onCanvasFocusObserver;
  37860. private _onCanvasBlurObserver;
  37861. private _scene;
  37862. /**
  37863. * Creates a new InputManager
  37864. * @param scene defines the hosting scene
  37865. */
  37866. constructor(scene: Scene);
  37867. /**
  37868. * Gets the mesh that is currently under the pointer
  37869. */
  37870. get meshUnderPointer(): Nullable<AbstractMesh>;
  37871. /**
  37872. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37873. */
  37874. get unTranslatedPointer(): Vector2;
  37875. /**
  37876. * Gets or sets the current on-screen X position of the pointer
  37877. */
  37878. get pointerX(): number;
  37879. set pointerX(value: number);
  37880. /**
  37881. * Gets or sets the current on-screen Y position of the pointer
  37882. */
  37883. get pointerY(): number;
  37884. set pointerY(value: number);
  37885. private _updatePointerPosition;
  37886. private _processPointerMove;
  37887. private _setRayOnPointerInfo;
  37888. private _checkPrePointerObservable;
  37889. /**
  37890. * Use this method to simulate a pointer move on a mesh
  37891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37894. */
  37895. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37896. /**
  37897. * Use this method to simulate a pointer down on a mesh
  37898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37901. */
  37902. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37903. private _processPointerDown;
  37904. /** @hidden */
  37905. _isPointerSwiping(): boolean;
  37906. /**
  37907. * Use this method to simulate a pointer up on a mesh
  37908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37911. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37912. */
  37913. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37914. private _processPointerUp;
  37915. /**
  37916. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37917. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37918. * @returns true if the pointer was captured
  37919. */
  37920. isPointerCaptured(pointerId?: number): boolean;
  37921. /**
  37922. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37923. * @param attachUp defines if you want to attach events to pointerup
  37924. * @param attachDown defines if you want to attach events to pointerdown
  37925. * @param attachMove defines if you want to attach events to pointermove
  37926. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37927. */
  37928. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37929. /**
  37930. * Detaches all event handlers
  37931. */
  37932. detachControl(): void;
  37933. /**
  37934. * Force the value of meshUnderPointer
  37935. * @param mesh defines the mesh to use
  37936. */
  37937. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37938. /**
  37939. * Gets the mesh under the pointer
  37940. * @returns a Mesh or null if no mesh is under the pointer
  37941. */
  37942. getPointerOverMesh(): Nullable<AbstractMesh>;
  37943. }
  37944. }
  37945. declare module BABYLON {
  37946. /**
  37947. * This class defines the direct association between an animation and a target
  37948. */
  37949. export class TargetedAnimation {
  37950. /**
  37951. * Animation to perform
  37952. */
  37953. animation: Animation;
  37954. /**
  37955. * Target to animate
  37956. */
  37957. target: any;
  37958. /**
  37959. * Returns the string "TargetedAnimation"
  37960. * @returns "TargetedAnimation"
  37961. */
  37962. getClassName(): string;
  37963. /**
  37964. * Serialize the object
  37965. * @returns the JSON object representing the current entity
  37966. */
  37967. serialize(): any;
  37968. }
  37969. /**
  37970. * Use this class to create coordinated animations on multiple targets
  37971. */
  37972. export class AnimationGroup implements IDisposable {
  37973. /** The name of the animation group */
  37974. name: string;
  37975. private _scene;
  37976. private _targetedAnimations;
  37977. private _animatables;
  37978. private _from;
  37979. private _to;
  37980. private _isStarted;
  37981. private _isPaused;
  37982. private _speedRatio;
  37983. private _loopAnimation;
  37984. private _isAdditive;
  37985. /**
  37986. * Gets or sets the unique id of the node
  37987. */
  37988. uniqueId: number;
  37989. /**
  37990. * This observable will notify when one animation have ended
  37991. */
  37992. onAnimationEndObservable: Observable<TargetedAnimation>;
  37993. /**
  37994. * Observer raised when one animation loops
  37995. */
  37996. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37997. /**
  37998. * Observer raised when all animations have looped
  37999. */
  38000. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38001. /**
  38002. * This observable will notify when all animations have ended.
  38003. */
  38004. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38005. /**
  38006. * This observable will notify when all animations have paused.
  38007. */
  38008. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38009. /**
  38010. * This observable will notify when all animations are playing.
  38011. */
  38012. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38013. /**
  38014. * Gets the first frame
  38015. */
  38016. get from(): number;
  38017. /**
  38018. * Gets the last frame
  38019. */
  38020. get to(): number;
  38021. /**
  38022. * Define if the animations are started
  38023. */
  38024. get isStarted(): boolean;
  38025. /**
  38026. * Gets a value indicating that the current group is playing
  38027. */
  38028. get isPlaying(): boolean;
  38029. /**
  38030. * Gets or sets the speed ratio to use for all animations
  38031. */
  38032. get speedRatio(): number;
  38033. /**
  38034. * Gets or sets the speed ratio to use for all animations
  38035. */
  38036. set speedRatio(value: number);
  38037. /**
  38038. * Gets or sets if all animations should loop or not
  38039. */
  38040. get loopAnimation(): boolean;
  38041. set loopAnimation(value: boolean);
  38042. /**
  38043. * Gets or sets if all animations should be evaluated additively
  38044. */
  38045. get isAdditive(): boolean;
  38046. set isAdditive(value: boolean);
  38047. /**
  38048. * Gets the targeted animations for this animation group
  38049. */
  38050. get targetedAnimations(): Array<TargetedAnimation>;
  38051. /**
  38052. * returning the list of animatables controlled by this animation group.
  38053. */
  38054. get animatables(): Array<Animatable>;
  38055. /**
  38056. * Gets the list of target animations
  38057. */
  38058. get children(): TargetedAnimation[];
  38059. /**
  38060. * Instantiates a new Animation Group.
  38061. * This helps managing several animations at once.
  38062. * @see http://doc.babylonjs.com/how_to/group
  38063. * @param name Defines the name of the group
  38064. * @param scene Defines the scene the group belongs to
  38065. */
  38066. constructor(
  38067. /** The name of the animation group */
  38068. name: string, scene?: Nullable<Scene>);
  38069. /**
  38070. * Add an animation (with its target) in the group
  38071. * @param animation defines the animation we want to add
  38072. * @param target defines the target of the animation
  38073. * @returns the TargetedAnimation object
  38074. */
  38075. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38076. /**
  38077. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38078. * It can add constant keys at begin or end
  38079. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38080. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38081. * @returns the animation group
  38082. */
  38083. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38084. private _animationLoopCount;
  38085. private _animationLoopFlags;
  38086. private _processLoop;
  38087. /**
  38088. * Start all animations on given targets
  38089. * @param loop defines if animations must loop
  38090. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38091. * @param from defines the from key (optional)
  38092. * @param to defines the to key (optional)
  38093. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38094. * @returns the current animation group
  38095. */
  38096. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38097. /**
  38098. * Pause all animations
  38099. * @returns the animation group
  38100. */
  38101. pause(): AnimationGroup;
  38102. /**
  38103. * Play all animations to initial state
  38104. * This function will start() the animations if they were not started or will restart() them if they were paused
  38105. * @param loop defines if animations must loop
  38106. * @returns the animation group
  38107. */
  38108. play(loop?: boolean): AnimationGroup;
  38109. /**
  38110. * Reset all animations to initial state
  38111. * @returns the animation group
  38112. */
  38113. reset(): AnimationGroup;
  38114. /**
  38115. * Restart animations from key 0
  38116. * @returns the animation group
  38117. */
  38118. restart(): AnimationGroup;
  38119. /**
  38120. * Stop all animations
  38121. * @returns the animation group
  38122. */
  38123. stop(): AnimationGroup;
  38124. /**
  38125. * Set animation weight for all animatables
  38126. * @param weight defines the weight to use
  38127. * @return the animationGroup
  38128. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38129. */
  38130. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38131. /**
  38132. * Synchronize and normalize all animatables with a source animatable
  38133. * @param root defines the root animatable to synchronize with
  38134. * @return the animationGroup
  38135. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38136. */
  38137. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38138. /**
  38139. * Goes to a specific frame in this animation group
  38140. * @param frame the frame number to go to
  38141. * @return the animationGroup
  38142. */
  38143. goToFrame(frame: number): AnimationGroup;
  38144. /**
  38145. * Dispose all associated resources
  38146. */
  38147. dispose(): void;
  38148. private _checkAnimationGroupEnded;
  38149. /**
  38150. * Clone the current animation group and returns a copy
  38151. * @param newName defines the name of the new group
  38152. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38153. * @returns the new aniamtion group
  38154. */
  38155. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38156. /**
  38157. * Serializes the animationGroup to an object
  38158. * @returns Serialized object
  38159. */
  38160. serialize(): any;
  38161. /**
  38162. * Returns a new AnimationGroup object parsed from the source provided.
  38163. * @param parsedAnimationGroup defines the source
  38164. * @param scene defines the scene that will receive the animationGroup
  38165. * @returns a new AnimationGroup
  38166. */
  38167. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38168. /**
  38169. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38170. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38171. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38172. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38173. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38174. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38175. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38176. */
  38177. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38178. /**
  38179. * Returns the string "AnimationGroup"
  38180. * @returns "AnimationGroup"
  38181. */
  38182. getClassName(): string;
  38183. /**
  38184. * Creates a detailled string about the object
  38185. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38186. * @returns a string representing the object
  38187. */
  38188. toString(fullDetails?: boolean): string;
  38189. }
  38190. }
  38191. declare module BABYLON {
  38192. /**
  38193. * Define an interface for all classes that will hold resources
  38194. */
  38195. export interface IDisposable {
  38196. /**
  38197. * Releases all held resources
  38198. */
  38199. dispose(): void;
  38200. }
  38201. /** Interface defining initialization parameters for Scene class */
  38202. export interface SceneOptions {
  38203. /**
  38204. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38205. * It will improve performance when the number of geometries becomes important.
  38206. */
  38207. useGeometryUniqueIdsMap?: boolean;
  38208. /**
  38209. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38210. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38211. */
  38212. useMaterialMeshMap?: boolean;
  38213. /**
  38214. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38215. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38216. */
  38217. useClonedMeshMap?: boolean;
  38218. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38219. virtual?: boolean;
  38220. }
  38221. /**
  38222. * Represents a scene to be rendered by the engine.
  38223. * @see http://doc.babylonjs.com/features/scene
  38224. */
  38225. export class Scene extends AbstractScene implements IAnimatable {
  38226. /** The fog is deactivated */
  38227. static readonly FOGMODE_NONE: number;
  38228. /** The fog density is following an exponential function */
  38229. static readonly FOGMODE_EXP: number;
  38230. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38231. static readonly FOGMODE_EXP2: number;
  38232. /** The fog density is following a linear function. */
  38233. static readonly FOGMODE_LINEAR: number;
  38234. /**
  38235. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38237. */
  38238. static MinDeltaTime: number;
  38239. /**
  38240. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38241. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38242. */
  38243. static MaxDeltaTime: number;
  38244. /**
  38245. * Factory used to create the default material.
  38246. * @param name The name of the material to create
  38247. * @param scene The scene to create the material for
  38248. * @returns The default material
  38249. */
  38250. static DefaultMaterialFactory(scene: Scene): Material;
  38251. /**
  38252. * Factory used to create the a collision coordinator.
  38253. * @returns The collision coordinator
  38254. */
  38255. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38256. /** @hidden */
  38257. _inputManager: InputManager;
  38258. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38259. cameraToUseForPointers: Nullable<Camera>;
  38260. /** @hidden */
  38261. readonly _isScene: boolean;
  38262. /** @hidden */
  38263. _blockEntityCollection: boolean;
  38264. /**
  38265. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38266. */
  38267. autoClear: boolean;
  38268. /**
  38269. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38270. */
  38271. autoClearDepthAndStencil: boolean;
  38272. /**
  38273. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38274. */
  38275. clearColor: Color4;
  38276. /**
  38277. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38278. */
  38279. ambientColor: Color3;
  38280. /**
  38281. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38282. * It should only be one of the following (if not the default embedded one):
  38283. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38284. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38285. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38286. * The material properties need to be setup according to the type of texture in use.
  38287. */
  38288. environmentBRDFTexture: BaseTexture;
  38289. /** @hidden */
  38290. protected _environmentTexture: Nullable<BaseTexture>;
  38291. /**
  38292. * Texture used in all pbr material as the reflection texture.
  38293. * As in the majority of the scene they are the same (exception for multi room and so on),
  38294. * this is easier to reference from here than from all the materials.
  38295. */
  38296. get environmentTexture(): Nullable<BaseTexture>;
  38297. /**
  38298. * Texture used in all pbr material as the reflection texture.
  38299. * As in the majority of the scene they are the same (exception for multi room and so on),
  38300. * this is easier to set here than in all the materials.
  38301. */
  38302. set environmentTexture(value: Nullable<BaseTexture>);
  38303. /** @hidden */
  38304. protected _environmentIntensity: number;
  38305. /**
  38306. * Intensity of the environment in all pbr material.
  38307. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38308. * As in the majority of the scene they are the same (exception for multi room and so on),
  38309. * this is easier to reference from here than from all the materials.
  38310. */
  38311. get environmentIntensity(): number;
  38312. /**
  38313. * Intensity of the environment in all pbr material.
  38314. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38315. * As in the majority of the scene they are the same (exception for multi room and so on),
  38316. * this is easier to set here than in all the materials.
  38317. */
  38318. set environmentIntensity(value: number);
  38319. /** @hidden */
  38320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38321. /**
  38322. * Default image processing configuration used either in the rendering
  38323. * Forward main pass or through the imageProcessingPostProcess if present.
  38324. * As in the majority of the scene they are the same (exception for multi camera),
  38325. * this is easier to reference from here than from all the materials and post process.
  38326. *
  38327. * No setter as we it is a shared configuration, you can set the values instead.
  38328. */
  38329. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38330. private _forceWireframe;
  38331. /**
  38332. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38333. */
  38334. set forceWireframe(value: boolean);
  38335. get forceWireframe(): boolean;
  38336. private _skipFrustumClipping;
  38337. /**
  38338. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38339. */
  38340. set skipFrustumClipping(value: boolean);
  38341. get skipFrustumClipping(): boolean;
  38342. private _forcePointsCloud;
  38343. /**
  38344. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38345. */
  38346. set forcePointsCloud(value: boolean);
  38347. get forcePointsCloud(): boolean;
  38348. /**
  38349. * Gets or sets the active clipplane 1
  38350. */
  38351. clipPlane: Nullable<Plane>;
  38352. /**
  38353. * Gets or sets the active clipplane 2
  38354. */
  38355. clipPlane2: Nullable<Plane>;
  38356. /**
  38357. * Gets or sets the active clipplane 3
  38358. */
  38359. clipPlane3: Nullable<Plane>;
  38360. /**
  38361. * Gets or sets the active clipplane 4
  38362. */
  38363. clipPlane4: Nullable<Plane>;
  38364. /**
  38365. * Gets or sets the active clipplane 5
  38366. */
  38367. clipPlane5: Nullable<Plane>;
  38368. /**
  38369. * Gets or sets the active clipplane 6
  38370. */
  38371. clipPlane6: Nullable<Plane>;
  38372. /**
  38373. * Gets or sets a boolean indicating if animations are enabled
  38374. */
  38375. animationsEnabled: boolean;
  38376. private _animationPropertiesOverride;
  38377. /**
  38378. * Gets or sets the animation properties override
  38379. */
  38380. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38381. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38382. /**
  38383. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38384. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38385. */
  38386. useConstantAnimationDeltaTime: boolean;
  38387. /**
  38388. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38389. * Please note that it requires to run a ray cast through the scene on every frame
  38390. */
  38391. constantlyUpdateMeshUnderPointer: boolean;
  38392. /**
  38393. * Defines the HTML cursor to use when hovering over interactive elements
  38394. */
  38395. hoverCursor: string;
  38396. /**
  38397. * Defines the HTML default cursor to use (empty by default)
  38398. */
  38399. defaultCursor: string;
  38400. /**
  38401. * Defines whether cursors are handled by the scene.
  38402. */
  38403. doNotHandleCursors: boolean;
  38404. /**
  38405. * This is used to call preventDefault() on pointer down
  38406. * in order to block unwanted artifacts like system double clicks
  38407. */
  38408. preventDefaultOnPointerDown: boolean;
  38409. /**
  38410. * This is used to call preventDefault() on pointer up
  38411. * in order to block unwanted artifacts like system double clicks
  38412. */
  38413. preventDefaultOnPointerUp: boolean;
  38414. /**
  38415. * Gets or sets user defined metadata
  38416. */
  38417. metadata: any;
  38418. /**
  38419. * For internal use only. Please do not use.
  38420. */
  38421. reservedDataStore: any;
  38422. /**
  38423. * Gets the name of the plugin used to load this scene (null by default)
  38424. */
  38425. loadingPluginName: string;
  38426. /**
  38427. * Use this array to add regular expressions used to disable offline support for specific urls
  38428. */
  38429. disableOfflineSupportExceptionRules: RegExp[];
  38430. /**
  38431. * An event triggered when the scene is disposed.
  38432. */
  38433. onDisposeObservable: Observable<Scene>;
  38434. private _onDisposeObserver;
  38435. /** Sets a function to be executed when this scene is disposed. */
  38436. set onDispose(callback: () => void);
  38437. /**
  38438. * An event triggered before rendering the scene (right after animations and physics)
  38439. */
  38440. onBeforeRenderObservable: Observable<Scene>;
  38441. private _onBeforeRenderObserver;
  38442. /** Sets a function to be executed before rendering this scene */
  38443. set beforeRender(callback: Nullable<() => void>);
  38444. /**
  38445. * An event triggered after rendering the scene
  38446. */
  38447. onAfterRenderObservable: Observable<Scene>;
  38448. /**
  38449. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38450. */
  38451. onAfterRenderCameraObservable: Observable<Camera>;
  38452. private _onAfterRenderObserver;
  38453. /** Sets a function to be executed after rendering this scene */
  38454. set afterRender(callback: Nullable<() => void>);
  38455. /**
  38456. * An event triggered before animating the scene
  38457. */
  38458. onBeforeAnimationsObservable: Observable<Scene>;
  38459. /**
  38460. * An event triggered after animations processing
  38461. */
  38462. onAfterAnimationsObservable: Observable<Scene>;
  38463. /**
  38464. * An event triggered before draw calls are ready to be sent
  38465. */
  38466. onBeforeDrawPhaseObservable: Observable<Scene>;
  38467. /**
  38468. * An event triggered after draw calls have been sent
  38469. */
  38470. onAfterDrawPhaseObservable: Observable<Scene>;
  38471. /**
  38472. * An event triggered when the scene is ready
  38473. */
  38474. onReadyObservable: Observable<Scene>;
  38475. /**
  38476. * An event triggered before rendering a camera
  38477. */
  38478. onBeforeCameraRenderObservable: Observable<Camera>;
  38479. private _onBeforeCameraRenderObserver;
  38480. /** Sets a function to be executed before rendering a camera*/
  38481. set beforeCameraRender(callback: () => void);
  38482. /**
  38483. * An event triggered after rendering a camera
  38484. */
  38485. onAfterCameraRenderObservable: Observable<Camera>;
  38486. private _onAfterCameraRenderObserver;
  38487. /** Sets a function to be executed after rendering a camera*/
  38488. set afterCameraRender(callback: () => void);
  38489. /**
  38490. * An event triggered when active meshes evaluation is about to start
  38491. */
  38492. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38493. /**
  38494. * An event triggered when active meshes evaluation is done
  38495. */
  38496. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38497. /**
  38498. * An event triggered when particles rendering is about to start
  38499. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38500. */
  38501. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38502. /**
  38503. * An event triggered when particles rendering is done
  38504. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38505. */
  38506. onAfterParticlesRenderingObservable: Observable<Scene>;
  38507. /**
  38508. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38509. */
  38510. onDataLoadedObservable: Observable<Scene>;
  38511. /**
  38512. * An event triggered when a camera is created
  38513. */
  38514. onNewCameraAddedObservable: Observable<Camera>;
  38515. /**
  38516. * An event triggered when a camera is removed
  38517. */
  38518. onCameraRemovedObservable: Observable<Camera>;
  38519. /**
  38520. * An event triggered when a light is created
  38521. */
  38522. onNewLightAddedObservable: Observable<Light>;
  38523. /**
  38524. * An event triggered when a light is removed
  38525. */
  38526. onLightRemovedObservable: Observable<Light>;
  38527. /**
  38528. * An event triggered when a geometry is created
  38529. */
  38530. onNewGeometryAddedObservable: Observable<Geometry>;
  38531. /**
  38532. * An event triggered when a geometry is removed
  38533. */
  38534. onGeometryRemovedObservable: Observable<Geometry>;
  38535. /**
  38536. * An event triggered when a transform node is created
  38537. */
  38538. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38539. /**
  38540. * An event triggered when a transform node is removed
  38541. */
  38542. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38543. /**
  38544. * An event triggered when a mesh is created
  38545. */
  38546. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38547. /**
  38548. * An event triggered when a mesh is removed
  38549. */
  38550. onMeshRemovedObservable: Observable<AbstractMesh>;
  38551. /**
  38552. * An event triggered when a skeleton is created
  38553. */
  38554. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38555. /**
  38556. * An event triggered when a skeleton is removed
  38557. */
  38558. onSkeletonRemovedObservable: Observable<Skeleton>;
  38559. /**
  38560. * An event triggered when a material is created
  38561. */
  38562. onNewMaterialAddedObservable: Observable<Material>;
  38563. /**
  38564. * An event triggered when a material is removed
  38565. */
  38566. onMaterialRemovedObservable: Observable<Material>;
  38567. /**
  38568. * An event triggered when a texture is created
  38569. */
  38570. onNewTextureAddedObservable: Observable<BaseTexture>;
  38571. /**
  38572. * An event triggered when a texture is removed
  38573. */
  38574. onTextureRemovedObservable: Observable<BaseTexture>;
  38575. /**
  38576. * An event triggered when render targets are about to be rendered
  38577. * Can happen multiple times per frame.
  38578. */
  38579. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38580. /**
  38581. * An event triggered when render targets were rendered.
  38582. * Can happen multiple times per frame.
  38583. */
  38584. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38585. /**
  38586. * An event triggered before calculating deterministic simulation step
  38587. */
  38588. onBeforeStepObservable: Observable<Scene>;
  38589. /**
  38590. * An event triggered after calculating deterministic simulation step
  38591. */
  38592. onAfterStepObservable: Observable<Scene>;
  38593. /**
  38594. * An event triggered when the activeCamera property is updated
  38595. */
  38596. onActiveCameraChanged: Observable<Scene>;
  38597. /**
  38598. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38599. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38600. * 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)
  38601. */
  38602. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38603. /**
  38604. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38605. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38606. * 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)
  38607. */
  38608. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38609. /**
  38610. * This Observable will when a mesh has been imported into the scene.
  38611. */
  38612. onMeshImportedObservable: Observable<AbstractMesh>;
  38613. /**
  38614. * This Observable will when an animation file has been imported into the scene.
  38615. */
  38616. onAnimationFileImportedObservable: Observable<Scene>;
  38617. /**
  38618. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38619. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38620. */
  38621. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38622. /** @hidden */
  38623. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38624. /**
  38625. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38626. */
  38627. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38628. /**
  38629. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38630. */
  38631. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38632. /**
  38633. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38634. */
  38635. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38636. /** Callback called when a pointer move is detected */
  38637. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38638. /** Callback called when a pointer down is detected */
  38639. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38640. /** Callback called when a pointer up is detected */
  38641. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38642. /** Callback called when a pointer pick is detected */
  38643. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38644. /**
  38645. * 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).
  38646. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38647. */
  38648. onPrePointerObservable: Observable<PointerInfoPre>;
  38649. /**
  38650. * Observable event triggered each time an input event is received from the rendering canvas
  38651. */
  38652. onPointerObservable: Observable<PointerInfo>;
  38653. /**
  38654. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38655. */
  38656. get unTranslatedPointer(): Vector2;
  38657. /**
  38658. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38659. */
  38660. static get DragMovementThreshold(): number;
  38661. static set DragMovementThreshold(value: number);
  38662. /**
  38663. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38664. */
  38665. static get LongPressDelay(): number;
  38666. static set LongPressDelay(value: number);
  38667. /**
  38668. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38669. */
  38670. static get DoubleClickDelay(): number;
  38671. static set DoubleClickDelay(value: number);
  38672. /** If you need to check double click without raising a single click at first click, enable this flag */
  38673. static get ExclusiveDoubleClickMode(): boolean;
  38674. static set ExclusiveDoubleClickMode(value: boolean);
  38675. /** @hidden */
  38676. _mirroredCameraPosition: Nullable<Vector3>;
  38677. /**
  38678. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38679. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38680. */
  38681. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38682. /**
  38683. * Observable event triggered each time an keyboard event is received from the hosting window
  38684. */
  38685. onKeyboardObservable: Observable<KeyboardInfo>;
  38686. private _useRightHandedSystem;
  38687. /**
  38688. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38689. */
  38690. set useRightHandedSystem(value: boolean);
  38691. get useRightHandedSystem(): boolean;
  38692. private _timeAccumulator;
  38693. private _currentStepId;
  38694. private _currentInternalStep;
  38695. /**
  38696. * Sets the step Id used by deterministic lock step
  38697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38698. * @param newStepId defines the step Id
  38699. */
  38700. setStepId(newStepId: number): void;
  38701. /**
  38702. * Gets the step Id used by deterministic lock step
  38703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38704. * @returns the step Id
  38705. */
  38706. getStepId(): number;
  38707. /**
  38708. * Gets the internal step used by deterministic lock step
  38709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38710. * @returns the internal step
  38711. */
  38712. getInternalStep(): number;
  38713. private _fogEnabled;
  38714. /**
  38715. * Gets or sets a boolean indicating if fog is enabled on this scene
  38716. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38717. * (Default is true)
  38718. */
  38719. set fogEnabled(value: boolean);
  38720. get fogEnabled(): boolean;
  38721. private _fogMode;
  38722. /**
  38723. * Gets or sets the fog mode to use
  38724. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38725. * | mode | value |
  38726. * | --- | --- |
  38727. * | FOGMODE_NONE | 0 |
  38728. * | FOGMODE_EXP | 1 |
  38729. * | FOGMODE_EXP2 | 2 |
  38730. * | FOGMODE_LINEAR | 3 |
  38731. */
  38732. set fogMode(value: number);
  38733. get fogMode(): number;
  38734. /**
  38735. * Gets or sets the fog color to use
  38736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38737. * (Default is Color3(0.2, 0.2, 0.3))
  38738. */
  38739. fogColor: Color3;
  38740. /**
  38741. * Gets or sets the fog density to use
  38742. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38743. * (Default is 0.1)
  38744. */
  38745. fogDensity: number;
  38746. /**
  38747. * Gets or sets the fog start distance to use
  38748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38749. * (Default is 0)
  38750. */
  38751. fogStart: number;
  38752. /**
  38753. * Gets or sets the fog end distance to use
  38754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38755. * (Default is 1000)
  38756. */
  38757. fogEnd: number;
  38758. private _shadowsEnabled;
  38759. /**
  38760. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38761. */
  38762. set shadowsEnabled(value: boolean);
  38763. get shadowsEnabled(): boolean;
  38764. private _lightsEnabled;
  38765. /**
  38766. * Gets or sets a boolean indicating if lights are enabled on this scene
  38767. */
  38768. set lightsEnabled(value: boolean);
  38769. get lightsEnabled(): boolean;
  38770. /** All of the active cameras added to this scene. */
  38771. activeCameras: Camera[];
  38772. /** @hidden */
  38773. _activeCamera: Nullable<Camera>;
  38774. /** Gets or sets the current active camera */
  38775. get activeCamera(): Nullable<Camera>;
  38776. set activeCamera(value: Nullable<Camera>);
  38777. private _defaultMaterial;
  38778. /** The default material used on meshes when no material is affected */
  38779. get defaultMaterial(): Material;
  38780. /** The default material used on meshes when no material is affected */
  38781. set defaultMaterial(value: Material);
  38782. private _texturesEnabled;
  38783. /**
  38784. * Gets or sets a boolean indicating if textures are enabled on this scene
  38785. */
  38786. set texturesEnabled(value: boolean);
  38787. get texturesEnabled(): boolean;
  38788. /**
  38789. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38790. */
  38791. physicsEnabled: boolean;
  38792. /**
  38793. * Gets or sets a boolean indicating if particles are enabled on this scene
  38794. */
  38795. particlesEnabled: boolean;
  38796. /**
  38797. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38798. */
  38799. spritesEnabled: boolean;
  38800. private _skeletonsEnabled;
  38801. /**
  38802. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38803. */
  38804. set skeletonsEnabled(value: boolean);
  38805. get skeletonsEnabled(): boolean;
  38806. /**
  38807. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38808. */
  38809. lensFlaresEnabled: boolean;
  38810. /**
  38811. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38813. */
  38814. collisionsEnabled: boolean;
  38815. private _collisionCoordinator;
  38816. /** @hidden */
  38817. get collisionCoordinator(): ICollisionCoordinator;
  38818. /**
  38819. * Defines the gravity applied to this scene (used only for collisions)
  38820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38821. */
  38822. gravity: Vector3;
  38823. /**
  38824. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38825. */
  38826. postProcessesEnabled: boolean;
  38827. /**
  38828. * The list of postprocesses added to the scene
  38829. */
  38830. postProcesses: PostProcess[];
  38831. /**
  38832. * Gets the current postprocess manager
  38833. */
  38834. postProcessManager: PostProcessManager;
  38835. /**
  38836. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38837. */
  38838. renderTargetsEnabled: boolean;
  38839. /**
  38840. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38841. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38842. */
  38843. dumpNextRenderTargets: boolean;
  38844. /**
  38845. * The list of user defined render targets added to the scene
  38846. */
  38847. customRenderTargets: RenderTargetTexture[];
  38848. /**
  38849. * Defines if texture loading must be delayed
  38850. * If true, textures will only be loaded when they need to be rendered
  38851. */
  38852. useDelayedTextureLoading: boolean;
  38853. /**
  38854. * Gets the list of meshes imported to the scene through SceneLoader
  38855. */
  38856. importedMeshesFiles: String[];
  38857. /**
  38858. * Gets or sets a boolean indicating if probes are enabled on this scene
  38859. */
  38860. probesEnabled: boolean;
  38861. /**
  38862. * Gets or sets the current offline provider to use to store scene data
  38863. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38864. */
  38865. offlineProvider: IOfflineProvider;
  38866. /**
  38867. * Gets or sets the action manager associated with the scene
  38868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38869. */
  38870. actionManager: AbstractActionManager;
  38871. private _meshesForIntersections;
  38872. /**
  38873. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38874. */
  38875. proceduralTexturesEnabled: boolean;
  38876. private _engine;
  38877. private _totalVertices;
  38878. /** @hidden */
  38879. _activeIndices: PerfCounter;
  38880. /** @hidden */
  38881. _activeParticles: PerfCounter;
  38882. /** @hidden */
  38883. _activeBones: PerfCounter;
  38884. private _animationRatio;
  38885. /** @hidden */
  38886. _animationTimeLast: number;
  38887. /** @hidden */
  38888. _animationTime: number;
  38889. /**
  38890. * Gets or sets a general scale for animation speed
  38891. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38892. */
  38893. animationTimeScale: number;
  38894. /** @hidden */
  38895. _cachedMaterial: Nullable<Material>;
  38896. /** @hidden */
  38897. _cachedEffect: Nullable<Effect>;
  38898. /** @hidden */
  38899. _cachedVisibility: Nullable<number>;
  38900. private _renderId;
  38901. private _frameId;
  38902. private _executeWhenReadyTimeoutId;
  38903. private _intermediateRendering;
  38904. private _viewUpdateFlag;
  38905. private _projectionUpdateFlag;
  38906. /** @hidden */
  38907. _toBeDisposed: Nullable<IDisposable>[];
  38908. private _activeRequests;
  38909. /** @hidden */
  38910. _pendingData: any[];
  38911. private _isDisposed;
  38912. /**
  38913. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38914. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38915. */
  38916. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38917. private _activeMeshes;
  38918. private _processedMaterials;
  38919. private _renderTargets;
  38920. /** @hidden */
  38921. _activeParticleSystems: SmartArray<IParticleSystem>;
  38922. private _activeSkeletons;
  38923. private _softwareSkinnedMeshes;
  38924. private _renderingManager;
  38925. /** @hidden */
  38926. _activeAnimatables: Animatable[];
  38927. private _transformMatrix;
  38928. private _sceneUbo;
  38929. /** @hidden */
  38930. _viewMatrix: Matrix;
  38931. private _projectionMatrix;
  38932. /** @hidden */
  38933. _forcedViewPosition: Nullable<Vector3>;
  38934. /** @hidden */
  38935. _frustumPlanes: Plane[];
  38936. /**
  38937. * Gets the list of frustum planes (built from the active camera)
  38938. */
  38939. get frustumPlanes(): Plane[];
  38940. /**
  38941. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38942. * This is useful if there are more lights that the maximum simulteanous authorized
  38943. */
  38944. requireLightSorting: boolean;
  38945. /** @hidden */
  38946. readonly useMaterialMeshMap: boolean;
  38947. /** @hidden */
  38948. readonly useClonedMeshMap: boolean;
  38949. private _externalData;
  38950. private _uid;
  38951. /**
  38952. * @hidden
  38953. * Backing store of defined scene components.
  38954. */
  38955. _components: ISceneComponent[];
  38956. /**
  38957. * @hidden
  38958. * Backing store of defined scene components.
  38959. */
  38960. _serializableComponents: ISceneSerializableComponent[];
  38961. /**
  38962. * List of components to register on the next registration step.
  38963. */
  38964. private _transientComponents;
  38965. /**
  38966. * Registers the transient components if needed.
  38967. */
  38968. private _registerTransientComponents;
  38969. /**
  38970. * @hidden
  38971. * Add a component to the scene.
  38972. * Note that the ccomponent could be registered on th next frame if this is called after
  38973. * the register component stage.
  38974. * @param component Defines the component to add to the scene
  38975. */
  38976. _addComponent(component: ISceneComponent): void;
  38977. /**
  38978. * @hidden
  38979. * Gets a component from the scene.
  38980. * @param name defines the name of the component to retrieve
  38981. * @returns the component or null if not present
  38982. */
  38983. _getComponent(name: string): Nullable<ISceneComponent>;
  38984. /**
  38985. * @hidden
  38986. * Defines the actions happening before camera updates.
  38987. */
  38988. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38989. /**
  38990. * @hidden
  38991. * Defines the actions happening before clear the canvas.
  38992. */
  38993. _beforeClearStage: Stage<SimpleStageAction>;
  38994. /**
  38995. * @hidden
  38996. * Defines the actions when collecting render targets for the frame.
  38997. */
  38998. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38999. /**
  39000. * @hidden
  39001. * Defines the actions happening for one camera in the frame.
  39002. */
  39003. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39004. /**
  39005. * @hidden
  39006. * Defines the actions happening during the per mesh ready checks.
  39007. */
  39008. _isReadyForMeshStage: Stage<MeshStageAction>;
  39009. /**
  39010. * @hidden
  39011. * Defines the actions happening before evaluate active mesh checks.
  39012. */
  39013. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39014. /**
  39015. * @hidden
  39016. * Defines the actions happening during the evaluate sub mesh checks.
  39017. */
  39018. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39019. /**
  39020. * @hidden
  39021. * Defines the actions happening during the active mesh stage.
  39022. */
  39023. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39024. /**
  39025. * @hidden
  39026. * Defines the actions happening during the per camera render target step.
  39027. */
  39028. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39029. /**
  39030. * @hidden
  39031. * Defines the actions happening just before the active camera is drawing.
  39032. */
  39033. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39034. /**
  39035. * @hidden
  39036. * Defines the actions happening just before a render target is drawing.
  39037. */
  39038. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39039. /**
  39040. * @hidden
  39041. * Defines the actions happening just before a rendering group is drawing.
  39042. */
  39043. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39044. /**
  39045. * @hidden
  39046. * Defines the actions happening just before a mesh is drawing.
  39047. */
  39048. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39049. /**
  39050. * @hidden
  39051. * Defines the actions happening just after a mesh has been drawn.
  39052. */
  39053. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39054. /**
  39055. * @hidden
  39056. * Defines the actions happening just after a rendering group has been drawn.
  39057. */
  39058. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39059. /**
  39060. * @hidden
  39061. * Defines the actions happening just after the active camera has been drawn.
  39062. */
  39063. _afterCameraDrawStage: Stage<CameraStageAction>;
  39064. /**
  39065. * @hidden
  39066. * Defines the actions happening just after a render target has been drawn.
  39067. */
  39068. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39069. /**
  39070. * @hidden
  39071. * Defines the actions happening just after rendering all cameras and computing intersections.
  39072. */
  39073. _afterRenderStage: Stage<SimpleStageAction>;
  39074. /**
  39075. * @hidden
  39076. * Defines the actions happening when a pointer move event happens.
  39077. */
  39078. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39079. /**
  39080. * @hidden
  39081. * Defines the actions happening when a pointer down event happens.
  39082. */
  39083. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39084. /**
  39085. * @hidden
  39086. * Defines the actions happening when a pointer up event happens.
  39087. */
  39088. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39089. /**
  39090. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39091. */
  39092. private geometriesByUniqueId;
  39093. /**
  39094. * Creates a new Scene
  39095. * @param engine defines the engine to use to render this scene
  39096. * @param options defines the scene options
  39097. */
  39098. constructor(engine: Engine, options?: SceneOptions);
  39099. /**
  39100. * Gets a string idenfifying the name of the class
  39101. * @returns "Scene" string
  39102. */
  39103. getClassName(): string;
  39104. private _defaultMeshCandidates;
  39105. /**
  39106. * @hidden
  39107. */
  39108. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39109. private _defaultSubMeshCandidates;
  39110. /**
  39111. * @hidden
  39112. */
  39113. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39114. /**
  39115. * Sets the default candidate providers for the scene.
  39116. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39117. * and getCollidingSubMeshCandidates to their default function
  39118. */
  39119. setDefaultCandidateProviders(): void;
  39120. /**
  39121. * Gets the mesh that is currently under the pointer
  39122. */
  39123. get meshUnderPointer(): Nullable<AbstractMesh>;
  39124. /**
  39125. * Gets or sets the current on-screen X position of the pointer
  39126. */
  39127. get pointerX(): number;
  39128. set pointerX(value: number);
  39129. /**
  39130. * Gets or sets the current on-screen Y position of the pointer
  39131. */
  39132. get pointerY(): number;
  39133. set pointerY(value: number);
  39134. /**
  39135. * Gets the cached material (ie. the latest rendered one)
  39136. * @returns the cached material
  39137. */
  39138. getCachedMaterial(): Nullable<Material>;
  39139. /**
  39140. * Gets the cached effect (ie. the latest rendered one)
  39141. * @returns the cached effect
  39142. */
  39143. getCachedEffect(): Nullable<Effect>;
  39144. /**
  39145. * Gets the cached visibility state (ie. the latest rendered one)
  39146. * @returns the cached visibility state
  39147. */
  39148. getCachedVisibility(): Nullable<number>;
  39149. /**
  39150. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39151. * @param material defines the current material
  39152. * @param effect defines the current effect
  39153. * @param visibility defines the current visibility state
  39154. * @returns true if one parameter is not cached
  39155. */
  39156. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39157. /**
  39158. * Gets the engine associated with the scene
  39159. * @returns an Engine
  39160. */
  39161. getEngine(): Engine;
  39162. /**
  39163. * Gets the total number of vertices rendered per frame
  39164. * @returns the total number of vertices rendered per frame
  39165. */
  39166. getTotalVertices(): number;
  39167. /**
  39168. * Gets the performance counter for total vertices
  39169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39170. */
  39171. get totalVerticesPerfCounter(): PerfCounter;
  39172. /**
  39173. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39174. * @returns the total number of active indices rendered per frame
  39175. */
  39176. getActiveIndices(): number;
  39177. /**
  39178. * Gets the performance counter for active indices
  39179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39180. */
  39181. get totalActiveIndicesPerfCounter(): PerfCounter;
  39182. /**
  39183. * Gets the total number of active particles rendered per frame
  39184. * @returns the total number of active particles rendered per frame
  39185. */
  39186. getActiveParticles(): number;
  39187. /**
  39188. * Gets the performance counter for active particles
  39189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39190. */
  39191. get activeParticlesPerfCounter(): PerfCounter;
  39192. /**
  39193. * Gets the total number of active bones rendered per frame
  39194. * @returns the total number of active bones rendered per frame
  39195. */
  39196. getActiveBones(): number;
  39197. /**
  39198. * Gets the performance counter for active bones
  39199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39200. */
  39201. get activeBonesPerfCounter(): PerfCounter;
  39202. /**
  39203. * Gets the array of active meshes
  39204. * @returns an array of AbstractMesh
  39205. */
  39206. getActiveMeshes(): SmartArray<AbstractMesh>;
  39207. /**
  39208. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39209. * @returns a number
  39210. */
  39211. getAnimationRatio(): number;
  39212. /**
  39213. * Gets an unique Id for the current render phase
  39214. * @returns a number
  39215. */
  39216. getRenderId(): number;
  39217. /**
  39218. * Gets an unique Id for the current frame
  39219. * @returns a number
  39220. */
  39221. getFrameId(): number;
  39222. /** Call this function if you want to manually increment the render Id*/
  39223. incrementRenderId(): void;
  39224. private _createUbo;
  39225. /**
  39226. * Use this method to simulate a pointer move on a mesh
  39227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39230. * @returns the current scene
  39231. */
  39232. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39233. /**
  39234. * Use this method to simulate a pointer down on a mesh
  39235. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39236. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39237. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39238. * @returns the current scene
  39239. */
  39240. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39241. /**
  39242. * Use this method to simulate a pointer up on a mesh
  39243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39246. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39247. * @returns the current scene
  39248. */
  39249. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39250. /**
  39251. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39252. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39253. * @returns true if the pointer was captured
  39254. */
  39255. isPointerCaptured(pointerId?: number): boolean;
  39256. /**
  39257. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39258. * @param attachUp defines if you want to attach events to pointerup
  39259. * @param attachDown defines if you want to attach events to pointerdown
  39260. * @param attachMove defines if you want to attach events to pointermove
  39261. */
  39262. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39263. /** Detaches all event handlers*/
  39264. detachControl(): void;
  39265. /**
  39266. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39267. * Delay loaded resources are not taking in account
  39268. * @return true if all required resources are ready
  39269. */
  39270. isReady(): boolean;
  39271. /** Resets all cached information relative to material (including effect and visibility) */
  39272. resetCachedMaterial(): void;
  39273. /**
  39274. * Registers a function to be called before every frame render
  39275. * @param func defines the function to register
  39276. */
  39277. registerBeforeRender(func: () => void): void;
  39278. /**
  39279. * Unregisters a function called before every frame render
  39280. * @param func defines the function to unregister
  39281. */
  39282. unregisterBeforeRender(func: () => void): void;
  39283. /**
  39284. * Registers a function to be called after every frame render
  39285. * @param func defines the function to register
  39286. */
  39287. registerAfterRender(func: () => void): void;
  39288. /**
  39289. * Unregisters a function called after every frame render
  39290. * @param func defines the function to unregister
  39291. */
  39292. unregisterAfterRender(func: () => void): void;
  39293. private _executeOnceBeforeRender;
  39294. /**
  39295. * The provided function will run before render once and will be disposed afterwards.
  39296. * A timeout delay can be provided so that the function will be executed in N ms.
  39297. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39298. * @param func The function to be executed.
  39299. * @param timeout optional delay in ms
  39300. */
  39301. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39302. /** @hidden */
  39303. _addPendingData(data: any): void;
  39304. /** @hidden */
  39305. _removePendingData(data: any): void;
  39306. /**
  39307. * Returns the number of items waiting to be loaded
  39308. * @returns the number of items waiting to be loaded
  39309. */
  39310. getWaitingItemsCount(): number;
  39311. /**
  39312. * Returns a boolean indicating if the scene is still loading data
  39313. */
  39314. get isLoading(): boolean;
  39315. /**
  39316. * Registers a function to be executed when the scene is ready
  39317. * @param {Function} func - the function to be executed
  39318. */
  39319. executeWhenReady(func: () => void): void;
  39320. /**
  39321. * Returns a promise that resolves when the scene is ready
  39322. * @returns A promise that resolves when the scene is ready
  39323. */
  39324. whenReadyAsync(): Promise<void>;
  39325. /** @hidden */
  39326. _checkIsReady(): void;
  39327. /**
  39328. * Gets all animatable attached to the scene
  39329. */
  39330. get animatables(): Animatable[];
  39331. /**
  39332. * Resets the last animation time frame.
  39333. * Useful to override when animations start running when loading a scene for the first time.
  39334. */
  39335. resetLastAnimationTimeFrame(): void;
  39336. /**
  39337. * Gets the current view matrix
  39338. * @returns a Matrix
  39339. */
  39340. getViewMatrix(): Matrix;
  39341. /**
  39342. * Gets the current projection matrix
  39343. * @returns a Matrix
  39344. */
  39345. getProjectionMatrix(): Matrix;
  39346. /**
  39347. * Gets the current transform matrix
  39348. * @returns a Matrix made of View * Projection
  39349. */
  39350. getTransformMatrix(): Matrix;
  39351. /**
  39352. * Sets the current transform matrix
  39353. * @param viewL defines the View matrix to use
  39354. * @param projectionL defines the Projection matrix to use
  39355. * @param viewR defines the right View matrix to use (if provided)
  39356. * @param projectionR defines the right Projection matrix to use (if provided)
  39357. */
  39358. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39359. /**
  39360. * Gets the uniform buffer used to store scene data
  39361. * @returns a UniformBuffer
  39362. */
  39363. getSceneUniformBuffer(): UniformBuffer;
  39364. /**
  39365. * Gets an unique (relatively to the current scene) Id
  39366. * @returns an unique number for the scene
  39367. */
  39368. getUniqueId(): number;
  39369. /**
  39370. * Add a mesh to the list of scene's meshes
  39371. * @param newMesh defines the mesh to add
  39372. * @param recursive if all child meshes should also be added to the scene
  39373. */
  39374. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39375. /**
  39376. * Remove a mesh for the list of scene's meshes
  39377. * @param toRemove defines the mesh to remove
  39378. * @param recursive if all child meshes should also be removed from the scene
  39379. * @returns the index where the mesh was in the mesh list
  39380. */
  39381. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39382. /**
  39383. * Add a transform node to the list of scene's transform nodes
  39384. * @param newTransformNode defines the transform node to add
  39385. */
  39386. addTransformNode(newTransformNode: TransformNode): void;
  39387. /**
  39388. * Remove a transform node for the list of scene's transform nodes
  39389. * @param toRemove defines the transform node to remove
  39390. * @returns the index where the transform node was in the transform node list
  39391. */
  39392. removeTransformNode(toRemove: TransformNode): number;
  39393. /**
  39394. * Remove a skeleton for the list of scene's skeletons
  39395. * @param toRemove defines the skeleton to remove
  39396. * @returns the index where the skeleton was in the skeleton list
  39397. */
  39398. removeSkeleton(toRemove: Skeleton): number;
  39399. /**
  39400. * Remove a morph target for the list of scene's morph targets
  39401. * @param toRemove defines the morph target to remove
  39402. * @returns the index where the morph target was in the morph target list
  39403. */
  39404. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39405. /**
  39406. * Remove a light for the list of scene's lights
  39407. * @param toRemove defines the light to remove
  39408. * @returns the index where the light was in the light list
  39409. */
  39410. removeLight(toRemove: Light): number;
  39411. /**
  39412. * Remove a camera for the list of scene's cameras
  39413. * @param toRemove defines the camera to remove
  39414. * @returns the index where the camera was in the camera list
  39415. */
  39416. removeCamera(toRemove: Camera): number;
  39417. /**
  39418. * Remove a particle system for the list of scene's particle systems
  39419. * @param toRemove defines the particle system to remove
  39420. * @returns the index where the particle system was in the particle system list
  39421. */
  39422. removeParticleSystem(toRemove: IParticleSystem): number;
  39423. /**
  39424. * Remove a animation for the list of scene's animations
  39425. * @param toRemove defines the animation to remove
  39426. * @returns the index where the animation was in the animation list
  39427. */
  39428. removeAnimation(toRemove: Animation): number;
  39429. /**
  39430. * Will stop the animation of the given target
  39431. * @param target - the target
  39432. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39433. * @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)
  39434. */
  39435. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39436. /**
  39437. * Removes the given animation group from this scene.
  39438. * @param toRemove The animation group to remove
  39439. * @returns The index of the removed animation group
  39440. */
  39441. removeAnimationGroup(toRemove: AnimationGroup): number;
  39442. /**
  39443. * Removes the given multi-material from this scene.
  39444. * @param toRemove The multi-material to remove
  39445. * @returns The index of the removed multi-material
  39446. */
  39447. removeMultiMaterial(toRemove: MultiMaterial): number;
  39448. /**
  39449. * Removes the given material from this scene.
  39450. * @param toRemove The material to remove
  39451. * @returns The index of the removed material
  39452. */
  39453. removeMaterial(toRemove: Material): number;
  39454. /**
  39455. * Removes the given action manager from this scene.
  39456. * @param toRemove The action manager to remove
  39457. * @returns The index of the removed action manager
  39458. */
  39459. removeActionManager(toRemove: AbstractActionManager): number;
  39460. /**
  39461. * Removes the given texture from this scene.
  39462. * @param toRemove The texture to remove
  39463. * @returns The index of the removed texture
  39464. */
  39465. removeTexture(toRemove: BaseTexture): number;
  39466. /**
  39467. * Adds the given light to this scene
  39468. * @param newLight The light to add
  39469. */
  39470. addLight(newLight: Light): void;
  39471. /**
  39472. * Sorts the list list based on light priorities
  39473. */
  39474. sortLightsByPriority(): void;
  39475. /**
  39476. * Adds the given camera to this scene
  39477. * @param newCamera The camera to add
  39478. */
  39479. addCamera(newCamera: Camera): void;
  39480. /**
  39481. * Adds the given skeleton to this scene
  39482. * @param newSkeleton The skeleton to add
  39483. */
  39484. addSkeleton(newSkeleton: Skeleton): void;
  39485. /**
  39486. * Adds the given particle system to this scene
  39487. * @param newParticleSystem The particle system to add
  39488. */
  39489. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39490. /**
  39491. * Adds the given animation to this scene
  39492. * @param newAnimation The animation to add
  39493. */
  39494. addAnimation(newAnimation: Animation): void;
  39495. /**
  39496. * Adds the given animation group to this scene.
  39497. * @param newAnimationGroup The animation group to add
  39498. */
  39499. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39500. /**
  39501. * Adds the given multi-material to this scene
  39502. * @param newMultiMaterial The multi-material to add
  39503. */
  39504. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39505. /**
  39506. * Adds the given material to this scene
  39507. * @param newMaterial The material to add
  39508. */
  39509. addMaterial(newMaterial: Material): void;
  39510. /**
  39511. * Adds the given morph target to this scene
  39512. * @param newMorphTargetManager The morph target to add
  39513. */
  39514. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39515. /**
  39516. * Adds the given geometry to this scene
  39517. * @param newGeometry The geometry to add
  39518. */
  39519. addGeometry(newGeometry: Geometry): void;
  39520. /**
  39521. * Adds the given action manager to this scene
  39522. * @param newActionManager The action manager to add
  39523. */
  39524. addActionManager(newActionManager: AbstractActionManager): void;
  39525. /**
  39526. * Adds the given texture to this scene.
  39527. * @param newTexture The texture to add
  39528. */
  39529. addTexture(newTexture: BaseTexture): void;
  39530. /**
  39531. * Switch active camera
  39532. * @param newCamera defines the new active camera
  39533. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39534. */
  39535. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39536. /**
  39537. * sets the active camera of the scene using its ID
  39538. * @param id defines the camera's ID
  39539. * @return the new active camera or null if none found.
  39540. */
  39541. setActiveCameraByID(id: string): Nullable<Camera>;
  39542. /**
  39543. * sets the active camera of the scene using its name
  39544. * @param name defines the camera's name
  39545. * @returns the new active camera or null if none found.
  39546. */
  39547. setActiveCameraByName(name: string): Nullable<Camera>;
  39548. /**
  39549. * get an animation group using its name
  39550. * @param name defines the material's name
  39551. * @return the animation group or null if none found.
  39552. */
  39553. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39554. /**
  39555. * Get a material using its unique id
  39556. * @param uniqueId defines the material's unique id
  39557. * @return the material or null if none found.
  39558. */
  39559. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39560. /**
  39561. * get a material using its id
  39562. * @param id defines the material's ID
  39563. * @return the material or null if none found.
  39564. */
  39565. getMaterialByID(id: string): Nullable<Material>;
  39566. /**
  39567. * Gets a the last added material using a given id
  39568. * @param id defines the material's ID
  39569. * @return the last material with the given id or null if none found.
  39570. */
  39571. getLastMaterialByID(id: string): Nullable<Material>;
  39572. /**
  39573. * Gets a material using its name
  39574. * @param name defines the material's name
  39575. * @return the material or null if none found.
  39576. */
  39577. getMaterialByName(name: string): Nullable<Material>;
  39578. /**
  39579. * Get a texture using its unique id
  39580. * @param uniqueId defines the texture's unique id
  39581. * @return the texture or null if none found.
  39582. */
  39583. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39584. /**
  39585. * Gets a camera using its id
  39586. * @param id defines the id to look for
  39587. * @returns the camera or null if not found
  39588. */
  39589. getCameraByID(id: string): Nullable<Camera>;
  39590. /**
  39591. * Gets a camera using its unique id
  39592. * @param uniqueId defines the unique id to look for
  39593. * @returns the camera or null if not found
  39594. */
  39595. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39596. /**
  39597. * Gets a camera using its name
  39598. * @param name defines the camera's name
  39599. * @return the camera or null if none found.
  39600. */
  39601. getCameraByName(name: string): Nullable<Camera>;
  39602. /**
  39603. * Gets a bone using its id
  39604. * @param id defines the bone's id
  39605. * @return the bone or null if not found
  39606. */
  39607. getBoneByID(id: string): Nullable<Bone>;
  39608. /**
  39609. * Gets a bone using its id
  39610. * @param name defines the bone's name
  39611. * @return the bone or null if not found
  39612. */
  39613. getBoneByName(name: string): Nullable<Bone>;
  39614. /**
  39615. * Gets a light node using its name
  39616. * @param name defines the the light's name
  39617. * @return the light or null if none found.
  39618. */
  39619. getLightByName(name: string): Nullable<Light>;
  39620. /**
  39621. * Gets a light node using its id
  39622. * @param id defines the light's id
  39623. * @return the light or null if none found.
  39624. */
  39625. getLightByID(id: string): Nullable<Light>;
  39626. /**
  39627. * Gets a light node using its scene-generated unique ID
  39628. * @param uniqueId defines the light's unique id
  39629. * @return the light or null if none found.
  39630. */
  39631. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39632. /**
  39633. * Gets a particle system by id
  39634. * @param id defines the particle system id
  39635. * @return the corresponding system or null if none found
  39636. */
  39637. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39638. /**
  39639. * Gets a geometry using its ID
  39640. * @param id defines the geometry's id
  39641. * @return the geometry or null if none found.
  39642. */
  39643. getGeometryByID(id: string): Nullable<Geometry>;
  39644. private _getGeometryByUniqueID;
  39645. /**
  39646. * Add a new geometry to this scene
  39647. * @param geometry defines the geometry to be added to the scene.
  39648. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39649. * @return a boolean defining if the geometry was added or not
  39650. */
  39651. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39652. /**
  39653. * Removes an existing geometry
  39654. * @param geometry defines the geometry to be removed from the scene
  39655. * @return a boolean defining if the geometry was removed or not
  39656. */
  39657. removeGeometry(geometry: Geometry): boolean;
  39658. /**
  39659. * Gets the list of geometries attached to the scene
  39660. * @returns an array of Geometry
  39661. */
  39662. getGeometries(): Geometry[];
  39663. /**
  39664. * Gets the first added mesh found of a given ID
  39665. * @param id defines the id to search for
  39666. * @return the mesh found or null if not found at all
  39667. */
  39668. getMeshByID(id: string): Nullable<AbstractMesh>;
  39669. /**
  39670. * Gets a list of meshes using their id
  39671. * @param id defines the id to search for
  39672. * @returns a list of meshes
  39673. */
  39674. getMeshesByID(id: string): Array<AbstractMesh>;
  39675. /**
  39676. * Gets the first added transform node found of a given ID
  39677. * @param id defines the id to search for
  39678. * @return the found transform node or null if not found at all.
  39679. */
  39680. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39681. /**
  39682. * Gets a transform node with its auto-generated unique id
  39683. * @param uniqueId efines the unique id to search for
  39684. * @return the found transform node or null if not found at all.
  39685. */
  39686. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39687. /**
  39688. * Gets a list of transform nodes using their id
  39689. * @param id defines the id to search for
  39690. * @returns a list of transform nodes
  39691. */
  39692. getTransformNodesByID(id: string): Array<TransformNode>;
  39693. /**
  39694. * Gets a mesh with its auto-generated unique id
  39695. * @param uniqueId defines the unique id to search for
  39696. * @return the found mesh or null if not found at all.
  39697. */
  39698. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39699. /**
  39700. * Gets a the last added mesh using a given id
  39701. * @param id defines the id to search for
  39702. * @return the found mesh or null if not found at all.
  39703. */
  39704. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39705. /**
  39706. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39707. * @param id defines the id to search for
  39708. * @return the found node or null if not found at all
  39709. */
  39710. getLastEntryByID(id: string): Nullable<Node>;
  39711. /**
  39712. * Gets a node (Mesh, Camera, Light) using a given id
  39713. * @param id defines the id to search for
  39714. * @return the found node or null if not found at all
  39715. */
  39716. getNodeByID(id: string): Nullable<Node>;
  39717. /**
  39718. * Gets a node (Mesh, Camera, Light) using a given name
  39719. * @param name defines the name to search for
  39720. * @return the found node or null if not found at all.
  39721. */
  39722. getNodeByName(name: string): Nullable<Node>;
  39723. /**
  39724. * Gets a mesh using a given name
  39725. * @param name defines the name to search for
  39726. * @return the found mesh or null if not found at all.
  39727. */
  39728. getMeshByName(name: string): Nullable<AbstractMesh>;
  39729. /**
  39730. * Gets a transform node using a given name
  39731. * @param name defines the name to search for
  39732. * @return the found transform node or null if not found at all.
  39733. */
  39734. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39735. /**
  39736. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39737. * @param id defines the id to search for
  39738. * @return the found skeleton or null if not found at all.
  39739. */
  39740. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39741. /**
  39742. * Gets a skeleton using a given auto generated unique id
  39743. * @param uniqueId defines the unique id to search for
  39744. * @return the found skeleton or null if not found at all.
  39745. */
  39746. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39747. /**
  39748. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39749. * @param id defines the id to search for
  39750. * @return the found skeleton or null if not found at all.
  39751. */
  39752. getSkeletonById(id: string): Nullable<Skeleton>;
  39753. /**
  39754. * Gets a skeleton using a given name
  39755. * @param name defines the name to search for
  39756. * @return the found skeleton or null if not found at all.
  39757. */
  39758. getSkeletonByName(name: string): Nullable<Skeleton>;
  39759. /**
  39760. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39761. * @param id defines the id to search for
  39762. * @return the found morph target manager or null if not found at all.
  39763. */
  39764. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39765. /**
  39766. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39767. * @param id defines the id to search for
  39768. * @return the found morph target or null if not found at all.
  39769. */
  39770. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39771. /**
  39772. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39773. * @param name defines the name to search for
  39774. * @return the found morph target or null if not found at all.
  39775. */
  39776. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39777. /**
  39778. * Gets a boolean indicating if the given mesh is active
  39779. * @param mesh defines the mesh to look for
  39780. * @returns true if the mesh is in the active list
  39781. */
  39782. isActiveMesh(mesh: AbstractMesh): boolean;
  39783. /**
  39784. * Return a unique id as a string which can serve as an identifier for the scene
  39785. */
  39786. get uid(): string;
  39787. /**
  39788. * Add an externaly attached data from its key.
  39789. * This method call will fail and return false, if such key already exists.
  39790. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39791. * @param key the unique key that identifies the data
  39792. * @param data the data object to associate to the key for this Engine instance
  39793. * @return true if no such key were already present and the data was added successfully, false otherwise
  39794. */
  39795. addExternalData<T>(key: string, data: T): boolean;
  39796. /**
  39797. * Get an externaly attached data from its key
  39798. * @param key the unique key that identifies the data
  39799. * @return the associated data, if present (can be null), or undefined if not present
  39800. */
  39801. getExternalData<T>(key: string): Nullable<T>;
  39802. /**
  39803. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39804. * @param key the unique key that identifies the data
  39805. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39806. * @return the associated data, can be null if the factory returned null.
  39807. */
  39808. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39809. /**
  39810. * Remove an externaly attached data from the Engine instance
  39811. * @param key the unique key that identifies the data
  39812. * @return true if the data was successfully removed, false if it doesn't exist
  39813. */
  39814. removeExternalData(key: string): boolean;
  39815. private _evaluateSubMesh;
  39816. /**
  39817. * Clear the processed materials smart array preventing retention point in material dispose.
  39818. */
  39819. freeProcessedMaterials(): void;
  39820. private _preventFreeActiveMeshesAndRenderingGroups;
  39821. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39822. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39823. * when disposing several meshes in a row or a hierarchy of meshes.
  39824. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39825. */
  39826. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39827. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39828. /**
  39829. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39830. */
  39831. freeActiveMeshes(): void;
  39832. /**
  39833. * Clear the info related to rendering groups preventing retention points during dispose.
  39834. */
  39835. freeRenderingGroups(): void;
  39836. /** @hidden */
  39837. _isInIntermediateRendering(): boolean;
  39838. /**
  39839. * Lambda returning the list of potentially active meshes.
  39840. */
  39841. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39842. /**
  39843. * Lambda returning the list of potentially active sub meshes.
  39844. */
  39845. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39846. /**
  39847. * Lambda returning the list of potentially intersecting sub meshes.
  39848. */
  39849. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39850. /**
  39851. * Lambda returning the list of potentially colliding sub meshes.
  39852. */
  39853. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39854. private _activeMeshesFrozen;
  39855. private _skipEvaluateActiveMeshesCompletely;
  39856. /**
  39857. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39858. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39859. * @returns the current scene
  39860. */
  39861. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39862. /**
  39863. * Use this function to restart evaluating active meshes on every frame
  39864. * @returns the current scene
  39865. */
  39866. unfreezeActiveMeshes(): Scene;
  39867. private _evaluateActiveMeshes;
  39868. private _activeMesh;
  39869. /**
  39870. * Update the transform matrix to update from the current active camera
  39871. * @param force defines a boolean used to force the update even if cache is up to date
  39872. */
  39873. updateTransformMatrix(force?: boolean): void;
  39874. private _bindFrameBuffer;
  39875. /** @hidden */
  39876. _allowPostProcessClearColor: boolean;
  39877. /** @hidden */
  39878. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39879. private _processSubCameras;
  39880. private _checkIntersections;
  39881. /** @hidden */
  39882. _advancePhysicsEngineStep(step: number): void;
  39883. /**
  39884. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39885. */
  39886. getDeterministicFrameTime: () => number;
  39887. /** @hidden */
  39888. _animate(): void;
  39889. /** Execute all animations (for a frame) */
  39890. animate(): void;
  39891. /**
  39892. * Render the scene
  39893. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39894. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39895. */
  39896. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39897. /**
  39898. * Freeze all materials
  39899. * A frozen material will not be updatable but should be faster to render
  39900. */
  39901. freezeMaterials(): void;
  39902. /**
  39903. * Unfreeze all materials
  39904. * A frozen material will not be updatable but should be faster to render
  39905. */
  39906. unfreezeMaterials(): void;
  39907. /**
  39908. * Releases all held ressources
  39909. */
  39910. dispose(): void;
  39911. /**
  39912. * Gets if the scene is already disposed
  39913. */
  39914. get isDisposed(): boolean;
  39915. /**
  39916. * Call this function to reduce memory footprint of the scene.
  39917. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39918. */
  39919. clearCachedVertexData(): void;
  39920. /**
  39921. * This function will remove the local cached buffer data from texture.
  39922. * It will save memory but will prevent the texture from being rebuilt
  39923. */
  39924. cleanCachedTextureBuffer(): void;
  39925. /**
  39926. * Get the world extend vectors with an optional filter
  39927. *
  39928. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39929. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39930. */
  39931. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39932. min: Vector3;
  39933. max: Vector3;
  39934. };
  39935. /**
  39936. * Creates a ray that can be used to pick in the scene
  39937. * @param x defines the x coordinate of the origin (on-screen)
  39938. * @param y defines the y coordinate of the origin (on-screen)
  39939. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39940. * @param camera defines the camera to use for the picking
  39941. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39942. * @returns a Ray
  39943. */
  39944. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39945. /**
  39946. * Creates a ray that can be used to pick in the scene
  39947. * @param x defines the x coordinate of the origin (on-screen)
  39948. * @param y defines the y coordinate of the origin (on-screen)
  39949. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39950. * @param result defines the ray where to store the picking ray
  39951. * @param camera defines the camera to use for the picking
  39952. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39953. * @returns the current scene
  39954. */
  39955. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39956. /**
  39957. * Creates a ray that can be used to pick in the scene
  39958. * @param x defines the x coordinate of the origin (on-screen)
  39959. * @param y defines the y coordinate of the origin (on-screen)
  39960. * @param camera defines the camera to use for the picking
  39961. * @returns a Ray
  39962. */
  39963. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39964. /**
  39965. * Creates a ray that can be used to pick in the scene
  39966. * @param x defines the x coordinate of the origin (on-screen)
  39967. * @param y defines the y coordinate of the origin (on-screen)
  39968. * @param result defines the ray where to store the picking ray
  39969. * @param camera defines the camera to use for the picking
  39970. * @returns the current scene
  39971. */
  39972. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39973. /** Launch a ray to try to pick a mesh in the scene
  39974. * @param x position on screen
  39975. * @param y position on screen
  39976. * @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
  39977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39978. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39979. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39980. * @returns a PickingInfo
  39981. */
  39982. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39983. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39984. * @param x position on screen
  39985. * @param y position on screen
  39986. * @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
  39987. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39988. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39989. * @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)
  39990. */
  39991. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39992. /** Use the given ray to pick a mesh in the scene
  39993. * @param ray The ray to use to pick meshes
  39994. * @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
  39995. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39996. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39997. * @returns a PickingInfo
  39998. */
  39999. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40000. /**
  40001. * Launch a ray to try to pick a mesh in the scene
  40002. * @param x X position on screen
  40003. * @param y Y position on screen
  40004. * @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
  40005. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40006. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40007. * @returns an array of PickingInfo
  40008. */
  40009. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40010. /**
  40011. * Launch a ray to try to pick a mesh in the scene
  40012. * @param ray Ray to use
  40013. * @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
  40014. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40015. * @returns an array of PickingInfo
  40016. */
  40017. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40018. /**
  40019. * Force the value of meshUnderPointer
  40020. * @param mesh defines the mesh to use
  40021. */
  40022. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40023. /**
  40024. * Gets the mesh under the pointer
  40025. * @returns a Mesh or null if no mesh is under the pointer
  40026. */
  40027. getPointerOverMesh(): Nullable<AbstractMesh>;
  40028. /** @hidden */
  40029. _rebuildGeometries(): void;
  40030. /** @hidden */
  40031. _rebuildTextures(): void;
  40032. private _getByTags;
  40033. /**
  40034. * Get a list of meshes by tags
  40035. * @param tagsQuery defines the tags query to use
  40036. * @param forEach defines a predicate used to filter results
  40037. * @returns an array of Mesh
  40038. */
  40039. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40040. /**
  40041. * Get a list of cameras by tags
  40042. * @param tagsQuery defines the tags query to use
  40043. * @param forEach defines a predicate used to filter results
  40044. * @returns an array of Camera
  40045. */
  40046. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40047. /**
  40048. * Get a list of lights by tags
  40049. * @param tagsQuery defines the tags query to use
  40050. * @param forEach defines a predicate used to filter results
  40051. * @returns an array of Light
  40052. */
  40053. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40054. /**
  40055. * Get a list of materials by tags
  40056. * @param tagsQuery defines the tags query to use
  40057. * @param forEach defines a predicate used to filter results
  40058. * @returns an array of Material
  40059. */
  40060. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40061. /**
  40062. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40063. * This allowed control for front to back rendering or reversly depending of the special needs.
  40064. *
  40065. * @param renderingGroupId The rendering group id corresponding to its index
  40066. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40067. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40068. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40069. */
  40070. 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;
  40071. /**
  40072. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40073. *
  40074. * @param renderingGroupId The rendering group id corresponding to its index
  40075. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40076. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40077. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40078. */
  40079. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40080. /**
  40081. * Gets the current auto clear configuration for one rendering group of the rendering
  40082. * manager.
  40083. * @param index the rendering group index to get the information for
  40084. * @returns The auto clear setup for the requested rendering group
  40085. */
  40086. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40087. private _blockMaterialDirtyMechanism;
  40088. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40089. get blockMaterialDirtyMechanism(): boolean;
  40090. set blockMaterialDirtyMechanism(value: boolean);
  40091. /**
  40092. * Will flag all materials as dirty to trigger new shader compilation
  40093. * @param flag defines the flag used to specify which material part must be marked as dirty
  40094. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40095. */
  40096. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40097. /** @hidden */
  40098. _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;
  40099. /** @hidden */
  40100. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40101. /** @hidden */
  40102. _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;
  40103. /** @hidden */
  40104. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40105. /** @hidden */
  40106. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40107. /** @hidden */
  40108. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40109. }
  40110. }
  40111. declare module BABYLON {
  40112. /**
  40113. * Set of assets to keep when moving a scene into an asset container.
  40114. */
  40115. export class KeepAssets extends AbstractScene {
  40116. }
  40117. /**
  40118. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40119. */
  40120. export class InstantiatedEntries {
  40121. /**
  40122. * List of new root nodes (eg. nodes with no parent)
  40123. */
  40124. rootNodes: TransformNode[];
  40125. /**
  40126. * List of new skeletons
  40127. */
  40128. skeletons: Skeleton[];
  40129. /**
  40130. * List of new animation groups
  40131. */
  40132. animationGroups: AnimationGroup[];
  40133. }
  40134. /**
  40135. * Container with a set of assets that can be added or removed from a scene.
  40136. */
  40137. export class AssetContainer extends AbstractScene {
  40138. private _wasAddedToScene;
  40139. /**
  40140. * The scene the AssetContainer belongs to.
  40141. */
  40142. scene: Scene;
  40143. /**
  40144. * Instantiates an AssetContainer.
  40145. * @param scene The scene the AssetContainer belongs to.
  40146. */
  40147. constructor(scene: Scene);
  40148. /**
  40149. * Instantiate or clone all meshes and add the new ones to the scene.
  40150. * Skeletons and animation groups will all be cloned
  40151. * @param nameFunction defines an optional function used to get new names for clones
  40152. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40153. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40154. */
  40155. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40156. /**
  40157. * Adds all the assets from the container to the scene.
  40158. */
  40159. addAllToScene(): void;
  40160. /**
  40161. * Removes all the assets in the container from the scene
  40162. */
  40163. removeAllFromScene(): void;
  40164. /**
  40165. * Disposes all the assets in the container
  40166. */
  40167. dispose(): void;
  40168. private _moveAssets;
  40169. /**
  40170. * Removes all the assets contained in the scene and adds them to the container.
  40171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40172. */
  40173. moveAllFromScene(keepAssets?: KeepAssets): void;
  40174. /**
  40175. * 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.
  40176. * @returns the root mesh
  40177. */
  40178. createRootMesh(): Mesh;
  40179. /**
  40180. * Merge animations (direct and animation groups) from this asset container into a scene
  40181. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40182. * @param animatables set of animatables to retarget to a node from the scene
  40183. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40184. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40185. */
  40186. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40187. }
  40188. }
  40189. declare module BABYLON {
  40190. /**
  40191. * Defines how the parser contract is defined.
  40192. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40193. */
  40194. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40195. /**
  40196. * Defines how the individual parser contract is defined.
  40197. * These parser can parse an individual asset
  40198. */
  40199. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40200. /**
  40201. * Base class of the scene acting as a container for the different elements composing a scene.
  40202. * This class is dynamically extended by the different components of the scene increasing
  40203. * flexibility and reducing coupling
  40204. */
  40205. export abstract class AbstractScene {
  40206. /**
  40207. * Stores the list of available parsers in the application.
  40208. */
  40209. private static _BabylonFileParsers;
  40210. /**
  40211. * Stores the list of available individual parsers in the application.
  40212. */
  40213. private static _IndividualBabylonFileParsers;
  40214. /**
  40215. * Adds a parser in the list of available ones
  40216. * @param name Defines the name of the parser
  40217. * @param parser Defines the parser to add
  40218. */
  40219. static AddParser(name: string, parser: BabylonFileParser): void;
  40220. /**
  40221. * Gets a general parser from the list of avaialble ones
  40222. * @param name Defines the name of the parser
  40223. * @returns the requested parser or null
  40224. */
  40225. static GetParser(name: string): Nullable<BabylonFileParser>;
  40226. /**
  40227. * Adds n individual parser in the list of available ones
  40228. * @param name Defines the name of the parser
  40229. * @param parser Defines the parser to add
  40230. */
  40231. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40232. /**
  40233. * Gets an individual parser from the list of avaialble ones
  40234. * @param name Defines the name of the parser
  40235. * @returns the requested parser or null
  40236. */
  40237. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40238. /**
  40239. * Parser json data and populate both a scene and its associated container object
  40240. * @param jsonData Defines the data to parse
  40241. * @param scene Defines the scene to parse the data for
  40242. * @param container Defines the container attached to the parsing sequence
  40243. * @param rootUrl Defines the root url of the data
  40244. */
  40245. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40246. /**
  40247. * Gets the list of root nodes (ie. nodes with no parent)
  40248. */
  40249. rootNodes: Node[];
  40250. /** All of the cameras added to this scene
  40251. * @see http://doc.babylonjs.com/babylon101/cameras
  40252. */
  40253. cameras: Camera[];
  40254. /**
  40255. * All of the lights added to this scene
  40256. * @see http://doc.babylonjs.com/babylon101/lights
  40257. */
  40258. lights: Light[];
  40259. /**
  40260. * All of the (abstract) meshes added to this scene
  40261. */
  40262. meshes: AbstractMesh[];
  40263. /**
  40264. * The list of skeletons added to the scene
  40265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40266. */
  40267. skeletons: Skeleton[];
  40268. /**
  40269. * All of the particle systems added to this scene
  40270. * @see http://doc.babylonjs.com/babylon101/particles
  40271. */
  40272. particleSystems: IParticleSystem[];
  40273. /**
  40274. * Gets a list of Animations associated with the scene
  40275. */
  40276. animations: Animation[];
  40277. /**
  40278. * All of the animation groups added to this scene
  40279. * @see http://doc.babylonjs.com/how_to/group
  40280. */
  40281. animationGroups: AnimationGroup[];
  40282. /**
  40283. * All of the multi-materials added to this scene
  40284. * @see http://doc.babylonjs.com/how_to/multi_materials
  40285. */
  40286. multiMaterials: MultiMaterial[];
  40287. /**
  40288. * All of the materials added to this scene
  40289. * In the context of a Scene, it is not supposed to be modified manually.
  40290. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40291. * Note also that the order of the Material within the array is not significant and might change.
  40292. * @see http://doc.babylonjs.com/babylon101/materials
  40293. */
  40294. materials: Material[];
  40295. /**
  40296. * The list of morph target managers added to the scene
  40297. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40298. */
  40299. morphTargetManagers: MorphTargetManager[];
  40300. /**
  40301. * The list of geometries used in the scene.
  40302. */
  40303. geometries: Geometry[];
  40304. /**
  40305. * All of the tranform nodes added to this scene
  40306. * In the context of a Scene, it is not supposed to be modified manually.
  40307. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40308. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40309. * @see http://doc.babylonjs.com/how_to/transformnode
  40310. */
  40311. transformNodes: TransformNode[];
  40312. /**
  40313. * ActionManagers available on the scene.
  40314. */
  40315. actionManagers: AbstractActionManager[];
  40316. /**
  40317. * Textures to keep.
  40318. */
  40319. textures: BaseTexture[];
  40320. /**
  40321. * Environment texture for the scene
  40322. */
  40323. environmentTexture: Nullable<BaseTexture>;
  40324. /**
  40325. * @returns all meshes, lights, cameras, transformNodes and bones
  40326. */
  40327. getNodes(): Array<Node>;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Interface used to define options for Sound class
  40333. */
  40334. export interface ISoundOptions {
  40335. /**
  40336. * Does the sound autoplay once loaded.
  40337. */
  40338. autoplay?: boolean;
  40339. /**
  40340. * Does the sound loop after it finishes playing once.
  40341. */
  40342. loop?: boolean;
  40343. /**
  40344. * Sound's volume
  40345. */
  40346. volume?: number;
  40347. /**
  40348. * Is it a spatial sound?
  40349. */
  40350. spatialSound?: boolean;
  40351. /**
  40352. * Maximum distance to hear that sound
  40353. */
  40354. maxDistance?: number;
  40355. /**
  40356. * Uses user defined attenuation function
  40357. */
  40358. useCustomAttenuation?: boolean;
  40359. /**
  40360. * Define the roll off factor of spatial sounds.
  40361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40362. */
  40363. rolloffFactor?: number;
  40364. /**
  40365. * Define the reference distance the sound should be heard perfectly.
  40366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40367. */
  40368. refDistance?: number;
  40369. /**
  40370. * Define the distance attenuation model the sound will follow.
  40371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40372. */
  40373. distanceModel?: string;
  40374. /**
  40375. * Defines the playback speed (1 by default)
  40376. */
  40377. playbackRate?: number;
  40378. /**
  40379. * Defines if the sound is from a streaming source
  40380. */
  40381. streaming?: boolean;
  40382. /**
  40383. * Defines an optional length (in seconds) inside the sound file
  40384. */
  40385. length?: number;
  40386. /**
  40387. * Defines an optional offset (in seconds) inside the sound file
  40388. */
  40389. offset?: number;
  40390. /**
  40391. * If true, URLs will not be required to state the audio file codec to use.
  40392. */
  40393. skipCodecCheck?: boolean;
  40394. }
  40395. /**
  40396. * Defines a sound that can be played in the application.
  40397. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40399. */
  40400. export class Sound {
  40401. /**
  40402. * The name of the sound in the scene.
  40403. */
  40404. name: string;
  40405. /**
  40406. * Does the sound autoplay once loaded.
  40407. */
  40408. autoplay: boolean;
  40409. /**
  40410. * Does the sound loop after it finishes playing once.
  40411. */
  40412. loop: boolean;
  40413. /**
  40414. * Does the sound use a custom attenuation curve to simulate the falloff
  40415. * happening when the source gets further away from the camera.
  40416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40417. */
  40418. useCustomAttenuation: boolean;
  40419. /**
  40420. * The sound track id this sound belongs to.
  40421. */
  40422. soundTrackId: number;
  40423. /**
  40424. * Is this sound currently played.
  40425. */
  40426. isPlaying: boolean;
  40427. /**
  40428. * Is this sound currently paused.
  40429. */
  40430. isPaused: boolean;
  40431. /**
  40432. * Does this sound enables spatial sound.
  40433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40434. */
  40435. spatialSound: boolean;
  40436. /**
  40437. * Define the reference distance the sound should be heard perfectly.
  40438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40439. */
  40440. refDistance: number;
  40441. /**
  40442. * Define the roll off factor of spatial sounds.
  40443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40444. */
  40445. rolloffFactor: number;
  40446. /**
  40447. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40449. */
  40450. maxDistance: number;
  40451. /**
  40452. * Define the distance attenuation model the sound will follow.
  40453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40454. */
  40455. distanceModel: string;
  40456. /**
  40457. * @hidden
  40458. * Back Compat
  40459. **/
  40460. onended: () => any;
  40461. /**
  40462. * Gets or sets an object used to store user defined information for the sound.
  40463. */
  40464. metadata: any;
  40465. /**
  40466. * Observable event when the current playing sound finishes.
  40467. */
  40468. onEndedObservable: Observable<Sound>;
  40469. private _panningModel;
  40470. private _playbackRate;
  40471. private _streaming;
  40472. private _startTime;
  40473. private _startOffset;
  40474. private _position;
  40475. /** @hidden */
  40476. _positionInEmitterSpace: boolean;
  40477. private _localDirection;
  40478. private _volume;
  40479. private _isReadyToPlay;
  40480. private _isDirectional;
  40481. private _readyToPlayCallback;
  40482. private _audioBuffer;
  40483. private _soundSource;
  40484. private _streamingSource;
  40485. private _soundPanner;
  40486. private _soundGain;
  40487. private _inputAudioNode;
  40488. private _outputAudioNode;
  40489. private _coneInnerAngle;
  40490. private _coneOuterAngle;
  40491. private _coneOuterGain;
  40492. private _scene;
  40493. private _connectedTransformNode;
  40494. private _customAttenuationFunction;
  40495. private _registerFunc;
  40496. private _isOutputConnected;
  40497. private _htmlAudioElement;
  40498. private _urlType;
  40499. private _length?;
  40500. private _offset?;
  40501. /** @hidden */
  40502. static _SceneComponentInitialization: (scene: Scene) => void;
  40503. /**
  40504. * Create a sound and attach it to a scene
  40505. * @param name Name of your sound
  40506. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40507. * @param scene defines the scene the sound belongs to
  40508. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40509. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40510. */
  40511. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40512. /**
  40513. * Release the sound and its associated resources
  40514. */
  40515. dispose(): void;
  40516. /**
  40517. * Gets if the sounds is ready to be played or not.
  40518. * @returns true if ready, otherwise false
  40519. */
  40520. isReady(): boolean;
  40521. private _soundLoaded;
  40522. /**
  40523. * Sets the data of the sound from an audiobuffer
  40524. * @param audioBuffer The audioBuffer containing the data
  40525. */
  40526. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40527. /**
  40528. * Updates the current sounds options such as maxdistance, loop...
  40529. * @param options A JSON object containing values named as the object properties
  40530. */
  40531. updateOptions(options: ISoundOptions): void;
  40532. private _createSpatialParameters;
  40533. private _updateSpatialParameters;
  40534. /**
  40535. * Switch the panning model to HRTF:
  40536. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40538. */
  40539. switchPanningModelToHRTF(): void;
  40540. /**
  40541. * Switch the panning model to Equal Power:
  40542. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40544. */
  40545. switchPanningModelToEqualPower(): void;
  40546. private _switchPanningModel;
  40547. /**
  40548. * Connect this sound to a sound track audio node like gain...
  40549. * @param soundTrackAudioNode the sound track audio node to connect to
  40550. */
  40551. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40552. /**
  40553. * Transform this sound into a directional source
  40554. * @param coneInnerAngle Size of the inner cone in degree
  40555. * @param coneOuterAngle Size of the outer cone in degree
  40556. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40557. */
  40558. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40559. /**
  40560. * Gets or sets the inner angle for the directional cone.
  40561. */
  40562. get directionalConeInnerAngle(): number;
  40563. /**
  40564. * Gets or sets the inner angle for the directional cone.
  40565. */
  40566. set directionalConeInnerAngle(value: number);
  40567. /**
  40568. * Gets or sets the outer angle for the directional cone.
  40569. */
  40570. get directionalConeOuterAngle(): number;
  40571. /**
  40572. * Gets or sets the outer angle for the directional cone.
  40573. */
  40574. set directionalConeOuterAngle(value: number);
  40575. /**
  40576. * Sets the position of the emitter if spatial sound is enabled
  40577. * @param newPosition Defines the new posisiton
  40578. */
  40579. setPosition(newPosition: Vector3): void;
  40580. /**
  40581. * Sets the local direction of the emitter if spatial sound is enabled
  40582. * @param newLocalDirection Defines the new local direction
  40583. */
  40584. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40585. private _updateDirection;
  40586. /** @hidden */
  40587. updateDistanceFromListener(): void;
  40588. /**
  40589. * Sets a new custom attenuation function for the sound.
  40590. * @param callback Defines the function used for the attenuation
  40591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40592. */
  40593. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40594. /**
  40595. * Play the sound
  40596. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40597. * @param offset (optional) Start the sound at a specific time in seconds
  40598. * @param length (optional) Sound duration (in seconds)
  40599. */
  40600. play(time?: number, offset?: number, length?: number): void;
  40601. private _onended;
  40602. /**
  40603. * Stop the sound
  40604. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40605. */
  40606. stop(time?: number): void;
  40607. /**
  40608. * Put the sound in pause
  40609. */
  40610. pause(): void;
  40611. /**
  40612. * Sets a dedicated volume for this sounds
  40613. * @param newVolume Define the new volume of the sound
  40614. * @param time Define time for gradual change to new volume
  40615. */
  40616. setVolume(newVolume: number, time?: number): void;
  40617. /**
  40618. * Set the sound play back rate
  40619. * @param newPlaybackRate Define the playback rate the sound should be played at
  40620. */
  40621. setPlaybackRate(newPlaybackRate: number): void;
  40622. /**
  40623. * Gets the volume of the sound.
  40624. * @returns the volume of the sound
  40625. */
  40626. getVolume(): number;
  40627. /**
  40628. * Attach the sound to a dedicated mesh
  40629. * @param transformNode The transform node to connect the sound with
  40630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40631. */
  40632. attachToMesh(transformNode: TransformNode): void;
  40633. /**
  40634. * Detach the sound from the previously attached mesh
  40635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40636. */
  40637. detachFromMesh(): void;
  40638. private _onRegisterAfterWorldMatrixUpdate;
  40639. /**
  40640. * Clone the current sound in the scene.
  40641. * @returns the new sound clone
  40642. */
  40643. clone(): Nullable<Sound>;
  40644. /**
  40645. * Gets the current underlying audio buffer containing the data
  40646. * @returns the audio buffer
  40647. */
  40648. getAudioBuffer(): Nullable<AudioBuffer>;
  40649. /**
  40650. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40651. * @returns the source node
  40652. */
  40653. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40654. /**
  40655. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40656. * @returns the gain node
  40657. */
  40658. getSoundGain(): Nullable<GainNode>;
  40659. /**
  40660. * Serializes the Sound in a JSON representation
  40661. * @returns the JSON representation of the sound
  40662. */
  40663. serialize(): any;
  40664. /**
  40665. * Parse a JSON representation of a sound to innstantiate in a given scene
  40666. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40667. * @param scene Define the scene the new parsed sound should be created in
  40668. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40669. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40670. * @returns the newly parsed sound
  40671. */
  40672. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40673. }
  40674. }
  40675. declare module BABYLON {
  40676. /**
  40677. * This defines an action helpful to play a defined sound on a triggered action.
  40678. */
  40679. export class PlaySoundAction extends Action {
  40680. private _sound;
  40681. /**
  40682. * Instantiate the action
  40683. * @param triggerOptions defines the trigger options
  40684. * @param sound defines the sound to play
  40685. * @param condition defines the trigger related conditions
  40686. */
  40687. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40688. /** @hidden */
  40689. _prepare(): void;
  40690. /**
  40691. * Execute the action and play the sound.
  40692. */
  40693. execute(): void;
  40694. /**
  40695. * Serializes the actions and its related information.
  40696. * @param parent defines the object to serialize in
  40697. * @returns the serialized object
  40698. */
  40699. serialize(parent: any): any;
  40700. }
  40701. /**
  40702. * This defines an action helpful to stop a defined sound on a triggered action.
  40703. */
  40704. export class StopSoundAction extends Action {
  40705. private _sound;
  40706. /**
  40707. * Instantiate the action
  40708. * @param triggerOptions defines the trigger options
  40709. * @param sound defines the sound to stop
  40710. * @param condition defines the trigger related conditions
  40711. */
  40712. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40713. /** @hidden */
  40714. _prepare(): void;
  40715. /**
  40716. * Execute the action and stop the sound.
  40717. */
  40718. execute(): void;
  40719. /**
  40720. * Serializes the actions and its related information.
  40721. * @param parent defines the object to serialize in
  40722. * @returns the serialized object
  40723. */
  40724. serialize(parent: any): any;
  40725. }
  40726. }
  40727. declare module BABYLON {
  40728. /**
  40729. * This defines an action responsible to change the value of a property
  40730. * by interpolating between its current value and the newly set one once triggered.
  40731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40732. */
  40733. export class InterpolateValueAction extends Action {
  40734. /**
  40735. * Defines the path of the property where the value should be interpolated
  40736. */
  40737. propertyPath: string;
  40738. /**
  40739. * Defines the target value at the end of the interpolation.
  40740. */
  40741. value: any;
  40742. /**
  40743. * Defines the time it will take for the property to interpolate to the value.
  40744. */
  40745. duration: number;
  40746. /**
  40747. * Defines if the other scene animations should be stopped when the action has been triggered
  40748. */
  40749. stopOtherAnimations?: boolean;
  40750. /**
  40751. * Defines a callback raised once the interpolation animation has been done.
  40752. */
  40753. onInterpolationDone?: () => void;
  40754. /**
  40755. * Observable triggered once the interpolation animation has been done.
  40756. */
  40757. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40758. private _target;
  40759. private _effectiveTarget;
  40760. private _property;
  40761. /**
  40762. * Instantiate the action
  40763. * @param triggerOptions defines the trigger options
  40764. * @param target defines the object containing the value to interpolate
  40765. * @param propertyPath defines the path to the property in the target object
  40766. * @param value defines the target value at the end of the interpolation
  40767. * @param duration deines the time it will take for the property to interpolate to the value.
  40768. * @param condition defines the trigger related conditions
  40769. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40770. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40771. */
  40772. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40773. /** @hidden */
  40774. _prepare(): void;
  40775. /**
  40776. * Execute the action starts the value interpolation.
  40777. */
  40778. execute(): void;
  40779. /**
  40780. * Serializes the actions and its related information.
  40781. * @param parent defines the object to serialize in
  40782. * @returns the serialized object
  40783. */
  40784. serialize(parent: any): any;
  40785. }
  40786. }
  40787. declare module BABYLON {
  40788. /**
  40789. * Options allowed during the creation of a sound track.
  40790. */
  40791. export interface ISoundTrackOptions {
  40792. /**
  40793. * The volume the sound track should take during creation
  40794. */
  40795. volume?: number;
  40796. /**
  40797. * Define if the sound track is the main sound track of the scene
  40798. */
  40799. mainTrack?: boolean;
  40800. }
  40801. /**
  40802. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40803. * It will be also used in a future release to apply effects on a specific track.
  40804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40805. */
  40806. export class SoundTrack {
  40807. /**
  40808. * The unique identifier of the sound track in the scene.
  40809. */
  40810. id: number;
  40811. /**
  40812. * The list of sounds included in the sound track.
  40813. */
  40814. soundCollection: Array<Sound>;
  40815. private _outputAudioNode;
  40816. private _scene;
  40817. private _connectedAnalyser;
  40818. private _options;
  40819. private _isInitialized;
  40820. /**
  40821. * Creates a new sound track.
  40822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40823. * @param scene Define the scene the sound track belongs to
  40824. * @param options
  40825. */
  40826. constructor(scene: Scene, options?: ISoundTrackOptions);
  40827. private _initializeSoundTrackAudioGraph;
  40828. /**
  40829. * Release the sound track and its associated resources
  40830. */
  40831. dispose(): void;
  40832. /**
  40833. * Adds a sound to this sound track
  40834. * @param sound define the cound to add
  40835. * @ignoreNaming
  40836. */
  40837. AddSound(sound: Sound): void;
  40838. /**
  40839. * Removes a sound to this sound track
  40840. * @param sound define the cound to remove
  40841. * @ignoreNaming
  40842. */
  40843. RemoveSound(sound: Sound): void;
  40844. /**
  40845. * Set a global volume for the full sound track.
  40846. * @param newVolume Define the new volume of the sound track
  40847. */
  40848. setVolume(newVolume: number): void;
  40849. /**
  40850. * Switch the panning model to HRTF:
  40851. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40853. */
  40854. switchPanningModelToHRTF(): void;
  40855. /**
  40856. * Switch the panning model to Equal Power:
  40857. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40859. */
  40860. switchPanningModelToEqualPower(): void;
  40861. /**
  40862. * Connect the sound track to an audio analyser allowing some amazing
  40863. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40865. * @param analyser The analyser to connect to the engine
  40866. */
  40867. connectToAnalyser(analyser: Analyser): void;
  40868. }
  40869. }
  40870. declare module BABYLON {
  40871. interface AbstractScene {
  40872. /**
  40873. * The list of sounds used in the scene.
  40874. */
  40875. sounds: Nullable<Array<Sound>>;
  40876. }
  40877. interface Scene {
  40878. /**
  40879. * @hidden
  40880. * Backing field
  40881. */
  40882. _mainSoundTrack: SoundTrack;
  40883. /**
  40884. * The main sound track played by the scene.
  40885. * It cotains your primary collection of sounds.
  40886. */
  40887. mainSoundTrack: SoundTrack;
  40888. /**
  40889. * The list of sound tracks added to the scene
  40890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40891. */
  40892. soundTracks: Nullable<Array<SoundTrack>>;
  40893. /**
  40894. * Gets a sound using a given name
  40895. * @param name defines the name to search for
  40896. * @return the found sound or null if not found at all.
  40897. */
  40898. getSoundByName(name: string): Nullable<Sound>;
  40899. /**
  40900. * Gets or sets if audio support is enabled
  40901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40902. */
  40903. audioEnabled: boolean;
  40904. /**
  40905. * Gets or sets if audio will be output to headphones
  40906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40907. */
  40908. headphone: boolean;
  40909. /**
  40910. * Gets or sets custom audio listener position provider
  40911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40912. */
  40913. audioListenerPositionProvider: Nullable<() => Vector3>;
  40914. /**
  40915. * Gets or sets a refresh rate when using 3D audio positioning
  40916. */
  40917. audioPositioningRefreshRate: number;
  40918. }
  40919. /**
  40920. * Defines the sound scene component responsible to manage any sounds
  40921. * in a given scene.
  40922. */
  40923. export class AudioSceneComponent implements ISceneSerializableComponent {
  40924. /**
  40925. * The component name helpfull to identify the component in the list of scene components.
  40926. */
  40927. readonly name: string;
  40928. /**
  40929. * The scene the component belongs to.
  40930. */
  40931. scene: Scene;
  40932. private _audioEnabled;
  40933. /**
  40934. * Gets whether audio is enabled or not.
  40935. * Please use related enable/disable method to switch state.
  40936. */
  40937. get audioEnabled(): boolean;
  40938. private _headphone;
  40939. /**
  40940. * Gets whether audio is outputing to headphone or not.
  40941. * Please use the according Switch methods to change output.
  40942. */
  40943. get headphone(): boolean;
  40944. /**
  40945. * Gets or sets a refresh rate when using 3D audio positioning
  40946. */
  40947. audioPositioningRefreshRate: number;
  40948. private _audioListenerPositionProvider;
  40949. /**
  40950. * Gets the current audio listener position provider
  40951. */
  40952. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40953. /**
  40954. * Sets a custom listener position for all sounds in the scene
  40955. * By default, this is the position of the first active camera
  40956. */
  40957. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40958. /**
  40959. * Creates a new instance of the component for the given scene
  40960. * @param scene Defines the scene to register the component in
  40961. */
  40962. constructor(scene: Scene);
  40963. /**
  40964. * Registers the component in a given scene
  40965. */
  40966. register(): void;
  40967. /**
  40968. * Rebuilds the elements related to this component in case of
  40969. * context lost for instance.
  40970. */
  40971. rebuild(): void;
  40972. /**
  40973. * Serializes the component data to the specified json object
  40974. * @param serializationObject The object to serialize to
  40975. */
  40976. serialize(serializationObject: any): void;
  40977. /**
  40978. * Adds all the elements from the container to the scene
  40979. * @param container the container holding the elements
  40980. */
  40981. addFromContainer(container: AbstractScene): void;
  40982. /**
  40983. * Removes all the elements in the container from the scene
  40984. * @param container contains the elements to remove
  40985. * @param dispose if the removed element should be disposed (default: false)
  40986. */
  40987. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40988. /**
  40989. * Disposes the component and the associated ressources.
  40990. */
  40991. dispose(): void;
  40992. /**
  40993. * Disables audio in the associated scene.
  40994. */
  40995. disableAudio(): void;
  40996. /**
  40997. * Enables audio in the associated scene.
  40998. */
  40999. enableAudio(): void;
  41000. /**
  41001. * Switch audio to headphone output.
  41002. */
  41003. switchAudioModeForHeadphones(): void;
  41004. /**
  41005. * Switch audio to normal speakers.
  41006. */
  41007. switchAudioModeForNormalSpeakers(): void;
  41008. private _cachedCameraDirection;
  41009. private _cachedCameraPosition;
  41010. private _lastCheck;
  41011. private _afterRender;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /**
  41016. * Wraps one or more Sound objects and selects one with random weight for playback.
  41017. */
  41018. export class WeightedSound {
  41019. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41020. loop: boolean;
  41021. private _coneInnerAngle;
  41022. private _coneOuterAngle;
  41023. private _volume;
  41024. /** A Sound is currently playing. */
  41025. isPlaying: boolean;
  41026. /** A Sound is currently paused. */
  41027. isPaused: boolean;
  41028. private _sounds;
  41029. private _weights;
  41030. private _currentIndex?;
  41031. /**
  41032. * Creates a new WeightedSound from the list of sounds given.
  41033. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41034. * @param sounds Array of Sounds that will be selected from.
  41035. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41036. */
  41037. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41038. /**
  41039. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41040. */
  41041. get directionalConeInnerAngle(): number;
  41042. /**
  41043. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41044. */
  41045. set directionalConeInnerAngle(value: number);
  41046. /**
  41047. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41048. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41049. */
  41050. get directionalConeOuterAngle(): number;
  41051. /**
  41052. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41053. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41054. */
  41055. set directionalConeOuterAngle(value: number);
  41056. /**
  41057. * Playback volume.
  41058. */
  41059. get volume(): number;
  41060. /**
  41061. * Playback volume.
  41062. */
  41063. set volume(value: number);
  41064. private _onended;
  41065. /**
  41066. * Suspend playback
  41067. */
  41068. pause(): void;
  41069. /**
  41070. * Stop playback
  41071. */
  41072. stop(): void;
  41073. /**
  41074. * Start playback.
  41075. * @param startOffset Position the clip head at a specific time in seconds.
  41076. */
  41077. play(startOffset?: number): void;
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41083. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41084. */
  41085. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41086. /**
  41087. * Gets the name of the behavior.
  41088. */
  41089. get name(): string;
  41090. /**
  41091. * The easing function used by animations
  41092. */
  41093. static EasingFunction: BackEase;
  41094. /**
  41095. * The easing mode used by animations
  41096. */
  41097. static EasingMode: number;
  41098. /**
  41099. * The duration of the animation, in milliseconds
  41100. */
  41101. transitionDuration: number;
  41102. /**
  41103. * Length of the distance animated by the transition when lower radius is reached
  41104. */
  41105. lowerRadiusTransitionRange: number;
  41106. /**
  41107. * Length of the distance animated by the transition when upper radius is reached
  41108. */
  41109. upperRadiusTransitionRange: number;
  41110. private _autoTransitionRange;
  41111. /**
  41112. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41113. */
  41114. get autoTransitionRange(): boolean;
  41115. /**
  41116. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41117. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41118. */
  41119. set autoTransitionRange(value: boolean);
  41120. private _attachedCamera;
  41121. private _onAfterCheckInputsObserver;
  41122. private _onMeshTargetChangedObserver;
  41123. /**
  41124. * Initializes the behavior.
  41125. */
  41126. init(): void;
  41127. /**
  41128. * Attaches the behavior to its arc rotate camera.
  41129. * @param camera Defines the camera to attach the behavior to
  41130. */
  41131. attach(camera: ArcRotateCamera): void;
  41132. /**
  41133. * Detaches the behavior from its current arc rotate camera.
  41134. */
  41135. detach(): void;
  41136. private _radiusIsAnimating;
  41137. private _radiusBounceTransition;
  41138. private _animatables;
  41139. private _cachedWheelPrecision;
  41140. /**
  41141. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41142. * @param radiusLimit The limit to check against.
  41143. * @return Bool to indicate if at limit.
  41144. */
  41145. private _isRadiusAtLimit;
  41146. /**
  41147. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41148. * @param radiusDelta The delta by which to animate to. Can be negative.
  41149. */
  41150. private _applyBoundRadiusAnimation;
  41151. /**
  41152. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41153. */
  41154. protected _clearAnimationLocks(): void;
  41155. /**
  41156. * Stops and removes all animations that have been applied to the camera
  41157. */
  41158. stopAllAnimations(): void;
  41159. }
  41160. }
  41161. declare module BABYLON {
  41162. /**
  41163. * 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.
  41164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41165. */
  41166. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41167. /**
  41168. * Gets the name of the behavior.
  41169. */
  41170. get name(): string;
  41171. private _mode;
  41172. private _radiusScale;
  41173. private _positionScale;
  41174. private _defaultElevation;
  41175. private _elevationReturnTime;
  41176. private _elevationReturnWaitTime;
  41177. private _zoomStopsAnimation;
  41178. private _framingTime;
  41179. /**
  41180. * The easing function used by animations
  41181. */
  41182. static EasingFunction: ExponentialEase;
  41183. /**
  41184. * The easing mode used by animations
  41185. */
  41186. static EasingMode: number;
  41187. /**
  41188. * Sets the current mode used by the behavior
  41189. */
  41190. set mode(mode: number);
  41191. /**
  41192. * Gets current mode used by the behavior.
  41193. */
  41194. get mode(): number;
  41195. /**
  41196. * Sets the scale applied to the radius (1 by default)
  41197. */
  41198. set radiusScale(radius: number);
  41199. /**
  41200. * Gets the scale applied to the radius
  41201. */
  41202. get radiusScale(): number;
  41203. /**
  41204. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41205. */
  41206. set positionScale(scale: number);
  41207. /**
  41208. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41209. */
  41210. get positionScale(): number;
  41211. /**
  41212. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41213. * behaviour is triggered, in radians.
  41214. */
  41215. set defaultElevation(elevation: number);
  41216. /**
  41217. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41218. * behaviour is triggered, in radians.
  41219. */
  41220. get defaultElevation(): number;
  41221. /**
  41222. * Sets the time (in milliseconds) taken to return to the default beta position.
  41223. * Negative value indicates camera should not return to default.
  41224. */
  41225. set elevationReturnTime(speed: number);
  41226. /**
  41227. * Gets the time (in milliseconds) taken to return to the default beta position.
  41228. * Negative value indicates camera should not return to default.
  41229. */
  41230. get elevationReturnTime(): number;
  41231. /**
  41232. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41233. */
  41234. set elevationReturnWaitTime(time: number);
  41235. /**
  41236. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41237. */
  41238. get elevationReturnWaitTime(): number;
  41239. /**
  41240. * Sets the flag that indicates if user zooming should stop animation.
  41241. */
  41242. set zoomStopsAnimation(flag: boolean);
  41243. /**
  41244. * Gets the flag that indicates if user zooming should stop animation.
  41245. */
  41246. get zoomStopsAnimation(): boolean;
  41247. /**
  41248. * Sets the transition time when framing the mesh, in milliseconds
  41249. */
  41250. set framingTime(time: number);
  41251. /**
  41252. * Gets the transition time when framing the mesh, in milliseconds
  41253. */
  41254. get framingTime(): number;
  41255. /**
  41256. * Define if the behavior should automatically change the configured
  41257. * camera limits and sensibilities.
  41258. */
  41259. autoCorrectCameraLimitsAndSensibility: boolean;
  41260. private _onPrePointerObservableObserver;
  41261. private _onAfterCheckInputsObserver;
  41262. private _onMeshTargetChangedObserver;
  41263. private _attachedCamera;
  41264. private _isPointerDown;
  41265. private _lastInteractionTime;
  41266. /**
  41267. * Initializes the behavior.
  41268. */
  41269. init(): void;
  41270. /**
  41271. * Attaches the behavior to its arc rotate camera.
  41272. * @param camera Defines the camera to attach the behavior to
  41273. */
  41274. attach(camera: ArcRotateCamera): void;
  41275. /**
  41276. * Detaches the behavior from its current arc rotate camera.
  41277. */
  41278. detach(): void;
  41279. private _animatables;
  41280. private _betaIsAnimating;
  41281. private _betaTransition;
  41282. private _radiusTransition;
  41283. private _vectorTransition;
  41284. /**
  41285. * Targets the given mesh and updates zoom level accordingly.
  41286. * @param mesh The mesh to target.
  41287. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41288. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41289. */
  41290. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41291. /**
  41292. * Targets the given mesh with its children and updates zoom level accordingly.
  41293. * @param mesh The mesh to target.
  41294. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41295. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41296. */
  41297. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41298. /**
  41299. * Targets the given meshes with their children and updates zoom level accordingly.
  41300. * @param meshes The mesh to target.
  41301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41303. */
  41304. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41305. /**
  41306. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41307. * @param minimumWorld Determines the smaller position of the bounding box extend
  41308. * @param maximumWorld Determines the bigger position of the bounding box extend
  41309. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41310. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41311. */
  41312. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41313. /**
  41314. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41315. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41316. * frustum width.
  41317. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41318. * to fully enclose the mesh in the viewing frustum.
  41319. */
  41320. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41321. /**
  41322. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41323. * is automatically returned to its default position (expected to be above ground plane).
  41324. */
  41325. private _maintainCameraAboveGround;
  41326. /**
  41327. * Returns the frustum slope based on the canvas ratio and camera FOV
  41328. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41329. */
  41330. private _getFrustumSlope;
  41331. /**
  41332. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41333. */
  41334. private _clearAnimationLocks;
  41335. /**
  41336. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41337. */
  41338. private _applyUserInteraction;
  41339. /**
  41340. * Stops and removes all animations that have been applied to the camera
  41341. */
  41342. stopAllAnimations(): void;
  41343. /**
  41344. * Gets a value indicating if the user is moving the camera
  41345. */
  41346. get isUserIsMoving(): boolean;
  41347. /**
  41348. * The camera can move all the way towards the mesh.
  41349. */
  41350. static IgnoreBoundsSizeMode: number;
  41351. /**
  41352. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41353. */
  41354. static FitFrustumSidesMode: number;
  41355. }
  41356. }
  41357. declare module BABYLON {
  41358. /**
  41359. * Base class for Camera Pointer Inputs.
  41360. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41361. * for example usage.
  41362. */
  41363. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41364. /**
  41365. * Defines the camera the input is attached to.
  41366. */
  41367. abstract camera: Camera;
  41368. /**
  41369. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41370. */
  41371. protected _altKey: boolean;
  41372. protected _ctrlKey: boolean;
  41373. protected _metaKey: boolean;
  41374. protected _shiftKey: boolean;
  41375. /**
  41376. * Which mouse buttons were pressed at time of last mouse event.
  41377. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41378. */
  41379. protected _buttonsPressed: number;
  41380. /**
  41381. * Defines the buttons associated with the input to handle camera move.
  41382. */
  41383. buttons: number[];
  41384. /**
  41385. * Attach the input controls to a specific dom element to get the input from.
  41386. * @param element Defines the element the controls should be listened from
  41387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41388. */
  41389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41390. /**
  41391. * Detach the current controls from the specified dom element.
  41392. * @param element Defines the element to stop listening the inputs from
  41393. */
  41394. detachControl(element: Nullable<HTMLElement>): void;
  41395. /**
  41396. * Gets the class name of the current input.
  41397. * @returns the class name
  41398. */
  41399. getClassName(): string;
  41400. /**
  41401. * Get the friendly name associated with the input class.
  41402. * @returns the input friendly name
  41403. */
  41404. getSimpleName(): string;
  41405. /**
  41406. * Called on pointer POINTERDOUBLETAP event.
  41407. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41408. */
  41409. protected onDoubleTap(type: string): void;
  41410. /**
  41411. * Called on pointer POINTERMOVE event if only a single touch is active.
  41412. * Override this method to provide functionality.
  41413. */
  41414. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41415. /**
  41416. * Called on pointer POINTERMOVE event if multiple touches are active.
  41417. * Override this method to provide functionality.
  41418. */
  41419. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41420. /**
  41421. * Called on JS contextmenu event.
  41422. * Override this method to provide functionality.
  41423. */
  41424. protected onContextMenu(evt: PointerEvent): void;
  41425. /**
  41426. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41427. * press.
  41428. * Override this method to provide functionality.
  41429. */
  41430. protected onButtonDown(evt: PointerEvent): void;
  41431. /**
  41432. * Called each time a new POINTERUP event occurs. Ie, for each button
  41433. * release.
  41434. * Override this method to provide functionality.
  41435. */
  41436. protected onButtonUp(evt: PointerEvent): void;
  41437. /**
  41438. * Called when window becomes inactive.
  41439. * Override this method to provide functionality.
  41440. */
  41441. protected onLostFocus(): void;
  41442. private _pointerInput;
  41443. private _observer;
  41444. private _onLostFocus;
  41445. private pointA;
  41446. private pointB;
  41447. }
  41448. }
  41449. declare module BABYLON {
  41450. /**
  41451. * Manage the pointers inputs to control an arc rotate camera.
  41452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41453. */
  41454. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41455. /**
  41456. * Defines the camera the input is attached to.
  41457. */
  41458. camera: ArcRotateCamera;
  41459. /**
  41460. * Gets the class name of the current input.
  41461. * @returns the class name
  41462. */
  41463. getClassName(): string;
  41464. /**
  41465. * Defines the buttons associated with the input to handle camera move.
  41466. */
  41467. buttons: number[];
  41468. /**
  41469. * Defines the pointer angular sensibility along the X axis or how fast is
  41470. * the camera rotating.
  41471. */
  41472. angularSensibilityX: number;
  41473. /**
  41474. * Defines the pointer angular sensibility along the Y axis or how fast is
  41475. * the camera rotating.
  41476. */
  41477. angularSensibilityY: number;
  41478. /**
  41479. * Defines the pointer pinch precision or how fast is the camera zooming.
  41480. */
  41481. pinchPrecision: number;
  41482. /**
  41483. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41484. * from 0.
  41485. * It defines the percentage of current camera.radius to use as delta when
  41486. * pinch zoom is used.
  41487. */
  41488. pinchDeltaPercentage: number;
  41489. /**
  41490. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41491. * that any object in the plane at the camera's target point will scale
  41492. * perfectly with finger motion.
  41493. * Overrides pinchDeltaPercentage and pinchPrecision.
  41494. */
  41495. useNaturalPinchZoom: boolean;
  41496. /**
  41497. * Defines the pointer panning sensibility or how fast is the camera moving.
  41498. */
  41499. panningSensibility: number;
  41500. /**
  41501. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41502. */
  41503. multiTouchPanning: boolean;
  41504. /**
  41505. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41506. * zoom (pinch) through multitouch.
  41507. */
  41508. multiTouchPanAndZoom: boolean;
  41509. /**
  41510. * Revers pinch action direction.
  41511. */
  41512. pinchInwards: boolean;
  41513. private _isPanClick;
  41514. private _twoFingerActivityCount;
  41515. private _isPinching;
  41516. /**
  41517. * Called on pointer POINTERMOVE event if only a single touch is active.
  41518. */
  41519. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41520. /**
  41521. * Called on pointer POINTERDOUBLETAP event.
  41522. */
  41523. protected onDoubleTap(type: string): void;
  41524. /**
  41525. * Called on pointer POINTERMOVE event if multiple touches are active.
  41526. */
  41527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41528. /**
  41529. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41530. * press.
  41531. */
  41532. protected onButtonDown(evt: PointerEvent): void;
  41533. /**
  41534. * Called each time a new POINTERUP event occurs. Ie, for each button
  41535. * release.
  41536. */
  41537. protected onButtonUp(evt: PointerEvent): void;
  41538. /**
  41539. * Called when window becomes inactive.
  41540. */
  41541. protected onLostFocus(): void;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41548. */
  41549. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41550. /**
  41551. * Defines the camera the input is attached to.
  41552. */
  41553. camera: ArcRotateCamera;
  41554. /**
  41555. * Defines the list of key codes associated with the up action (increase alpha)
  41556. */
  41557. keysUp: number[];
  41558. /**
  41559. * Defines the list of key codes associated with the down action (decrease alpha)
  41560. */
  41561. keysDown: number[];
  41562. /**
  41563. * Defines the list of key codes associated with the left action (increase beta)
  41564. */
  41565. keysLeft: number[];
  41566. /**
  41567. * Defines the list of key codes associated with the right action (decrease beta)
  41568. */
  41569. keysRight: number[];
  41570. /**
  41571. * Defines the list of key codes associated with the reset action.
  41572. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41573. */
  41574. keysReset: number[];
  41575. /**
  41576. * Defines the panning sensibility of the inputs.
  41577. * (How fast is the camera panning)
  41578. */
  41579. panningSensibility: number;
  41580. /**
  41581. * Defines the zooming sensibility of the inputs.
  41582. * (How fast is the camera zooming)
  41583. */
  41584. zoomingSensibility: number;
  41585. /**
  41586. * Defines whether maintaining the alt key down switch the movement mode from
  41587. * orientation to zoom.
  41588. */
  41589. useAltToZoom: boolean;
  41590. /**
  41591. * Rotation speed of the camera
  41592. */
  41593. angularSpeed: number;
  41594. private _keys;
  41595. private _ctrlPressed;
  41596. private _altPressed;
  41597. private _onCanvasBlurObserver;
  41598. private _onKeyboardObserver;
  41599. private _engine;
  41600. private _scene;
  41601. /**
  41602. * Attach the input controls to a specific dom element to get the input from.
  41603. * @param element Defines the element the controls should be listened from
  41604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41605. */
  41606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41607. /**
  41608. * Detach the current controls from the specified dom element.
  41609. * @param element Defines the element to stop listening the inputs from
  41610. */
  41611. detachControl(element: Nullable<HTMLElement>): void;
  41612. /**
  41613. * Update the current camera state depending on the inputs that have been used this frame.
  41614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41615. */
  41616. checkInputs(): void;
  41617. /**
  41618. * Gets the class name of the current intput.
  41619. * @returns the class name
  41620. */
  41621. getClassName(): string;
  41622. /**
  41623. * Get the friendly name associated with the input class.
  41624. * @returns the input friendly name
  41625. */
  41626. getSimpleName(): string;
  41627. }
  41628. }
  41629. declare module BABYLON {
  41630. /**
  41631. * Manage the mouse wheel inputs to control an arc rotate camera.
  41632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41633. */
  41634. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41635. /**
  41636. * Defines the camera the input is attached to.
  41637. */
  41638. camera: ArcRotateCamera;
  41639. /**
  41640. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41641. */
  41642. wheelPrecision: number;
  41643. /**
  41644. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41645. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41646. */
  41647. wheelDeltaPercentage: number;
  41648. private _wheel;
  41649. private _observer;
  41650. private computeDeltaFromMouseWheelLegacyEvent;
  41651. /**
  41652. * Attach the input controls to a specific dom element to get the input from.
  41653. * @param element Defines the element the controls should be listened from
  41654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41655. */
  41656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41657. /**
  41658. * Detach the current controls from the specified dom element.
  41659. * @param element Defines the element to stop listening the inputs from
  41660. */
  41661. detachControl(element: Nullable<HTMLElement>): void;
  41662. /**
  41663. * Gets the class name of the current intput.
  41664. * @returns the class name
  41665. */
  41666. getClassName(): string;
  41667. /**
  41668. * Get the friendly name associated with the input class.
  41669. * @returns the input friendly name
  41670. */
  41671. getSimpleName(): string;
  41672. }
  41673. }
  41674. declare module BABYLON {
  41675. /**
  41676. * Default Inputs manager for the ArcRotateCamera.
  41677. * It groups all the default supported inputs for ease of use.
  41678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41679. */
  41680. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41681. /**
  41682. * Instantiates a new ArcRotateCameraInputsManager.
  41683. * @param camera Defines the camera the inputs belong to
  41684. */
  41685. constructor(camera: ArcRotateCamera);
  41686. /**
  41687. * Add mouse wheel input support to the input manager.
  41688. * @returns the current input manager
  41689. */
  41690. addMouseWheel(): ArcRotateCameraInputsManager;
  41691. /**
  41692. * Add pointers input support to the input manager.
  41693. * @returns the current input manager
  41694. */
  41695. addPointers(): ArcRotateCameraInputsManager;
  41696. /**
  41697. * Add keyboard input support to the input manager.
  41698. * @returns the current input manager
  41699. */
  41700. addKeyboard(): ArcRotateCameraInputsManager;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * This represents an orbital type of camera.
  41706. *
  41707. * 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.
  41708. * 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.
  41709. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41710. */
  41711. export class ArcRotateCamera extends TargetCamera {
  41712. /**
  41713. * Defines the rotation angle of the camera along the longitudinal axis.
  41714. */
  41715. alpha: number;
  41716. /**
  41717. * Defines the rotation angle of the camera along the latitudinal axis.
  41718. */
  41719. beta: number;
  41720. /**
  41721. * Defines the radius of the camera from it s target point.
  41722. */
  41723. radius: number;
  41724. protected _target: Vector3;
  41725. protected _targetHost: Nullable<AbstractMesh>;
  41726. /**
  41727. * Defines the target point of the camera.
  41728. * The camera looks towards it form the radius distance.
  41729. */
  41730. get target(): Vector3;
  41731. set target(value: Vector3);
  41732. /**
  41733. * Define the current local position of the camera in the scene
  41734. */
  41735. get position(): Vector3;
  41736. set position(newPosition: Vector3);
  41737. protected _upVector: Vector3;
  41738. protected _upToYMatrix: Matrix;
  41739. protected _YToUpMatrix: Matrix;
  41740. /**
  41741. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41742. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41743. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41744. */
  41745. set upVector(vec: Vector3);
  41746. get upVector(): Vector3;
  41747. /**
  41748. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41749. */
  41750. setMatUp(): void;
  41751. /**
  41752. * Current inertia value on the longitudinal axis.
  41753. * The bigger this number the longer it will take for the camera to stop.
  41754. */
  41755. inertialAlphaOffset: number;
  41756. /**
  41757. * Current inertia value on the latitudinal axis.
  41758. * The bigger this number the longer it will take for the camera to stop.
  41759. */
  41760. inertialBetaOffset: number;
  41761. /**
  41762. * Current inertia value on the radius axis.
  41763. * The bigger this number the longer it will take for the camera to stop.
  41764. */
  41765. inertialRadiusOffset: number;
  41766. /**
  41767. * Minimum allowed angle on the longitudinal axis.
  41768. * This can help limiting how the Camera is able to move in the scene.
  41769. */
  41770. lowerAlphaLimit: Nullable<number>;
  41771. /**
  41772. * Maximum allowed angle on the longitudinal axis.
  41773. * This can help limiting how the Camera is able to move in the scene.
  41774. */
  41775. upperAlphaLimit: Nullable<number>;
  41776. /**
  41777. * Minimum allowed angle on the latitudinal axis.
  41778. * This can help limiting how the Camera is able to move in the scene.
  41779. */
  41780. lowerBetaLimit: number;
  41781. /**
  41782. * Maximum allowed angle on the latitudinal axis.
  41783. * This can help limiting how the Camera is able to move in the scene.
  41784. */
  41785. upperBetaLimit: number;
  41786. /**
  41787. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41788. * This can help limiting how the Camera is able to move in the scene.
  41789. */
  41790. lowerRadiusLimit: Nullable<number>;
  41791. /**
  41792. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41793. * This can help limiting how the Camera is able to move in the scene.
  41794. */
  41795. upperRadiusLimit: Nullable<number>;
  41796. /**
  41797. * Defines the current inertia value used during panning of the camera along the X axis.
  41798. */
  41799. inertialPanningX: number;
  41800. /**
  41801. * Defines the current inertia value used during panning of the camera along the Y axis.
  41802. */
  41803. inertialPanningY: number;
  41804. /**
  41805. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41806. * Basically if your fingers moves away from more than this distance you will be considered
  41807. * in pinch mode.
  41808. */
  41809. pinchToPanMaxDistance: number;
  41810. /**
  41811. * Defines the maximum distance the camera can pan.
  41812. * This could help keeping the cammera always in your scene.
  41813. */
  41814. panningDistanceLimit: Nullable<number>;
  41815. /**
  41816. * Defines the target of the camera before paning.
  41817. */
  41818. panningOriginTarget: Vector3;
  41819. /**
  41820. * Defines the value of the inertia used during panning.
  41821. * 0 would mean stop inertia and one would mean no decelleration at all.
  41822. */
  41823. panningInertia: number;
  41824. /**
  41825. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41826. */
  41827. get angularSensibilityX(): number;
  41828. set angularSensibilityX(value: number);
  41829. /**
  41830. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41831. */
  41832. get angularSensibilityY(): number;
  41833. set angularSensibilityY(value: number);
  41834. /**
  41835. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41836. */
  41837. get pinchPrecision(): number;
  41838. set pinchPrecision(value: number);
  41839. /**
  41840. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41841. * It will be used instead of pinchDeltaPrecision if different from 0.
  41842. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41843. */
  41844. get pinchDeltaPercentage(): number;
  41845. set pinchDeltaPercentage(value: number);
  41846. /**
  41847. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41848. * and pinch delta percentage.
  41849. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41850. * that any object in the plane at the camera's target point will scale
  41851. * perfectly with finger motion.
  41852. */
  41853. get useNaturalPinchZoom(): boolean;
  41854. set useNaturalPinchZoom(value: boolean);
  41855. /**
  41856. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41857. */
  41858. get panningSensibility(): number;
  41859. set panningSensibility(value: number);
  41860. /**
  41861. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41862. */
  41863. get keysUp(): number[];
  41864. set keysUp(value: number[]);
  41865. /**
  41866. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41867. */
  41868. get keysDown(): number[];
  41869. set keysDown(value: number[]);
  41870. /**
  41871. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41872. */
  41873. get keysLeft(): number[];
  41874. set keysLeft(value: number[]);
  41875. /**
  41876. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41877. */
  41878. get keysRight(): number[];
  41879. set keysRight(value: number[]);
  41880. /**
  41881. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41882. */
  41883. get wheelPrecision(): number;
  41884. set wheelPrecision(value: number);
  41885. /**
  41886. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41887. * It will be used instead of pinchDeltaPrecision if different from 0.
  41888. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41889. */
  41890. get wheelDeltaPercentage(): number;
  41891. set wheelDeltaPercentage(value: number);
  41892. /**
  41893. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41894. */
  41895. zoomOnFactor: number;
  41896. /**
  41897. * Defines a screen offset for the camera position.
  41898. */
  41899. targetScreenOffset: Vector2;
  41900. /**
  41901. * Allows the camera to be completely reversed.
  41902. * If false the camera can not arrive upside down.
  41903. */
  41904. allowUpsideDown: boolean;
  41905. /**
  41906. * Define if double tap/click is used to restore the previously saved state of the camera.
  41907. */
  41908. useInputToRestoreState: boolean;
  41909. /** @hidden */
  41910. _viewMatrix: Matrix;
  41911. /** @hidden */
  41912. _useCtrlForPanning: boolean;
  41913. /** @hidden */
  41914. _panningMouseButton: number;
  41915. /**
  41916. * Defines the input associated to the camera.
  41917. */
  41918. inputs: ArcRotateCameraInputsManager;
  41919. /** @hidden */
  41920. _reset: () => void;
  41921. /**
  41922. * Defines the allowed panning axis.
  41923. */
  41924. panningAxis: Vector3;
  41925. protected _localDirection: Vector3;
  41926. protected _transformedDirection: Vector3;
  41927. private _bouncingBehavior;
  41928. /**
  41929. * Gets the bouncing behavior of the camera if it has been enabled.
  41930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41931. */
  41932. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41933. /**
  41934. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41936. */
  41937. get useBouncingBehavior(): boolean;
  41938. set useBouncingBehavior(value: boolean);
  41939. private _framingBehavior;
  41940. /**
  41941. * Gets the framing behavior of the camera if it has been enabled.
  41942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41943. */
  41944. get framingBehavior(): Nullable<FramingBehavior>;
  41945. /**
  41946. * Defines if the framing behavior of the camera is enabled on the camera.
  41947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41948. */
  41949. get useFramingBehavior(): boolean;
  41950. set useFramingBehavior(value: boolean);
  41951. private _autoRotationBehavior;
  41952. /**
  41953. * Gets the auto rotation behavior of the camera if it has been enabled.
  41954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41955. */
  41956. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41957. /**
  41958. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41960. */
  41961. get useAutoRotationBehavior(): boolean;
  41962. set useAutoRotationBehavior(value: boolean);
  41963. /**
  41964. * Observable triggered when the mesh target has been changed on the camera.
  41965. */
  41966. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41967. /**
  41968. * Event raised when the camera is colliding with a mesh.
  41969. */
  41970. onCollide: (collidedMesh: AbstractMesh) => void;
  41971. /**
  41972. * Defines whether the camera should check collision with the objects oh the scene.
  41973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41974. */
  41975. checkCollisions: boolean;
  41976. /**
  41977. * Defines the collision radius of the camera.
  41978. * This simulates a sphere around the camera.
  41979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41980. */
  41981. collisionRadius: Vector3;
  41982. protected _collider: Collider;
  41983. protected _previousPosition: Vector3;
  41984. protected _collisionVelocity: Vector3;
  41985. protected _newPosition: Vector3;
  41986. protected _previousAlpha: number;
  41987. protected _previousBeta: number;
  41988. protected _previousRadius: number;
  41989. protected _collisionTriggered: boolean;
  41990. protected _targetBoundingCenter: Nullable<Vector3>;
  41991. private _computationVector;
  41992. /**
  41993. * Instantiates a new ArcRotateCamera in a given scene
  41994. * @param name Defines the name of the camera
  41995. * @param alpha Defines the camera rotation along the logitudinal axis
  41996. * @param beta Defines the camera rotation along the latitudinal axis
  41997. * @param radius Defines the camera distance from its target
  41998. * @param target Defines the camera target
  41999. * @param scene Defines the scene the camera belongs to
  42000. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42001. */
  42002. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42003. /** @hidden */
  42004. _initCache(): void;
  42005. /** @hidden */
  42006. _updateCache(ignoreParentClass?: boolean): void;
  42007. protected _getTargetPosition(): Vector3;
  42008. private _storedAlpha;
  42009. private _storedBeta;
  42010. private _storedRadius;
  42011. private _storedTarget;
  42012. private _storedTargetScreenOffset;
  42013. /**
  42014. * Stores the current state of the camera (alpha, beta, radius and target)
  42015. * @returns the camera itself
  42016. */
  42017. storeState(): Camera;
  42018. /**
  42019. * @hidden
  42020. * Restored camera state. You must call storeState() first
  42021. */
  42022. _restoreStateValues(): boolean;
  42023. /** @hidden */
  42024. _isSynchronizedViewMatrix(): boolean;
  42025. /**
  42026. * Attached controls to the current camera.
  42027. * @param element Defines the element the controls should be listened from
  42028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42029. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42030. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42031. */
  42032. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42033. /**
  42034. * Detach the current controls from the camera.
  42035. * The camera will stop reacting to inputs.
  42036. * @param element Defines the element to stop listening the inputs from
  42037. */
  42038. detachControl(element: HTMLElement): void;
  42039. /** @hidden */
  42040. _checkInputs(): void;
  42041. protected _checkLimits(): void;
  42042. /**
  42043. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42044. */
  42045. rebuildAnglesAndRadius(): void;
  42046. /**
  42047. * Use a position to define the current camera related information like alpha, beta and radius
  42048. * @param position Defines the position to set the camera at
  42049. */
  42050. setPosition(position: Vector3): void;
  42051. /**
  42052. * Defines the target the camera should look at.
  42053. * This will automatically adapt alpha beta and radius to fit within the new target.
  42054. * @param target Defines the new target as a Vector or a mesh
  42055. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42056. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42057. */
  42058. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42059. /** @hidden */
  42060. _getViewMatrix(): Matrix;
  42061. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42062. /**
  42063. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42064. * @param meshes Defines the mesh to zoom on
  42065. * @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)
  42066. */
  42067. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42068. /**
  42069. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42070. * The target will be changed but the radius
  42071. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42072. * @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)
  42073. */
  42074. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42075. min: Vector3;
  42076. max: Vector3;
  42077. distance: number;
  42078. }, doNotUpdateMaxZ?: boolean): void;
  42079. /**
  42080. * @override
  42081. * Override Camera.createRigCamera
  42082. */
  42083. createRigCamera(name: string, cameraIndex: number): Camera;
  42084. /**
  42085. * @hidden
  42086. * @override
  42087. * Override Camera._updateRigCameras
  42088. */
  42089. _updateRigCameras(): void;
  42090. /**
  42091. * Destroy the camera and release the current resources hold by it.
  42092. */
  42093. dispose(): void;
  42094. /**
  42095. * Gets the current object class name.
  42096. * @return the class name
  42097. */
  42098. getClassName(): string;
  42099. }
  42100. }
  42101. declare module BABYLON {
  42102. /**
  42103. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42105. */
  42106. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42107. /**
  42108. * Gets the name of the behavior.
  42109. */
  42110. get name(): string;
  42111. private _zoomStopsAnimation;
  42112. private _idleRotationSpeed;
  42113. private _idleRotationWaitTime;
  42114. private _idleRotationSpinupTime;
  42115. /**
  42116. * Sets the flag that indicates if user zooming should stop animation.
  42117. */
  42118. set zoomStopsAnimation(flag: boolean);
  42119. /**
  42120. * Gets the flag that indicates if user zooming should stop animation.
  42121. */
  42122. get zoomStopsAnimation(): boolean;
  42123. /**
  42124. * Sets the default speed at which the camera rotates around the model.
  42125. */
  42126. set idleRotationSpeed(speed: number);
  42127. /**
  42128. * Gets the default speed at which the camera rotates around the model.
  42129. */
  42130. get idleRotationSpeed(): number;
  42131. /**
  42132. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42133. */
  42134. set idleRotationWaitTime(time: number);
  42135. /**
  42136. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42137. */
  42138. get idleRotationWaitTime(): number;
  42139. /**
  42140. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42141. */
  42142. set idleRotationSpinupTime(time: number);
  42143. /**
  42144. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42145. */
  42146. get idleRotationSpinupTime(): number;
  42147. /**
  42148. * Gets a value indicating if the camera is currently rotating because of this behavior
  42149. */
  42150. get rotationInProgress(): boolean;
  42151. private _onPrePointerObservableObserver;
  42152. private _onAfterCheckInputsObserver;
  42153. private _attachedCamera;
  42154. private _isPointerDown;
  42155. private _lastFrameTime;
  42156. private _lastInteractionTime;
  42157. private _cameraRotationSpeed;
  42158. /**
  42159. * Initializes the behavior.
  42160. */
  42161. init(): void;
  42162. /**
  42163. * Attaches the behavior to its arc rotate camera.
  42164. * @param camera Defines the camera to attach the behavior to
  42165. */
  42166. attach(camera: ArcRotateCamera): void;
  42167. /**
  42168. * Detaches the behavior from its current arc rotate camera.
  42169. */
  42170. detach(): void;
  42171. /**
  42172. * Returns true if user is scrolling.
  42173. * @return true if user is scrolling.
  42174. */
  42175. private _userIsZooming;
  42176. private _lastFrameRadius;
  42177. private _shouldAnimationStopForInteraction;
  42178. /**
  42179. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42180. */
  42181. private _applyUserInteraction;
  42182. private _userIsMoving;
  42183. }
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42188. */
  42189. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42190. private ui;
  42191. /**
  42192. * The name of the behavior
  42193. */
  42194. name: string;
  42195. /**
  42196. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42197. */
  42198. distanceAwayFromFace: number;
  42199. /**
  42200. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42201. */
  42202. distanceAwayFromBottomOfFace: number;
  42203. private _faceVectors;
  42204. private _target;
  42205. private _scene;
  42206. private _onRenderObserver;
  42207. private _tmpMatrix;
  42208. private _tmpVector;
  42209. /**
  42210. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42211. * @param ui The transform node that should be attched to the mesh
  42212. */
  42213. constructor(ui: TransformNode);
  42214. /**
  42215. * Initializes the behavior
  42216. */
  42217. init(): void;
  42218. private _closestFace;
  42219. private _zeroVector;
  42220. private _lookAtTmpMatrix;
  42221. private _lookAtToRef;
  42222. /**
  42223. * Attaches the AttachToBoxBehavior to the passed in mesh
  42224. * @param target The mesh that the specified node will be attached to
  42225. */
  42226. attach(target: Mesh): void;
  42227. /**
  42228. * Detaches the behavior from the mesh
  42229. */
  42230. detach(): void;
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /**
  42235. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42236. */
  42237. export class FadeInOutBehavior implements Behavior<Mesh> {
  42238. /**
  42239. * Time in milliseconds to delay before fading in (Default: 0)
  42240. */
  42241. delay: number;
  42242. /**
  42243. * Time in milliseconds for the mesh to fade in (Default: 300)
  42244. */
  42245. fadeInTime: number;
  42246. private _millisecondsPerFrame;
  42247. private _hovered;
  42248. private _hoverValue;
  42249. private _ownerNode;
  42250. /**
  42251. * Instatiates the FadeInOutBehavior
  42252. */
  42253. constructor();
  42254. /**
  42255. * The name of the behavior
  42256. */
  42257. get name(): string;
  42258. /**
  42259. * Initializes the behavior
  42260. */
  42261. init(): void;
  42262. /**
  42263. * Attaches the fade behavior on the passed in mesh
  42264. * @param ownerNode The mesh that will be faded in/out once attached
  42265. */
  42266. attach(ownerNode: Mesh): void;
  42267. /**
  42268. * Detaches the behavior from the mesh
  42269. */
  42270. detach(): void;
  42271. /**
  42272. * Triggers the mesh to begin fading in or out
  42273. * @param value if the object should fade in or out (true to fade in)
  42274. */
  42275. fadeIn(value: boolean): void;
  42276. private _update;
  42277. private _setAllVisibility;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Class containing a set of static utilities functions for managing Pivots
  42283. * @hidden
  42284. */
  42285. export class PivotTools {
  42286. private static _PivotCached;
  42287. private static _OldPivotPoint;
  42288. private static _PivotTranslation;
  42289. private static _PivotTmpVector;
  42290. /** @hidden */
  42291. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42292. /** @hidden */
  42293. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42294. }
  42295. }
  42296. declare module BABYLON {
  42297. /**
  42298. * Class containing static functions to help procedurally build meshes
  42299. */
  42300. export class PlaneBuilder {
  42301. /**
  42302. * Creates a plane mesh
  42303. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42304. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42305. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42307. * * 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
  42308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42309. * @param name defines the name of the mesh
  42310. * @param options defines the options used to create the mesh
  42311. * @param scene defines the hosting scene
  42312. * @returns the plane mesh
  42313. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42314. */
  42315. static CreatePlane(name: string, options: {
  42316. size?: number;
  42317. width?: number;
  42318. height?: number;
  42319. sideOrientation?: number;
  42320. frontUVs?: Vector4;
  42321. backUVs?: Vector4;
  42322. updatable?: boolean;
  42323. sourcePlane?: Plane;
  42324. }, scene?: Nullable<Scene>): Mesh;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /**
  42329. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42330. */
  42331. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42332. private static _AnyMouseID;
  42333. /**
  42334. * Abstract mesh the behavior is set on
  42335. */
  42336. attachedNode: AbstractMesh;
  42337. private _dragPlane;
  42338. private _scene;
  42339. private _pointerObserver;
  42340. private _beforeRenderObserver;
  42341. private static _planeScene;
  42342. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42343. /**
  42344. * 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)
  42345. */
  42346. maxDragAngle: number;
  42347. /**
  42348. * @hidden
  42349. */
  42350. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42351. /**
  42352. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42353. */
  42354. currentDraggingPointerID: number;
  42355. /**
  42356. * The last position where the pointer hit the drag plane in world space
  42357. */
  42358. lastDragPosition: Vector3;
  42359. /**
  42360. * If the behavior is currently in a dragging state
  42361. */
  42362. dragging: boolean;
  42363. /**
  42364. * 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)
  42365. */
  42366. dragDeltaRatio: number;
  42367. /**
  42368. * If the drag plane orientation should be updated during the dragging (Default: true)
  42369. */
  42370. updateDragPlane: boolean;
  42371. private _debugMode;
  42372. private _moving;
  42373. /**
  42374. * Fires each time the attached mesh is dragged with the pointer
  42375. * * delta between last drag position and current drag position in world space
  42376. * * dragDistance along the drag axis
  42377. * * dragPlaneNormal normal of the current drag plane used during the drag
  42378. * * dragPlanePoint in world space where the drag intersects the drag plane
  42379. */
  42380. onDragObservable: Observable<{
  42381. delta: Vector3;
  42382. dragPlanePoint: Vector3;
  42383. dragPlaneNormal: Vector3;
  42384. dragDistance: number;
  42385. pointerId: number;
  42386. }>;
  42387. /**
  42388. * Fires each time a drag begins (eg. mouse down on mesh)
  42389. */
  42390. onDragStartObservable: Observable<{
  42391. dragPlanePoint: Vector3;
  42392. pointerId: number;
  42393. }>;
  42394. /**
  42395. * Fires each time a drag ends (eg. mouse release after drag)
  42396. */
  42397. onDragEndObservable: Observable<{
  42398. dragPlanePoint: Vector3;
  42399. pointerId: number;
  42400. }>;
  42401. /**
  42402. * If the attached mesh should be moved when dragged
  42403. */
  42404. moveAttached: boolean;
  42405. /**
  42406. * If the drag behavior will react to drag events (Default: true)
  42407. */
  42408. enabled: boolean;
  42409. /**
  42410. * If pointer events should start and release the drag (Default: true)
  42411. */
  42412. startAndReleaseDragOnPointerEvents: boolean;
  42413. /**
  42414. * If camera controls should be detached during the drag
  42415. */
  42416. detachCameraControls: boolean;
  42417. /**
  42418. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42419. */
  42420. useObjectOrientationForDragging: boolean;
  42421. private _options;
  42422. /**
  42423. * Gets the options used by the behavior
  42424. */
  42425. get options(): {
  42426. dragAxis?: Vector3;
  42427. dragPlaneNormal?: Vector3;
  42428. };
  42429. /**
  42430. * Sets the options used by the behavior
  42431. */
  42432. set options(options: {
  42433. dragAxis?: Vector3;
  42434. dragPlaneNormal?: Vector3;
  42435. });
  42436. /**
  42437. * Creates a pointer drag behavior that can be attached to a mesh
  42438. * @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)
  42439. */
  42440. constructor(options?: {
  42441. dragAxis?: Vector3;
  42442. dragPlaneNormal?: Vector3;
  42443. });
  42444. /**
  42445. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42446. */
  42447. validateDrag: (targetPosition: Vector3) => boolean;
  42448. /**
  42449. * The name of the behavior
  42450. */
  42451. get name(): string;
  42452. /**
  42453. * Initializes the behavior
  42454. */
  42455. init(): void;
  42456. private _tmpVector;
  42457. private _alternatePickedPoint;
  42458. private _worldDragAxis;
  42459. private _targetPosition;
  42460. private _attachedElement;
  42461. /**
  42462. * Attaches the drag behavior the passed in mesh
  42463. * @param ownerNode The mesh that will be dragged around once attached
  42464. * @param predicate Predicate to use for pick filtering
  42465. */
  42466. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42467. /**
  42468. * Force relase the drag action by code.
  42469. */
  42470. releaseDrag(): void;
  42471. private _startDragRay;
  42472. private _lastPointerRay;
  42473. /**
  42474. * Simulates the start of a pointer drag event on the behavior
  42475. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42476. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42477. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42478. */
  42479. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42480. private _startDrag;
  42481. private _dragDelta;
  42482. private _moveDrag;
  42483. private _pickWithRayOnDragPlane;
  42484. private _pointA;
  42485. private _pointB;
  42486. private _pointC;
  42487. private _lineA;
  42488. private _lineB;
  42489. private _localAxis;
  42490. private _lookAt;
  42491. private _updateDragPlanePosition;
  42492. /**
  42493. * Detaches the behavior from the mesh
  42494. */
  42495. detach(): void;
  42496. }
  42497. }
  42498. declare module BABYLON {
  42499. /**
  42500. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42501. */
  42502. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42503. private _dragBehaviorA;
  42504. private _dragBehaviorB;
  42505. private _startDistance;
  42506. private _initialScale;
  42507. private _targetScale;
  42508. private _ownerNode;
  42509. private _sceneRenderObserver;
  42510. /**
  42511. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42512. */
  42513. constructor();
  42514. /**
  42515. * The name of the behavior
  42516. */
  42517. get name(): string;
  42518. /**
  42519. * Initializes the behavior
  42520. */
  42521. init(): void;
  42522. private _getCurrentDistance;
  42523. /**
  42524. * Attaches the scale behavior the passed in mesh
  42525. * @param ownerNode The mesh that will be scaled around once attached
  42526. */
  42527. attach(ownerNode: Mesh): void;
  42528. /**
  42529. * Detaches the behavior from the mesh
  42530. */
  42531. detach(): void;
  42532. }
  42533. }
  42534. declare module BABYLON {
  42535. /**
  42536. * 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
  42537. */
  42538. export class SixDofDragBehavior implements Behavior<Mesh> {
  42539. private static _virtualScene;
  42540. private _ownerNode;
  42541. private _sceneRenderObserver;
  42542. private _scene;
  42543. private _targetPosition;
  42544. private _virtualOriginMesh;
  42545. private _virtualDragMesh;
  42546. private _pointerObserver;
  42547. private _moving;
  42548. private _startingOrientation;
  42549. private _attachedElement;
  42550. /**
  42551. * 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)
  42552. */
  42553. private zDragFactor;
  42554. /**
  42555. * If the object should rotate to face the drag origin
  42556. */
  42557. rotateDraggedObject: boolean;
  42558. /**
  42559. * If the behavior is currently in a dragging state
  42560. */
  42561. dragging: boolean;
  42562. /**
  42563. * 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)
  42564. */
  42565. dragDeltaRatio: number;
  42566. /**
  42567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42568. */
  42569. currentDraggingPointerID: number;
  42570. /**
  42571. * If camera controls should be detached during the drag
  42572. */
  42573. detachCameraControls: boolean;
  42574. /**
  42575. * Fires each time a drag starts
  42576. */
  42577. onDragStartObservable: Observable<{}>;
  42578. /**
  42579. * Fires each time a drag ends (eg. mouse release after drag)
  42580. */
  42581. onDragEndObservable: Observable<{}>;
  42582. /**
  42583. * 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
  42584. */
  42585. constructor();
  42586. /**
  42587. * The name of the behavior
  42588. */
  42589. get name(): string;
  42590. /**
  42591. * Initializes the behavior
  42592. */
  42593. init(): void;
  42594. /**
  42595. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42596. */
  42597. private get _pointerCamera();
  42598. /**
  42599. * Attaches the scale behavior the passed in mesh
  42600. * @param ownerNode The mesh that will be scaled around once attached
  42601. */
  42602. attach(ownerNode: Mesh): void;
  42603. /**
  42604. * Detaches the behavior from the mesh
  42605. */
  42606. detach(): void;
  42607. }
  42608. }
  42609. declare module BABYLON {
  42610. /**
  42611. * Class used to apply inverse kinematics to bones
  42612. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42613. */
  42614. export class BoneIKController {
  42615. private static _tmpVecs;
  42616. private static _tmpQuat;
  42617. private static _tmpMats;
  42618. /**
  42619. * Gets or sets the target mesh
  42620. */
  42621. targetMesh: AbstractMesh;
  42622. /** Gets or sets the mesh used as pole */
  42623. poleTargetMesh: AbstractMesh;
  42624. /**
  42625. * Gets or sets the bone used as pole
  42626. */
  42627. poleTargetBone: Nullable<Bone>;
  42628. /**
  42629. * Gets or sets the target position
  42630. */
  42631. targetPosition: Vector3;
  42632. /**
  42633. * Gets or sets the pole target position
  42634. */
  42635. poleTargetPosition: Vector3;
  42636. /**
  42637. * Gets or sets the pole target local offset
  42638. */
  42639. poleTargetLocalOffset: Vector3;
  42640. /**
  42641. * Gets or sets the pole angle
  42642. */
  42643. poleAngle: number;
  42644. /**
  42645. * Gets or sets the mesh associated with the controller
  42646. */
  42647. mesh: AbstractMesh;
  42648. /**
  42649. * 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)
  42650. */
  42651. slerpAmount: number;
  42652. private _bone1Quat;
  42653. private _bone1Mat;
  42654. private _bone2Ang;
  42655. private _bone1;
  42656. private _bone2;
  42657. private _bone1Length;
  42658. private _bone2Length;
  42659. private _maxAngle;
  42660. private _maxReach;
  42661. private _rightHandedSystem;
  42662. private _bendAxis;
  42663. private _slerping;
  42664. private _adjustRoll;
  42665. /**
  42666. * Gets or sets maximum allowed angle
  42667. */
  42668. get maxAngle(): number;
  42669. set maxAngle(value: number);
  42670. /**
  42671. * Creates a new BoneIKController
  42672. * @param mesh defines the mesh to control
  42673. * @param bone defines the bone to control
  42674. * @param options defines options to set up the controller
  42675. */
  42676. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42677. targetMesh?: AbstractMesh;
  42678. poleTargetMesh?: AbstractMesh;
  42679. poleTargetBone?: Bone;
  42680. poleTargetLocalOffset?: Vector3;
  42681. poleAngle?: number;
  42682. bendAxis?: Vector3;
  42683. maxAngle?: number;
  42684. slerpAmount?: number;
  42685. });
  42686. private _setMaxAngle;
  42687. /**
  42688. * Force the controller to update the bones
  42689. */
  42690. update(): void;
  42691. }
  42692. }
  42693. declare module BABYLON {
  42694. /**
  42695. * Class used to make a bone look toward a point in space
  42696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42697. */
  42698. export class BoneLookController {
  42699. private static _tmpVecs;
  42700. private static _tmpQuat;
  42701. private static _tmpMats;
  42702. /**
  42703. * The target Vector3 that the bone will look at
  42704. */
  42705. target: Vector3;
  42706. /**
  42707. * The mesh that the bone is attached to
  42708. */
  42709. mesh: AbstractMesh;
  42710. /**
  42711. * The bone that will be looking to the target
  42712. */
  42713. bone: Bone;
  42714. /**
  42715. * The up axis of the coordinate system that is used when the bone is rotated
  42716. */
  42717. upAxis: Vector3;
  42718. /**
  42719. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42720. */
  42721. upAxisSpace: Space;
  42722. /**
  42723. * Used to make an adjustment to the yaw of the bone
  42724. */
  42725. adjustYaw: number;
  42726. /**
  42727. * Used to make an adjustment to the pitch of the bone
  42728. */
  42729. adjustPitch: number;
  42730. /**
  42731. * Used to make an adjustment to the roll of the bone
  42732. */
  42733. adjustRoll: number;
  42734. /**
  42735. * 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)
  42736. */
  42737. slerpAmount: number;
  42738. private _minYaw;
  42739. private _maxYaw;
  42740. private _minPitch;
  42741. private _maxPitch;
  42742. private _minYawSin;
  42743. private _minYawCos;
  42744. private _maxYawSin;
  42745. private _maxYawCos;
  42746. private _midYawConstraint;
  42747. private _minPitchTan;
  42748. private _maxPitchTan;
  42749. private _boneQuat;
  42750. private _slerping;
  42751. private _transformYawPitch;
  42752. private _transformYawPitchInv;
  42753. private _firstFrameSkipped;
  42754. private _yawRange;
  42755. private _fowardAxis;
  42756. /**
  42757. * Gets or sets the minimum yaw angle that the bone can look to
  42758. */
  42759. get minYaw(): number;
  42760. set minYaw(value: number);
  42761. /**
  42762. * Gets or sets the maximum yaw angle that the bone can look to
  42763. */
  42764. get maxYaw(): number;
  42765. set maxYaw(value: number);
  42766. /**
  42767. * Gets or sets the minimum pitch angle that the bone can look to
  42768. */
  42769. get minPitch(): number;
  42770. set minPitch(value: number);
  42771. /**
  42772. * Gets or sets the maximum pitch angle that the bone can look to
  42773. */
  42774. get maxPitch(): number;
  42775. set maxPitch(value: number);
  42776. /**
  42777. * Create a BoneLookController
  42778. * @param mesh the mesh that the bone belongs to
  42779. * @param bone the bone that will be looking to the target
  42780. * @param target the target Vector3 to look at
  42781. * @param options optional settings:
  42782. * * maxYaw: the maximum angle the bone will yaw to
  42783. * * minYaw: the minimum angle the bone will yaw to
  42784. * * maxPitch: the maximum angle the bone will pitch to
  42785. * * minPitch: the minimum angle the bone will yaw to
  42786. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42787. * * upAxis: the up axis of the coordinate system
  42788. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42789. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42790. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42791. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42792. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42793. * * adjustRoll: used to make an adjustment to the roll of the bone
  42794. **/
  42795. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42796. maxYaw?: number;
  42797. minYaw?: number;
  42798. maxPitch?: number;
  42799. minPitch?: number;
  42800. slerpAmount?: number;
  42801. upAxis?: Vector3;
  42802. upAxisSpace?: Space;
  42803. yawAxis?: Vector3;
  42804. pitchAxis?: Vector3;
  42805. adjustYaw?: number;
  42806. adjustPitch?: number;
  42807. adjustRoll?: number;
  42808. });
  42809. /**
  42810. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42811. */
  42812. update(): void;
  42813. private _getAngleDiff;
  42814. private _getAngleBetween;
  42815. private _isAngleBetween;
  42816. }
  42817. }
  42818. declare module BABYLON {
  42819. /**
  42820. * Manage the gamepad inputs to control an arc rotate camera.
  42821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42822. */
  42823. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42824. /**
  42825. * Defines the camera the input is attached to.
  42826. */
  42827. camera: ArcRotateCamera;
  42828. /**
  42829. * Defines the gamepad the input is gathering event from.
  42830. */
  42831. gamepad: Nullable<Gamepad>;
  42832. /**
  42833. * Defines the gamepad rotation sensiblity.
  42834. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42835. */
  42836. gamepadRotationSensibility: number;
  42837. /**
  42838. * Defines the gamepad move sensiblity.
  42839. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42840. */
  42841. gamepadMoveSensibility: number;
  42842. private _yAxisScale;
  42843. /**
  42844. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42845. */
  42846. get invertYAxis(): boolean;
  42847. set invertYAxis(value: boolean);
  42848. private _onGamepadConnectedObserver;
  42849. private _onGamepadDisconnectedObserver;
  42850. /**
  42851. * Attach the input controls to a specific dom element to get the input from.
  42852. * @param element Defines the element the controls should be listened from
  42853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42854. */
  42855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42856. /**
  42857. * Detach the current controls from the specified dom element.
  42858. * @param element Defines the element to stop listening the inputs from
  42859. */
  42860. detachControl(element: Nullable<HTMLElement>): void;
  42861. /**
  42862. * Update the current camera state depending on the inputs that have been used this frame.
  42863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42864. */
  42865. checkInputs(): void;
  42866. /**
  42867. * Gets the class name of the current intput.
  42868. * @returns the class name
  42869. */
  42870. getClassName(): string;
  42871. /**
  42872. * Get the friendly name associated with the input class.
  42873. * @returns the input friendly name
  42874. */
  42875. getSimpleName(): string;
  42876. }
  42877. }
  42878. declare module BABYLON {
  42879. interface ArcRotateCameraInputsManager {
  42880. /**
  42881. * Add orientation input support to the input manager.
  42882. * @returns the current input manager
  42883. */
  42884. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42885. }
  42886. /**
  42887. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42889. */
  42890. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42891. /**
  42892. * Defines the camera the input is attached to.
  42893. */
  42894. camera: ArcRotateCamera;
  42895. /**
  42896. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42897. */
  42898. alphaCorrection: number;
  42899. /**
  42900. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42901. */
  42902. gammaCorrection: number;
  42903. private _alpha;
  42904. private _gamma;
  42905. private _dirty;
  42906. private _deviceOrientationHandler;
  42907. /**
  42908. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42909. */
  42910. constructor();
  42911. /**
  42912. * Attach the input controls to a specific dom element to get the input from.
  42913. * @param element Defines the element the controls should be listened from
  42914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42915. */
  42916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42917. /** @hidden */
  42918. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42919. /**
  42920. * Update the current camera state depending on the inputs that have been used this frame.
  42921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42922. */
  42923. checkInputs(): void;
  42924. /**
  42925. * Detach the current controls from the specified dom element.
  42926. * @param element Defines the element to stop listening the inputs from
  42927. */
  42928. detachControl(element: Nullable<HTMLElement>): void;
  42929. /**
  42930. * Gets the class name of the current intput.
  42931. * @returns the class name
  42932. */
  42933. getClassName(): string;
  42934. /**
  42935. * Get the friendly name associated with the input class.
  42936. * @returns the input friendly name
  42937. */
  42938. getSimpleName(): string;
  42939. }
  42940. }
  42941. declare module BABYLON {
  42942. /**
  42943. * Listen to mouse events to control the camera.
  42944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42945. */
  42946. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42947. /**
  42948. * Defines the camera the input is attached to.
  42949. */
  42950. camera: FlyCamera;
  42951. /**
  42952. * Defines if touch is enabled. (Default is true.)
  42953. */
  42954. touchEnabled: boolean;
  42955. /**
  42956. * Defines the buttons associated with the input to handle camera rotation.
  42957. */
  42958. buttons: number[];
  42959. /**
  42960. * Assign buttons for Yaw control.
  42961. */
  42962. buttonsYaw: number[];
  42963. /**
  42964. * Assign buttons for Pitch control.
  42965. */
  42966. buttonsPitch: number[];
  42967. /**
  42968. * Assign buttons for Roll control.
  42969. */
  42970. buttonsRoll: number[];
  42971. /**
  42972. * Detect if any button is being pressed while mouse is moved.
  42973. * -1 = Mouse locked.
  42974. * 0 = Left button.
  42975. * 1 = Middle Button.
  42976. * 2 = Right Button.
  42977. */
  42978. activeButton: number;
  42979. /**
  42980. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42981. * Higher values reduce its sensitivity.
  42982. */
  42983. angularSensibility: number;
  42984. private _mousemoveCallback;
  42985. private _observer;
  42986. private _rollObserver;
  42987. private previousPosition;
  42988. private noPreventDefault;
  42989. private element;
  42990. /**
  42991. * Listen to mouse events to control the camera.
  42992. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42994. */
  42995. constructor(touchEnabled?: boolean);
  42996. /**
  42997. * Attach the mouse control to the HTML DOM element.
  42998. * @param element Defines the element that listens to the input events.
  42999. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43000. */
  43001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43002. /**
  43003. * Detach the current controls from the specified dom element.
  43004. * @param element Defines the element to stop listening the inputs from
  43005. */
  43006. detachControl(element: Nullable<HTMLElement>): void;
  43007. /**
  43008. * Gets the class name of the current input.
  43009. * @returns the class name.
  43010. */
  43011. getClassName(): string;
  43012. /**
  43013. * Get the friendly name associated with the input class.
  43014. * @returns the input's friendly name.
  43015. */
  43016. getSimpleName(): string;
  43017. private _pointerInput;
  43018. private _onMouseMove;
  43019. /**
  43020. * Rotate camera by mouse offset.
  43021. */
  43022. private rotateCamera;
  43023. }
  43024. }
  43025. declare module BABYLON {
  43026. /**
  43027. * Default Inputs manager for the FlyCamera.
  43028. * It groups all the default supported inputs for ease of use.
  43029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43030. */
  43031. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43032. /**
  43033. * Instantiates a new FlyCameraInputsManager.
  43034. * @param camera Defines the camera the inputs belong to.
  43035. */
  43036. constructor(camera: FlyCamera);
  43037. /**
  43038. * Add keyboard input support to the input manager.
  43039. * @returns the new FlyCameraKeyboardMoveInput().
  43040. */
  43041. addKeyboard(): FlyCameraInputsManager;
  43042. /**
  43043. * Add mouse input support to the input manager.
  43044. * @param touchEnabled Enable touch screen support.
  43045. * @returns the new FlyCameraMouseInput().
  43046. */
  43047. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43048. }
  43049. }
  43050. declare module BABYLON {
  43051. /**
  43052. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43053. * such as in a 3D Space Shooter or a Flight Simulator.
  43054. */
  43055. export class FlyCamera extends TargetCamera {
  43056. /**
  43057. * Define the collision ellipsoid of the camera.
  43058. * This is helpful for simulating a camera body, like a player's body.
  43059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43060. */
  43061. ellipsoid: Vector3;
  43062. /**
  43063. * Define an offset for the position of the ellipsoid around the camera.
  43064. * This can be helpful if the camera is attached away from the player's body center,
  43065. * such as at its head.
  43066. */
  43067. ellipsoidOffset: Vector3;
  43068. /**
  43069. * Enable or disable collisions of the camera with the rest of the scene objects.
  43070. */
  43071. checkCollisions: boolean;
  43072. /**
  43073. * Enable or disable gravity on the camera.
  43074. */
  43075. applyGravity: boolean;
  43076. /**
  43077. * Define the current direction the camera is moving to.
  43078. */
  43079. cameraDirection: Vector3;
  43080. /**
  43081. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43082. * This overrides and empties cameraRotation.
  43083. */
  43084. rotationQuaternion: Quaternion;
  43085. /**
  43086. * Track Roll to maintain the wanted Rolling when looking around.
  43087. */
  43088. _trackRoll: number;
  43089. /**
  43090. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43091. */
  43092. rollCorrect: number;
  43093. /**
  43094. * Mimic a banked turn, Rolling the camera when Yawing.
  43095. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43096. */
  43097. bankedTurn: boolean;
  43098. /**
  43099. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43100. */
  43101. bankedTurnLimit: number;
  43102. /**
  43103. * Value of 0 disables the banked Roll.
  43104. * Value of 1 is equal to the Yaw angle in radians.
  43105. */
  43106. bankedTurnMultiplier: number;
  43107. /**
  43108. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43109. */
  43110. inputs: FlyCameraInputsManager;
  43111. /**
  43112. * Gets the input sensibility for mouse input.
  43113. * Higher values reduce sensitivity.
  43114. */
  43115. get angularSensibility(): number;
  43116. /**
  43117. * Sets the input sensibility for a mouse input.
  43118. * Higher values reduce sensitivity.
  43119. */
  43120. set angularSensibility(value: number);
  43121. /**
  43122. * Get the keys for camera movement forward.
  43123. */
  43124. get keysForward(): number[];
  43125. /**
  43126. * Set the keys for camera movement forward.
  43127. */
  43128. set keysForward(value: number[]);
  43129. /**
  43130. * Get the keys for camera movement backward.
  43131. */
  43132. get keysBackward(): number[];
  43133. set keysBackward(value: number[]);
  43134. /**
  43135. * Get the keys for camera movement up.
  43136. */
  43137. get keysUp(): number[];
  43138. /**
  43139. * Set the keys for camera movement up.
  43140. */
  43141. set keysUp(value: number[]);
  43142. /**
  43143. * Get the keys for camera movement down.
  43144. */
  43145. get keysDown(): number[];
  43146. /**
  43147. * Set the keys for camera movement down.
  43148. */
  43149. set keysDown(value: number[]);
  43150. /**
  43151. * Get the keys for camera movement left.
  43152. */
  43153. get keysLeft(): number[];
  43154. /**
  43155. * Set the keys for camera movement left.
  43156. */
  43157. set keysLeft(value: number[]);
  43158. /**
  43159. * Set the keys for camera movement right.
  43160. */
  43161. get keysRight(): number[];
  43162. /**
  43163. * Set the keys for camera movement right.
  43164. */
  43165. set keysRight(value: number[]);
  43166. /**
  43167. * Event raised when the camera collides with a mesh in the scene.
  43168. */
  43169. onCollide: (collidedMesh: AbstractMesh) => void;
  43170. private _collider;
  43171. private _needMoveForGravity;
  43172. private _oldPosition;
  43173. private _diffPosition;
  43174. private _newPosition;
  43175. /** @hidden */
  43176. _localDirection: Vector3;
  43177. /** @hidden */
  43178. _transformedDirection: Vector3;
  43179. /**
  43180. * Instantiates a FlyCamera.
  43181. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43182. * such as in a 3D Space Shooter or a Flight Simulator.
  43183. * @param name Define the name of the camera in the scene.
  43184. * @param position Define the starting position of the camera in the scene.
  43185. * @param scene Define the scene the camera belongs to.
  43186. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43187. */
  43188. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43189. /**
  43190. * Attach a control to the HTML DOM element.
  43191. * @param element Defines the element that listens to the input events.
  43192. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43193. */
  43194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43195. /**
  43196. * Detach a control from the HTML DOM element.
  43197. * The camera will stop reacting to that input.
  43198. * @param element Defines the element that listens to the input events.
  43199. */
  43200. detachControl(element: HTMLElement): void;
  43201. private _collisionMask;
  43202. /**
  43203. * Get the mask that the camera ignores in collision events.
  43204. */
  43205. get collisionMask(): number;
  43206. /**
  43207. * Set the mask that the camera ignores in collision events.
  43208. */
  43209. set collisionMask(mask: number);
  43210. /** @hidden */
  43211. _collideWithWorld(displacement: Vector3): void;
  43212. /** @hidden */
  43213. private _onCollisionPositionChange;
  43214. /** @hidden */
  43215. _checkInputs(): void;
  43216. /** @hidden */
  43217. _decideIfNeedsToMove(): boolean;
  43218. /** @hidden */
  43219. _updatePosition(): void;
  43220. /**
  43221. * Restore the Roll to its target value at the rate specified.
  43222. * @param rate - Higher means slower restoring.
  43223. * @hidden
  43224. */
  43225. restoreRoll(rate: number): void;
  43226. /**
  43227. * Destroy the camera and release the current resources held by it.
  43228. */
  43229. dispose(): void;
  43230. /**
  43231. * Get the current object class name.
  43232. * @returns the class name.
  43233. */
  43234. getClassName(): string;
  43235. }
  43236. }
  43237. declare module BABYLON {
  43238. /**
  43239. * Listen to keyboard events to control the camera.
  43240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43241. */
  43242. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43243. /**
  43244. * Defines the camera the input is attached to.
  43245. */
  43246. camera: FlyCamera;
  43247. /**
  43248. * The list of keyboard keys used to control the forward move of the camera.
  43249. */
  43250. keysForward: number[];
  43251. /**
  43252. * The list of keyboard keys used to control the backward move of the camera.
  43253. */
  43254. keysBackward: number[];
  43255. /**
  43256. * The list of keyboard keys used to control the forward move of the camera.
  43257. */
  43258. keysUp: number[];
  43259. /**
  43260. * The list of keyboard keys used to control the backward move of the camera.
  43261. */
  43262. keysDown: number[];
  43263. /**
  43264. * The list of keyboard keys used to control the right strafe move of the camera.
  43265. */
  43266. keysRight: number[];
  43267. /**
  43268. * The list of keyboard keys used to control the left strafe move of the camera.
  43269. */
  43270. keysLeft: number[];
  43271. private _keys;
  43272. private _onCanvasBlurObserver;
  43273. private _onKeyboardObserver;
  43274. private _engine;
  43275. private _scene;
  43276. /**
  43277. * Attach the input controls to a specific dom element to get the input from.
  43278. * @param element Defines the element the controls should be listened from
  43279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43280. */
  43281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43282. /**
  43283. * Detach the current controls from the specified dom element.
  43284. * @param element Defines the element to stop listening the inputs from
  43285. */
  43286. detachControl(element: Nullable<HTMLElement>): void;
  43287. /**
  43288. * Gets the class name of the current intput.
  43289. * @returns the class name
  43290. */
  43291. getClassName(): string;
  43292. /** @hidden */
  43293. _onLostFocus(e: FocusEvent): void;
  43294. /**
  43295. * Get the friendly name associated with the input class.
  43296. * @returns the input friendly name
  43297. */
  43298. getSimpleName(): string;
  43299. /**
  43300. * Update the current camera state depending on the inputs that have been used this frame.
  43301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43302. */
  43303. checkInputs(): void;
  43304. }
  43305. }
  43306. declare module BABYLON {
  43307. /**
  43308. * Manage the mouse wheel inputs to control a follow camera.
  43309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43310. */
  43311. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43312. /**
  43313. * Defines the camera the input is attached to.
  43314. */
  43315. camera: FollowCamera;
  43316. /**
  43317. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43318. */
  43319. axisControlRadius: boolean;
  43320. /**
  43321. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43322. */
  43323. axisControlHeight: boolean;
  43324. /**
  43325. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43326. */
  43327. axisControlRotation: boolean;
  43328. /**
  43329. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43330. * relation to mouseWheel events.
  43331. */
  43332. wheelPrecision: number;
  43333. /**
  43334. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43335. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43336. */
  43337. wheelDeltaPercentage: number;
  43338. private _wheel;
  43339. private _observer;
  43340. /**
  43341. * Attach the input controls to a specific dom element to get the input from.
  43342. * @param element Defines the element the controls should be listened from
  43343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43344. */
  43345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43346. /**
  43347. * Detach the current controls from the specified dom element.
  43348. * @param element Defines the element to stop listening the inputs from
  43349. */
  43350. detachControl(element: Nullable<HTMLElement>): void;
  43351. /**
  43352. * Gets the class name of the current intput.
  43353. * @returns the class name
  43354. */
  43355. getClassName(): string;
  43356. /**
  43357. * Get the friendly name associated with the input class.
  43358. * @returns the input friendly name
  43359. */
  43360. getSimpleName(): string;
  43361. }
  43362. }
  43363. declare module BABYLON {
  43364. /**
  43365. * Manage the pointers inputs to control an follow camera.
  43366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43367. */
  43368. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43369. /**
  43370. * Defines the camera the input is attached to.
  43371. */
  43372. camera: FollowCamera;
  43373. /**
  43374. * Gets the class name of the current input.
  43375. * @returns the class name
  43376. */
  43377. getClassName(): string;
  43378. /**
  43379. * Defines the pointer angular sensibility along the X axis or how fast is
  43380. * the camera rotating.
  43381. * A negative number will reverse the axis direction.
  43382. */
  43383. angularSensibilityX: number;
  43384. /**
  43385. * Defines the pointer angular sensibility along the Y axis or how fast is
  43386. * the camera rotating.
  43387. * A negative number will reverse the axis direction.
  43388. */
  43389. angularSensibilityY: number;
  43390. /**
  43391. * Defines the pointer pinch precision or how fast is the camera zooming.
  43392. * A negative number will reverse the axis direction.
  43393. */
  43394. pinchPrecision: number;
  43395. /**
  43396. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43397. * from 0.
  43398. * It defines the percentage of current camera.radius to use as delta when
  43399. * pinch zoom is used.
  43400. */
  43401. pinchDeltaPercentage: number;
  43402. /**
  43403. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43404. */
  43405. axisXControlRadius: boolean;
  43406. /**
  43407. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43408. */
  43409. axisXControlHeight: boolean;
  43410. /**
  43411. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43412. */
  43413. axisXControlRotation: boolean;
  43414. /**
  43415. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43416. */
  43417. axisYControlRadius: boolean;
  43418. /**
  43419. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43420. */
  43421. axisYControlHeight: boolean;
  43422. /**
  43423. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43424. */
  43425. axisYControlRotation: boolean;
  43426. /**
  43427. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43428. */
  43429. axisPinchControlRadius: boolean;
  43430. /**
  43431. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43432. */
  43433. axisPinchControlHeight: boolean;
  43434. /**
  43435. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43436. */
  43437. axisPinchControlRotation: boolean;
  43438. /**
  43439. * Log error messages if basic misconfiguration has occurred.
  43440. */
  43441. warningEnable: boolean;
  43442. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43443. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43444. private _warningCounter;
  43445. private _warning;
  43446. }
  43447. }
  43448. declare module BABYLON {
  43449. /**
  43450. * Default Inputs manager for the FollowCamera.
  43451. * It groups all the default supported inputs for ease of use.
  43452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43453. */
  43454. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43455. /**
  43456. * Instantiates a new FollowCameraInputsManager.
  43457. * @param camera Defines the camera the inputs belong to
  43458. */
  43459. constructor(camera: FollowCamera);
  43460. /**
  43461. * Add keyboard input support to the input manager.
  43462. * @returns the current input manager
  43463. */
  43464. addKeyboard(): FollowCameraInputsManager;
  43465. /**
  43466. * Add mouse wheel input support to the input manager.
  43467. * @returns the current input manager
  43468. */
  43469. addMouseWheel(): FollowCameraInputsManager;
  43470. /**
  43471. * Add pointers input support to the input manager.
  43472. * @returns the current input manager
  43473. */
  43474. addPointers(): FollowCameraInputsManager;
  43475. /**
  43476. * Add orientation input support to the input manager.
  43477. * @returns the current input manager
  43478. */
  43479. addVRDeviceOrientation(): FollowCameraInputsManager;
  43480. }
  43481. }
  43482. declare module BABYLON {
  43483. /**
  43484. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43485. * an arc rotate version arcFollowCamera are available.
  43486. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43487. */
  43488. export class FollowCamera extends TargetCamera {
  43489. /**
  43490. * Distance the follow camera should follow an object at
  43491. */
  43492. radius: number;
  43493. /**
  43494. * Minimum allowed distance of the camera to the axis of rotation
  43495. * (The camera can not get closer).
  43496. * This can help limiting how the Camera is able to move in the scene.
  43497. */
  43498. lowerRadiusLimit: Nullable<number>;
  43499. /**
  43500. * Maximum allowed distance of the camera to the axis of rotation
  43501. * (The camera can not get further).
  43502. * This can help limiting how the Camera is able to move in the scene.
  43503. */
  43504. upperRadiusLimit: Nullable<number>;
  43505. /**
  43506. * Define a rotation offset between the camera and the object it follows
  43507. */
  43508. rotationOffset: number;
  43509. /**
  43510. * Minimum allowed angle to camera position relative to target object.
  43511. * This can help limiting how the Camera is able to move in the scene.
  43512. */
  43513. lowerRotationOffsetLimit: Nullable<number>;
  43514. /**
  43515. * Maximum allowed angle to camera position relative to target object.
  43516. * This can help limiting how the Camera is able to move in the scene.
  43517. */
  43518. upperRotationOffsetLimit: Nullable<number>;
  43519. /**
  43520. * Define a height offset between the camera and the object it follows.
  43521. * It can help following an object from the top (like a car chaing a plane)
  43522. */
  43523. heightOffset: number;
  43524. /**
  43525. * Minimum allowed height of camera position relative to target object.
  43526. * This can help limiting how the Camera is able to move in the scene.
  43527. */
  43528. lowerHeightOffsetLimit: Nullable<number>;
  43529. /**
  43530. * Maximum allowed height of camera position relative to target object.
  43531. * This can help limiting how the Camera is able to move in the scene.
  43532. */
  43533. upperHeightOffsetLimit: Nullable<number>;
  43534. /**
  43535. * Define how fast the camera can accelerate to follow it s target.
  43536. */
  43537. cameraAcceleration: number;
  43538. /**
  43539. * Define the speed limit of the camera following an object.
  43540. */
  43541. maxCameraSpeed: number;
  43542. /**
  43543. * Define the target of the camera.
  43544. */
  43545. lockedTarget: Nullable<AbstractMesh>;
  43546. /**
  43547. * Defines the input associated with the camera.
  43548. */
  43549. inputs: FollowCameraInputsManager;
  43550. /**
  43551. * Instantiates the follow camera.
  43552. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43553. * @param name Define the name of the camera in the scene
  43554. * @param position Define the position of the camera
  43555. * @param scene Define the scene the camera belong to
  43556. * @param lockedTarget Define the target of the camera
  43557. */
  43558. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43559. private _follow;
  43560. /**
  43561. * Attached controls to the current camera.
  43562. * @param element Defines the element the controls should be listened from
  43563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43564. */
  43565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43566. /**
  43567. * Detach the current controls from the camera.
  43568. * The camera will stop reacting to inputs.
  43569. * @param element Defines the element to stop listening the inputs from
  43570. */
  43571. detachControl(element: HTMLElement): void;
  43572. /** @hidden */
  43573. _checkInputs(): void;
  43574. private _checkLimits;
  43575. /**
  43576. * Gets the camera class name.
  43577. * @returns the class name
  43578. */
  43579. getClassName(): string;
  43580. }
  43581. /**
  43582. * Arc Rotate version of the follow camera.
  43583. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43584. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43585. */
  43586. export class ArcFollowCamera extends TargetCamera {
  43587. /** The longitudinal angle of the camera */
  43588. alpha: number;
  43589. /** The latitudinal angle of the camera */
  43590. beta: number;
  43591. /** The radius of the camera from its target */
  43592. radius: number;
  43593. /** Define the camera target (the mesh it should follow) */
  43594. target: Nullable<AbstractMesh>;
  43595. private _cartesianCoordinates;
  43596. /**
  43597. * Instantiates a new ArcFollowCamera
  43598. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43599. * @param name Define the name of the camera
  43600. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43601. * @param beta Define the rotation angle of the camera around the elevation axis
  43602. * @param radius Define the radius of the camera from its target point
  43603. * @param target Define the target of the camera
  43604. * @param scene Define the scene the camera belongs to
  43605. */
  43606. constructor(name: string,
  43607. /** The longitudinal angle of the camera */
  43608. alpha: number,
  43609. /** The latitudinal angle of the camera */
  43610. beta: number,
  43611. /** The radius of the camera from its target */
  43612. radius: number,
  43613. /** Define the camera target (the mesh it should follow) */
  43614. target: Nullable<AbstractMesh>, scene: Scene);
  43615. private _follow;
  43616. /** @hidden */
  43617. _checkInputs(): void;
  43618. /**
  43619. * Returns the class name of the object.
  43620. * It is mostly used internally for serialization purposes.
  43621. */
  43622. getClassName(): string;
  43623. }
  43624. }
  43625. declare module BABYLON {
  43626. /**
  43627. * Manage the keyboard inputs to control the movement of a follow camera.
  43628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43629. */
  43630. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43631. /**
  43632. * Defines the camera the input is attached to.
  43633. */
  43634. camera: FollowCamera;
  43635. /**
  43636. * Defines the list of key codes associated with the up action (increase heightOffset)
  43637. */
  43638. keysHeightOffsetIncr: number[];
  43639. /**
  43640. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43641. */
  43642. keysHeightOffsetDecr: number[];
  43643. /**
  43644. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43645. */
  43646. keysHeightOffsetModifierAlt: boolean;
  43647. /**
  43648. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43649. */
  43650. keysHeightOffsetModifierCtrl: boolean;
  43651. /**
  43652. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43653. */
  43654. keysHeightOffsetModifierShift: boolean;
  43655. /**
  43656. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43657. */
  43658. keysRotationOffsetIncr: number[];
  43659. /**
  43660. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43661. */
  43662. keysRotationOffsetDecr: number[];
  43663. /**
  43664. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43665. */
  43666. keysRotationOffsetModifierAlt: boolean;
  43667. /**
  43668. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43669. */
  43670. keysRotationOffsetModifierCtrl: boolean;
  43671. /**
  43672. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43673. */
  43674. keysRotationOffsetModifierShift: boolean;
  43675. /**
  43676. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43677. */
  43678. keysRadiusIncr: number[];
  43679. /**
  43680. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43681. */
  43682. keysRadiusDecr: number[];
  43683. /**
  43684. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43685. */
  43686. keysRadiusModifierAlt: boolean;
  43687. /**
  43688. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43689. */
  43690. keysRadiusModifierCtrl: boolean;
  43691. /**
  43692. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43693. */
  43694. keysRadiusModifierShift: boolean;
  43695. /**
  43696. * Defines the rate of change of heightOffset.
  43697. */
  43698. heightSensibility: number;
  43699. /**
  43700. * Defines the rate of change of rotationOffset.
  43701. */
  43702. rotationSensibility: number;
  43703. /**
  43704. * Defines the rate of change of radius.
  43705. */
  43706. radiusSensibility: number;
  43707. private _keys;
  43708. private _ctrlPressed;
  43709. private _altPressed;
  43710. private _shiftPressed;
  43711. private _onCanvasBlurObserver;
  43712. private _onKeyboardObserver;
  43713. private _engine;
  43714. private _scene;
  43715. /**
  43716. * Attach the input controls to a specific dom element to get the input from.
  43717. * @param element Defines the element the controls should be listened from
  43718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43719. */
  43720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43721. /**
  43722. * Detach the current controls from the specified dom element.
  43723. * @param element Defines the element to stop listening the inputs from
  43724. */
  43725. detachControl(element: Nullable<HTMLElement>): void;
  43726. /**
  43727. * Update the current camera state depending on the inputs that have been used this frame.
  43728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43729. */
  43730. checkInputs(): void;
  43731. /**
  43732. * Gets the class name of the current input.
  43733. * @returns the class name
  43734. */
  43735. getClassName(): string;
  43736. /**
  43737. * Get the friendly name associated with the input class.
  43738. * @returns the input friendly name
  43739. */
  43740. getSimpleName(): string;
  43741. /**
  43742. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43743. * allow modification of the heightOffset value.
  43744. */
  43745. private _modifierHeightOffset;
  43746. /**
  43747. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43748. * allow modification of the rotationOffset value.
  43749. */
  43750. private _modifierRotationOffset;
  43751. /**
  43752. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43753. * allow modification of the radius value.
  43754. */
  43755. private _modifierRadius;
  43756. }
  43757. }
  43758. declare module BABYLON {
  43759. interface FreeCameraInputsManager {
  43760. /**
  43761. * @hidden
  43762. */
  43763. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43764. /**
  43765. * Add orientation input support to the input manager.
  43766. * @returns the current input manager
  43767. */
  43768. addDeviceOrientation(): FreeCameraInputsManager;
  43769. }
  43770. /**
  43771. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43772. * Screen rotation is taken into account.
  43773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43774. */
  43775. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43776. private _camera;
  43777. private _screenOrientationAngle;
  43778. private _constantTranform;
  43779. private _screenQuaternion;
  43780. private _alpha;
  43781. private _beta;
  43782. private _gamma;
  43783. /**
  43784. * Can be used to detect if a device orientation sensor is available on a device
  43785. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43786. * @returns a promise that will resolve on orientation change
  43787. */
  43788. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43789. /**
  43790. * @hidden
  43791. */
  43792. _onDeviceOrientationChangedObservable: Observable<void>;
  43793. /**
  43794. * Instantiates a new input
  43795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43796. */
  43797. constructor();
  43798. /**
  43799. * Define the camera controlled by the input.
  43800. */
  43801. get camera(): FreeCamera;
  43802. set camera(camera: FreeCamera);
  43803. /**
  43804. * Attach the input controls to a specific dom element to get the input from.
  43805. * @param element Defines the element the controls should be listened from
  43806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43807. */
  43808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43809. private _orientationChanged;
  43810. private _deviceOrientation;
  43811. /**
  43812. * Detach the current controls from the specified dom element.
  43813. * @param element Defines the element to stop listening the inputs from
  43814. */
  43815. detachControl(element: Nullable<HTMLElement>): void;
  43816. /**
  43817. * Update the current camera state depending on the inputs that have been used this frame.
  43818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43819. */
  43820. checkInputs(): void;
  43821. /**
  43822. * Gets the class name of the current intput.
  43823. * @returns the class name
  43824. */
  43825. getClassName(): string;
  43826. /**
  43827. * Get the friendly name associated with the input class.
  43828. * @returns the input friendly name
  43829. */
  43830. getSimpleName(): string;
  43831. }
  43832. }
  43833. declare module BABYLON {
  43834. /**
  43835. * Manage the gamepad inputs to control a free camera.
  43836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43837. */
  43838. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43839. /**
  43840. * Define the camera the input is attached to.
  43841. */
  43842. camera: FreeCamera;
  43843. /**
  43844. * Define the Gamepad controlling the input
  43845. */
  43846. gamepad: Nullable<Gamepad>;
  43847. /**
  43848. * Defines the gamepad rotation sensiblity.
  43849. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43850. */
  43851. gamepadAngularSensibility: number;
  43852. /**
  43853. * Defines the gamepad move sensiblity.
  43854. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43855. */
  43856. gamepadMoveSensibility: number;
  43857. private _yAxisScale;
  43858. /**
  43859. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43860. */
  43861. get invertYAxis(): boolean;
  43862. set invertYAxis(value: boolean);
  43863. private _onGamepadConnectedObserver;
  43864. private _onGamepadDisconnectedObserver;
  43865. private _cameraTransform;
  43866. private _deltaTransform;
  43867. private _vector3;
  43868. private _vector2;
  43869. /**
  43870. * Attach the input controls to a specific dom element to get the input from.
  43871. * @param element Defines the element the controls should be listened from
  43872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43873. */
  43874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43875. /**
  43876. * Detach the current controls from the specified dom element.
  43877. * @param element Defines the element to stop listening the inputs from
  43878. */
  43879. detachControl(element: Nullable<HTMLElement>): void;
  43880. /**
  43881. * Update the current camera state depending on the inputs that have been used this frame.
  43882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43883. */
  43884. checkInputs(): void;
  43885. /**
  43886. * Gets the class name of the current intput.
  43887. * @returns the class name
  43888. */
  43889. getClassName(): string;
  43890. /**
  43891. * Get the friendly name associated with the input class.
  43892. * @returns the input friendly name
  43893. */
  43894. getSimpleName(): string;
  43895. }
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Defines the potential axis of a Joystick
  43900. */
  43901. export enum JoystickAxis {
  43902. /** X axis */
  43903. X = 0,
  43904. /** Y axis */
  43905. Y = 1,
  43906. /** Z axis */
  43907. Z = 2
  43908. }
  43909. /**
  43910. * Class used to define virtual joystick (used in touch mode)
  43911. */
  43912. export class VirtualJoystick {
  43913. /**
  43914. * Gets or sets a boolean indicating that left and right values must be inverted
  43915. */
  43916. reverseLeftRight: boolean;
  43917. /**
  43918. * Gets or sets a boolean indicating that up and down values must be inverted
  43919. */
  43920. reverseUpDown: boolean;
  43921. /**
  43922. * Gets the offset value for the position (ie. the change of the position value)
  43923. */
  43924. deltaPosition: Vector3;
  43925. /**
  43926. * Gets a boolean indicating if the virtual joystick was pressed
  43927. */
  43928. pressed: boolean;
  43929. /**
  43930. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43931. */
  43932. static Canvas: Nullable<HTMLCanvasElement>;
  43933. private static _globalJoystickIndex;
  43934. private static vjCanvasContext;
  43935. private static vjCanvasWidth;
  43936. private static vjCanvasHeight;
  43937. private static halfWidth;
  43938. private _action;
  43939. private _axisTargetedByLeftAndRight;
  43940. private _axisTargetedByUpAndDown;
  43941. private _joystickSensibility;
  43942. private _inversedSensibility;
  43943. private _joystickPointerID;
  43944. private _joystickColor;
  43945. private _joystickPointerPos;
  43946. private _joystickPreviousPointerPos;
  43947. private _joystickPointerStartPos;
  43948. private _deltaJoystickVector;
  43949. private _leftJoystick;
  43950. private _touches;
  43951. private _onPointerDownHandlerRef;
  43952. private _onPointerMoveHandlerRef;
  43953. private _onPointerUpHandlerRef;
  43954. private _onResize;
  43955. /**
  43956. * Creates a new virtual joystick
  43957. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43958. */
  43959. constructor(leftJoystick?: boolean);
  43960. /**
  43961. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43962. * @param newJoystickSensibility defines the new sensibility
  43963. */
  43964. setJoystickSensibility(newJoystickSensibility: number): void;
  43965. private _onPointerDown;
  43966. private _onPointerMove;
  43967. private _onPointerUp;
  43968. /**
  43969. * Change the color of the virtual joystick
  43970. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43971. */
  43972. setJoystickColor(newColor: string): void;
  43973. /**
  43974. * Defines a callback to call when the joystick is touched
  43975. * @param action defines the callback
  43976. */
  43977. setActionOnTouch(action: () => any): void;
  43978. /**
  43979. * Defines which axis you'd like to control for left & right
  43980. * @param axis defines the axis to use
  43981. */
  43982. setAxisForLeftRight(axis: JoystickAxis): void;
  43983. /**
  43984. * Defines which axis you'd like to control for up & down
  43985. * @param axis defines the axis to use
  43986. */
  43987. setAxisForUpDown(axis: JoystickAxis): void;
  43988. private _drawVirtualJoystick;
  43989. /**
  43990. * Release internal HTML canvas
  43991. */
  43992. releaseCanvas(): void;
  43993. }
  43994. }
  43995. declare module BABYLON {
  43996. interface FreeCameraInputsManager {
  43997. /**
  43998. * Add virtual joystick input support to the input manager.
  43999. * @returns the current input manager
  44000. */
  44001. addVirtualJoystick(): FreeCameraInputsManager;
  44002. }
  44003. /**
  44004. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44006. */
  44007. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44008. /**
  44009. * Defines the camera the input is attached to.
  44010. */
  44011. camera: FreeCamera;
  44012. private _leftjoystick;
  44013. private _rightjoystick;
  44014. /**
  44015. * Gets the left stick of the virtual joystick.
  44016. * @returns The virtual Joystick
  44017. */
  44018. getLeftJoystick(): VirtualJoystick;
  44019. /**
  44020. * Gets the right stick of the virtual joystick.
  44021. * @returns The virtual Joystick
  44022. */
  44023. getRightJoystick(): VirtualJoystick;
  44024. /**
  44025. * Update the current camera state depending on the inputs that have been used this frame.
  44026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44027. */
  44028. checkInputs(): void;
  44029. /**
  44030. * Attach the input controls to a specific dom element to get the input from.
  44031. * @param element Defines the element the controls should be listened from
  44032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44033. */
  44034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44035. /**
  44036. * Detach the current controls from the specified dom element.
  44037. * @param element Defines the element to stop listening the inputs from
  44038. */
  44039. detachControl(element: Nullable<HTMLElement>): void;
  44040. /**
  44041. * Gets the class name of the current intput.
  44042. * @returns the class name
  44043. */
  44044. getClassName(): string;
  44045. /**
  44046. * Get the friendly name associated with the input class.
  44047. * @returns the input friendly name
  44048. */
  44049. getSimpleName(): string;
  44050. }
  44051. }
  44052. declare module BABYLON {
  44053. /**
  44054. * This represents a FPS type of camera controlled by touch.
  44055. * This is like a universal camera minus the Gamepad controls.
  44056. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44057. */
  44058. export class TouchCamera extends FreeCamera {
  44059. /**
  44060. * Defines the touch sensibility for rotation.
  44061. * The higher the faster.
  44062. */
  44063. get touchAngularSensibility(): number;
  44064. set touchAngularSensibility(value: number);
  44065. /**
  44066. * Defines the touch sensibility for move.
  44067. * The higher the faster.
  44068. */
  44069. get touchMoveSensibility(): number;
  44070. set touchMoveSensibility(value: number);
  44071. /**
  44072. * Instantiates a new touch camera.
  44073. * This represents a FPS type of camera controlled by touch.
  44074. * This is like a universal camera minus the Gamepad controls.
  44075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44076. * @param name Define the name of the camera in the scene
  44077. * @param position Define the start position of the camera in the scene
  44078. * @param scene Define the scene the camera belongs to
  44079. */
  44080. constructor(name: string, position: Vector3, scene: Scene);
  44081. /**
  44082. * Gets the current object class name.
  44083. * @return the class name
  44084. */
  44085. getClassName(): string;
  44086. /** @hidden */
  44087. _setupInputs(): void;
  44088. }
  44089. }
  44090. declare module BABYLON {
  44091. /**
  44092. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44093. * being tilted forward or back and left or right.
  44094. */
  44095. export class DeviceOrientationCamera extends FreeCamera {
  44096. private _initialQuaternion;
  44097. private _quaternionCache;
  44098. private _tmpDragQuaternion;
  44099. private _disablePointerInputWhenUsingDeviceOrientation;
  44100. /**
  44101. * Creates a new device orientation camera
  44102. * @param name The name of the camera
  44103. * @param position The start position camera
  44104. * @param scene The scene the camera belongs to
  44105. */
  44106. constructor(name: string, position: Vector3, scene: Scene);
  44107. /**
  44108. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44109. */
  44110. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44111. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44112. private _dragFactor;
  44113. /**
  44114. * Enabled turning on the y axis when the orientation sensor is active
  44115. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44116. */
  44117. enableHorizontalDragging(dragFactor?: number): void;
  44118. /**
  44119. * Gets the current instance class name ("DeviceOrientationCamera").
  44120. * This helps avoiding instanceof at run time.
  44121. * @returns the class name
  44122. */
  44123. getClassName(): string;
  44124. /**
  44125. * @hidden
  44126. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44127. */
  44128. _checkInputs(): void;
  44129. /**
  44130. * Reset the camera to its default orientation on the specified axis only.
  44131. * @param axis The axis to reset
  44132. */
  44133. resetToCurrentRotation(axis?: Axis): void;
  44134. }
  44135. }
  44136. declare module BABYLON {
  44137. /**
  44138. * Defines supported buttons for XBox360 compatible gamepads
  44139. */
  44140. export enum Xbox360Button {
  44141. /** A */
  44142. A = 0,
  44143. /** B */
  44144. B = 1,
  44145. /** X */
  44146. X = 2,
  44147. /** Y */
  44148. Y = 3,
  44149. /** Left button */
  44150. LB = 4,
  44151. /** Right button */
  44152. RB = 5,
  44153. /** Back */
  44154. Back = 8,
  44155. /** Start */
  44156. Start = 9,
  44157. /** Left stick */
  44158. LeftStick = 10,
  44159. /** Right stick */
  44160. RightStick = 11
  44161. }
  44162. /** Defines values for XBox360 DPad */
  44163. export enum Xbox360Dpad {
  44164. /** Up */
  44165. Up = 12,
  44166. /** Down */
  44167. Down = 13,
  44168. /** Left */
  44169. Left = 14,
  44170. /** Right */
  44171. Right = 15
  44172. }
  44173. /**
  44174. * Defines a XBox360 gamepad
  44175. */
  44176. export class Xbox360Pad extends Gamepad {
  44177. private _leftTrigger;
  44178. private _rightTrigger;
  44179. private _onlefttriggerchanged;
  44180. private _onrighttriggerchanged;
  44181. private _onbuttondown;
  44182. private _onbuttonup;
  44183. private _ondpaddown;
  44184. private _ondpadup;
  44185. /** Observable raised when a button is pressed */
  44186. onButtonDownObservable: Observable<Xbox360Button>;
  44187. /** Observable raised when a button is released */
  44188. onButtonUpObservable: Observable<Xbox360Button>;
  44189. /** Observable raised when a pad is pressed */
  44190. onPadDownObservable: Observable<Xbox360Dpad>;
  44191. /** Observable raised when a pad is released */
  44192. onPadUpObservable: Observable<Xbox360Dpad>;
  44193. private _buttonA;
  44194. private _buttonB;
  44195. private _buttonX;
  44196. private _buttonY;
  44197. private _buttonBack;
  44198. private _buttonStart;
  44199. private _buttonLB;
  44200. private _buttonRB;
  44201. private _buttonLeftStick;
  44202. private _buttonRightStick;
  44203. private _dPadUp;
  44204. private _dPadDown;
  44205. private _dPadLeft;
  44206. private _dPadRight;
  44207. private _isXboxOnePad;
  44208. /**
  44209. * Creates a new XBox360 gamepad object
  44210. * @param id defines the id of this gamepad
  44211. * @param index defines its index
  44212. * @param gamepad defines the internal HTML gamepad object
  44213. * @param xboxOne defines if it is a XBox One gamepad
  44214. */
  44215. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44216. /**
  44217. * Defines the callback to call when left trigger is pressed
  44218. * @param callback defines the callback to use
  44219. */
  44220. onlefttriggerchanged(callback: (value: number) => void): void;
  44221. /**
  44222. * Defines the callback to call when right trigger is pressed
  44223. * @param callback defines the callback to use
  44224. */
  44225. onrighttriggerchanged(callback: (value: number) => void): void;
  44226. /**
  44227. * Gets the left trigger value
  44228. */
  44229. get leftTrigger(): number;
  44230. /**
  44231. * Sets the left trigger value
  44232. */
  44233. set leftTrigger(newValue: number);
  44234. /**
  44235. * Gets the right trigger value
  44236. */
  44237. get rightTrigger(): number;
  44238. /**
  44239. * Sets the right trigger value
  44240. */
  44241. set rightTrigger(newValue: number);
  44242. /**
  44243. * Defines the callback to call when a button is pressed
  44244. * @param callback defines the callback to use
  44245. */
  44246. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44247. /**
  44248. * Defines the callback to call when a button is released
  44249. * @param callback defines the callback to use
  44250. */
  44251. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44252. /**
  44253. * Defines the callback to call when a pad is pressed
  44254. * @param callback defines the callback to use
  44255. */
  44256. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44257. /**
  44258. * Defines the callback to call when a pad is released
  44259. * @param callback defines the callback to use
  44260. */
  44261. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44262. private _setButtonValue;
  44263. private _setDPadValue;
  44264. /**
  44265. * Gets the value of the `A` button
  44266. */
  44267. get buttonA(): number;
  44268. /**
  44269. * Sets the value of the `A` button
  44270. */
  44271. set buttonA(value: number);
  44272. /**
  44273. * Gets the value of the `B` button
  44274. */
  44275. get buttonB(): number;
  44276. /**
  44277. * Sets the value of the `B` button
  44278. */
  44279. set buttonB(value: number);
  44280. /**
  44281. * Gets the value of the `X` button
  44282. */
  44283. get buttonX(): number;
  44284. /**
  44285. * Sets the value of the `X` button
  44286. */
  44287. set buttonX(value: number);
  44288. /**
  44289. * Gets the value of the `Y` button
  44290. */
  44291. get buttonY(): number;
  44292. /**
  44293. * Sets the value of the `Y` button
  44294. */
  44295. set buttonY(value: number);
  44296. /**
  44297. * Gets the value of the `Start` button
  44298. */
  44299. get buttonStart(): number;
  44300. /**
  44301. * Sets the value of the `Start` button
  44302. */
  44303. set buttonStart(value: number);
  44304. /**
  44305. * Gets the value of the `Back` button
  44306. */
  44307. get buttonBack(): number;
  44308. /**
  44309. * Sets the value of the `Back` button
  44310. */
  44311. set buttonBack(value: number);
  44312. /**
  44313. * Gets the value of the `Left` button
  44314. */
  44315. get buttonLB(): number;
  44316. /**
  44317. * Sets the value of the `Left` button
  44318. */
  44319. set buttonLB(value: number);
  44320. /**
  44321. * Gets the value of the `Right` button
  44322. */
  44323. get buttonRB(): number;
  44324. /**
  44325. * Sets the value of the `Right` button
  44326. */
  44327. set buttonRB(value: number);
  44328. /**
  44329. * Gets the value of the Left joystick
  44330. */
  44331. get buttonLeftStick(): number;
  44332. /**
  44333. * Sets the value of the Left joystick
  44334. */
  44335. set buttonLeftStick(value: number);
  44336. /**
  44337. * Gets the value of the Right joystick
  44338. */
  44339. get buttonRightStick(): number;
  44340. /**
  44341. * Sets the value of the Right joystick
  44342. */
  44343. set buttonRightStick(value: number);
  44344. /**
  44345. * Gets the value of D-pad up
  44346. */
  44347. get dPadUp(): number;
  44348. /**
  44349. * Sets the value of D-pad up
  44350. */
  44351. set dPadUp(value: number);
  44352. /**
  44353. * Gets the value of D-pad down
  44354. */
  44355. get dPadDown(): number;
  44356. /**
  44357. * Sets the value of D-pad down
  44358. */
  44359. set dPadDown(value: number);
  44360. /**
  44361. * Gets the value of D-pad left
  44362. */
  44363. get dPadLeft(): number;
  44364. /**
  44365. * Sets the value of D-pad left
  44366. */
  44367. set dPadLeft(value: number);
  44368. /**
  44369. * Gets the value of D-pad right
  44370. */
  44371. get dPadRight(): number;
  44372. /**
  44373. * Sets the value of D-pad right
  44374. */
  44375. set dPadRight(value: number);
  44376. /**
  44377. * Force the gamepad to synchronize with device values
  44378. */
  44379. update(): void;
  44380. /**
  44381. * Disposes the gamepad
  44382. */
  44383. dispose(): void;
  44384. }
  44385. }
  44386. declare module BABYLON {
  44387. /**
  44388. * Defines supported buttons for DualShock compatible gamepads
  44389. */
  44390. export enum DualShockButton {
  44391. /** Cross */
  44392. Cross = 0,
  44393. /** Circle */
  44394. Circle = 1,
  44395. /** Square */
  44396. Square = 2,
  44397. /** Triangle */
  44398. Triangle = 3,
  44399. /** L1 */
  44400. L1 = 4,
  44401. /** R1 */
  44402. R1 = 5,
  44403. /** Share */
  44404. Share = 8,
  44405. /** Options */
  44406. Options = 9,
  44407. /** Left stick */
  44408. LeftStick = 10,
  44409. /** Right stick */
  44410. RightStick = 11
  44411. }
  44412. /** Defines values for DualShock DPad */
  44413. export enum DualShockDpad {
  44414. /** Up */
  44415. Up = 12,
  44416. /** Down */
  44417. Down = 13,
  44418. /** Left */
  44419. Left = 14,
  44420. /** Right */
  44421. Right = 15
  44422. }
  44423. /**
  44424. * Defines a DualShock gamepad
  44425. */
  44426. export class DualShockPad extends Gamepad {
  44427. private _leftTrigger;
  44428. private _rightTrigger;
  44429. private _onlefttriggerchanged;
  44430. private _onrighttriggerchanged;
  44431. private _onbuttondown;
  44432. private _onbuttonup;
  44433. private _ondpaddown;
  44434. private _ondpadup;
  44435. /** Observable raised when a button is pressed */
  44436. onButtonDownObservable: Observable<DualShockButton>;
  44437. /** Observable raised when a button is released */
  44438. onButtonUpObservable: Observable<DualShockButton>;
  44439. /** Observable raised when a pad is pressed */
  44440. onPadDownObservable: Observable<DualShockDpad>;
  44441. /** Observable raised when a pad is released */
  44442. onPadUpObservable: Observable<DualShockDpad>;
  44443. private _buttonCross;
  44444. private _buttonCircle;
  44445. private _buttonSquare;
  44446. private _buttonTriangle;
  44447. private _buttonShare;
  44448. private _buttonOptions;
  44449. private _buttonL1;
  44450. private _buttonR1;
  44451. private _buttonLeftStick;
  44452. private _buttonRightStick;
  44453. private _dPadUp;
  44454. private _dPadDown;
  44455. private _dPadLeft;
  44456. private _dPadRight;
  44457. /**
  44458. * Creates a new DualShock gamepad object
  44459. * @param id defines the id of this gamepad
  44460. * @param index defines its index
  44461. * @param gamepad defines the internal HTML gamepad object
  44462. */
  44463. constructor(id: string, index: number, gamepad: any);
  44464. /**
  44465. * Defines the callback to call when left trigger is pressed
  44466. * @param callback defines the callback to use
  44467. */
  44468. onlefttriggerchanged(callback: (value: number) => void): void;
  44469. /**
  44470. * Defines the callback to call when right trigger is pressed
  44471. * @param callback defines the callback to use
  44472. */
  44473. onrighttriggerchanged(callback: (value: number) => void): void;
  44474. /**
  44475. * Gets the left trigger value
  44476. */
  44477. get leftTrigger(): number;
  44478. /**
  44479. * Sets the left trigger value
  44480. */
  44481. set leftTrigger(newValue: number);
  44482. /**
  44483. * Gets the right trigger value
  44484. */
  44485. get rightTrigger(): number;
  44486. /**
  44487. * Sets the right trigger value
  44488. */
  44489. set rightTrigger(newValue: number);
  44490. /**
  44491. * Defines the callback to call when a button is pressed
  44492. * @param callback defines the callback to use
  44493. */
  44494. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44495. /**
  44496. * Defines the callback to call when a button is released
  44497. * @param callback defines the callback to use
  44498. */
  44499. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44500. /**
  44501. * Defines the callback to call when a pad is pressed
  44502. * @param callback defines the callback to use
  44503. */
  44504. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44505. /**
  44506. * Defines the callback to call when a pad is released
  44507. * @param callback defines the callback to use
  44508. */
  44509. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44510. private _setButtonValue;
  44511. private _setDPadValue;
  44512. /**
  44513. * Gets the value of the `Cross` button
  44514. */
  44515. get buttonCross(): number;
  44516. /**
  44517. * Sets the value of the `Cross` button
  44518. */
  44519. set buttonCross(value: number);
  44520. /**
  44521. * Gets the value of the `Circle` button
  44522. */
  44523. get buttonCircle(): number;
  44524. /**
  44525. * Sets the value of the `Circle` button
  44526. */
  44527. set buttonCircle(value: number);
  44528. /**
  44529. * Gets the value of the `Square` button
  44530. */
  44531. get buttonSquare(): number;
  44532. /**
  44533. * Sets the value of the `Square` button
  44534. */
  44535. set buttonSquare(value: number);
  44536. /**
  44537. * Gets the value of the `Triangle` button
  44538. */
  44539. get buttonTriangle(): number;
  44540. /**
  44541. * Sets the value of the `Triangle` button
  44542. */
  44543. set buttonTriangle(value: number);
  44544. /**
  44545. * Gets the value of the `Options` button
  44546. */
  44547. get buttonOptions(): number;
  44548. /**
  44549. * Sets the value of the `Options` button
  44550. */
  44551. set buttonOptions(value: number);
  44552. /**
  44553. * Gets the value of the `Share` button
  44554. */
  44555. get buttonShare(): number;
  44556. /**
  44557. * Sets the value of the `Share` button
  44558. */
  44559. set buttonShare(value: number);
  44560. /**
  44561. * Gets the value of the `L1` button
  44562. */
  44563. get buttonL1(): number;
  44564. /**
  44565. * Sets the value of the `L1` button
  44566. */
  44567. set buttonL1(value: number);
  44568. /**
  44569. * Gets the value of the `R1` button
  44570. */
  44571. get buttonR1(): number;
  44572. /**
  44573. * Sets the value of the `R1` button
  44574. */
  44575. set buttonR1(value: number);
  44576. /**
  44577. * Gets the value of the Left joystick
  44578. */
  44579. get buttonLeftStick(): number;
  44580. /**
  44581. * Sets the value of the Left joystick
  44582. */
  44583. set buttonLeftStick(value: number);
  44584. /**
  44585. * Gets the value of the Right joystick
  44586. */
  44587. get buttonRightStick(): number;
  44588. /**
  44589. * Sets the value of the Right joystick
  44590. */
  44591. set buttonRightStick(value: number);
  44592. /**
  44593. * Gets the value of D-pad up
  44594. */
  44595. get dPadUp(): number;
  44596. /**
  44597. * Sets the value of D-pad up
  44598. */
  44599. set dPadUp(value: number);
  44600. /**
  44601. * Gets the value of D-pad down
  44602. */
  44603. get dPadDown(): number;
  44604. /**
  44605. * Sets the value of D-pad down
  44606. */
  44607. set dPadDown(value: number);
  44608. /**
  44609. * Gets the value of D-pad left
  44610. */
  44611. get dPadLeft(): number;
  44612. /**
  44613. * Sets the value of D-pad left
  44614. */
  44615. set dPadLeft(value: number);
  44616. /**
  44617. * Gets the value of D-pad right
  44618. */
  44619. get dPadRight(): number;
  44620. /**
  44621. * Sets the value of D-pad right
  44622. */
  44623. set dPadRight(value: number);
  44624. /**
  44625. * Force the gamepad to synchronize with device values
  44626. */
  44627. update(): void;
  44628. /**
  44629. * Disposes the gamepad
  44630. */
  44631. dispose(): void;
  44632. }
  44633. }
  44634. declare module BABYLON {
  44635. /**
  44636. * Manager for handling gamepads
  44637. */
  44638. export class GamepadManager {
  44639. private _scene?;
  44640. private _babylonGamepads;
  44641. private _oneGamepadConnected;
  44642. /** @hidden */
  44643. _isMonitoring: boolean;
  44644. private _gamepadEventSupported;
  44645. private _gamepadSupport?;
  44646. /**
  44647. * observable to be triggered when the gamepad controller has been connected
  44648. */
  44649. onGamepadConnectedObservable: Observable<Gamepad>;
  44650. /**
  44651. * observable to be triggered when the gamepad controller has been disconnected
  44652. */
  44653. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44654. private _onGamepadConnectedEvent;
  44655. private _onGamepadDisconnectedEvent;
  44656. /**
  44657. * Initializes the gamepad manager
  44658. * @param _scene BabylonJS scene
  44659. */
  44660. constructor(_scene?: Scene | undefined);
  44661. /**
  44662. * The gamepads in the game pad manager
  44663. */
  44664. get gamepads(): Gamepad[];
  44665. /**
  44666. * Get the gamepad controllers based on type
  44667. * @param type The type of gamepad controller
  44668. * @returns Nullable gamepad
  44669. */
  44670. getGamepadByType(type?: number): Nullable<Gamepad>;
  44671. /**
  44672. * Disposes the gamepad manager
  44673. */
  44674. dispose(): void;
  44675. private _addNewGamepad;
  44676. private _startMonitoringGamepads;
  44677. private _stopMonitoringGamepads;
  44678. /** @hidden */
  44679. _checkGamepadsStatus(): void;
  44680. private _updateGamepadObjects;
  44681. }
  44682. }
  44683. declare module BABYLON {
  44684. interface Scene {
  44685. /** @hidden */
  44686. _gamepadManager: Nullable<GamepadManager>;
  44687. /**
  44688. * Gets the gamepad manager associated with the scene
  44689. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44690. */
  44691. gamepadManager: GamepadManager;
  44692. }
  44693. /**
  44694. * Interface representing a free camera inputs manager
  44695. */
  44696. interface FreeCameraInputsManager {
  44697. /**
  44698. * Adds gamepad input support to the FreeCameraInputsManager.
  44699. * @returns the FreeCameraInputsManager
  44700. */
  44701. addGamepad(): FreeCameraInputsManager;
  44702. }
  44703. /**
  44704. * Interface representing an arc rotate camera inputs manager
  44705. */
  44706. interface ArcRotateCameraInputsManager {
  44707. /**
  44708. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44709. * @returns the camera inputs manager
  44710. */
  44711. addGamepad(): ArcRotateCameraInputsManager;
  44712. }
  44713. /**
  44714. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44715. */
  44716. export class GamepadSystemSceneComponent implements ISceneComponent {
  44717. /**
  44718. * The component name helpfull to identify the component in the list of scene components.
  44719. */
  44720. readonly name: string;
  44721. /**
  44722. * The scene the component belongs to.
  44723. */
  44724. scene: Scene;
  44725. /**
  44726. * Creates a new instance of the component for the given scene
  44727. * @param scene Defines the scene to register the component in
  44728. */
  44729. constructor(scene: Scene);
  44730. /**
  44731. * Registers the component in a given scene
  44732. */
  44733. register(): void;
  44734. /**
  44735. * Rebuilds the elements related to this component in case of
  44736. * context lost for instance.
  44737. */
  44738. rebuild(): void;
  44739. /**
  44740. * Disposes the component and the associated ressources
  44741. */
  44742. dispose(): void;
  44743. private _beforeCameraUpdate;
  44744. }
  44745. }
  44746. declare module BABYLON {
  44747. /**
  44748. * 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,
  44749. * which still works and will still be found in many Playgrounds.
  44750. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44751. */
  44752. export class UniversalCamera extends TouchCamera {
  44753. /**
  44754. * Defines the gamepad rotation sensiblity.
  44755. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44756. */
  44757. get gamepadAngularSensibility(): number;
  44758. set gamepadAngularSensibility(value: number);
  44759. /**
  44760. * Defines the gamepad move sensiblity.
  44761. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44762. */
  44763. get gamepadMoveSensibility(): number;
  44764. set gamepadMoveSensibility(value: number);
  44765. /**
  44766. * 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,
  44767. * which still works and will still be found in many Playgrounds.
  44768. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44769. * @param name Define the name of the camera in the scene
  44770. * @param position Define the start position of the camera in the scene
  44771. * @param scene Define the scene the camera belongs to
  44772. */
  44773. constructor(name: string, position: Vector3, scene: Scene);
  44774. /**
  44775. * Gets the current object class name.
  44776. * @return the class name
  44777. */
  44778. getClassName(): string;
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * This represents a FPS type of camera. This is only here for back compat purpose.
  44784. * Please use the UniversalCamera instead as both are identical.
  44785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44786. */
  44787. export class GamepadCamera extends UniversalCamera {
  44788. /**
  44789. * Instantiates a new Gamepad Camera
  44790. * This represents a FPS type of camera. This is only here for back compat purpose.
  44791. * Please use the UniversalCamera instead as both are identical.
  44792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44793. * @param name Define the name of the camera in the scene
  44794. * @param position Define the start position of the camera in the scene
  44795. * @param scene Define the scene the camera belongs to
  44796. */
  44797. constructor(name: string, position: Vector3, scene: Scene);
  44798. /**
  44799. * Gets the current object class name.
  44800. * @return the class name
  44801. */
  44802. getClassName(): string;
  44803. }
  44804. }
  44805. declare module BABYLON {
  44806. /** @hidden */
  44807. export var passPixelShader: {
  44808. name: string;
  44809. shader: string;
  44810. };
  44811. }
  44812. declare module BABYLON {
  44813. /** @hidden */
  44814. export var passCubePixelShader: {
  44815. name: string;
  44816. shader: string;
  44817. };
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * PassPostProcess which produces an output the same as it's input
  44822. */
  44823. export class PassPostProcess extends PostProcess {
  44824. /**
  44825. * Creates the PassPostProcess
  44826. * @param name The name of the effect.
  44827. * @param options The required width/height ratio to downsize to before computing the render pass.
  44828. * @param camera The camera to apply the render pass to.
  44829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44830. * @param engine The engine which the post process will be applied. (default: current engine)
  44831. * @param reusable If the post process can be reused on the same frame. (default: false)
  44832. * @param textureType The type of texture to be used when performing the post processing.
  44833. * @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)
  44834. */
  44835. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44836. }
  44837. /**
  44838. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44839. */
  44840. export class PassCubePostProcess extends PostProcess {
  44841. private _face;
  44842. /**
  44843. * Gets or sets the cube face to display.
  44844. * * 0 is +X
  44845. * * 1 is -X
  44846. * * 2 is +Y
  44847. * * 3 is -Y
  44848. * * 4 is +Z
  44849. * * 5 is -Z
  44850. */
  44851. get face(): number;
  44852. set face(value: number);
  44853. /**
  44854. * Creates the PassCubePostProcess
  44855. * @param name The name of the effect.
  44856. * @param options The required width/height ratio to downsize to before computing the render pass.
  44857. * @param camera The camera to apply the render pass to.
  44858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44859. * @param engine The engine which the post process will be applied. (default: current engine)
  44860. * @param reusable If the post process can be reused on the same frame. (default: false)
  44861. * @param textureType The type of texture to be used when performing the post processing.
  44862. * @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)
  44863. */
  44864. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44865. }
  44866. }
  44867. declare module BABYLON {
  44868. /** @hidden */
  44869. export var anaglyphPixelShader: {
  44870. name: string;
  44871. shader: string;
  44872. };
  44873. }
  44874. declare module BABYLON {
  44875. /**
  44876. * Postprocess used to generate anaglyphic rendering
  44877. */
  44878. export class AnaglyphPostProcess extends PostProcess {
  44879. private _passedProcess;
  44880. /**
  44881. * Creates a new AnaglyphPostProcess
  44882. * @param name defines postprocess name
  44883. * @param options defines creation options or target ratio scale
  44884. * @param rigCameras defines cameras using this postprocess
  44885. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44886. * @param engine defines hosting engine
  44887. * @param reusable defines if the postprocess will be reused multiple times per frame
  44888. */
  44889. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44890. }
  44891. }
  44892. declare module BABYLON {
  44893. /**
  44894. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44895. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44896. */
  44897. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44898. /**
  44899. * Creates a new AnaglyphArcRotateCamera
  44900. * @param name defines camera name
  44901. * @param alpha defines alpha angle (in radians)
  44902. * @param beta defines beta angle (in radians)
  44903. * @param radius defines radius
  44904. * @param target defines camera target
  44905. * @param interaxialDistance defines distance between each color axis
  44906. * @param scene defines the hosting scene
  44907. */
  44908. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44909. /**
  44910. * Gets camera class name
  44911. * @returns AnaglyphArcRotateCamera
  44912. */
  44913. getClassName(): string;
  44914. }
  44915. }
  44916. declare module BABYLON {
  44917. /**
  44918. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44919. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44920. */
  44921. export class AnaglyphFreeCamera extends FreeCamera {
  44922. /**
  44923. * Creates a new AnaglyphFreeCamera
  44924. * @param name defines camera name
  44925. * @param position defines initial position
  44926. * @param interaxialDistance defines distance between each color axis
  44927. * @param scene defines the hosting scene
  44928. */
  44929. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44930. /**
  44931. * Gets camera class name
  44932. * @returns AnaglyphFreeCamera
  44933. */
  44934. getClassName(): string;
  44935. }
  44936. }
  44937. declare module BABYLON {
  44938. /**
  44939. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44940. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44941. */
  44942. export class AnaglyphGamepadCamera extends GamepadCamera {
  44943. /**
  44944. * Creates a new AnaglyphGamepadCamera
  44945. * @param name defines camera name
  44946. * @param position defines initial position
  44947. * @param interaxialDistance defines distance between each color axis
  44948. * @param scene defines the hosting scene
  44949. */
  44950. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44951. /**
  44952. * Gets camera class name
  44953. * @returns AnaglyphGamepadCamera
  44954. */
  44955. getClassName(): string;
  44956. }
  44957. }
  44958. declare module BABYLON {
  44959. /**
  44960. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44961. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44962. */
  44963. export class AnaglyphUniversalCamera extends UniversalCamera {
  44964. /**
  44965. * Creates a new AnaglyphUniversalCamera
  44966. * @param name defines camera name
  44967. * @param position defines initial position
  44968. * @param interaxialDistance defines distance between each color axis
  44969. * @param scene defines the hosting scene
  44970. */
  44971. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44972. /**
  44973. * Gets camera class name
  44974. * @returns AnaglyphUniversalCamera
  44975. */
  44976. getClassName(): string;
  44977. }
  44978. }
  44979. declare module BABYLON {
  44980. /**
  44981. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44982. * @see http://doc.babylonjs.com/features/cameras
  44983. */
  44984. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44985. /**
  44986. * Creates a new StereoscopicArcRotateCamera
  44987. * @param name defines camera name
  44988. * @param alpha defines alpha angle (in radians)
  44989. * @param beta defines beta angle (in radians)
  44990. * @param radius defines radius
  44991. * @param target defines camera target
  44992. * @param interaxialDistance defines distance between each color axis
  44993. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44994. * @param scene defines the hosting scene
  44995. */
  44996. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44997. /**
  44998. * Gets camera class name
  44999. * @returns StereoscopicArcRotateCamera
  45000. */
  45001. getClassName(): string;
  45002. }
  45003. }
  45004. declare module BABYLON {
  45005. /**
  45006. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45007. * @see http://doc.babylonjs.com/features/cameras
  45008. */
  45009. export class StereoscopicFreeCamera extends FreeCamera {
  45010. /**
  45011. * Creates a new StereoscopicFreeCamera
  45012. * @param name defines camera name
  45013. * @param position defines initial position
  45014. * @param interaxialDistance defines distance between each color axis
  45015. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45016. * @param scene defines the hosting scene
  45017. */
  45018. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45019. /**
  45020. * Gets camera class name
  45021. * @returns StereoscopicFreeCamera
  45022. */
  45023. getClassName(): string;
  45024. }
  45025. }
  45026. declare module BABYLON {
  45027. /**
  45028. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45029. * @see http://doc.babylonjs.com/features/cameras
  45030. */
  45031. export class StereoscopicGamepadCamera extends GamepadCamera {
  45032. /**
  45033. * Creates a new StereoscopicGamepadCamera
  45034. * @param name defines camera name
  45035. * @param position defines initial position
  45036. * @param interaxialDistance defines distance between each color axis
  45037. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45038. * @param scene defines the hosting scene
  45039. */
  45040. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45041. /**
  45042. * Gets camera class name
  45043. * @returns StereoscopicGamepadCamera
  45044. */
  45045. getClassName(): string;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. /**
  45050. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45051. * @see http://doc.babylonjs.com/features/cameras
  45052. */
  45053. export class StereoscopicUniversalCamera extends UniversalCamera {
  45054. /**
  45055. * Creates a new StereoscopicUniversalCamera
  45056. * @param name defines camera name
  45057. * @param position defines initial position
  45058. * @param interaxialDistance defines distance between each color axis
  45059. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45060. * @param scene defines the hosting scene
  45061. */
  45062. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45063. /**
  45064. * Gets camera class name
  45065. * @returns StereoscopicUniversalCamera
  45066. */
  45067. getClassName(): string;
  45068. }
  45069. }
  45070. declare module BABYLON {
  45071. /**
  45072. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45073. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45074. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45075. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45076. */
  45077. export class VirtualJoysticksCamera extends FreeCamera {
  45078. /**
  45079. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45083. * @param name Define the name of the camera in the scene
  45084. * @param position Define the start position of the camera in the scene
  45085. * @param scene Define the scene the camera belongs to
  45086. */
  45087. constructor(name: string, position: Vector3, scene: Scene);
  45088. /**
  45089. * Gets the current object class name.
  45090. * @return the class name
  45091. */
  45092. getClassName(): string;
  45093. }
  45094. }
  45095. declare module BABYLON {
  45096. /**
  45097. * This represents all the required metrics to create a VR camera.
  45098. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45099. */
  45100. export class VRCameraMetrics {
  45101. /**
  45102. * Define the horizontal resolution off the screen.
  45103. */
  45104. hResolution: number;
  45105. /**
  45106. * Define the vertical resolution off the screen.
  45107. */
  45108. vResolution: number;
  45109. /**
  45110. * Define the horizontal screen size.
  45111. */
  45112. hScreenSize: number;
  45113. /**
  45114. * Define the vertical screen size.
  45115. */
  45116. vScreenSize: number;
  45117. /**
  45118. * Define the vertical screen center position.
  45119. */
  45120. vScreenCenter: number;
  45121. /**
  45122. * Define the distance of the eyes to the screen.
  45123. */
  45124. eyeToScreenDistance: number;
  45125. /**
  45126. * Define the distance between both lenses
  45127. */
  45128. lensSeparationDistance: number;
  45129. /**
  45130. * Define the distance between both viewer's eyes.
  45131. */
  45132. interpupillaryDistance: number;
  45133. /**
  45134. * Define the distortion factor of the VR postprocess.
  45135. * Please, touch with care.
  45136. */
  45137. distortionK: number[];
  45138. /**
  45139. * Define the chromatic aberration correction factors for the VR post process.
  45140. */
  45141. chromaAbCorrection: number[];
  45142. /**
  45143. * Define the scale factor of the post process.
  45144. * The smaller the better but the slower.
  45145. */
  45146. postProcessScaleFactor: number;
  45147. /**
  45148. * Define an offset for the lens center.
  45149. */
  45150. lensCenterOffset: number;
  45151. /**
  45152. * Define if the current vr camera should compensate the distortion of the lense or not.
  45153. */
  45154. compensateDistortion: boolean;
  45155. /**
  45156. * Defines if multiview should be enabled when rendering (Default: false)
  45157. */
  45158. multiviewEnabled: boolean;
  45159. /**
  45160. * Gets the rendering aspect ratio based on the provided resolutions.
  45161. */
  45162. get aspectRatio(): number;
  45163. /**
  45164. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45165. */
  45166. get aspectRatioFov(): number;
  45167. /**
  45168. * @hidden
  45169. */
  45170. get leftHMatrix(): Matrix;
  45171. /**
  45172. * @hidden
  45173. */
  45174. get rightHMatrix(): Matrix;
  45175. /**
  45176. * @hidden
  45177. */
  45178. get leftPreViewMatrix(): Matrix;
  45179. /**
  45180. * @hidden
  45181. */
  45182. get rightPreViewMatrix(): Matrix;
  45183. /**
  45184. * Get the default VRMetrics based on the most generic setup.
  45185. * @returns the default vr metrics
  45186. */
  45187. static GetDefault(): VRCameraMetrics;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /** @hidden */
  45192. export var vrDistortionCorrectionPixelShader: {
  45193. name: string;
  45194. shader: string;
  45195. };
  45196. }
  45197. declare module BABYLON {
  45198. /**
  45199. * VRDistortionCorrectionPostProcess used for mobile VR
  45200. */
  45201. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45202. private _isRightEye;
  45203. private _distortionFactors;
  45204. private _postProcessScaleFactor;
  45205. private _lensCenterOffset;
  45206. private _scaleIn;
  45207. private _scaleFactor;
  45208. private _lensCenter;
  45209. /**
  45210. * Initializes the VRDistortionCorrectionPostProcess
  45211. * @param name The name of the effect.
  45212. * @param camera The camera to apply the render pass to.
  45213. * @param isRightEye If this is for the right eye distortion
  45214. * @param vrMetrics All the required metrics for the VR camera
  45215. */
  45216. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45217. }
  45218. }
  45219. declare module BABYLON {
  45220. /**
  45221. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45222. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45223. */
  45224. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45225. /**
  45226. * Creates a new VRDeviceOrientationArcRotateCamera
  45227. * @param name defines camera name
  45228. * @param alpha defines the camera rotation along the logitudinal axis
  45229. * @param beta defines the camera rotation along the latitudinal axis
  45230. * @param radius defines the camera distance from its target
  45231. * @param target defines the camera target
  45232. * @param scene defines the scene the camera belongs to
  45233. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45234. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45235. */
  45236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45237. /**
  45238. * Gets camera class name
  45239. * @returns VRDeviceOrientationArcRotateCamera
  45240. */
  45241. getClassName(): string;
  45242. }
  45243. }
  45244. declare module BABYLON {
  45245. /**
  45246. * Camera used to simulate VR rendering (based on FreeCamera)
  45247. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45248. */
  45249. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45250. /**
  45251. * Creates a new VRDeviceOrientationFreeCamera
  45252. * @param name defines camera name
  45253. * @param position defines the start position of the camera
  45254. * @param scene defines the scene the camera belongs to
  45255. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45256. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45257. */
  45258. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45259. /**
  45260. * Gets camera class name
  45261. * @returns VRDeviceOrientationFreeCamera
  45262. */
  45263. getClassName(): string;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /**
  45268. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45269. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45270. */
  45271. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45272. /**
  45273. * Creates a new VRDeviceOrientationGamepadCamera
  45274. * @param name defines camera name
  45275. * @param position defines the start position of the camera
  45276. * @param scene defines the scene the camera belongs to
  45277. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45278. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45279. */
  45280. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45281. /**
  45282. * Gets camera class name
  45283. * @returns VRDeviceOrientationGamepadCamera
  45284. */
  45285. getClassName(): string;
  45286. }
  45287. }
  45288. declare module BABYLON {
  45289. /** @hidden */
  45290. export var imageProcessingPixelShader: {
  45291. name: string;
  45292. shader: string;
  45293. };
  45294. }
  45295. declare module BABYLON {
  45296. /**
  45297. * ImageProcessingPostProcess
  45298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45299. */
  45300. export class ImageProcessingPostProcess extends PostProcess {
  45301. /**
  45302. * Default configuration related to image processing available in the PBR Material.
  45303. */
  45304. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45305. /**
  45306. * Gets the image processing configuration used either in this material.
  45307. */
  45308. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45309. /**
  45310. * Sets the Default image processing configuration used either in the this material.
  45311. *
  45312. * If sets to null, the scene one is in use.
  45313. */
  45314. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45315. /**
  45316. * Keep track of the image processing observer to allow dispose and replace.
  45317. */
  45318. private _imageProcessingObserver;
  45319. /**
  45320. * Attaches a new image processing configuration to the PBR Material.
  45321. * @param configuration
  45322. */
  45323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45324. /**
  45325. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45326. */
  45327. get colorCurves(): Nullable<ColorCurves>;
  45328. /**
  45329. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45330. */
  45331. set colorCurves(value: Nullable<ColorCurves>);
  45332. /**
  45333. * Gets wether the color curves effect is enabled.
  45334. */
  45335. get colorCurvesEnabled(): boolean;
  45336. /**
  45337. * Sets wether the color curves effect is enabled.
  45338. */
  45339. set colorCurvesEnabled(value: boolean);
  45340. /**
  45341. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45342. */
  45343. get colorGradingTexture(): Nullable<BaseTexture>;
  45344. /**
  45345. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45346. */
  45347. set colorGradingTexture(value: Nullable<BaseTexture>);
  45348. /**
  45349. * Gets wether the color grading effect is enabled.
  45350. */
  45351. get colorGradingEnabled(): boolean;
  45352. /**
  45353. * Gets wether the color grading effect is enabled.
  45354. */
  45355. set colorGradingEnabled(value: boolean);
  45356. /**
  45357. * Gets exposure used in the effect.
  45358. */
  45359. get exposure(): number;
  45360. /**
  45361. * Sets exposure used in the effect.
  45362. */
  45363. set exposure(value: number);
  45364. /**
  45365. * Gets wether tonemapping is enabled or not.
  45366. */
  45367. get toneMappingEnabled(): boolean;
  45368. /**
  45369. * Sets wether tonemapping is enabled or not
  45370. */
  45371. set toneMappingEnabled(value: boolean);
  45372. /**
  45373. * Gets the type of tone mapping effect.
  45374. */
  45375. get toneMappingType(): number;
  45376. /**
  45377. * Sets the type of tone mapping effect.
  45378. */
  45379. set toneMappingType(value: number);
  45380. /**
  45381. * Gets contrast used in the effect.
  45382. */
  45383. get contrast(): number;
  45384. /**
  45385. * Sets contrast used in the effect.
  45386. */
  45387. set contrast(value: number);
  45388. /**
  45389. * Gets Vignette stretch size.
  45390. */
  45391. get vignetteStretch(): number;
  45392. /**
  45393. * Sets Vignette stretch size.
  45394. */
  45395. set vignetteStretch(value: number);
  45396. /**
  45397. * Gets Vignette centre X Offset.
  45398. */
  45399. get vignetteCentreX(): number;
  45400. /**
  45401. * Sets Vignette centre X Offset.
  45402. */
  45403. set vignetteCentreX(value: number);
  45404. /**
  45405. * Gets Vignette centre Y Offset.
  45406. */
  45407. get vignetteCentreY(): number;
  45408. /**
  45409. * Sets Vignette centre Y Offset.
  45410. */
  45411. set vignetteCentreY(value: number);
  45412. /**
  45413. * Gets Vignette weight or intensity of the vignette effect.
  45414. */
  45415. get vignetteWeight(): number;
  45416. /**
  45417. * Sets Vignette weight or intensity of the vignette effect.
  45418. */
  45419. set vignetteWeight(value: number);
  45420. /**
  45421. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45422. * if vignetteEnabled is set to true.
  45423. */
  45424. get vignetteColor(): Color4;
  45425. /**
  45426. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45427. * if vignetteEnabled is set to true.
  45428. */
  45429. set vignetteColor(value: Color4);
  45430. /**
  45431. * Gets Camera field of view used by the Vignette effect.
  45432. */
  45433. get vignetteCameraFov(): number;
  45434. /**
  45435. * Sets Camera field of view used by the Vignette effect.
  45436. */
  45437. set vignetteCameraFov(value: number);
  45438. /**
  45439. * Gets the vignette blend mode allowing different kind of effect.
  45440. */
  45441. get vignetteBlendMode(): number;
  45442. /**
  45443. * Sets the vignette blend mode allowing different kind of effect.
  45444. */
  45445. set vignetteBlendMode(value: number);
  45446. /**
  45447. * Gets wether the vignette effect is enabled.
  45448. */
  45449. get vignetteEnabled(): boolean;
  45450. /**
  45451. * Sets wether the vignette effect is enabled.
  45452. */
  45453. set vignetteEnabled(value: boolean);
  45454. private _fromLinearSpace;
  45455. /**
  45456. * Gets wether the input of the processing is in Gamma or Linear Space.
  45457. */
  45458. get fromLinearSpace(): boolean;
  45459. /**
  45460. * Sets wether the input of the processing is in Gamma or Linear Space.
  45461. */
  45462. set fromLinearSpace(value: boolean);
  45463. /**
  45464. * Defines cache preventing GC.
  45465. */
  45466. private _defines;
  45467. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45468. /**
  45469. * "ImageProcessingPostProcess"
  45470. * @returns "ImageProcessingPostProcess"
  45471. */
  45472. getClassName(): string;
  45473. protected _updateParameters(): void;
  45474. dispose(camera?: Camera): void;
  45475. }
  45476. }
  45477. declare module BABYLON {
  45478. /**
  45479. * Class containing static functions to help procedurally build meshes
  45480. */
  45481. export class GroundBuilder {
  45482. /**
  45483. * Creates a ground mesh
  45484. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45485. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45487. * @param name defines the name of the mesh
  45488. * @param options defines the options used to create the mesh
  45489. * @param scene defines the hosting scene
  45490. * @returns the ground mesh
  45491. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45492. */
  45493. static CreateGround(name: string, options: {
  45494. width?: number;
  45495. height?: number;
  45496. subdivisions?: number;
  45497. subdivisionsX?: number;
  45498. subdivisionsY?: number;
  45499. updatable?: boolean;
  45500. }, scene: any): Mesh;
  45501. /**
  45502. * Creates a tiled ground mesh
  45503. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45504. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45505. * * 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
  45506. * * 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
  45507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45508. * @param name defines the name of the mesh
  45509. * @param options defines the options used to create the mesh
  45510. * @param scene defines the hosting scene
  45511. * @returns the tiled ground mesh
  45512. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45513. */
  45514. static CreateTiledGround(name: string, options: {
  45515. xmin: number;
  45516. zmin: number;
  45517. xmax: number;
  45518. zmax: number;
  45519. subdivisions?: {
  45520. w: number;
  45521. h: number;
  45522. };
  45523. precision?: {
  45524. w: number;
  45525. h: number;
  45526. };
  45527. updatable?: boolean;
  45528. }, scene?: Nullable<Scene>): Mesh;
  45529. /**
  45530. * Creates a ground mesh from a height map
  45531. * * The parameter `url` sets the URL of the height map image resource.
  45532. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45533. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45534. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45535. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45536. * * 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.
  45537. * * 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).
  45538. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45540. * @param name defines the name of the mesh
  45541. * @param url defines the url to the height map
  45542. * @param options defines the options used to create the mesh
  45543. * @param scene defines the hosting scene
  45544. * @returns the ground mesh
  45545. * @see https://doc.babylonjs.com/babylon101/height_map
  45546. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45547. */
  45548. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45549. width?: number;
  45550. height?: number;
  45551. subdivisions?: number;
  45552. minHeight?: number;
  45553. maxHeight?: number;
  45554. colorFilter?: Color3;
  45555. alphaFilter?: number;
  45556. updatable?: boolean;
  45557. onReady?: (mesh: GroundMesh) => void;
  45558. }, scene?: Nullable<Scene>): GroundMesh;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Class containing static functions to help procedurally build meshes
  45564. */
  45565. export class TorusBuilder {
  45566. /**
  45567. * Creates a torus mesh
  45568. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45569. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45570. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45572. * * 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
  45573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45574. * @param name defines the name of the mesh
  45575. * @param options defines the options used to create the mesh
  45576. * @param scene defines the hosting scene
  45577. * @returns the torus mesh
  45578. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45579. */
  45580. static CreateTorus(name: string, options: {
  45581. diameter?: number;
  45582. thickness?: number;
  45583. tessellation?: number;
  45584. updatable?: boolean;
  45585. sideOrientation?: number;
  45586. frontUVs?: Vector4;
  45587. backUVs?: Vector4;
  45588. }, scene: any): Mesh;
  45589. }
  45590. }
  45591. declare module BABYLON {
  45592. /**
  45593. * Class containing static functions to help procedurally build meshes
  45594. */
  45595. export class CylinderBuilder {
  45596. /**
  45597. * Creates a cylinder or a cone mesh
  45598. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45599. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45600. * * 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.
  45601. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45602. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45603. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45604. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45605. * * 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).
  45606. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45607. * * 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).
  45608. * * 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
  45609. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45610. * * 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
  45611. * * 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.
  45612. * * If `enclose` is false, a ring surface is one element.
  45613. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45614. * * 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
  45615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45616. * * 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
  45617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45618. * @param name defines the name of the mesh
  45619. * @param options defines the options used to create the mesh
  45620. * @param scene defines the hosting scene
  45621. * @returns the cylinder mesh
  45622. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45623. */
  45624. static CreateCylinder(name: string, options: {
  45625. height?: number;
  45626. diameterTop?: number;
  45627. diameterBottom?: number;
  45628. diameter?: number;
  45629. tessellation?: number;
  45630. subdivisions?: number;
  45631. arc?: number;
  45632. faceColors?: Color4[];
  45633. faceUV?: Vector4[];
  45634. updatable?: boolean;
  45635. hasRings?: boolean;
  45636. enclose?: boolean;
  45637. cap?: number;
  45638. sideOrientation?: number;
  45639. frontUVs?: Vector4;
  45640. backUVs?: Vector4;
  45641. }, scene: any): Mesh;
  45642. }
  45643. }
  45644. declare module BABYLON {
  45645. /**
  45646. * States of the webXR experience
  45647. */
  45648. export enum WebXRState {
  45649. /**
  45650. * Transitioning to being in XR mode
  45651. */
  45652. ENTERING_XR = 0,
  45653. /**
  45654. * Transitioning to non XR mode
  45655. */
  45656. EXITING_XR = 1,
  45657. /**
  45658. * In XR mode and presenting
  45659. */
  45660. IN_XR = 2,
  45661. /**
  45662. * Not entered XR mode
  45663. */
  45664. NOT_IN_XR = 3
  45665. }
  45666. /**
  45667. * Abstraction of the XR render target
  45668. */
  45669. export interface WebXRRenderTarget extends IDisposable {
  45670. /**
  45671. * xrpresent context of the canvas which can be used to display/mirror xr content
  45672. */
  45673. canvasContext: WebGLRenderingContext;
  45674. /**
  45675. * xr layer for the canvas
  45676. */
  45677. xrLayer: Nullable<XRWebGLLayer>;
  45678. /**
  45679. * Initializes the xr layer for the session
  45680. * @param xrSession xr session
  45681. * @returns a promise that will resolve once the XR Layer has been created
  45682. */
  45683. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45684. }
  45685. }
  45686. declare module BABYLON {
  45687. /**
  45688. * COnfiguration object for WebXR output canvas
  45689. */
  45690. export class WebXRManagedOutputCanvasOptions {
  45691. /**
  45692. * An optional canvas in case you wish to create it yourself and provide it here.
  45693. * If not provided, a new canvas will be created
  45694. */
  45695. canvasElement?: HTMLCanvasElement;
  45696. /**
  45697. * Options for this XR Layer output
  45698. */
  45699. canvasOptions?: XRWebGLLayerOptions;
  45700. /**
  45701. * CSS styling for a newly created canvas (if not provided)
  45702. */
  45703. newCanvasCssStyle?: string;
  45704. /**
  45705. * Get the default values of the configuration object
  45706. * @returns default values of this configuration object
  45707. */
  45708. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45709. }
  45710. /**
  45711. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45712. */
  45713. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45714. private _options;
  45715. private _canvas;
  45716. private _engine;
  45717. /**
  45718. * Rendering context of the canvas which can be used to display/mirror xr content
  45719. */
  45720. canvasContext: WebGLRenderingContext;
  45721. /**
  45722. * xr layer for the canvas
  45723. */
  45724. xrLayer: Nullable<XRWebGLLayer>;
  45725. /**
  45726. * Initializes the canvas to be added/removed upon entering/exiting xr
  45727. * @param _xrSessionManager The XR Session manager
  45728. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45729. */
  45730. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45731. /**
  45732. * Disposes of the object
  45733. */
  45734. dispose(): void;
  45735. /**
  45736. * Initializes the xr layer for the session
  45737. * @param xrSession xr session
  45738. * @returns a promise that will resolve once the XR Layer has been created
  45739. */
  45740. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45741. private _addCanvas;
  45742. private _removeCanvas;
  45743. private _setManagedOutputCanvas;
  45744. }
  45745. }
  45746. declare module BABYLON {
  45747. /**
  45748. * Manages an XRSession to work with Babylon's engine
  45749. * @see https://doc.babylonjs.com/how_to/webxr
  45750. */
  45751. export class WebXRSessionManager implements IDisposable {
  45752. /** The scene which the session should be created for */
  45753. scene: Scene;
  45754. private _referenceSpace;
  45755. private _rttProvider;
  45756. private _sessionEnded;
  45757. private _xrNavigator;
  45758. private baseLayer;
  45759. /**
  45760. * The base reference space from which the session started. good if you want to reset your
  45761. * reference space
  45762. */
  45763. baseReferenceSpace: XRReferenceSpace;
  45764. /**
  45765. * Current XR frame
  45766. */
  45767. currentFrame: Nullable<XRFrame>;
  45768. /** WebXR timestamp updated every frame */
  45769. currentTimestamp: number;
  45770. /**
  45771. * Used just in case of a failure to initialize an immersive session.
  45772. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45773. */
  45774. defaultHeightCompensation: number;
  45775. /**
  45776. * Fires every time a new xrFrame arrives which can be used to update the camera
  45777. */
  45778. onXRFrameObservable: Observable<XRFrame>;
  45779. /**
  45780. * Fires when the reference space changed
  45781. */
  45782. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45783. /**
  45784. * Fires when the xr session is ended either by the device or manually done
  45785. */
  45786. onXRSessionEnded: Observable<any>;
  45787. /**
  45788. * Fires when the xr session is ended either by the device or manually done
  45789. */
  45790. onXRSessionInit: Observable<XRSession>;
  45791. /**
  45792. * Underlying xr session
  45793. */
  45794. session: XRSession;
  45795. /**
  45796. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45797. * or get the offset the player is currently at.
  45798. */
  45799. viewerReferenceSpace: XRReferenceSpace;
  45800. /**
  45801. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45802. * @param scene The scene which the session should be created for
  45803. */
  45804. constructor(
  45805. /** The scene which the session should be created for */
  45806. scene: Scene);
  45807. /**
  45808. * The current reference space used in this session. This reference space can constantly change!
  45809. * It is mainly used to offset the camera's position.
  45810. */
  45811. get referenceSpace(): XRReferenceSpace;
  45812. /**
  45813. * Set a new reference space and triggers the observable
  45814. */
  45815. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45816. /**
  45817. * Disposes of the session manager
  45818. */
  45819. dispose(): void;
  45820. /**
  45821. * Stops the xrSession and restores the render loop
  45822. * @returns Promise which resolves after it exits XR
  45823. */
  45824. exitXRAsync(): Promise<void>;
  45825. /**
  45826. * Gets the correct render target texture to be rendered this frame for this eye
  45827. * @param eye the eye for which to get the render target
  45828. * @returns the render target for the specified eye
  45829. */
  45830. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45831. /**
  45832. * Creates a WebXRRenderTarget object for the XR session
  45833. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45834. * @param options optional options to provide when creating a new render target
  45835. * @returns a WebXR render target to which the session can render
  45836. */
  45837. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45838. /**
  45839. * Initializes the manager
  45840. * After initialization enterXR can be called to start an XR session
  45841. * @returns Promise which resolves after it is initialized
  45842. */
  45843. initializeAsync(): Promise<void>;
  45844. /**
  45845. * Initializes an xr session
  45846. * @param xrSessionMode mode to initialize
  45847. * @param xrSessionInit defines optional and required values to pass to the session builder
  45848. * @returns a promise which will resolve once the session has been initialized
  45849. */
  45850. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45851. /**
  45852. * Checks if a session would be supported for the creation options specified
  45853. * @param sessionMode session mode to check if supported eg. immersive-vr
  45854. * @returns A Promise that resolves to true if supported and false if not
  45855. */
  45856. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45857. /**
  45858. * Resets the reference space to the one started the session
  45859. */
  45860. resetReferenceSpace(): void;
  45861. /**
  45862. * Starts rendering to the xr layer
  45863. */
  45864. runXRRenderLoop(): void;
  45865. /**
  45866. * Sets the reference space on the xr session
  45867. * @param referenceSpaceType space to set
  45868. * @returns a promise that will resolve once the reference space has been set
  45869. */
  45870. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45871. /**
  45872. * Updates the render state of the session
  45873. * @param state state to set
  45874. * @returns a promise that resolves once the render state has been updated
  45875. */
  45876. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45877. /**
  45878. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45879. * @param sessionMode defines the session to test
  45880. * @returns a promise with boolean as final value
  45881. */
  45882. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45883. private _createRenderTargetTexture;
  45884. }
  45885. }
  45886. declare module BABYLON {
  45887. /**
  45888. * WebXR Camera which holds the views for the xrSession
  45889. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45890. */
  45891. export class WebXRCamera extends FreeCamera {
  45892. private _xrSessionManager;
  45893. private _firstFrame;
  45894. private _referenceQuaternion;
  45895. private _referencedPosition;
  45896. private _xrInvPositionCache;
  45897. private _xrInvQuaternionCache;
  45898. /**
  45899. * Should position compensation execute on first frame.
  45900. * This is used when copying the position from a native (non XR) camera
  45901. */
  45902. compensateOnFirstFrame: boolean;
  45903. /**
  45904. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45905. * @param name the name of the camera
  45906. * @param scene the scene to add the camera to
  45907. * @param _xrSessionManager a constructed xr session manager
  45908. */
  45909. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45910. /**
  45911. * Return the user's height, unrelated to the current ground.
  45912. * This will be the y position of this camera, when ground level is 0.
  45913. */
  45914. get realWorldHeight(): number;
  45915. /** @hidden */
  45916. _updateForDualEyeDebugging(): void;
  45917. /**
  45918. * Sets this camera's transformation based on a non-vr camera
  45919. * @param otherCamera the non-vr camera to copy the transformation from
  45920. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45921. */
  45922. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45923. /**
  45924. * Gets the current instance class name ("WebXRCamera").
  45925. * @returns the class name
  45926. */
  45927. getClassName(): string;
  45928. /**
  45929. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45930. */
  45931. _getViewMatrix(): Matrix;
  45932. private _updateFromXRSession;
  45933. private _updateNumberOfRigCameras;
  45934. private _updateReferenceSpace;
  45935. private _updateReferenceSpaceOffset;
  45936. }
  45937. }
  45938. declare module BABYLON {
  45939. /**
  45940. * Defining the interface required for a (webxr) feature
  45941. */
  45942. export interface IWebXRFeature extends IDisposable {
  45943. /**
  45944. * Is this feature attached
  45945. */
  45946. attached: boolean;
  45947. /**
  45948. * Should auto-attach be disabled?
  45949. */
  45950. disableAutoAttach: boolean;
  45951. /**
  45952. * Attach the feature to the session
  45953. * Will usually be called by the features manager
  45954. *
  45955. * @param force should attachment be forced (even when already attached)
  45956. * @returns true if successful.
  45957. */
  45958. attach(force?: boolean): boolean;
  45959. /**
  45960. * Detach the feature from the session
  45961. * Will usually be called by the features manager
  45962. *
  45963. * @returns true if successful.
  45964. */
  45965. detach(): boolean;
  45966. }
  45967. /**
  45968. * A list of the currently available features without referencing them
  45969. */
  45970. export class WebXRFeatureName {
  45971. /**
  45972. * The name of the anchor system feature
  45973. */
  45974. static ANCHOR_SYSTEM: string;
  45975. /**
  45976. * The name of the background remover feature
  45977. */
  45978. static BACKGROUND_REMOVER: string;
  45979. /**
  45980. * The name of the hit test feature
  45981. */
  45982. static HIT_TEST: string;
  45983. /**
  45984. * physics impostors for xr controllers feature
  45985. */
  45986. static PHYSICS_CONTROLLERS: string;
  45987. /**
  45988. * The name of the plane detection feature
  45989. */
  45990. static PLANE_DETECTION: string;
  45991. /**
  45992. * The name of the pointer selection feature
  45993. */
  45994. static POINTER_SELECTION: string;
  45995. /**
  45996. * The name of the teleportation feature
  45997. */
  45998. static TELEPORTATION: string;
  45999. }
  46000. /**
  46001. * Defining the constructor of a feature. Used to register the modules.
  46002. */
  46003. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46004. /**
  46005. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46006. * It is mainly used in AR sessions.
  46007. *
  46008. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46009. */
  46010. export class WebXRFeaturesManager implements IDisposable {
  46011. private _xrSessionManager;
  46012. private static readonly _AvailableFeatures;
  46013. private _features;
  46014. /**
  46015. * constructs a new features manages.
  46016. *
  46017. * @param _xrSessionManager an instance of WebXRSessionManager
  46018. */
  46019. constructor(_xrSessionManager: WebXRSessionManager);
  46020. /**
  46021. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46022. * Mainly used internally.
  46023. *
  46024. * @param featureName the name of the feature to register
  46025. * @param constructorFunction the function used to construct the module
  46026. * @param version the (babylon) version of the module
  46027. * @param stable is that a stable version of this module
  46028. */
  46029. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46030. /**
  46031. * Returns a constructor of a specific feature.
  46032. *
  46033. * @param featureName the name of the feature to construct
  46034. * @param version the version of the feature to load
  46035. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46036. * @param options optional options provided to the module.
  46037. * @returns a function that, when called, will return a new instance of this feature
  46038. */
  46039. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46040. /**
  46041. * Can be used to return the list of features currently registered
  46042. *
  46043. * @returns an Array of available features
  46044. */
  46045. static GetAvailableFeatures(): string[];
  46046. /**
  46047. * Gets the versions available for a specific feature
  46048. * @param featureName the name of the feature
  46049. * @returns an array with the available versions
  46050. */
  46051. static GetAvailableVersions(featureName: string): string[];
  46052. /**
  46053. * Return the latest unstable version of this feature
  46054. * @param featureName the name of the feature to search
  46055. * @returns the version number. if not found will return -1
  46056. */
  46057. static GetLatestVersionOfFeature(featureName: string): number;
  46058. /**
  46059. * Return the latest stable version of this feature
  46060. * @param featureName the name of the feature to search
  46061. * @returns the version number. if not found will return -1
  46062. */
  46063. static GetStableVersionOfFeature(featureName: string): number;
  46064. /**
  46065. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46066. * Can be used during a session to start a feature
  46067. * @param featureName the name of feature to attach
  46068. */
  46069. attachFeature(featureName: string): void;
  46070. /**
  46071. * Can be used inside a session or when the session ends to detach a specific feature
  46072. * @param featureName the name of the feature to detach
  46073. */
  46074. detachFeature(featureName: string): void;
  46075. /**
  46076. * Used to disable an already-enabled feature
  46077. * The feature will be disposed and will be recreated once enabled.
  46078. * @param featureName the feature to disable
  46079. * @returns true if disable was successful
  46080. */
  46081. disableFeature(featureName: string | {
  46082. Name: string;
  46083. }): boolean;
  46084. /**
  46085. * dispose this features manager
  46086. */
  46087. dispose(): void;
  46088. /**
  46089. * 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.
  46090. * 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.
  46091. *
  46092. * @param featureName the name of the feature to load or the class of the feature
  46093. * @param version optional version to load. if not provided the latest version will be enabled
  46094. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46095. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46096. * @returns a new constructed feature or throws an error if feature not found.
  46097. */
  46098. enableFeature(featureName: string | {
  46099. Name: string;
  46100. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46101. /**
  46102. * get the implementation of an enabled feature.
  46103. * @param featureName the name of the feature to load
  46104. * @returns the feature class, if found
  46105. */
  46106. getEnabledFeature(featureName: string): IWebXRFeature;
  46107. /**
  46108. * Get the list of enabled features
  46109. * @returns an array of enabled features
  46110. */
  46111. getEnabledFeatures(): string[];
  46112. }
  46113. }
  46114. declare module BABYLON {
  46115. /**
  46116. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46117. * @see https://doc.babylonjs.com/how_to/webxr
  46118. */
  46119. export class WebXRExperienceHelper implements IDisposable {
  46120. private scene;
  46121. private _nonVRCamera;
  46122. private _originalSceneAutoClear;
  46123. private _supported;
  46124. /**
  46125. * Camera used to render xr content
  46126. */
  46127. camera: WebXRCamera;
  46128. /** A features manager for this xr session */
  46129. featuresManager: WebXRFeaturesManager;
  46130. /**
  46131. * Observers registered here will be triggered after the camera's initial transformation is set
  46132. * This can be used to set a different ground level or an extra rotation.
  46133. *
  46134. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46135. * to the position set after this observable is done executing.
  46136. */
  46137. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46138. /**
  46139. * Fires when the state of the experience helper has changed
  46140. */
  46141. onStateChangedObservable: Observable<WebXRState>;
  46142. /** Session manager used to keep track of xr session */
  46143. sessionManager: WebXRSessionManager;
  46144. /**
  46145. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46146. */
  46147. state: WebXRState;
  46148. /**
  46149. * Creates a WebXRExperienceHelper
  46150. * @param scene The scene the helper should be created in
  46151. */
  46152. private constructor();
  46153. /**
  46154. * Creates the experience helper
  46155. * @param scene the scene to attach the experience helper to
  46156. * @returns a promise for the experience helper
  46157. */
  46158. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46159. /**
  46160. * Disposes of the experience helper
  46161. */
  46162. dispose(): void;
  46163. /**
  46164. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46165. * @param sessionMode options for the XR session
  46166. * @param referenceSpaceType frame of reference of the XR session
  46167. * @param renderTarget the output canvas that will be used to enter XR mode
  46168. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46169. * @returns promise that resolves after xr mode has entered
  46170. */
  46171. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46172. /**
  46173. * Exits XR mode and returns the scene to its original state
  46174. * @returns promise that resolves after xr mode has exited
  46175. */
  46176. exitXRAsync(): Promise<void>;
  46177. private _nonXRToXRCamera;
  46178. private _setState;
  46179. }
  46180. }
  46181. declare module BABYLON {
  46182. /**
  46183. * X-Y values for axes in WebXR
  46184. */
  46185. export interface IWebXRMotionControllerAxesValue {
  46186. /**
  46187. * The value of the x axis
  46188. */
  46189. x: number;
  46190. /**
  46191. * The value of the y-axis
  46192. */
  46193. y: number;
  46194. }
  46195. /**
  46196. * changed / previous values for the values of this component
  46197. */
  46198. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46199. /**
  46200. * current (this frame) value
  46201. */
  46202. current: T;
  46203. /**
  46204. * previous (last change) value
  46205. */
  46206. previous: T;
  46207. }
  46208. /**
  46209. * Represents changes in the component between current frame and last values recorded
  46210. */
  46211. export interface IWebXRMotionControllerComponentChanges {
  46212. /**
  46213. * will be populated with previous and current values if axes changed
  46214. */
  46215. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46216. /**
  46217. * will be populated with previous and current values if pressed changed
  46218. */
  46219. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46220. /**
  46221. * will be populated with previous and current values if touched changed
  46222. */
  46223. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46224. /**
  46225. * will be populated with previous and current values if value changed
  46226. */
  46227. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46228. }
  46229. /**
  46230. * This class represents a single component (for example button or thumbstick) of a motion controller
  46231. */
  46232. export class WebXRControllerComponent implements IDisposable {
  46233. /**
  46234. * the id of this component
  46235. */
  46236. id: string;
  46237. /**
  46238. * the type of the component
  46239. */
  46240. type: MotionControllerComponentType;
  46241. private _buttonIndex;
  46242. private _axesIndices;
  46243. private _axes;
  46244. private _changes;
  46245. private _currentValue;
  46246. private _hasChanges;
  46247. private _pressed;
  46248. private _touched;
  46249. /**
  46250. * button component type
  46251. */
  46252. static BUTTON_TYPE: MotionControllerComponentType;
  46253. /**
  46254. * squeeze component type
  46255. */
  46256. static SQUEEZE_TYPE: MotionControllerComponentType;
  46257. /**
  46258. * Thumbstick component type
  46259. */
  46260. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46261. /**
  46262. * Touchpad component type
  46263. */
  46264. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46265. /**
  46266. * trigger component type
  46267. */
  46268. static TRIGGER_TYPE: MotionControllerComponentType;
  46269. /**
  46270. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46271. * the axes data changes
  46272. */
  46273. onAxisValueChangedObservable: Observable<{
  46274. x: number;
  46275. y: number;
  46276. }>;
  46277. /**
  46278. * Observers registered here will be triggered when the state of a button changes
  46279. * State change is either pressed / touched / value
  46280. */
  46281. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46282. /**
  46283. * Creates a new component for a motion controller.
  46284. * It is created by the motion controller itself
  46285. *
  46286. * @param id the id of this component
  46287. * @param type the type of the component
  46288. * @param _buttonIndex index in the buttons array of the gamepad
  46289. * @param _axesIndices indices of the values in the axes array of the gamepad
  46290. */
  46291. constructor(
  46292. /**
  46293. * the id of this component
  46294. */
  46295. id: string,
  46296. /**
  46297. * the type of the component
  46298. */
  46299. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46300. /**
  46301. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46302. */
  46303. get axes(): IWebXRMotionControllerAxesValue;
  46304. /**
  46305. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46306. */
  46307. get changes(): IWebXRMotionControllerComponentChanges;
  46308. /**
  46309. * Return whether or not the component changed the last frame
  46310. */
  46311. get hasChanges(): boolean;
  46312. /**
  46313. * is the button currently pressed
  46314. */
  46315. get pressed(): boolean;
  46316. /**
  46317. * is the button currently touched
  46318. */
  46319. get touched(): boolean;
  46320. /**
  46321. * Get the current value of this component
  46322. */
  46323. get value(): number;
  46324. /**
  46325. * Dispose this component
  46326. */
  46327. dispose(): void;
  46328. /**
  46329. * Are there axes correlating to this component
  46330. * @return true is axes data is available
  46331. */
  46332. isAxes(): boolean;
  46333. /**
  46334. * Is this component a button (hence - pressable)
  46335. * @returns true if can be pressed
  46336. */
  46337. isButton(): boolean;
  46338. /**
  46339. * update this component using the gamepad object it is in. Called on every frame
  46340. * @param nativeController the native gamepad controller object
  46341. */
  46342. update(nativeController: IMinimalMotionControllerObject): void;
  46343. }
  46344. }
  46345. declare module BABYLON {
  46346. /**
  46347. * Class used to represent data loading progression
  46348. */
  46349. export class SceneLoaderProgressEvent {
  46350. /** defines if data length to load can be evaluated */
  46351. readonly lengthComputable: boolean;
  46352. /** defines the loaded data length */
  46353. readonly loaded: number;
  46354. /** defines the data length to load */
  46355. readonly total: number;
  46356. /**
  46357. * Create a new progress event
  46358. * @param lengthComputable defines if data length to load can be evaluated
  46359. * @param loaded defines the loaded data length
  46360. * @param total defines the data length to load
  46361. */
  46362. constructor(
  46363. /** defines if data length to load can be evaluated */
  46364. lengthComputable: boolean,
  46365. /** defines the loaded data length */
  46366. loaded: number,
  46367. /** defines the data length to load */
  46368. total: number);
  46369. /**
  46370. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46371. * @param event defines the source event
  46372. * @returns a new SceneLoaderProgressEvent
  46373. */
  46374. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46375. }
  46376. /**
  46377. * Interface used by SceneLoader plugins to define supported file extensions
  46378. */
  46379. export interface ISceneLoaderPluginExtensions {
  46380. /**
  46381. * Defines the list of supported extensions
  46382. */
  46383. [extension: string]: {
  46384. isBinary: boolean;
  46385. };
  46386. }
  46387. /**
  46388. * Interface used by SceneLoader plugin factory
  46389. */
  46390. export interface ISceneLoaderPluginFactory {
  46391. /**
  46392. * Defines the name of the factory
  46393. */
  46394. name: string;
  46395. /**
  46396. * Function called to create a new plugin
  46397. * @return the new plugin
  46398. */
  46399. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46400. /**
  46401. * The callback that returns true if the data can be directly loaded.
  46402. * @param data string containing the file data
  46403. * @returns if the data can be loaded directly
  46404. */
  46405. canDirectLoad?(data: string): boolean;
  46406. }
  46407. /**
  46408. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46409. */
  46410. export interface ISceneLoaderPluginBase {
  46411. /**
  46412. * The friendly name of this plugin.
  46413. */
  46414. name: string;
  46415. /**
  46416. * The file extensions supported by this plugin.
  46417. */
  46418. extensions: string | ISceneLoaderPluginExtensions;
  46419. /**
  46420. * The callback called when loading from a url.
  46421. * @param scene scene loading this url
  46422. * @param url url to load
  46423. * @param onSuccess callback called when the file successfully loads
  46424. * @param onProgress callback called while file is loading (if the server supports this mode)
  46425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46426. * @param onError callback called when the file fails to load
  46427. * @returns a file request object
  46428. */
  46429. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46430. /**
  46431. * The callback called when loading from a file object.
  46432. * @param scene scene loading this file
  46433. * @param file defines the file to load
  46434. * @param onSuccess defines the callback to call when data is loaded
  46435. * @param onProgress defines the callback to call during loading process
  46436. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46437. * @param onError defines the callback to call when an error occurs
  46438. * @returns a file request object
  46439. */
  46440. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46441. /**
  46442. * The callback that returns true if the data can be directly loaded.
  46443. * @param data string containing the file data
  46444. * @returns if the data can be loaded directly
  46445. */
  46446. canDirectLoad?(data: string): boolean;
  46447. /**
  46448. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46449. * @param scene scene loading this data
  46450. * @param data string containing the data
  46451. * @returns data to pass to the plugin
  46452. */
  46453. directLoad?(scene: Scene, data: string): any;
  46454. /**
  46455. * The callback that allows custom handling of the root url based on the response url.
  46456. * @param rootUrl the original root url
  46457. * @param responseURL the response url if available
  46458. * @returns the new root url
  46459. */
  46460. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46461. }
  46462. /**
  46463. * Interface used to define a SceneLoader plugin
  46464. */
  46465. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46466. /**
  46467. * Import meshes into a scene.
  46468. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46469. * @param scene The scene to import into
  46470. * @param data The data to import
  46471. * @param rootUrl The root url for scene and resources
  46472. * @param meshes The meshes array to import into
  46473. * @param particleSystems The particle systems array to import into
  46474. * @param skeletons The skeletons array to import into
  46475. * @param onError The callback when import fails
  46476. * @returns True if successful or false otherwise
  46477. */
  46478. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46479. /**
  46480. * Load into a scene.
  46481. * @param scene The scene to load into
  46482. * @param data The data to import
  46483. * @param rootUrl The root url for scene and resources
  46484. * @param onError The callback when import fails
  46485. * @returns True if successful or false otherwise
  46486. */
  46487. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46488. /**
  46489. * Load into an asset container.
  46490. * @param scene The scene to load into
  46491. * @param data The data to import
  46492. * @param rootUrl The root url for scene and resources
  46493. * @param onError The callback when import fails
  46494. * @returns The loaded asset container
  46495. */
  46496. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46497. }
  46498. /**
  46499. * Interface used to define an async SceneLoader plugin
  46500. */
  46501. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46502. /**
  46503. * Import meshes into a scene.
  46504. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46505. * @param scene The scene to import into
  46506. * @param data The data to import
  46507. * @param rootUrl The root url for scene and resources
  46508. * @param onProgress The callback when the load progresses
  46509. * @param fileName Defines the name of the file to load
  46510. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46511. */
  46512. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46513. meshes: AbstractMesh[];
  46514. particleSystems: IParticleSystem[];
  46515. skeletons: Skeleton[];
  46516. animationGroups: AnimationGroup[];
  46517. }>;
  46518. /**
  46519. * Load into a scene.
  46520. * @param scene The scene to load into
  46521. * @param data The data to import
  46522. * @param rootUrl The root url for scene and resources
  46523. * @param onProgress The callback when the load progresses
  46524. * @param fileName Defines the name of the file to load
  46525. * @returns Nothing
  46526. */
  46527. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46528. /**
  46529. * Load into an asset container.
  46530. * @param scene The scene to load into
  46531. * @param data The data to import
  46532. * @param rootUrl The root url for scene and resources
  46533. * @param onProgress The callback when the load progresses
  46534. * @param fileName Defines the name of the file to load
  46535. * @returns The loaded asset container
  46536. */
  46537. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46538. }
  46539. /**
  46540. * Mode that determines how to handle old animation groups before loading new ones.
  46541. */
  46542. export enum SceneLoaderAnimationGroupLoadingMode {
  46543. /**
  46544. * Reset all old animations to initial state then dispose them.
  46545. */
  46546. Clean = 0,
  46547. /**
  46548. * Stop all old animations.
  46549. */
  46550. Stop = 1,
  46551. /**
  46552. * Restart old animations from first frame.
  46553. */
  46554. Sync = 2,
  46555. /**
  46556. * Old animations remains untouched.
  46557. */
  46558. NoSync = 3
  46559. }
  46560. /**
  46561. * Class used to load scene from various file formats using registered plugins
  46562. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46563. */
  46564. export class SceneLoader {
  46565. /**
  46566. * No logging while loading
  46567. */
  46568. static readonly NO_LOGGING: number;
  46569. /**
  46570. * Minimal logging while loading
  46571. */
  46572. static readonly MINIMAL_LOGGING: number;
  46573. /**
  46574. * Summary logging while loading
  46575. */
  46576. static readonly SUMMARY_LOGGING: number;
  46577. /**
  46578. * Detailled logging while loading
  46579. */
  46580. static readonly DETAILED_LOGGING: number;
  46581. /**
  46582. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46583. */
  46584. static get ForceFullSceneLoadingForIncremental(): boolean;
  46585. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46586. /**
  46587. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46588. */
  46589. static get ShowLoadingScreen(): boolean;
  46590. static set ShowLoadingScreen(value: boolean);
  46591. /**
  46592. * Defines the current logging level (while loading the scene)
  46593. * @ignorenaming
  46594. */
  46595. static get loggingLevel(): number;
  46596. static set loggingLevel(value: number);
  46597. /**
  46598. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46599. */
  46600. static get CleanBoneMatrixWeights(): boolean;
  46601. static set CleanBoneMatrixWeights(value: boolean);
  46602. /**
  46603. * Event raised when a plugin is used to load a scene
  46604. */
  46605. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46606. private static _registeredPlugins;
  46607. private static _getDefaultPlugin;
  46608. private static _getPluginForExtension;
  46609. private static _getPluginForDirectLoad;
  46610. private static _getPluginForFilename;
  46611. private static _getDirectLoad;
  46612. private static _loadData;
  46613. private static _getFileInfo;
  46614. /**
  46615. * Gets a plugin that can load the given extension
  46616. * @param extension defines the extension to load
  46617. * @returns a plugin or null if none works
  46618. */
  46619. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46620. /**
  46621. * Gets a boolean indicating that the given extension can be loaded
  46622. * @param extension defines the extension to load
  46623. * @returns true if the extension is supported
  46624. */
  46625. static IsPluginForExtensionAvailable(extension: string): boolean;
  46626. /**
  46627. * Adds a new plugin to the list of registered plugins
  46628. * @param plugin defines the plugin to add
  46629. */
  46630. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46631. /**
  46632. * Import meshes into a scene
  46633. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46634. * @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)
  46635. * @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)
  46636. * @param scene the instance of BABYLON.Scene to append to
  46637. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46638. * @param onProgress a callback with a progress event for each file being loaded
  46639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46640. * @param pluginExtension the extension used to determine the plugin
  46641. * @returns The loaded plugin
  46642. */
  46643. 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>;
  46644. /**
  46645. * Import meshes into a scene
  46646. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46647. * @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)
  46648. * @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)
  46649. * @param scene the instance of BABYLON.Scene to append to
  46650. * @param onProgress a callback with a progress event for each file being loaded
  46651. * @param pluginExtension the extension used to determine the plugin
  46652. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46653. */
  46654. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46655. meshes: AbstractMesh[];
  46656. particleSystems: IParticleSystem[];
  46657. skeletons: Skeleton[];
  46658. animationGroups: AnimationGroup[];
  46659. }>;
  46660. /**
  46661. * Load a scene
  46662. * @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)
  46663. * @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)
  46664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46665. * @param onSuccess a callback with the scene when import succeeds
  46666. * @param onProgress a callback with a progress event for each file being loaded
  46667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46668. * @param pluginExtension the extension used to determine the plugin
  46669. * @returns The loaded plugin
  46670. */
  46671. 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>;
  46672. /**
  46673. * Load a scene
  46674. * @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)
  46675. * @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)
  46676. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46677. * @param onProgress a callback with a progress event for each file being loaded
  46678. * @param pluginExtension the extension used to determine the plugin
  46679. * @returns The loaded scene
  46680. */
  46681. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46682. /**
  46683. * Append a scene
  46684. * @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)
  46685. * @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)
  46686. * @param scene is the instance of BABYLON.Scene to append to
  46687. * @param onSuccess a callback with the scene when import succeeds
  46688. * @param onProgress a callback with a progress event for each file being loaded
  46689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46690. * @param pluginExtension the extension used to determine the plugin
  46691. * @returns The loaded plugin
  46692. */
  46693. 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>;
  46694. /**
  46695. * Append a scene
  46696. * @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)
  46697. * @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)
  46698. * @param scene is the instance of BABYLON.Scene to append to
  46699. * @param onProgress a callback with a progress event for each file being loaded
  46700. * @param pluginExtension the extension used to determine the plugin
  46701. * @returns The given scene
  46702. */
  46703. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46704. /**
  46705. * Load a scene into an asset container
  46706. * @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)
  46707. * @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)
  46708. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46709. * @param onSuccess a callback with the scene when import succeeds
  46710. * @param onProgress a callback with a progress event for each file being loaded
  46711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46712. * @param pluginExtension the extension used to determine the plugin
  46713. * @returns The loaded plugin
  46714. */
  46715. 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>;
  46716. /**
  46717. * Load a scene into an asset container
  46718. * @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)
  46719. * @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)
  46720. * @param scene is the instance of Scene to append to
  46721. * @param onProgress a callback with a progress event for each file being loaded
  46722. * @param pluginExtension the extension used to determine the plugin
  46723. * @returns The loaded asset container
  46724. */
  46725. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46726. /**
  46727. * Import animations from a file into a scene
  46728. * @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)
  46729. * @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)
  46730. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46731. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46732. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46733. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46734. * @param onSuccess a callback with the scene when import succeeds
  46735. * @param onProgress a callback with a progress event for each file being loaded
  46736. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46737. */
  46738. 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;
  46739. /**
  46740. * Import animations from a file into a scene
  46741. * @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)
  46742. * @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)
  46743. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46744. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46745. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46746. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46747. * @param onSuccess a callback with the scene when import succeeds
  46748. * @param onProgress a callback with a progress event for each file being loaded
  46749. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46750. * @returns the updated scene with imported animations
  46751. */
  46752. 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>;
  46753. }
  46754. }
  46755. declare module BABYLON {
  46756. /**
  46757. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46758. */
  46759. export type MotionControllerHandedness = "none" | "left" | "right";
  46760. /**
  46761. * The type of components available in motion controllers.
  46762. * This is not the name of the component.
  46763. */
  46764. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46765. /**
  46766. * The state of a controller component
  46767. */
  46768. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46769. /**
  46770. * The schema of motion controller layout.
  46771. * No object will be initialized using this interface
  46772. * This is used just to define the profile.
  46773. */
  46774. export interface IMotionControllerLayout {
  46775. /**
  46776. * Path to load the assets. Usually relative to the base path
  46777. */
  46778. assetPath: string;
  46779. /**
  46780. * Available components (unsorted)
  46781. */
  46782. components: {
  46783. /**
  46784. * A map of component Ids
  46785. */
  46786. [componentId: string]: {
  46787. /**
  46788. * The type of input the component outputs
  46789. */
  46790. type: MotionControllerComponentType;
  46791. /**
  46792. * The indices of this component in the gamepad object
  46793. */
  46794. gamepadIndices: {
  46795. /**
  46796. * Index of button
  46797. */
  46798. button?: number;
  46799. /**
  46800. * If available, index of x-axis
  46801. */
  46802. xAxis?: number;
  46803. /**
  46804. * If available, index of y-axis
  46805. */
  46806. yAxis?: number;
  46807. };
  46808. /**
  46809. * The mesh's root node name
  46810. */
  46811. rootNodeName: string;
  46812. /**
  46813. * Animation definitions for this model
  46814. */
  46815. visualResponses: {
  46816. [stateKey: string]: {
  46817. /**
  46818. * What property will be animated
  46819. */
  46820. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46821. /**
  46822. * What states influence this visual response
  46823. */
  46824. states: MotionControllerComponentStateType[];
  46825. /**
  46826. * Type of animation - movement or visibility
  46827. */
  46828. valueNodeProperty: "transform" | "visibility";
  46829. /**
  46830. * Base node name to move. Its position will be calculated according to the min and max nodes
  46831. */
  46832. valueNodeName?: string;
  46833. /**
  46834. * Minimum movement node
  46835. */
  46836. minNodeName?: string;
  46837. /**
  46838. * Max movement node
  46839. */
  46840. maxNodeName?: string;
  46841. };
  46842. };
  46843. /**
  46844. * If touch enabled, what is the name of node to display user feedback
  46845. */
  46846. touchPointNodeName?: string;
  46847. };
  46848. };
  46849. /**
  46850. * Is it xr standard mapping or not
  46851. */
  46852. gamepadMapping: "" | "xr-standard";
  46853. /**
  46854. * Base root node of this entire model
  46855. */
  46856. rootNodeName: string;
  46857. /**
  46858. * Defines the main button component id
  46859. */
  46860. selectComponentId: string;
  46861. }
  46862. /**
  46863. * A definition for the layout map in the input profile
  46864. */
  46865. export interface IMotionControllerLayoutMap {
  46866. /**
  46867. * Layouts with handedness type as a key
  46868. */
  46869. [handedness: string]: IMotionControllerLayout;
  46870. }
  46871. /**
  46872. * The XR Input profile schema
  46873. * Profiles can be found here:
  46874. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46875. */
  46876. export interface IMotionControllerProfile {
  46877. /**
  46878. * fallback profiles for this profileId
  46879. */
  46880. fallbackProfileIds: string[];
  46881. /**
  46882. * The layout map, with handedness as key
  46883. */
  46884. layouts: IMotionControllerLayoutMap;
  46885. /**
  46886. * The id of this profile
  46887. * correlates to the profile(s) in the xrInput.profiles array
  46888. */
  46889. profileId: string;
  46890. }
  46891. /**
  46892. * A helper-interface for the 3 meshes needed for controller button animation
  46893. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46894. */
  46895. export interface IMotionControllerButtonMeshMap {
  46896. /**
  46897. * the mesh that defines the pressed value mesh position.
  46898. * This is used to find the max-position of this button
  46899. */
  46900. pressedMesh: AbstractMesh;
  46901. /**
  46902. * the mesh that defines the unpressed value mesh position.
  46903. * This is used to find the min (or initial) position of this button
  46904. */
  46905. unpressedMesh: AbstractMesh;
  46906. /**
  46907. * The mesh that will be changed when value changes
  46908. */
  46909. valueMesh: AbstractMesh;
  46910. }
  46911. /**
  46912. * A helper-interface for the 3 meshes needed for controller axis animation.
  46913. * This will be expanded when touchpad animations are fully supported
  46914. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46915. */
  46916. export interface IMotionControllerMeshMap {
  46917. /**
  46918. * the mesh that defines the maximum value mesh position.
  46919. */
  46920. maxMesh?: AbstractMesh;
  46921. /**
  46922. * the mesh that defines the minimum value mesh position.
  46923. */
  46924. minMesh?: AbstractMesh;
  46925. /**
  46926. * The mesh that will be changed when axis value changes
  46927. */
  46928. valueMesh: AbstractMesh;
  46929. }
  46930. /**
  46931. * The elements needed for change-detection of the gamepad objects in motion controllers
  46932. */
  46933. export interface IMinimalMotionControllerObject {
  46934. /**
  46935. * Available axes of this controller
  46936. */
  46937. axes: number[];
  46938. /**
  46939. * An array of available buttons
  46940. */
  46941. buttons: Array<{
  46942. /**
  46943. * Value of the button/trigger
  46944. */
  46945. value: number;
  46946. /**
  46947. * If the button/trigger is currently touched
  46948. */
  46949. touched: boolean;
  46950. /**
  46951. * If the button/trigger is currently pressed
  46952. */
  46953. pressed: boolean;
  46954. }>;
  46955. /**
  46956. * EXPERIMENTAL haptic support.
  46957. */
  46958. hapticActuators?: Array<{
  46959. pulse: (value: number, duration: number) => Promise<boolean>;
  46960. }>;
  46961. }
  46962. /**
  46963. * An Abstract Motion controller
  46964. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46965. * Each component has an observable to check for changes in value and state
  46966. */
  46967. export abstract class WebXRAbstractMotionController implements IDisposable {
  46968. protected scene: Scene;
  46969. protected layout: IMotionControllerLayout;
  46970. /**
  46971. * The gamepad object correlating to this controller
  46972. */
  46973. gamepadObject: IMinimalMotionControllerObject;
  46974. /**
  46975. * handedness (left/right/none) of this controller
  46976. */
  46977. handedness: MotionControllerHandedness;
  46978. private _initComponent;
  46979. private _modelReady;
  46980. /**
  46981. * A map of components (WebXRControllerComponent) in this motion controller
  46982. * Components have a ComponentType and can also have both button and axis definitions
  46983. */
  46984. readonly components: {
  46985. [id: string]: WebXRControllerComponent;
  46986. };
  46987. /**
  46988. * Disable the model's animation. Can be set at any time.
  46989. */
  46990. disableAnimation: boolean;
  46991. /**
  46992. * Observers registered here will be triggered when the model of this controller is done loading
  46993. */
  46994. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46995. /**
  46996. * The profile id of this motion controller
  46997. */
  46998. abstract profileId: string;
  46999. /**
  47000. * The root mesh of the model. It is null if the model was not yet initialized
  47001. */
  47002. rootMesh: Nullable<AbstractMesh>;
  47003. /**
  47004. * constructs a new abstract motion controller
  47005. * @param scene the scene to which the model of the controller will be added
  47006. * @param layout The profile layout to load
  47007. * @param gamepadObject The gamepad object correlating to this controller
  47008. * @param handedness handedness (left/right/none) of this controller
  47009. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47010. */
  47011. constructor(scene: Scene, layout: IMotionControllerLayout,
  47012. /**
  47013. * The gamepad object correlating to this controller
  47014. */
  47015. gamepadObject: IMinimalMotionControllerObject,
  47016. /**
  47017. * handedness (left/right/none) of this controller
  47018. */
  47019. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47020. /**
  47021. * Dispose this controller, the model mesh and all its components
  47022. */
  47023. dispose(): void;
  47024. /**
  47025. * Returns all components of specific type
  47026. * @param type the type to search for
  47027. * @return an array of components with this type
  47028. */
  47029. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47030. /**
  47031. * get a component based an its component id as defined in layout.components
  47032. * @param id the id of the component
  47033. * @returns the component correlates to the id or undefined if not found
  47034. */
  47035. getComponent(id: string): WebXRControllerComponent;
  47036. /**
  47037. * Get the list of components available in this motion controller
  47038. * @returns an array of strings correlating to available components
  47039. */
  47040. getComponentIds(): string[];
  47041. /**
  47042. * Get the first component of specific type
  47043. * @param type type of component to find
  47044. * @return a controller component or null if not found
  47045. */
  47046. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47047. /**
  47048. * Get the main (Select) component of this controller as defined in the layout
  47049. * @returns the main component of this controller
  47050. */
  47051. getMainComponent(): WebXRControllerComponent;
  47052. /**
  47053. * Loads the model correlating to this controller
  47054. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47055. * @returns A promise fulfilled with the result of the model loading
  47056. */
  47057. loadModel(): Promise<boolean>;
  47058. /**
  47059. * Update this model using the current XRFrame
  47060. * @param xrFrame the current xr frame to use and update the model
  47061. */
  47062. updateFromXRFrame(xrFrame: XRFrame): void;
  47063. /**
  47064. * Backwards compatibility due to a deeply-integrated typo
  47065. */
  47066. get handness(): XREye;
  47067. /**
  47068. * Pulse (vibrate) this controller
  47069. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47070. * Consecutive calls to this function will cancel the last pulse call
  47071. *
  47072. * @param value the strength of the pulse in 0.0...1.0 range
  47073. * @param duration Duration of the pulse in milliseconds
  47074. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47075. * @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
  47076. */
  47077. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47078. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47079. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47080. /**
  47081. * Moves the axis on the controller mesh based on its current state
  47082. * @param axis the index of the axis
  47083. * @param axisValue the value of the axis which determines the meshes new position
  47084. * @hidden
  47085. */
  47086. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47087. /**
  47088. * Update the model itself with the current frame data
  47089. * @param xrFrame the frame to use for updating the model mesh
  47090. */
  47091. protected updateModel(xrFrame: XRFrame): void;
  47092. /**
  47093. * Get the filename and path for this controller's model
  47094. * @returns a map of filename and path
  47095. */
  47096. protected abstract _getFilenameAndPath(): {
  47097. filename: string;
  47098. path: string;
  47099. };
  47100. /**
  47101. * This function is called before the mesh is loaded. It checks for loading constraints.
  47102. * For example, this function can check if the GLB loader is available
  47103. * If this function returns false, the generic controller will be loaded instead
  47104. * @returns Is the client ready to load the mesh
  47105. */
  47106. protected abstract _getModelLoadingConstraints(): boolean;
  47107. /**
  47108. * This function will be called after the model was successfully loaded and can be used
  47109. * for mesh transformations before it is available for the user
  47110. * @param meshes the loaded meshes
  47111. */
  47112. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47113. /**
  47114. * Set the root mesh for this controller. Important for the WebXR controller class
  47115. * @param meshes the loaded meshes
  47116. */
  47117. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47118. /**
  47119. * A function executed each frame that updates the mesh (if needed)
  47120. * @param xrFrame the current xrFrame
  47121. */
  47122. protected abstract _updateModel(xrFrame: XRFrame): void;
  47123. private _getGenericFilenameAndPath;
  47124. private _getGenericParentMesh;
  47125. }
  47126. }
  47127. declare module BABYLON {
  47128. /**
  47129. * A generic trigger-only motion controller for WebXR
  47130. */
  47131. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47132. /**
  47133. * Static version of the profile id of this controller
  47134. */
  47135. static ProfileId: string;
  47136. profileId: string;
  47137. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47138. protected _getFilenameAndPath(): {
  47139. filename: string;
  47140. path: string;
  47141. };
  47142. protected _getModelLoadingConstraints(): boolean;
  47143. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47144. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47145. protected _updateModel(): void;
  47146. }
  47147. }
  47148. declare module BABYLON {
  47149. /**
  47150. * Class containing static functions to help procedurally build meshes
  47151. */
  47152. export class SphereBuilder {
  47153. /**
  47154. * Creates a sphere mesh
  47155. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47156. * * 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`)
  47157. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47158. * * 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
  47159. * * 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)
  47160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47161. * * 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
  47162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47163. * @param name defines the name of the mesh
  47164. * @param options defines the options used to create the mesh
  47165. * @param scene defines the hosting scene
  47166. * @returns the sphere mesh
  47167. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47168. */
  47169. static CreateSphere(name: string, options: {
  47170. segments?: number;
  47171. diameter?: number;
  47172. diameterX?: number;
  47173. diameterY?: number;
  47174. diameterZ?: number;
  47175. arc?: number;
  47176. slice?: number;
  47177. sideOrientation?: number;
  47178. frontUVs?: Vector4;
  47179. backUVs?: Vector4;
  47180. updatable?: boolean;
  47181. }, scene?: Nullable<Scene>): Mesh;
  47182. }
  47183. }
  47184. declare module BABYLON {
  47185. /**
  47186. * A profiled motion controller has its profile loaded from an online repository.
  47187. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47188. */
  47189. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47190. private _repositoryUrl;
  47191. private _buttonMeshMapping;
  47192. private _touchDots;
  47193. /**
  47194. * The profile ID of this controller. Will be populated when the controller initializes.
  47195. */
  47196. profileId: string;
  47197. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47198. dispose(): void;
  47199. protected _getFilenameAndPath(): {
  47200. filename: string;
  47201. path: string;
  47202. };
  47203. protected _getModelLoadingConstraints(): boolean;
  47204. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47205. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47206. protected _updateModel(_xrFrame: XRFrame): void;
  47207. }
  47208. }
  47209. declare module BABYLON {
  47210. /**
  47211. * A construction function type to create a new controller based on an xrInput object
  47212. */
  47213. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47214. /**
  47215. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47216. *
  47217. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47218. * it should be replaced with auto-loaded controllers.
  47219. *
  47220. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47221. */
  47222. export class WebXRMotionControllerManager {
  47223. private static _AvailableControllers;
  47224. private static _Fallbacks;
  47225. private static _ProfileLoadingPromises;
  47226. private static _ProfilesList;
  47227. /**
  47228. * The base URL of the online controller repository. Can be changed at any time.
  47229. */
  47230. static BaseRepositoryUrl: string;
  47231. /**
  47232. * Which repository gets priority - local or online
  47233. */
  47234. static PrioritizeOnlineRepository: boolean;
  47235. /**
  47236. * Use the online repository, or use only locally-defined controllers
  47237. */
  47238. static UseOnlineRepository: boolean;
  47239. /**
  47240. * Clear the cache used for profile loading and reload when requested again
  47241. */
  47242. static ClearProfilesCache(): void;
  47243. /**
  47244. * Register the default fallbacks.
  47245. * This function is called automatically when this file is imported.
  47246. */
  47247. static DefaultFallbacks(): void;
  47248. /**
  47249. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47250. * @param profileId the profile to which a fallback needs to be found
  47251. * @return an array with corresponding fallback profiles
  47252. */
  47253. static FindFallbackWithProfileId(profileId: string): string[];
  47254. /**
  47255. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47256. * The order of search:
  47257. *
  47258. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47259. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47260. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47261. * 4) return the generic trigger controller if none were found
  47262. *
  47263. * @param xrInput the xrInput to which a new controller is initialized
  47264. * @param scene the scene to which the model will be added
  47265. * @param forceProfile force a certain profile for this controller
  47266. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47267. */
  47268. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47269. /**
  47270. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47271. *
  47272. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47273. *
  47274. * @param type the profile type to register
  47275. * @param constructFunction the function to be called when loading this profile
  47276. */
  47277. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47278. /**
  47279. * Register a fallback to a specific profile.
  47280. * @param profileId the profileId that will receive the fallbacks
  47281. * @param fallbacks A list of fallback profiles
  47282. */
  47283. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47284. /**
  47285. * Will update the list of profiles available in the repository
  47286. * @return a promise that resolves to a map of profiles available online
  47287. */
  47288. static UpdateProfilesList(): Promise<{
  47289. [profile: string]: string;
  47290. }>;
  47291. private static _LoadProfileFromRepository;
  47292. private static _LoadProfilesFromAvailableControllers;
  47293. }
  47294. }
  47295. declare module BABYLON {
  47296. /**
  47297. * Configuration options for the WebXR controller creation
  47298. */
  47299. export interface IWebXRControllerOptions {
  47300. /**
  47301. * Should the controller mesh be animated when a user interacts with it
  47302. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47303. */
  47304. disableMotionControllerAnimation?: boolean;
  47305. /**
  47306. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47307. */
  47308. doNotLoadControllerMesh?: boolean;
  47309. /**
  47310. * Force a specific controller type for this controller.
  47311. * This can be used when creating your own profile or when testing different controllers
  47312. */
  47313. forceControllerProfile?: string;
  47314. /**
  47315. * Defines a rendering group ID for meshes that will be loaded.
  47316. * This is for the default controllers only.
  47317. */
  47318. renderingGroupId?: number;
  47319. }
  47320. /**
  47321. * Represents an XR controller
  47322. */
  47323. export class WebXRInputSource {
  47324. private _scene;
  47325. /** The underlying input source for the controller */
  47326. inputSource: XRInputSource;
  47327. private _options;
  47328. private _tmpVector;
  47329. private _uniqueId;
  47330. /**
  47331. * 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
  47332. */
  47333. grip?: AbstractMesh;
  47334. /**
  47335. * If available, this is the gamepad object related to this controller.
  47336. * Using this object it is possible to get click events and trackpad changes of the
  47337. * webxr controller that is currently being used.
  47338. */
  47339. motionController?: WebXRAbstractMotionController;
  47340. /**
  47341. * Event that fires when the controller is removed/disposed.
  47342. * The object provided as event data is this controller, after associated assets were disposed.
  47343. * uniqueId is still available.
  47344. */
  47345. onDisposeObservable: Observable<WebXRInputSource>;
  47346. /**
  47347. * Will be triggered when the mesh associated with the motion controller is done loading.
  47348. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47349. * A shortened version of controller -> motion controller -> on mesh loaded.
  47350. */
  47351. onMeshLoadedObservable: Observable<AbstractMesh>;
  47352. /**
  47353. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47354. */
  47355. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47356. /**
  47357. * Pointer which can be used to select objects or attach a visible laser to
  47358. */
  47359. pointer: AbstractMesh;
  47360. /**
  47361. * Creates the controller
  47362. * @see https://doc.babylonjs.com/how_to/webxr
  47363. * @param _scene the scene which the controller should be associated to
  47364. * @param inputSource the underlying input source for the controller
  47365. * @param _options options for this controller creation
  47366. */
  47367. constructor(_scene: Scene,
  47368. /** The underlying input source for the controller */
  47369. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47370. /**
  47371. * Get this controllers unique id
  47372. */
  47373. get uniqueId(): string;
  47374. /**
  47375. * Disposes of the object
  47376. */
  47377. dispose(): void;
  47378. /**
  47379. * Gets a world space ray coming from the pointer or grip
  47380. * @param result the resulting ray
  47381. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47382. */
  47383. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47384. /**
  47385. * Updates the controller pose based on the given XRFrame
  47386. * @param xrFrame xr frame to update the pose with
  47387. * @param referenceSpace reference space to use
  47388. */
  47389. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47390. }
  47391. }
  47392. declare module BABYLON {
  47393. /**
  47394. * The schema for initialization options of the XR Input class
  47395. */
  47396. export interface IWebXRInputOptions {
  47397. /**
  47398. * If set to true no model will be automatically loaded
  47399. */
  47400. doNotLoadControllerMeshes?: boolean;
  47401. /**
  47402. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47403. * If not found, the xr input profile data will be used.
  47404. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47405. */
  47406. forceInputProfile?: string;
  47407. /**
  47408. * Do not send a request to the controller repository to load the profile.
  47409. *
  47410. * Instead, use the controllers available in babylon itself.
  47411. */
  47412. disableOnlineControllerRepository?: boolean;
  47413. /**
  47414. * A custom URL for the controllers repository
  47415. */
  47416. customControllersRepositoryURL?: string;
  47417. /**
  47418. * Should the controller model's components not move according to the user input
  47419. */
  47420. disableControllerAnimation?: boolean;
  47421. /**
  47422. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47423. */
  47424. controllerOptions?: IWebXRControllerOptions;
  47425. }
  47426. /**
  47427. * XR input used to track XR inputs such as controllers/rays
  47428. */
  47429. export class WebXRInput implements IDisposable {
  47430. /**
  47431. * the xr session manager for this session
  47432. */
  47433. xrSessionManager: WebXRSessionManager;
  47434. /**
  47435. * the WebXR camera for this session. Mainly used for teleportation
  47436. */
  47437. xrCamera: WebXRCamera;
  47438. private readonly options;
  47439. /**
  47440. * XR controllers being tracked
  47441. */
  47442. controllers: Array<WebXRInputSource>;
  47443. private _frameObserver;
  47444. private _sessionEndedObserver;
  47445. private _sessionInitObserver;
  47446. /**
  47447. * Event when a controller has been connected/added
  47448. */
  47449. onControllerAddedObservable: Observable<WebXRInputSource>;
  47450. /**
  47451. * Event when a controller has been removed/disconnected
  47452. */
  47453. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47454. /**
  47455. * Initializes the WebXRInput
  47456. * @param xrSessionManager the xr session manager for this session
  47457. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47458. * @param options = initialization options for this xr input
  47459. */
  47460. constructor(
  47461. /**
  47462. * the xr session manager for this session
  47463. */
  47464. xrSessionManager: WebXRSessionManager,
  47465. /**
  47466. * the WebXR camera for this session. Mainly used for teleportation
  47467. */
  47468. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47469. private _onInputSourcesChange;
  47470. private _addAndRemoveControllers;
  47471. /**
  47472. * Disposes of the object
  47473. */
  47474. dispose(): void;
  47475. }
  47476. }
  47477. declare module BABYLON {
  47478. /**
  47479. * This is the base class for all WebXR features.
  47480. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47481. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47482. */
  47483. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47484. protected _xrSessionManager: WebXRSessionManager;
  47485. private _attached;
  47486. private _removeOnDetach;
  47487. /**
  47488. * Should auto-attach be disabled?
  47489. */
  47490. disableAutoAttach: boolean;
  47491. /**
  47492. * Construct a new (abstract) WebXR feature
  47493. * @param _xrSessionManager the xr session manager for this feature
  47494. */
  47495. constructor(_xrSessionManager: WebXRSessionManager);
  47496. /**
  47497. * Is this feature attached
  47498. */
  47499. get attached(): boolean;
  47500. /**
  47501. * attach this feature
  47502. *
  47503. * @param force should attachment be forced (even when already attached)
  47504. * @returns true if successful, false is failed or already attached
  47505. */
  47506. attach(force?: boolean): boolean;
  47507. /**
  47508. * detach this feature.
  47509. *
  47510. * @returns true if successful, false if failed or already detached
  47511. */
  47512. detach(): boolean;
  47513. /**
  47514. * Dispose this feature and all of the resources attached
  47515. */
  47516. dispose(): void;
  47517. /**
  47518. * This is used to register callbacks that will automatically be removed when detach is called.
  47519. * @param observable the observable to which the observer will be attached
  47520. * @param callback the callback to register
  47521. */
  47522. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47523. /**
  47524. * Code in this function will be executed on each xrFrame received from the browser.
  47525. * This function will not execute after the feature is detached.
  47526. * @param _xrFrame the current frame
  47527. */
  47528. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47529. }
  47530. }
  47531. declare module BABYLON {
  47532. /**
  47533. * Renders a layer on top of an existing scene
  47534. */
  47535. export class UtilityLayerRenderer implements IDisposable {
  47536. /** the original scene that will be rendered on top of */
  47537. originalScene: Scene;
  47538. private _pointerCaptures;
  47539. private _lastPointerEvents;
  47540. private static _DefaultUtilityLayer;
  47541. private static _DefaultKeepDepthUtilityLayer;
  47542. private _sharedGizmoLight;
  47543. private _renderCamera;
  47544. /**
  47545. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47546. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47547. * @returns the camera that is used when rendering the utility layer
  47548. */
  47549. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47550. /**
  47551. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47552. * @param cam the camera that should be used when rendering the utility layer
  47553. */
  47554. setRenderCamera(cam: Nullable<Camera>): void;
  47555. /**
  47556. * @hidden
  47557. * Light which used by gizmos to get light shading
  47558. */
  47559. _getSharedGizmoLight(): HemisphericLight;
  47560. /**
  47561. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47562. */
  47563. pickUtilitySceneFirst: boolean;
  47564. /**
  47565. * 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)
  47566. */
  47567. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47568. /**
  47569. * 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)
  47570. */
  47571. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47572. /**
  47573. * The scene that is rendered on top of the original scene
  47574. */
  47575. utilityLayerScene: Scene;
  47576. /**
  47577. * If the utility layer should automatically be rendered on top of existing scene
  47578. */
  47579. shouldRender: boolean;
  47580. /**
  47581. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47582. */
  47583. onlyCheckPointerDownEvents: boolean;
  47584. /**
  47585. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47586. */
  47587. processAllEvents: boolean;
  47588. /**
  47589. * Observable raised when the pointer move from the utility layer scene to the main scene
  47590. */
  47591. onPointerOutObservable: Observable<number>;
  47592. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47593. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47594. private _afterRenderObserver;
  47595. private _sceneDisposeObserver;
  47596. private _originalPointerObserver;
  47597. /**
  47598. * Instantiates a UtilityLayerRenderer
  47599. * @param originalScene the original scene that will be rendered on top of
  47600. * @param handleEvents boolean indicating if the utility layer should handle events
  47601. */
  47602. constructor(
  47603. /** the original scene that will be rendered on top of */
  47604. originalScene: Scene, handleEvents?: boolean);
  47605. private _notifyObservers;
  47606. /**
  47607. * Renders the utility layers scene on top of the original scene
  47608. */
  47609. render(): void;
  47610. /**
  47611. * Disposes of the renderer
  47612. */
  47613. dispose(): void;
  47614. private _updateCamera;
  47615. }
  47616. }
  47617. declare module BABYLON {
  47618. /**
  47619. * Options interface for the pointer selection module
  47620. */
  47621. export interface IWebXRControllerPointerSelectionOptions {
  47622. /**
  47623. * if provided, this scene will be used to render meshes.
  47624. */
  47625. customUtilityLayerScene?: Scene;
  47626. /**
  47627. * 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)
  47628. * If not disabled, the last picked point will be used to execute a pointer up event
  47629. * If disabled, pointer up event will be triggered right after the pointer down event.
  47630. * Used in screen and gaze target ray mode only
  47631. */
  47632. disablePointerUpOnTouchOut: boolean;
  47633. /**
  47634. * For gaze mode (time to select instead of press)
  47635. */
  47636. forceGazeMode: boolean;
  47637. /**
  47638. * 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
  47639. * to start a new countdown to the pointer down event.
  47640. * Defaults to 1.
  47641. */
  47642. gazeModePointerMovedFactor?: number;
  47643. /**
  47644. * Different button type to use instead of the main component
  47645. */
  47646. overrideButtonId?: string;
  47647. /**
  47648. * use this rendering group id for the meshes (optional)
  47649. */
  47650. renderingGroupId?: number;
  47651. /**
  47652. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47653. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47654. * 3000 means 3 seconds between pointing at something and selecting it
  47655. */
  47656. timeToSelect?: number;
  47657. /**
  47658. * Should meshes created here be added to a utility layer or the main scene
  47659. */
  47660. useUtilityLayer?: boolean;
  47661. /**
  47662. * the xr input to use with this pointer selection
  47663. */
  47664. xrInput: WebXRInput;
  47665. }
  47666. /**
  47667. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47668. */
  47669. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47670. private readonly _options;
  47671. private static _idCounter;
  47672. private _attachController;
  47673. private _controllers;
  47674. private _scene;
  47675. private _tmpVectorForPickCompare;
  47676. /**
  47677. * The module's name
  47678. */
  47679. static readonly Name: string;
  47680. /**
  47681. * The (Babylon) version of this module.
  47682. * This is an integer representing the implementation version.
  47683. * This number does not correspond to the WebXR specs version
  47684. */
  47685. static readonly Version: number;
  47686. /**
  47687. * Disable lighting on the laser pointer (so it will always be visible)
  47688. */
  47689. disablePointerLighting: boolean;
  47690. /**
  47691. * Disable lighting on the selection mesh (so it will always be visible)
  47692. */
  47693. disableSelectionMeshLighting: boolean;
  47694. /**
  47695. * Should the laser pointer be displayed
  47696. */
  47697. displayLaserPointer: boolean;
  47698. /**
  47699. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47700. */
  47701. displaySelectionMesh: boolean;
  47702. /**
  47703. * This color will be set to the laser pointer when selection is triggered
  47704. */
  47705. laserPointerPickedColor: Color3;
  47706. /**
  47707. * Default color of the laser pointer
  47708. */
  47709. laserPointerDefaultColor: Color3;
  47710. /**
  47711. * default color of the selection ring
  47712. */
  47713. selectionMeshDefaultColor: Color3;
  47714. /**
  47715. * This color will be applied to the selection ring when selection is triggered
  47716. */
  47717. selectionMeshPickedColor: Color3;
  47718. /**
  47719. * Optional filter to be used for ray selection. This predicate shares behavior with
  47720. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47721. */
  47722. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47723. /**
  47724. * constructs a new background remover module
  47725. * @param _xrSessionManager the session manager for this module
  47726. * @param _options read-only options to be used in this module
  47727. */
  47728. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47729. /**
  47730. * attach this feature
  47731. * Will usually be called by the features manager
  47732. *
  47733. * @returns true if successful.
  47734. */
  47735. attach(): boolean;
  47736. /**
  47737. * detach this feature.
  47738. * Will usually be called by the features manager
  47739. *
  47740. * @returns true if successful.
  47741. */
  47742. detach(): boolean;
  47743. /**
  47744. * Will get the mesh under a specific pointer.
  47745. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47746. * @param controllerId the controllerId to check
  47747. * @returns The mesh under pointer or null if no mesh is under the pointer
  47748. */
  47749. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47750. /**
  47751. * Get the xr controller that correlates to the pointer id in the pointer event
  47752. *
  47753. * @param id the pointer id to search for
  47754. * @returns the controller that correlates to this id or null if not found
  47755. */
  47756. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47757. protected _onXRFrame(_xrFrame: XRFrame): void;
  47758. private _attachGazeMode;
  47759. private _attachScreenRayMode;
  47760. private _attachTrackedPointerRayMode;
  47761. private _convertNormalToDirectionOfRay;
  47762. private _detachController;
  47763. private _generateNewMeshPair;
  47764. private _pickingMoved;
  47765. private _updatePointerDistance;
  47766. /** @hidden */
  47767. get lasterPointerDefaultColor(): Color3;
  47768. }
  47769. }
  47770. declare module BABYLON {
  47771. /**
  47772. * Button which can be used to enter a different mode of XR
  47773. */
  47774. export class WebXREnterExitUIButton {
  47775. /** button element */
  47776. element: HTMLElement;
  47777. /** XR initialization options for the button */
  47778. sessionMode: XRSessionMode;
  47779. /** Reference space type */
  47780. referenceSpaceType: XRReferenceSpaceType;
  47781. /**
  47782. * Creates a WebXREnterExitUIButton
  47783. * @param element button element
  47784. * @param sessionMode XR initialization session mode
  47785. * @param referenceSpaceType the type of reference space to be used
  47786. */
  47787. constructor(
  47788. /** button element */
  47789. element: HTMLElement,
  47790. /** XR initialization options for the button */
  47791. sessionMode: XRSessionMode,
  47792. /** Reference space type */
  47793. referenceSpaceType: XRReferenceSpaceType);
  47794. /**
  47795. * Extendable function which can be used to update the button's visuals when the state changes
  47796. * @param activeButton the current active button in the UI
  47797. */
  47798. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47799. }
  47800. /**
  47801. * Options to create the webXR UI
  47802. */
  47803. export class WebXREnterExitUIOptions {
  47804. /**
  47805. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47806. */
  47807. customButtons?: Array<WebXREnterExitUIButton>;
  47808. /**
  47809. * A reference space type to use when creating the default button.
  47810. * Default is local-floor
  47811. */
  47812. referenceSpaceType?: XRReferenceSpaceType;
  47813. /**
  47814. * Context to enter xr with
  47815. */
  47816. renderTarget?: Nullable<WebXRRenderTarget>;
  47817. /**
  47818. * A session mode to use when creating the default button.
  47819. * Default is immersive-vr
  47820. */
  47821. sessionMode?: XRSessionMode;
  47822. /**
  47823. * A list of optional features to init the session with
  47824. */
  47825. optionalFeatures?: string[];
  47826. }
  47827. /**
  47828. * UI to allow the user to enter/exit XR mode
  47829. */
  47830. export class WebXREnterExitUI implements IDisposable {
  47831. private scene;
  47832. /** version of the options passed to this UI */
  47833. options: WebXREnterExitUIOptions;
  47834. private _activeButton;
  47835. private _buttons;
  47836. private _overlay;
  47837. /**
  47838. * Fired every time the active button is changed.
  47839. *
  47840. * When xr is entered via a button that launches xr that button will be the callback parameter
  47841. *
  47842. * When exiting xr the callback parameter will be null)
  47843. */
  47844. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47845. /**
  47846. *
  47847. * @param scene babylon scene object to use
  47848. * @param options (read-only) version of the options passed to this UI
  47849. */
  47850. private constructor();
  47851. /**
  47852. * Creates UI to allow the user to enter/exit XR mode
  47853. * @param scene the scene to add the ui to
  47854. * @param helper the xr experience helper to enter/exit xr with
  47855. * @param options options to configure the UI
  47856. * @returns the created ui
  47857. */
  47858. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47859. /**
  47860. * Disposes of the XR UI component
  47861. */
  47862. dispose(): void;
  47863. private _updateButtons;
  47864. }
  47865. }
  47866. declare module BABYLON {
  47867. /**
  47868. * Class containing static functions to help procedurally build meshes
  47869. */
  47870. export class LinesBuilder {
  47871. /**
  47872. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47873. * * 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
  47874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47875. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47876. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47877. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47878. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47879. * * 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
  47880. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47883. * @param name defines the name of the new line system
  47884. * @param options defines the options used to create the line system
  47885. * @param scene defines the hosting scene
  47886. * @returns a new line system mesh
  47887. */
  47888. static CreateLineSystem(name: string, options: {
  47889. lines: Vector3[][];
  47890. updatable?: boolean;
  47891. instance?: Nullable<LinesMesh>;
  47892. colors?: Nullable<Color4[][]>;
  47893. useVertexAlpha?: boolean;
  47894. }, scene: Nullable<Scene>): LinesMesh;
  47895. /**
  47896. * Creates a line mesh
  47897. * 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
  47898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47899. * * The parameter `points` is an array successive Vector3
  47900. * * 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
  47901. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47902. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47903. * * When updating an instance, remember that only point positions can change, not the number of points
  47904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47906. * @param name defines the name of the new line system
  47907. * @param options defines the options used to create the line system
  47908. * @param scene defines the hosting scene
  47909. * @returns a new line mesh
  47910. */
  47911. static CreateLines(name: string, options: {
  47912. points: Vector3[];
  47913. updatable?: boolean;
  47914. instance?: Nullable<LinesMesh>;
  47915. colors?: Color4[];
  47916. useVertexAlpha?: boolean;
  47917. }, scene?: Nullable<Scene>): LinesMesh;
  47918. /**
  47919. * Creates a dashed line mesh
  47920. * * 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
  47921. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47922. * * The parameter `points` is an array successive Vector3
  47923. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47924. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47925. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47926. * * 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
  47927. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47928. * * When updating an instance, remember that only point positions can change, not the number of points
  47929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47930. * @param name defines the name of the mesh
  47931. * @param options defines the options used to create the mesh
  47932. * @param scene defines the hosting scene
  47933. * @returns the dashed line mesh
  47934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47935. */
  47936. static CreateDashedLines(name: string, options: {
  47937. points: Vector3[];
  47938. dashSize?: number;
  47939. gapSize?: number;
  47940. dashNb?: number;
  47941. updatable?: boolean;
  47942. instance?: LinesMesh;
  47943. useVertexAlpha?: boolean;
  47944. }, scene?: Nullable<Scene>): LinesMesh;
  47945. }
  47946. }
  47947. declare module BABYLON {
  47948. /**
  47949. * Construction options for a timer
  47950. */
  47951. export interface ITimerOptions<T> {
  47952. /**
  47953. * Time-to-end
  47954. */
  47955. timeout: number;
  47956. /**
  47957. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  47958. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  47959. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  47960. */
  47961. contextObservable: Observable<T>;
  47962. /**
  47963. * Optional parameters when adding an observer to the observable
  47964. */
  47965. observableParameters?: {
  47966. mask?: number;
  47967. insertFirst?: boolean;
  47968. scope?: any;
  47969. };
  47970. /**
  47971. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  47972. */
  47973. breakCondition?: (data?: ITimerData<T>) => boolean;
  47974. /**
  47975. * Will be triggered when the time condition has met
  47976. */
  47977. onEnded?: (data: ITimerData<any>) => void;
  47978. /**
  47979. * Will be triggered when the break condition has met (prematurely ended)
  47980. */
  47981. onAborted?: (data: ITimerData<any>) => void;
  47982. /**
  47983. * Optional function to execute on each tick (or count)
  47984. */
  47985. onTick?: (data: ITimerData<any>) => void;
  47986. }
  47987. /**
  47988. * An interface defining the data sent by the timer
  47989. */
  47990. export interface ITimerData<T> {
  47991. /**
  47992. * When did it start
  47993. */
  47994. startTime: number;
  47995. /**
  47996. * Time now
  47997. */
  47998. currentTime: number;
  47999. /**
  48000. * Time passed since started
  48001. */
  48002. deltaTime: number;
  48003. /**
  48004. * How much is completed, in [0.0...1.0].
  48005. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48006. */
  48007. completeRate: number;
  48008. /**
  48009. * What the registered observable sent in the last count
  48010. */
  48011. payload: T;
  48012. }
  48013. /**
  48014. * The current state of the timer
  48015. */
  48016. export enum TimerState {
  48017. /**
  48018. * Timer initialized, not yet started
  48019. */
  48020. INIT = 0,
  48021. /**
  48022. * Timer started and counting
  48023. */
  48024. STARTED = 1,
  48025. /**
  48026. * Timer ended (whether aborted or time reached)
  48027. */
  48028. ENDED = 2
  48029. }
  48030. /**
  48031. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48032. *
  48033. * @param options options with which to initialize this timer
  48034. */
  48035. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48036. /**
  48037. * An advanced implementation of a timer class
  48038. */
  48039. export class AdvancedTimer<T = any> implements IDisposable {
  48040. /**
  48041. * Will notify each time the timer calculates the remaining time
  48042. */
  48043. onEachCountObservable: Observable<ITimerData<T>>;
  48044. /**
  48045. * Will trigger when the timer was aborted due to the break condition
  48046. */
  48047. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48048. /**
  48049. * Will trigger when the timer ended successfully
  48050. */
  48051. onTimerEndedObservable: Observable<ITimerData<T>>;
  48052. /**
  48053. * Will trigger when the timer state has changed
  48054. */
  48055. onStateChangedObservable: Observable<TimerState>;
  48056. private _observer;
  48057. private _contextObservable;
  48058. private _observableParameters;
  48059. private _startTime;
  48060. private _timer;
  48061. private _state;
  48062. private _breakCondition;
  48063. private _timeToEnd;
  48064. private _breakOnNextTick;
  48065. /**
  48066. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48067. * @param options construction options for this advanced timer
  48068. */
  48069. constructor(options: ITimerOptions<T>);
  48070. /**
  48071. * set a breaking condition for this timer. Default is to never break during count
  48072. * @param predicate the new break condition. Returns true to break, false otherwise
  48073. */
  48074. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48075. /**
  48076. * Reset ALL associated observables in this advanced timer
  48077. */
  48078. clearObservables(): void;
  48079. /**
  48080. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48081. *
  48082. * @param timeToEnd how much time to measure until timer ended
  48083. */
  48084. start(timeToEnd?: number): void;
  48085. /**
  48086. * Will force a stop on the next tick.
  48087. */
  48088. stop(): void;
  48089. /**
  48090. * Dispose this timer, clearing all resources
  48091. */
  48092. dispose(): void;
  48093. private _setState;
  48094. private _tick;
  48095. private _stop;
  48096. }
  48097. }
  48098. declare module BABYLON {
  48099. /**
  48100. * The options container for the teleportation module
  48101. */
  48102. export interface IWebXRTeleportationOptions {
  48103. /**
  48104. * if provided, this scene will be used to render meshes.
  48105. */
  48106. customUtilityLayerScene?: Scene;
  48107. /**
  48108. * Values to configure the default target mesh
  48109. */
  48110. defaultTargetMeshOptions?: {
  48111. /**
  48112. * Fill color of the teleportation area
  48113. */
  48114. teleportationFillColor?: string;
  48115. /**
  48116. * Border color for the teleportation area
  48117. */
  48118. teleportationBorderColor?: string;
  48119. /**
  48120. * Disable the mesh's animation sequence
  48121. */
  48122. disableAnimation?: boolean;
  48123. /**
  48124. * Disable lighting on the material or the ring and arrow
  48125. */
  48126. disableLighting?: boolean;
  48127. /**
  48128. * Override the default material of the torus and arrow
  48129. */
  48130. torusArrowMaterial?: Material;
  48131. };
  48132. /**
  48133. * A list of meshes to use as floor meshes.
  48134. * Meshes can be added and removed after initializing the feature using the
  48135. * addFloorMesh and removeFloorMesh functions
  48136. * If empty, rotation will still work
  48137. */
  48138. floorMeshes?: AbstractMesh[];
  48139. /**
  48140. * use this rendering group id for the meshes (optional)
  48141. */
  48142. renderingGroupId?: number;
  48143. /**
  48144. * Should teleportation move only to snap points
  48145. */
  48146. snapPointsOnly?: boolean;
  48147. /**
  48148. * An array of points to which the teleportation will snap to.
  48149. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48150. */
  48151. snapPositions?: Vector3[];
  48152. /**
  48153. * How close should the teleportation ray be in order to snap to position.
  48154. * Default to 0.8 units (meters)
  48155. */
  48156. snapToPositionRadius?: number;
  48157. /**
  48158. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48159. * If you want to support rotation, make sure your mesh has a direction indicator.
  48160. *
  48161. * When left untouched, the default mesh will be initialized.
  48162. */
  48163. teleportationTargetMesh?: AbstractMesh;
  48164. /**
  48165. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48166. */
  48167. timeToTeleport?: number;
  48168. /**
  48169. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48170. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48171. */
  48172. useMainComponentOnly?: boolean;
  48173. /**
  48174. * Should meshes created here be added to a utility layer or the main scene
  48175. */
  48176. useUtilityLayer?: boolean;
  48177. /**
  48178. * Babylon XR Input class for controller
  48179. */
  48180. xrInput: WebXRInput;
  48181. }
  48182. /**
  48183. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48184. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48185. * the input of the attached controllers.
  48186. */
  48187. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48188. private _options;
  48189. private _controllers;
  48190. private _currentTeleportationControllerId;
  48191. private _floorMeshes;
  48192. private _quadraticBezierCurve;
  48193. private _selectionFeature;
  48194. private _snapToPositions;
  48195. private _snappedToPoint;
  48196. private _teleportationRingMaterial?;
  48197. private _tmpRay;
  48198. private _tmpVector;
  48199. /**
  48200. * The module's name
  48201. */
  48202. static readonly Name: string;
  48203. /**
  48204. * The (Babylon) version of this module.
  48205. * This is an integer representing the implementation version.
  48206. * This number does not correspond to the webxr specs version
  48207. */
  48208. static readonly Version: number;
  48209. /**
  48210. * Is movement backwards enabled
  48211. */
  48212. backwardsMovementEnabled: boolean;
  48213. /**
  48214. * Distance to travel when moving backwards
  48215. */
  48216. backwardsTeleportationDistance: number;
  48217. /**
  48218. * The distance from the user to the inspection point in the direction of the controller
  48219. * A higher number will allow the user to move further
  48220. * defaults to 5 (meters, in xr units)
  48221. */
  48222. parabolicCheckRadius: number;
  48223. /**
  48224. * Should the module support parabolic ray on top of direct ray
  48225. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48226. * Very helpful when moving between floors / different heights
  48227. */
  48228. parabolicRayEnabled: boolean;
  48229. /**
  48230. * How much rotation should be applied when rotating right and left
  48231. */
  48232. rotationAngle: number;
  48233. /**
  48234. * Is rotation enabled when moving forward?
  48235. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48236. */
  48237. rotationEnabled: boolean;
  48238. /**
  48239. * constructs a new anchor system
  48240. * @param _xrSessionManager an instance of WebXRSessionManager
  48241. * @param _options configuration object for this feature
  48242. */
  48243. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48244. /**
  48245. * Get the snapPointsOnly flag
  48246. */
  48247. get snapPointsOnly(): boolean;
  48248. /**
  48249. * Sets the snapPointsOnly flag
  48250. * @param snapToPoints should teleportation be exclusively to snap points
  48251. */
  48252. set snapPointsOnly(snapToPoints: boolean);
  48253. /**
  48254. * Add a new mesh to the floor meshes array
  48255. * @param mesh the mesh to use as floor mesh
  48256. */
  48257. addFloorMesh(mesh: AbstractMesh): void;
  48258. /**
  48259. * Add a new snap-to point to fix teleportation to this position
  48260. * @param newSnapPoint The new Snap-To point
  48261. */
  48262. addSnapPoint(newSnapPoint: Vector3): void;
  48263. attach(): boolean;
  48264. detach(): boolean;
  48265. dispose(): void;
  48266. /**
  48267. * Remove a mesh from the floor meshes array
  48268. * @param mesh the mesh to remove
  48269. */
  48270. removeFloorMesh(mesh: AbstractMesh): void;
  48271. /**
  48272. * Remove a mesh from the floor meshes array using its name
  48273. * @param name the mesh name to remove
  48274. */
  48275. removeFloorMeshByName(name: string): void;
  48276. /**
  48277. * 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
  48278. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48279. * @returns was the point found and removed or not
  48280. */
  48281. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48282. /**
  48283. * This function sets a selection feature that will be disabled when
  48284. * the forward ray is shown and will be reattached when hidden.
  48285. * This is used to remove the selection rays when moving.
  48286. * @param selectionFeature the feature to disable when forward movement is enabled
  48287. */
  48288. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48289. protected _onXRFrame(_xrFrame: XRFrame): void;
  48290. private _attachController;
  48291. private _createDefaultTargetMesh;
  48292. private _detachController;
  48293. private _findClosestSnapPointWithRadius;
  48294. private _setTargetMeshPosition;
  48295. private _setTargetMeshVisibility;
  48296. private _showParabolicPath;
  48297. private _teleportForward;
  48298. }
  48299. }
  48300. declare module BABYLON {
  48301. /**
  48302. * Options for the default xr helper
  48303. */
  48304. export class WebXRDefaultExperienceOptions {
  48305. /**
  48306. * Enable or disable default UI to enter XR
  48307. */
  48308. disableDefaultUI?: boolean;
  48309. /**
  48310. * Should teleportation not initialize. defaults to false.
  48311. */
  48312. disableTeleportation?: boolean;
  48313. /**
  48314. * Floor meshes that will be used for teleport
  48315. */
  48316. floorMeshes?: Array<AbstractMesh>;
  48317. /**
  48318. * If set to true, the first frame will not be used to reset position
  48319. * The first frame is mainly used when copying transformation from the old camera
  48320. * Mainly used in AR
  48321. */
  48322. ignoreNativeCameraTransformation?: boolean;
  48323. /**
  48324. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48325. */
  48326. inputOptions?: IWebXRInputOptions;
  48327. /**
  48328. * optional configuration for the output canvas
  48329. */
  48330. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48331. /**
  48332. * optional UI options. This can be used among other to change session mode and reference space type
  48333. */
  48334. uiOptions?: WebXREnterExitUIOptions;
  48335. /**
  48336. * When loading teleportation and pointer select, use stable versions instead of latest.
  48337. */
  48338. useStablePlugins?: boolean;
  48339. /**
  48340. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48341. */
  48342. renderingGroupId?: number;
  48343. /**
  48344. * A list of optional features to init the session with
  48345. * If set to true, all features we support will be added
  48346. */
  48347. optionalFeatures?: boolean | string[];
  48348. }
  48349. /**
  48350. * Default experience which provides a similar setup to the previous webVRExperience
  48351. */
  48352. export class WebXRDefaultExperience {
  48353. /**
  48354. * Base experience
  48355. */
  48356. baseExperience: WebXRExperienceHelper;
  48357. /**
  48358. * Enables ui for entering/exiting xr
  48359. */
  48360. enterExitUI: WebXREnterExitUI;
  48361. /**
  48362. * Input experience extension
  48363. */
  48364. input: WebXRInput;
  48365. /**
  48366. * Enables laser pointer and selection
  48367. */
  48368. pointerSelection: WebXRControllerPointerSelection;
  48369. /**
  48370. * Default target xr should render to
  48371. */
  48372. renderTarget: WebXRRenderTarget;
  48373. /**
  48374. * Enables teleportation
  48375. */
  48376. teleportation: WebXRMotionControllerTeleportation;
  48377. private constructor();
  48378. /**
  48379. * Creates the default xr experience
  48380. * @param scene scene
  48381. * @param options options for basic configuration
  48382. * @returns resulting WebXRDefaultExperience
  48383. */
  48384. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48385. /**
  48386. * DIsposes of the experience helper
  48387. */
  48388. dispose(): void;
  48389. }
  48390. }
  48391. declare module BABYLON {
  48392. /**
  48393. * Options to modify the vr teleportation behavior.
  48394. */
  48395. export interface VRTeleportationOptions {
  48396. /**
  48397. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48398. */
  48399. floorMeshName?: string;
  48400. /**
  48401. * A list of meshes to be used as the teleportation floor. (default: empty)
  48402. */
  48403. floorMeshes?: Mesh[];
  48404. /**
  48405. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48406. */
  48407. teleportationMode?: number;
  48408. /**
  48409. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48410. */
  48411. teleportationTime?: number;
  48412. /**
  48413. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48414. */
  48415. teleportationSpeed?: number;
  48416. /**
  48417. * The easing function used in the animation or null for Linear. (default CircleEase)
  48418. */
  48419. easingFunction?: EasingFunction;
  48420. }
  48421. /**
  48422. * Options to modify the vr experience helper's behavior.
  48423. */
  48424. export interface VRExperienceHelperOptions extends WebVROptions {
  48425. /**
  48426. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48427. */
  48428. createDeviceOrientationCamera?: boolean;
  48429. /**
  48430. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48431. */
  48432. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48433. /**
  48434. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48435. */
  48436. laserToggle?: boolean;
  48437. /**
  48438. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48439. */
  48440. floorMeshes?: Mesh[];
  48441. /**
  48442. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48443. */
  48444. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48445. /**
  48446. * Defines if WebXR should be used instead of WebVR (if available)
  48447. */
  48448. useXR?: boolean;
  48449. }
  48450. /**
  48451. * Event containing information after VR has been entered
  48452. */
  48453. export class OnAfterEnteringVRObservableEvent {
  48454. /**
  48455. * If entering vr was successful
  48456. */
  48457. success: boolean;
  48458. }
  48459. /**
  48460. * Helps to quickly add VR support to an existing scene.
  48461. * See http://doc.babylonjs.com/how_to/webvr_helper
  48462. */
  48463. export class VRExperienceHelper {
  48464. /** Options to modify the vr experience helper's behavior. */
  48465. webVROptions: VRExperienceHelperOptions;
  48466. private _scene;
  48467. private _position;
  48468. private _btnVR;
  48469. private _btnVRDisplayed;
  48470. private _webVRsupported;
  48471. private _webVRready;
  48472. private _webVRrequesting;
  48473. private _webVRpresenting;
  48474. private _hasEnteredVR;
  48475. private _fullscreenVRpresenting;
  48476. private _inputElement;
  48477. private _webVRCamera;
  48478. private _vrDeviceOrientationCamera;
  48479. private _deviceOrientationCamera;
  48480. private _existingCamera;
  48481. private _onKeyDown;
  48482. private _onVrDisplayPresentChange;
  48483. private _onVRDisplayChanged;
  48484. private _onVRRequestPresentStart;
  48485. private _onVRRequestPresentComplete;
  48486. /**
  48487. * 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)
  48488. */
  48489. enableGazeEvenWhenNoPointerLock: boolean;
  48490. /**
  48491. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48492. */
  48493. exitVROnDoubleTap: boolean;
  48494. /**
  48495. * Observable raised right before entering VR.
  48496. */
  48497. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48498. /**
  48499. * Observable raised when entering VR has completed.
  48500. */
  48501. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48502. /**
  48503. * Observable raised when exiting VR.
  48504. */
  48505. onExitingVRObservable: Observable<VRExperienceHelper>;
  48506. /**
  48507. * Observable raised when controller mesh is loaded.
  48508. */
  48509. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48510. /** Return this.onEnteringVRObservable
  48511. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48512. */
  48513. get onEnteringVR(): Observable<VRExperienceHelper>;
  48514. /** Return this.onExitingVRObservable
  48515. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48516. */
  48517. get onExitingVR(): Observable<VRExperienceHelper>;
  48518. /** Return this.onControllerMeshLoadedObservable
  48519. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48520. */
  48521. get onControllerMeshLoaded(): Observable<WebVRController>;
  48522. private _rayLength;
  48523. private _useCustomVRButton;
  48524. private _teleportationRequested;
  48525. private _teleportActive;
  48526. private _floorMeshName;
  48527. private _floorMeshesCollection;
  48528. private _teleportationMode;
  48529. private _teleportationTime;
  48530. private _teleportationSpeed;
  48531. private _teleportationEasing;
  48532. private _rotationAllowed;
  48533. private _teleportBackwardsVector;
  48534. private _teleportationTarget;
  48535. private _isDefaultTeleportationTarget;
  48536. private _postProcessMove;
  48537. private _teleportationFillColor;
  48538. private _teleportationBorderColor;
  48539. private _rotationAngle;
  48540. private _haloCenter;
  48541. private _cameraGazer;
  48542. private _padSensibilityUp;
  48543. private _padSensibilityDown;
  48544. private _leftController;
  48545. private _rightController;
  48546. private _gazeColor;
  48547. private _laserColor;
  48548. private _pickedLaserColor;
  48549. private _pickedGazeColor;
  48550. /**
  48551. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48552. */
  48553. onNewMeshSelected: Observable<AbstractMesh>;
  48554. /**
  48555. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48556. * This observable will provide the mesh and the controller used to select the mesh
  48557. */
  48558. onMeshSelectedWithController: Observable<{
  48559. mesh: AbstractMesh;
  48560. controller: WebVRController;
  48561. }>;
  48562. /**
  48563. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48564. */
  48565. onNewMeshPicked: Observable<PickingInfo>;
  48566. private _circleEase;
  48567. /**
  48568. * Observable raised before camera teleportation
  48569. */
  48570. onBeforeCameraTeleport: Observable<Vector3>;
  48571. /**
  48572. * Observable raised after camera teleportation
  48573. */
  48574. onAfterCameraTeleport: Observable<Vector3>;
  48575. /**
  48576. * Observable raised when current selected mesh gets unselected
  48577. */
  48578. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48579. private _raySelectionPredicate;
  48580. /**
  48581. * To be optionaly changed by user to define custom ray selection
  48582. */
  48583. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48584. /**
  48585. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48586. */
  48587. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48588. /**
  48589. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48590. */
  48591. teleportationEnabled: boolean;
  48592. private _defaultHeight;
  48593. private _teleportationInitialized;
  48594. private _interactionsEnabled;
  48595. private _interactionsRequested;
  48596. private _displayGaze;
  48597. private _displayLaserPointer;
  48598. /**
  48599. * The mesh used to display where the user is going to teleport.
  48600. */
  48601. get teleportationTarget(): Mesh;
  48602. /**
  48603. * Sets the mesh to be used to display where the user is going to teleport.
  48604. */
  48605. set teleportationTarget(value: Mesh);
  48606. /**
  48607. * 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
  48608. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48609. * See http://doc.babylonjs.com/resources/baking_transformations
  48610. */
  48611. get gazeTrackerMesh(): Mesh;
  48612. set gazeTrackerMesh(value: Mesh);
  48613. /**
  48614. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48615. */
  48616. updateGazeTrackerScale: boolean;
  48617. /**
  48618. * If the gaze trackers color should be updated when selecting meshes
  48619. */
  48620. updateGazeTrackerColor: boolean;
  48621. /**
  48622. * If the controller laser color should be updated when selecting meshes
  48623. */
  48624. updateControllerLaserColor: boolean;
  48625. /**
  48626. * The gaze tracking mesh corresponding to the left controller
  48627. */
  48628. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48629. /**
  48630. * The gaze tracking mesh corresponding to the right controller
  48631. */
  48632. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48633. /**
  48634. * If the ray of the gaze should be displayed.
  48635. */
  48636. get displayGaze(): boolean;
  48637. /**
  48638. * Sets if the ray of the gaze should be displayed.
  48639. */
  48640. set displayGaze(value: boolean);
  48641. /**
  48642. * If the ray of the LaserPointer should be displayed.
  48643. */
  48644. get displayLaserPointer(): boolean;
  48645. /**
  48646. * Sets if the ray of the LaserPointer should be displayed.
  48647. */
  48648. set displayLaserPointer(value: boolean);
  48649. /**
  48650. * The deviceOrientationCamera used as the camera when not in VR.
  48651. */
  48652. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48653. /**
  48654. * Based on the current WebVR support, returns the current VR camera used.
  48655. */
  48656. get currentVRCamera(): Nullable<Camera>;
  48657. /**
  48658. * The webVRCamera which is used when in VR.
  48659. */
  48660. get webVRCamera(): WebVRFreeCamera;
  48661. /**
  48662. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48663. */
  48664. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48665. /**
  48666. * The html button that is used to trigger entering into VR.
  48667. */
  48668. get vrButton(): Nullable<HTMLButtonElement>;
  48669. private get _teleportationRequestInitiated();
  48670. /**
  48671. * Defines whether or not Pointer lock should be requested when switching to
  48672. * full screen.
  48673. */
  48674. requestPointerLockOnFullScreen: boolean;
  48675. /**
  48676. * If asking to force XR, this will be populated with the default xr experience
  48677. */
  48678. xr: WebXRDefaultExperience;
  48679. /**
  48680. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48681. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48682. */
  48683. xrTestDone: boolean;
  48684. /**
  48685. * Instantiates a VRExperienceHelper.
  48686. * Helps to quickly add VR support to an existing scene.
  48687. * @param scene The scene the VRExperienceHelper belongs to.
  48688. * @param webVROptions Options to modify the vr experience helper's behavior.
  48689. */
  48690. constructor(scene: Scene,
  48691. /** Options to modify the vr experience helper's behavior. */
  48692. webVROptions?: VRExperienceHelperOptions);
  48693. private completeVRInit;
  48694. private _onDefaultMeshLoaded;
  48695. private _onResize;
  48696. private _onFullscreenChange;
  48697. /**
  48698. * Gets a value indicating if we are currently in VR mode.
  48699. */
  48700. get isInVRMode(): boolean;
  48701. private onVrDisplayPresentChange;
  48702. private onVRDisplayChanged;
  48703. private moveButtonToBottomRight;
  48704. private displayVRButton;
  48705. private updateButtonVisibility;
  48706. private _cachedAngularSensibility;
  48707. /**
  48708. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48709. * Otherwise, will use the fullscreen API.
  48710. */
  48711. enterVR(): void;
  48712. /**
  48713. * Attempt to exit VR, or fullscreen.
  48714. */
  48715. exitVR(): void;
  48716. /**
  48717. * The position of the vr experience helper.
  48718. */
  48719. get position(): Vector3;
  48720. /**
  48721. * Sets the position of the vr experience helper.
  48722. */
  48723. set position(value: Vector3);
  48724. /**
  48725. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48726. */
  48727. enableInteractions(): void;
  48728. private get _noControllerIsActive();
  48729. private beforeRender;
  48730. private _isTeleportationFloor;
  48731. /**
  48732. * Adds a floor mesh to be used for teleportation.
  48733. * @param floorMesh the mesh to be used for teleportation.
  48734. */
  48735. addFloorMesh(floorMesh: Mesh): void;
  48736. /**
  48737. * Removes a floor mesh from being used for teleportation.
  48738. * @param floorMesh the mesh to be removed.
  48739. */
  48740. removeFloorMesh(floorMesh: Mesh): void;
  48741. /**
  48742. * Enables interactions and teleportation using the VR controllers and gaze.
  48743. * @param vrTeleportationOptions options to modify teleportation behavior.
  48744. */
  48745. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48746. private _onNewGamepadConnected;
  48747. private _tryEnableInteractionOnController;
  48748. private _onNewGamepadDisconnected;
  48749. private _enableInteractionOnController;
  48750. private _checkTeleportWithRay;
  48751. private _checkRotate;
  48752. private _checkTeleportBackwards;
  48753. private _enableTeleportationOnController;
  48754. private _createTeleportationCircles;
  48755. private _displayTeleportationTarget;
  48756. private _hideTeleportationTarget;
  48757. private _rotateCamera;
  48758. private _moveTeleportationSelectorTo;
  48759. private _workingVector;
  48760. private _workingQuaternion;
  48761. private _workingMatrix;
  48762. /**
  48763. * Time Constant Teleportation Mode
  48764. */
  48765. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48766. /**
  48767. * Speed Constant Teleportation Mode
  48768. */
  48769. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48770. /**
  48771. * Teleports the users feet to the desired location
  48772. * @param location The location where the user's feet should be placed
  48773. */
  48774. teleportCamera(location: Vector3): void;
  48775. private _convertNormalToDirectionOfRay;
  48776. private _castRayAndSelectObject;
  48777. private _notifySelectedMeshUnselected;
  48778. /**
  48779. * Permanently set new colors for the laser pointer
  48780. * @param color the new laser color
  48781. * @param pickedColor the new laser color when picked mesh detected
  48782. */
  48783. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48784. /**
  48785. * Set lighting enabled / disabled on the laser pointer of both controllers
  48786. * @param enabled should the lighting be enabled on the laser pointer
  48787. */
  48788. setLaserLightingState(enabled?: boolean): void;
  48789. /**
  48790. * Permanently set new colors for the gaze pointer
  48791. * @param color the new gaze color
  48792. * @param pickedColor the new gaze color when picked mesh detected
  48793. */
  48794. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48795. /**
  48796. * Sets the color of the laser ray from the vr controllers.
  48797. * @param color new color for the ray.
  48798. */
  48799. changeLaserColor(color: Color3): void;
  48800. /**
  48801. * Sets the color of the ray from the vr headsets gaze.
  48802. * @param color new color for the ray.
  48803. */
  48804. changeGazeColor(color: Color3): void;
  48805. /**
  48806. * Exits VR and disposes of the vr experience helper
  48807. */
  48808. dispose(): void;
  48809. /**
  48810. * Gets the name of the VRExperienceHelper class
  48811. * @returns "VRExperienceHelper"
  48812. */
  48813. getClassName(): string;
  48814. }
  48815. }
  48816. declare module BABYLON {
  48817. /**
  48818. * Contains an array of blocks representing the octree
  48819. */
  48820. export interface IOctreeContainer<T> {
  48821. /**
  48822. * Blocks within the octree
  48823. */
  48824. blocks: Array<OctreeBlock<T>>;
  48825. }
  48826. /**
  48827. * Class used to store a cell in an octree
  48828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48829. */
  48830. export class OctreeBlock<T> {
  48831. /**
  48832. * Gets the content of the current block
  48833. */
  48834. entries: T[];
  48835. /**
  48836. * Gets the list of block children
  48837. */
  48838. blocks: Array<OctreeBlock<T>>;
  48839. private _depth;
  48840. private _maxDepth;
  48841. private _capacity;
  48842. private _minPoint;
  48843. private _maxPoint;
  48844. private _boundingVectors;
  48845. private _creationFunc;
  48846. /**
  48847. * Creates a new block
  48848. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48849. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48850. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48851. * @param depth defines the current depth of this block in the octree
  48852. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48853. * @param creationFunc defines a callback to call when an element is added to the block
  48854. */
  48855. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48856. /**
  48857. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48858. */
  48859. get capacity(): number;
  48860. /**
  48861. * Gets the minimum vector (in world space) of the block's bounding box
  48862. */
  48863. get minPoint(): Vector3;
  48864. /**
  48865. * Gets the maximum vector (in world space) of the block's bounding box
  48866. */
  48867. get maxPoint(): Vector3;
  48868. /**
  48869. * Add a new element to this block
  48870. * @param entry defines the element to add
  48871. */
  48872. addEntry(entry: T): void;
  48873. /**
  48874. * Remove an element from this block
  48875. * @param entry defines the element to remove
  48876. */
  48877. removeEntry(entry: T): void;
  48878. /**
  48879. * Add an array of elements to this block
  48880. * @param entries defines the array of elements to add
  48881. */
  48882. addEntries(entries: T[]): void;
  48883. /**
  48884. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48885. * @param frustumPlanes defines the frustum planes to test
  48886. * @param selection defines the array to store current content if selection is positive
  48887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48888. */
  48889. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48890. /**
  48891. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48892. * @param sphereCenter defines the bounding sphere center
  48893. * @param sphereRadius defines the bounding sphere radius
  48894. * @param selection defines the array to store current content if selection is positive
  48895. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48896. */
  48897. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48898. /**
  48899. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48900. * @param ray defines the ray to test with
  48901. * @param selection defines the array to store current content if selection is positive
  48902. */
  48903. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48904. /**
  48905. * Subdivide the content into child blocks (this block will then be empty)
  48906. */
  48907. createInnerBlocks(): void;
  48908. /**
  48909. * @hidden
  48910. */
  48911. 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;
  48912. }
  48913. }
  48914. declare module BABYLON {
  48915. /**
  48916. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48917. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48918. */
  48919. export class Octree<T> {
  48920. /** 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.) */
  48921. maxDepth: number;
  48922. /**
  48923. * Blocks within the octree containing objects
  48924. */
  48925. blocks: Array<OctreeBlock<T>>;
  48926. /**
  48927. * Content stored in the octree
  48928. */
  48929. dynamicContent: T[];
  48930. private _maxBlockCapacity;
  48931. private _selectionContent;
  48932. private _creationFunc;
  48933. /**
  48934. * Creates a octree
  48935. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48936. * @param creationFunc function to be used to instatiate the octree
  48937. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48938. * @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.)
  48939. */
  48940. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48941. /** 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.) */
  48942. maxDepth?: number);
  48943. /**
  48944. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48945. * @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);
  48946. * @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);
  48947. * @param entries meshes to be added to the octree blocks
  48948. */
  48949. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48950. /**
  48951. * Adds a mesh to the octree
  48952. * @param entry Mesh to add to the octree
  48953. */
  48954. addMesh(entry: T): void;
  48955. /**
  48956. * Remove an element from the octree
  48957. * @param entry defines the element to remove
  48958. */
  48959. removeMesh(entry: T): void;
  48960. /**
  48961. * Selects an array of meshes within the frustum
  48962. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48963. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48964. * @returns array of meshes within the frustum
  48965. */
  48966. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48967. /**
  48968. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48969. * @param sphereCenter defines the bounding sphere center
  48970. * @param sphereRadius defines the bounding sphere radius
  48971. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48972. * @returns an array of objects that intersect the sphere
  48973. */
  48974. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48975. /**
  48976. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48977. * @param ray defines the ray to test with
  48978. * @returns array of intersected objects
  48979. */
  48980. intersectsRay(ray: Ray): SmartArray<T>;
  48981. /**
  48982. * Adds a mesh into the octree block if it intersects the block
  48983. */
  48984. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48985. /**
  48986. * Adds a submesh into the octree block if it intersects the block
  48987. */
  48988. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. interface Scene {
  48993. /**
  48994. * @hidden
  48995. * Backing Filed
  48996. */
  48997. _selectionOctree: Octree<AbstractMesh>;
  48998. /**
  48999. * Gets the octree used to boost mesh selection (picking)
  49000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49001. */
  49002. selectionOctree: Octree<AbstractMesh>;
  49003. /**
  49004. * Creates or updates the octree used to boost selection (picking)
  49005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49006. * @param maxCapacity defines the maximum capacity per leaf
  49007. * @param maxDepth defines the maximum depth of the octree
  49008. * @returns an octree of AbstractMesh
  49009. */
  49010. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49011. }
  49012. interface AbstractMesh {
  49013. /**
  49014. * @hidden
  49015. * Backing Field
  49016. */
  49017. _submeshesOctree: Octree<SubMesh>;
  49018. /**
  49019. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49020. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49021. * @param maxCapacity defines the maximum size of each block (64 by default)
  49022. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49023. * @returns the new octree
  49024. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49026. */
  49027. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49028. }
  49029. /**
  49030. * Defines the octree scene component responsible to manage any octrees
  49031. * in a given scene.
  49032. */
  49033. export class OctreeSceneComponent {
  49034. /**
  49035. * The component name help to identify the component in the list of scene components.
  49036. */
  49037. readonly name: string;
  49038. /**
  49039. * The scene the component belongs to.
  49040. */
  49041. scene: Scene;
  49042. /**
  49043. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49044. */
  49045. readonly checksIsEnabled: boolean;
  49046. /**
  49047. * Creates a new instance of the component for the given scene
  49048. * @param scene Defines the scene to register the component in
  49049. */
  49050. constructor(scene: Scene);
  49051. /**
  49052. * Registers the component in a given scene
  49053. */
  49054. register(): void;
  49055. /**
  49056. * Return the list of active meshes
  49057. * @returns the list of active meshes
  49058. */
  49059. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49060. /**
  49061. * Return the list of active sub meshes
  49062. * @param mesh The mesh to get the candidates sub meshes from
  49063. * @returns the list of active sub meshes
  49064. */
  49065. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49066. private _tempRay;
  49067. /**
  49068. * Return the list of sub meshes intersecting with a given local ray
  49069. * @param mesh defines the mesh to find the submesh for
  49070. * @param localRay defines the ray in local space
  49071. * @returns the list of intersecting sub meshes
  49072. */
  49073. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49074. /**
  49075. * Return the list of sub meshes colliding with a collider
  49076. * @param mesh defines the mesh to find the submesh for
  49077. * @param collider defines the collider to evaluate the collision against
  49078. * @returns the list of colliding sub meshes
  49079. */
  49080. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49081. /**
  49082. * Rebuilds the elements related to this component in case of
  49083. * context lost for instance.
  49084. */
  49085. rebuild(): void;
  49086. /**
  49087. * Disposes the component and the associated ressources.
  49088. */
  49089. dispose(): void;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49095. */
  49096. export class Gizmo implements IDisposable {
  49097. /** The utility layer the gizmo will be added to */
  49098. gizmoLayer: UtilityLayerRenderer;
  49099. /**
  49100. * The root mesh of the gizmo
  49101. */
  49102. _rootMesh: Mesh;
  49103. private _attachedMesh;
  49104. /**
  49105. * Ratio for the scale of the gizmo (Default: 1)
  49106. */
  49107. scaleRatio: number;
  49108. /**
  49109. * If a custom mesh has been set (Default: false)
  49110. */
  49111. protected _customMeshSet: boolean;
  49112. /**
  49113. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49114. * * When set, interactions will be enabled
  49115. */
  49116. get attachedMesh(): Nullable<AbstractMesh>;
  49117. set attachedMesh(value: Nullable<AbstractMesh>);
  49118. /**
  49119. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49120. * @param mesh The mesh to replace the default mesh of the gizmo
  49121. */
  49122. setCustomMesh(mesh: Mesh): void;
  49123. /**
  49124. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49125. */
  49126. updateGizmoRotationToMatchAttachedMesh: boolean;
  49127. /**
  49128. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49129. */
  49130. updateGizmoPositionToMatchAttachedMesh: boolean;
  49131. /**
  49132. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49133. */
  49134. updateScale: boolean;
  49135. protected _interactionsEnabled: boolean;
  49136. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49137. private _beforeRenderObserver;
  49138. private _tempVector;
  49139. /**
  49140. * Creates a gizmo
  49141. * @param gizmoLayer The utility layer the gizmo will be added to
  49142. */
  49143. constructor(
  49144. /** The utility layer the gizmo will be added to */
  49145. gizmoLayer?: UtilityLayerRenderer);
  49146. /**
  49147. * Updates the gizmo to match the attached mesh's position/rotation
  49148. */
  49149. protected _update(): void;
  49150. /**
  49151. * Disposes of the gizmo
  49152. */
  49153. dispose(): void;
  49154. }
  49155. }
  49156. declare module BABYLON {
  49157. /**
  49158. * Single plane drag gizmo
  49159. */
  49160. export class PlaneDragGizmo extends Gizmo {
  49161. /**
  49162. * Drag behavior responsible for the gizmos dragging interactions
  49163. */
  49164. dragBehavior: PointerDragBehavior;
  49165. private _pointerObserver;
  49166. /**
  49167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49168. */
  49169. snapDistance: number;
  49170. /**
  49171. * Event that fires each time the gizmo snaps to a new location.
  49172. * * snapDistance is the the change in distance
  49173. */
  49174. onSnapObservable: Observable<{
  49175. snapDistance: number;
  49176. }>;
  49177. private _plane;
  49178. private _coloredMaterial;
  49179. private _hoverMaterial;
  49180. private _isEnabled;
  49181. private _parent;
  49182. /** @hidden */
  49183. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49184. /** @hidden */
  49185. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49186. /**
  49187. * Creates a PlaneDragGizmo
  49188. * @param gizmoLayer The utility layer the gizmo will be added to
  49189. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49190. * @param color The color of the gizmo
  49191. */
  49192. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49194. /**
  49195. * If the gizmo is enabled
  49196. */
  49197. set isEnabled(value: boolean);
  49198. get isEnabled(): boolean;
  49199. /**
  49200. * Disposes of the gizmo
  49201. */
  49202. dispose(): void;
  49203. }
  49204. }
  49205. declare module BABYLON {
  49206. /**
  49207. * Gizmo that enables dragging a mesh along 3 axis
  49208. */
  49209. export class PositionGizmo extends Gizmo {
  49210. /**
  49211. * Internal gizmo used for interactions on the x axis
  49212. */
  49213. xGizmo: AxisDragGizmo;
  49214. /**
  49215. * Internal gizmo used for interactions on the y axis
  49216. */
  49217. yGizmo: AxisDragGizmo;
  49218. /**
  49219. * Internal gizmo used for interactions on the z axis
  49220. */
  49221. zGizmo: AxisDragGizmo;
  49222. /**
  49223. * Internal gizmo used for interactions on the yz plane
  49224. */
  49225. xPlaneGizmo: PlaneDragGizmo;
  49226. /**
  49227. * Internal gizmo used for interactions on the xz plane
  49228. */
  49229. yPlaneGizmo: PlaneDragGizmo;
  49230. /**
  49231. * Internal gizmo used for interactions on the xy plane
  49232. */
  49233. zPlaneGizmo: PlaneDragGizmo;
  49234. /**
  49235. * private variables
  49236. */
  49237. private _meshAttached;
  49238. private _updateGizmoRotationToMatchAttachedMesh;
  49239. private _snapDistance;
  49240. private _scaleRatio;
  49241. /** Fires an event when any of it's sub gizmos are dragged */
  49242. onDragStartObservable: Observable<unknown>;
  49243. /** Fires an event when any of it's sub gizmos are released from dragging */
  49244. onDragEndObservable: Observable<unknown>;
  49245. /**
  49246. * If set to true, planar drag is enabled
  49247. */
  49248. private _planarGizmoEnabled;
  49249. get attachedMesh(): Nullable<AbstractMesh>;
  49250. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49251. /**
  49252. * Creates a PositionGizmo
  49253. * @param gizmoLayer The utility layer the gizmo will be added to
  49254. */
  49255. constructor(gizmoLayer?: UtilityLayerRenderer);
  49256. /**
  49257. * If the planar drag gizmo is enabled
  49258. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49259. */
  49260. set planarGizmoEnabled(value: boolean);
  49261. get planarGizmoEnabled(): boolean;
  49262. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49263. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49264. /**
  49265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49266. */
  49267. set snapDistance(value: number);
  49268. get snapDistance(): number;
  49269. /**
  49270. * Ratio for the scale of the gizmo (Default: 1)
  49271. */
  49272. set scaleRatio(value: number);
  49273. get scaleRatio(): number;
  49274. /**
  49275. * Disposes of the gizmo
  49276. */
  49277. dispose(): void;
  49278. /**
  49279. * CustomMeshes are not supported by this gizmo
  49280. * @param mesh The mesh to replace the default mesh of the gizmo
  49281. */
  49282. setCustomMesh(mesh: Mesh): void;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * Single axis drag gizmo
  49288. */
  49289. export class AxisDragGizmo extends Gizmo {
  49290. /**
  49291. * Drag behavior responsible for the gizmos dragging interactions
  49292. */
  49293. dragBehavior: PointerDragBehavior;
  49294. private _pointerObserver;
  49295. /**
  49296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49297. */
  49298. snapDistance: number;
  49299. /**
  49300. * Event that fires each time the gizmo snaps to a new location.
  49301. * * snapDistance is the the change in distance
  49302. */
  49303. onSnapObservable: Observable<{
  49304. snapDistance: number;
  49305. }>;
  49306. private _isEnabled;
  49307. private _parent;
  49308. private _arrow;
  49309. private _coloredMaterial;
  49310. private _hoverMaterial;
  49311. /** @hidden */
  49312. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49313. /** @hidden */
  49314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49315. /**
  49316. * Creates an AxisDragGizmo
  49317. * @param gizmoLayer The utility layer the gizmo will be added to
  49318. * @param dragAxis The axis which the gizmo will be able to drag on
  49319. * @param color The color of the gizmo
  49320. */
  49321. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49323. /**
  49324. * If the gizmo is enabled
  49325. */
  49326. set isEnabled(value: boolean);
  49327. get isEnabled(): boolean;
  49328. /**
  49329. * Disposes of the gizmo
  49330. */
  49331. dispose(): void;
  49332. }
  49333. }
  49334. declare module BABYLON.Debug {
  49335. /**
  49336. * The Axes viewer will show 3 axes in a specific point in space
  49337. */
  49338. export class AxesViewer {
  49339. private _xAxis;
  49340. private _yAxis;
  49341. private _zAxis;
  49342. private _scaleLinesFactor;
  49343. private _instanced;
  49344. /**
  49345. * Gets the hosting scene
  49346. */
  49347. scene: Scene;
  49348. /**
  49349. * Gets or sets a number used to scale line length
  49350. */
  49351. scaleLines: number;
  49352. /** Gets the node hierarchy used to render x-axis */
  49353. get xAxis(): TransformNode;
  49354. /** Gets the node hierarchy used to render y-axis */
  49355. get yAxis(): TransformNode;
  49356. /** Gets the node hierarchy used to render z-axis */
  49357. get zAxis(): TransformNode;
  49358. /**
  49359. * Creates a new AxesViewer
  49360. * @param scene defines the hosting scene
  49361. * @param scaleLines defines a number used to scale line length (1 by default)
  49362. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49363. * @param xAxis defines the node hierarchy used to render the x-axis
  49364. * @param yAxis defines the node hierarchy used to render the y-axis
  49365. * @param zAxis defines the node hierarchy used to render the z-axis
  49366. */
  49367. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49368. /**
  49369. * Force the viewer to update
  49370. * @param position defines the position of the viewer
  49371. * @param xaxis defines the x axis of the viewer
  49372. * @param yaxis defines the y axis of the viewer
  49373. * @param zaxis defines the z axis of the viewer
  49374. */
  49375. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49376. /**
  49377. * Creates an instance of this axes viewer.
  49378. * @returns a new axes viewer with instanced meshes
  49379. */
  49380. createInstance(): AxesViewer;
  49381. /** Releases resources */
  49382. dispose(): void;
  49383. private static _SetRenderingGroupId;
  49384. }
  49385. }
  49386. declare module BABYLON.Debug {
  49387. /**
  49388. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49389. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49390. */
  49391. export class BoneAxesViewer extends AxesViewer {
  49392. /**
  49393. * Gets or sets the target mesh where to display the axes viewer
  49394. */
  49395. mesh: Nullable<Mesh>;
  49396. /**
  49397. * Gets or sets the target bone where to display the axes viewer
  49398. */
  49399. bone: Nullable<Bone>;
  49400. /** Gets current position */
  49401. pos: Vector3;
  49402. /** Gets direction of X axis */
  49403. xaxis: Vector3;
  49404. /** Gets direction of Y axis */
  49405. yaxis: Vector3;
  49406. /** Gets direction of Z axis */
  49407. zaxis: Vector3;
  49408. /**
  49409. * Creates a new BoneAxesViewer
  49410. * @param scene defines the hosting scene
  49411. * @param bone defines the target bone
  49412. * @param mesh defines the target mesh
  49413. * @param scaleLines defines a scaling factor for line length (1 by default)
  49414. */
  49415. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49416. /**
  49417. * Force the viewer to update
  49418. */
  49419. update(): void;
  49420. /** Releases resources */
  49421. dispose(): void;
  49422. }
  49423. }
  49424. declare module BABYLON {
  49425. /**
  49426. * Interface used to define scene explorer extensibility option
  49427. */
  49428. export interface IExplorerExtensibilityOption {
  49429. /**
  49430. * Define the option label
  49431. */
  49432. label: string;
  49433. /**
  49434. * Defines the action to execute on click
  49435. */
  49436. action: (entity: any) => void;
  49437. }
  49438. /**
  49439. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49440. */
  49441. export interface IExplorerExtensibilityGroup {
  49442. /**
  49443. * Defines a predicate to test if a given type mut be extended
  49444. */
  49445. predicate: (entity: any) => boolean;
  49446. /**
  49447. * Gets the list of options added to a type
  49448. */
  49449. entries: IExplorerExtensibilityOption[];
  49450. }
  49451. /**
  49452. * Interface used to define the options to use to create the Inspector
  49453. */
  49454. export interface IInspectorOptions {
  49455. /**
  49456. * Display in overlay mode (default: false)
  49457. */
  49458. overlay?: boolean;
  49459. /**
  49460. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49461. */
  49462. globalRoot?: HTMLElement;
  49463. /**
  49464. * Display the Scene explorer
  49465. */
  49466. showExplorer?: boolean;
  49467. /**
  49468. * Display the property inspector
  49469. */
  49470. showInspector?: boolean;
  49471. /**
  49472. * Display in embed mode (both panes on the right)
  49473. */
  49474. embedMode?: boolean;
  49475. /**
  49476. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49477. */
  49478. handleResize?: boolean;
  49479. /**
  49480. * Allow the panes to popup (default: true)
  49481. */
  49482. enablePopup?: boolean;
  49483. /**
  49484. * Allow the panes to be closed by users (default: true)
  49485. */
  49486. enableClose?: boolean;
  49487. /**
  49488. * Optional list of extensibility entries
  49489. */
  49490. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49491. /**
  49492. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49493. */
  49494. inspectorURL?: string;
  49495. /**
  49496. * Optional initial tab (default to DebugLayerTab.Properties)
  49497. */
  49498. initialTab?: DebugLayerTab;
  49499. }
  49500. interface Scene {
  49501. /**
  49502. * @hidden
  49503. * Backing field
  49504. */
  49505. _debugLayer: DebugLayer;
  49506. /**
  49507. * Gets the debug layer (aka Inspector) associated with the scene
  49508. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49509. */
  49510. debugLayer: DebugLayer;
  49511. }
  49512. /**
  49513. * Enum of inspector action tab
  49514. */
  49515. export enum DebugLayerTab {
  49516. /**
  49517. * Properties tag (default)
  49518. */
  49519. Properties = 0,
  49520. /**
  49521. * Debug tab
  49522. */
  49523. Debug = 1,
  49524. /**
  49525. * Statistics tab
  49526. */
  49527. Statistics = 2,
  49528. /**
  49529. * Tools tab
  49530. */
  49531. Tools = 3,
  49532. /**
  49533. * Settings tab
  49534. */
  49535. Settings = 4
  49536. }
  49537. /**
  49538. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49539. * what is happening in your scene
  49540. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49541. */
  49542. export class DebugLayer {
  49543. /**
  49544. * Define the url to get the inspector script from.
  49545. * By default it uses the babylonjs CDN.
  49546. * @ignoreNaming
  49547. */
  49548. static InspectorURL: string;
  49549. private _scene;
  49550. private BJSINSPECTOR;
  49551. private _onPropertyChangedObservable?;
  49552. /**
  49553. * Observable triggered when a property is changed through the inspector.
  49554. */
  49555. get onPropertyChangedObservable(): any;
  49556. /**
  49557. * Instantiates a new debug layer.
  49558. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49559. * what is happening in your scene
  49560. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49561. * @param scene Defines the scene to inspect
  49562. */
  49563. constructor(scene: Scene);
  49564. /** Creates the inspector window. */
  49565. private _createInspector;
  49566. /**
  49567. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49568. * @param entity defines the entity to select
  49569. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49570. */
  49571. select(entity: any, lineContainerTitles?: string | string[]): void;
  49572. /** Get the inspector from bundle or global */
  49573. private _getGlobalInspector;
  49574. /**
  49575. * Get if the inspector is visible or not.
  49576. * @returns true if visible otherwise, false
  49577. */
  49578. isVisible(): boolean;
  49579. /**
  49580. * Hide the inspector and close its window.
  49581. */
  49582. hide(): void;
  49583. /**
  49584. * Update the scene in the inspector
  49585. */
  49586. setAsActiveScene(): void;
  49587. /**
  49588. * Launch the debugLayer.
  49589. * @param config Define the configuration of the inspector
  49590. * @return a promise fulfilled when the debug layer is visible
  49591. */
  49592. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49593. }
  49594. }
  49595. declare module BABYLON {
  49596. /**
  49597. * Class containing static functions to help procedurally build meshes
  49598. */
  49599. export class BoxBuilder {
  49600. /**
  49601. * Creates a box mesh
  49602. * * The parameter `size` sets the size (float) of each box side (default 1)
  49603. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49604. * * 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)
  49605. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49607. * * 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
  49608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49609. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49610. * @param name defines the name of the mesh
  49611. * @param options defines the options used to create the mesh
  49612. * @param scene defines the hosting scene
  49613. * @returns the box mesh
  49614. */
  49615. static CreateBox(name: string, options: {
  49616. size?: number;
  49617. width?: number;
  49618. height?: number;
  49619. depth?: number;
  49620. faceUV?: Vector4[];
  49621. faceColors?: Color4[];
  49622. sideOrientation?: number;
  49623. frontUVs?: Vector4;
  49624. backUVs?: Vector4;
  49625. wrap?: boolean;
  49626. topBaseAt?: number;
  49627. bottomBaseAt?: number;
  49628. updatable?: boolean;
  49629. }, scene?: Nullable<Scene>): Mesh;
  49630. }
  49631. }
  49632. declare module BABYLON.Debug {
  49633. /**
  49634. * Used to show the physics impostor around the specific mesh
  49635. */
  49636. export class PhysicsViewer {
  49637. /** @hidden */
  49638. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49639. /** @hidden */
  49640. protected _meshes: Array<Nullable<AbstractMesh>>;
  49641. /** @hidden */
  49642. protected _scene: Nullable<Scene>;
  49643. /** @hidden */
  49644. protected _numMeshes: number;
  49645. /** @hidden */
  49646. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49647. private _renderFunction;
  49648. private _utilityLayer;
  49649. private _debugBoxMesh;
  49650. private _debugSphereMesh;
  49651. private _debugCylinderMesh;
  49652. private _debugMaterial;
  49653. private _debugMeshMeshes;
  49654. /**
  49655. * Creates a new PhysicsViewer
  49656. * @param scene defines the hosting scene
  49657. */
  49658. constructor(scene: Scene);
  49659. /** @hidden */
  49660. protected _updateDebugMeshes(): void;
  49661. /**
  49662. * Renders a specified physic impostor
  49663. * @param impostor defines the impostor to render
  49664. * @param targetMesh defines the mesh represented by the impostor
  49665. * @returns the new debug mesh used to render the impostor
  49666. */
  49667. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49668. /**
  49669. * Hides a specified physic impostor
  49670. * @param impostor defines the impostor to hide
  49671. */
  49672. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49673. private _getDebugMaterial;
  49674. private _getDebugBoxMesh;
  49675. private _getDebugSphereMesh;
  49676. private _getDebugCylinderMesh;
  49677. private _getDebugMeshMesh;
  49678. private _getDebugMesh;
  49679. /** Releases all resources */
  49680. dispose(): void;
  49681. }
  49682. }
  49683. declare module BABYLON {
  49684. /**
  49685. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49686. * in order to better appreciate the issue one might have.
  49687. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49688. */
  49689. export class RayHelper {
  49690. /**
  49691. * Defines the ray we are currently tryin to visualize.
  49692. */
  49693. ray: Nullable<Ray>;
  49694. private _renderPoints;
  49695. private _renderLine;
  49696. private _renderFunction;
  49697. private _scene;
  49698. private _updateToMeshFunction;
  49699. private _attachedToMesh;
  49700. private _meshSpaceDirection;
  49701. private _meshSpaceOrigin;
  49702. /**
  49703. * Helper function to create a colored helper in a scene in one line.
  49704. * @param ray Defines the ray we are currently tryin to visualize
  49705. * @param scene Defines the scene the ray is used in
  49706. * @param color Defines the color we want to see the ray in
  49707. * @returns The newly created ray helper.
  49708. */
  49709. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49710. /**
  49711. * Instantiate a new ray helper.
  49712. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49713. * in order to better appreciate the issue one might have.
  49714. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49715. * @param ray Defines the ray we are currently tryin to visualize
  49716. */
  49717. constructor(ray: Ray);
  49718. /**
  49719. * Shows the ray we are willing to debug.
  49720. * @param scene Defines the scene the ray needs to be rendered in
  49721. * @param color Defines the color the ray needs to be rendered in
  49722. */
  49723. show(scene: Scene, color?: Color3): void;
  49724. /**
  49725. * Hides the ray we are debugging.
  49726. */
  49727. hide(): void;
  49728. private _render;
  49729. /**
  49730. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49731. * @param mesh Defines the mesh we want the helper attached to
  49732. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49733. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49734. * @param length Defines the length of the ray
  49735. */
  49736. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49737. /**
  49738. * Detach the ray helper from the mesh it has previously been attached to.
  49739. */
  49740. detachFromMesh(): void;
  49741. private _updateToMesh;
  49742. /**
  49743. * Dispose the helper and release its associated resources.
  49744. */
  49745. dispose(): void;
  49746. }
  49747. }
  49748. declare module BABYLON.Debug {
  49749. /**
  49750. * Class used to render a debug view of a given skeleton
  49751. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49752. */
  49753. export class SkeletonViewer {
  49754. /** defines the skeleton to render */
  49755. skeleton: Skeleton;
  49756. /** defines the mesh attached to the skeleton */
  49757. mesh: AbstractMesh;
  49758. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49759. autoUpdateBonesMatrices: boolean;
  49760. /** defines the rendering group id to use with the viewer */
  49761. renderingGroupId: number;
  49762. /** Gets or sets the color used to render the skeleton */
  49763. color: Color3;
  49764. private _scene;
  49765. private _debugLines;
  49766. private _debugMesh;
  49767. private _isEnabled;
  49768. private _renderFunction;
  49769. private _utilityLayer;
  49770. /**
  49771. * Returns the mesh used to render the bones
  49772. */
  49773. get debugMesh(): Nullable<LinesMesh>;
  49774. /**
  49775. * Creates a new SkeletonViewer
  49776. * @param skeleton defines the skeleton to render
  49777. * @param mesh defines the mesh attached to the skeleton
  49778. * @param scene defines the hosting scene
  49779. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49780. * @param renderingGroupId defines the rendering group id to use with the viewer
  49781. */
  49782. constructor(
  49783. /** defines the skeleton to render */
  49784. skeleton: Skeleton,
  49785. /** defines the mesh attached to the skeleton */
  49786. mesh: AbstractMesh, scene: Scene,
  49787. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49788. autoUpdateBonesMatrices?: boolean,
  49789. /** defines the rendering group id to use with the viewer */
  49790. renderingGroupId?: number);
  49791. /** Gets or sets a boolean indicating if the viewer is enabled */
  49792. set isEnabled(value: boolean);
  49793. get isEnabled(): boolean;
  49794. private _getBonePosition;
  49795. private _getLinesForBonesWithLength;
  49796. private _getLinesForBonesNoLength;
  49797. /** Update the viewer to sync with current skeleton state */
  49798. update(): void;
  49799. /** Release associated resources */
  49800. dispose(): void;
  49801. }
  49802. }
  49803. declare module BABYLON {
  49804. /**
  49805. * Enum for Device Types
  49806. */
  49807. export enum DeviceType {
  49808. /** Generic */
  49809. Generic = 0,
  49810. /** Keyboard */
  49811. Keyboard = 1,
  49812. /** Mouse */
  49813. Mouse = 2,
  49814. /** Touch Pointers */
  49815. Touch = 3,
  49816. /** PS4 Dual Shock */
  49817. DualShock = 4,
  49818. /** Xbox */
  49819. Xbox = 5,
  49820. /** Switch Controller */
  49821. Switch = 6
  49822. }
  49823. /**
  49824. * Enum for All Pointers (Touch/Mouse)
  49825. */
  49826. export enum PointerInput {
  49827. /** Horizontal Axis */
  49828. Horizontal = 0,
  49829. /** Vertical Axis */
  49830. Vertical = 1,
  49831. /** Left Click or Touch */
  49832. LeftClick = 2,
  49833. /** Middle Click */
  49834. MiddleClick = 3,
  49835. /** Right Click */
  49836. RightClick = 4,
  49837. /** Browser Back */
  49838. BrowserBack = 5,
  49839. /** Browser Forward */
  49840. BrowserForward = 6
  49841. }
  49842. /**
  49843. * Enum for Dual Shock Gamepad
  49844. */
  49845. export enum DualShockInput {
  49846. /** Cross */
  49847. Cross = 0,
  49848. /** Circle */
  49849. Circle = 1,
  49850. /** Square */
  49851. Square = 2,
  49852. /** Triangle */
  49853. Triangle = 3,
  49854. /** L1 */
  49855. L1 = 4,
  49856. /** R1 */
  49857. R1 = 5,
  49858. /** L2 */
  49859. L2 = 6,
  49860. /** R2 */
  49861. R2 = 7,
  49862. /** Share */
  49863. Share = 8,
  49864. /** Options */
  49865. Options = 9,
  49866. /** L3 */
  49867. L3 = 10,
  49868. /** R3 */
  49869. R3 = 11,
  49870. /** DPadUp */
  49871. DPadUp = 12,
  49872. /** DPadDown */
  49873. DPadDown = 13,
  49874. /** DPadLeft */
  49875. DPadLeft = 14,
  49876. /** DRight */
  49877. DPadRight = 15,
  49878. /** Home */
  49879. Home = 16,
  49880. /** TouchPad */
  49881. TouchPad = 17,
  49882. /** LStickXAxis */
  49883. LStickXAxis = 18,
  49884. /** LStickYAxis */
  49885. LStickYAxis = 19,
  49886. /** RStickXAxis */
  49887. RStickXAxis = 20,
  49888. /** RStickYAxis */
  49889. RStickYAxis = 21
  49890. }
  49891. /**
  49892. * Enum for Xbox Gamepad
  49893. */
  49894. export enum XboxInput {
  49895. /** A */
  49896. A = 0,
  49897. /** B */
  49898. B = 1,
  49899. /** X */
  49900. X = 2,
  49901. /** Y */
  49902. Y = 3,
  49903. /** LB */
  49904. LB = 4,
  49905. /** RB */
  49906. RB = 5,
  49907. /** LT */
  49908. LT = 6,
  49909. /** RT */
  49910. RT = 7,
  49911. /** Back */
  49912. Back = 8,
  49913. /** Start */
  49914. Start = 9,
  49915. /** LS */
  49916. LS = 10,
  49917. /** RS */
  49918. RS = 11,
  49919. /** DPadUp */
  49920. DPadUp = 12,
  49921. /** DPadDown */
  49922. DPadDown = 13,
  49923. /** DPadLeft */
  49924. DPadLeft = 14,
  49925. /** DRight */
  49926. DPadRight = 15,
  49927. /** Home */
  49928. Home = 16,
  49929. /** LStickXAxis */
  49930. LStickXAxis = 17,
  49931. /** LStickYAxis */
  49932. LStickYAxis = 18,
  49933. /** RStickXAxis */
  49934. RStickXAxis = 19,
  49935. /** RStickYAxis */
  49936. RStickYAxis = 20
  49937. }
  49938. /**
  49939. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49940. */
  49941. export enum SwitchInput {
  49942. /** B */
  49943. B = 0,
  49944. /** A */
  49945. A = 1,
  49946. /** Y */
  49947. Y = 2,
  49948. /** X */
  49949. X = 3,
  49950. /** L */
  49951. L = 4,
  49952. /** R */
  49953. R = 5,
  49954. /** ZL */
  49955. ZL = 6,
  49956. /** ZR */
  49957. ZR = 7,
  49958. /** Minus */
  49959. Minus = 8,
  49960. /** Plus */
  49961. Plus = 9,
  49962. /** LS */
  49963. LS = 10,
  49964. /** RS */
  49965. RS = 11,
  49966. /** DPadUp */
  49967. DPadUp = 12,
  49968. /** DPadDown */
  49969. DPadDown = 13,
  49970. /** DPadLeft */
  49971. DPadLeft = 14,
  49972. /** DRight */
  49973. DPadRight = 15,
  49974. /** Home */
  49975. Home = 16,
  49976. /** Capture */
  49977. Capture = 17,
  49978. /** LStickXAxis */
  49979. LStickXAxis = 18,
  49980. /** LStickYAxis */
  49981. LStickYAxis = 19,
  49982. /** RStickXAxis */
  49983. RStickXAxis = 20,
  49984. /** RStickYAxis */
  49985. RStickYAxis = 21
  49986. }
  49987. }
  49988. declare module BABYLON {
  49989. /**
  49990. * This class will take all inputs from Keyboard, Pointer, and
  49991. * any Gamepads and provide a polling system that all devices
  49992. * will use. This class assumes that there will only be one
  49993. * pointer device and one keyboard.
  49994. */
  49995. export class DeviceInputSystem implements IDisposable {
  49996. /**
  49997. * Callback to be triggered when a device is connected
  49998. */
  49999. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50000. /**
  50001. * Callback to be triggered when a device is disconnected
  50002. */
  50003. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50004. /**
  50005. * Callback to be triggered when event driven input is updated
  50006. */
  50007. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50008. private _inputs;
  50009. private _gamepads;
  50010. private _keyboardActive;
  50011. private _pointerActive;
  50012. private _elementToAttachTo;
  50013. private _keyboardDownEvent;
  50014. private _keyboardUpEvent;
  50015. private _pointerMoveEvent;
  50016. private _pointerDownEvent;
  50017. private _pointerUpEvent;
  50018. private _gamepadConnectedEvent;
  50019. private _gamepadDisconnectedEvent;
  50020. private static _MAX_KEYCODES;
  50021. private static _MAX_POINTER_INPUTS;
  50022. private constructor();
  50023. /**
  50024. * Creates a new DeviceInputSystem instance
  50025. * @param engine Engine to pull input element from
  50026. * @returns The new instance
  50027. */
  50028. static Create(engine: Engine): DeviceInputSystem;
  50029. /**
  50030. * Checks for current device input value, given an id and input index
  50031. * @param deviceName Id of connected device
  50032. * @param inputIndex Index of device input
  50033. * @returns Current value of input
  50034. */
  50035. /**
  50036. * Checks for current device input value, given an id and input index
  50037. * @param deviceType Enum specifiying device type
  50038. * @param deviceSlot "Slot" or index that device is referenced in
  50039. * @param inputIndex Id of input to be checked
  50040. * @returns Current value of input
  50041. */
  50042. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50043. /**
  50044. * Dispose of all the eventlisteners
  50045. */
  50046. dispose(): void;
  50047. /**
  50048. * Add device and inputs to device array
  50049. * @param deviceType Enum specifiying device type
  50050. * @param deviceSlot "Slot" or index that device is referenced in
  50051. * @param numberOfInputs Number of input entries to create for given device
  50052. */
  50053. private _registerDevice;
  50054. /**
  50055. * Given a specific device name, remove that device from the device map
  50056. * @param deviceType Enum specifiying device type
  50057. * @param deviceSlot "Slot" or index that device is referenced in
  50058. */
  50059. private _unregisterDevice;
  50060. /**
  50061. * Handle all actions that come from keyboard interaction
  50062. */
  50063. private _handleKeyActions;
  50064. /**
  50065. * Handle all actions that come from pointer interaction
  50066. */
  50067. private _handlePointerActions;
  50068. /**
  50069. * Handle all actions that come from gamepad interaction
  50070. */
  50071. private _handleGamepadActions;
  50072. /**
  50073. * Update all non-event based devices with each frame
  50074. * @param deviceType Enum specifiying device type
  50075. * @param deviceSlot "Slot" or index that device is referenced in
  50076. * @param inputIndex Id of input to be checked
  50077. */
  50078. private _updateDevice;
  50079. /**
  50080. * Gets DeviceType from the device name
  50081. * @param deviceName Name of Device from DeviceInputSystem
  50082. * @returns DeviceType enum value
  50083. */
  50084. private _getGamepadDeviceType;
  50085. }
  50086. }
  50087. declare module BABYLON {
  50088. /**
  50089. * Type to handle enforcement of inputs
  50090. */
  50091. 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;
  50092. }
  50093. declare module BABYLON {
  50094. /**
  50095. * Class that handles all input for a specific device
  50096. */
  50097. export class DeviceSource<T extends DeviceType> {
  50098. /** Type of device */
  50099. readonly deviceType: DeviceType;
  50100. /** "Slot" or index that device is referenced in */
  50101. readonly deviceSlot: number;
  50102. /**
  50103. * Observable to handle device input changes per device
  50104. */
  50105. readonly onInputChangedObservable: Observable<{
  50106. inputIndex: DeviceInput<T>;
  50107. previousState: Nullable<number>;
  50108. currentState: Nullable<number>;
  50109. }>;
  50110. private readonly _deviceInputSystem;
  50111. /**
  50112. * Default Constructor
  50113. * @param deviceInputSystem Reference to DeviceInputSystem
  50114. * @param deviceType Type of device
  50115. * @param deviceSlot "Slot" or index that device is referenced in
  50116. */
  50117. constructor(deviceInputSystem: DeviceInputSystem,
  50118. /** Type of device */
  50119. deviceType: DeviceType,
  50120. /** "Slot" or index that device is referenced in */
  50121. deviceSlot?: number);
  50122. /**
  50123. * Get input for specific input
  50124. * @param inputIndex index of specific input on device
  50125. * @returns Input value from DeviceInputSystem
  50126. */
  50127. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50128. }
  50129. /**
  50130. * Class to keep track of devices
  50131. */
  50132. export class DeviceSourceManager implements IDisposable {
  50133. /**
  50134. * Observable to be triggered when before a device is connected
  50135. */
  50136. readonly onBeforeDeviceConnectedObservable: Observable<{
  50137. deviceType: DeviceType;
  50138. deviceSlot: number;
  50139. }>;
  50140. /**
  50141. * Observable to be triggered when before a device is disconnected
  50142. */
  50143. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50144. deviceType: DeviceType;
  50145. deviceSlot: number;
  50146. }>;
  50147. /**
  50148. * Observable to be triggered when after a device is connected
  50149. */
  50150. readonly onAfterDeviceConnectedObservable: Observable<{
  50151. deviceType: DeviceType;
  50152. deviceSlot: number;
  50153. }>;
  50154. /**
  50155. * Observable to be triggered when after a device is disconnected
  50156. */
  50157. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50158. deviceType: DeviceType;
  50159. deviceSlot: number;
  50160. }>;
  50161. private readonly _devices;
  50162. private readonly _firstDevice;
  50163. private readonly _deviceInputSystem;
  50164. /**
  50165. * Default Constructor
  50166. * @param engine engine to pull input element from
  50167. */
  50168. constructor(engine: Engine);
  50169. /**
  50170. * Gets a DeviceSource, given a type and slot
  50171. * @param deviceType Enum specifying device type
  50172. * @param deviceSlot "Slot" or index that device is referenced in
  50173. * @returns DeviceSource object
  50174. */
  50175. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50176. /**
  50177. * Gets an array of DeviceSource objects for a given device type
  50178. * @param deviceType Enum specifying device type
  50179. * @returns Array of DeviceSource objects
  50180. */
  50181. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50182. /**
  50183. * Dispose of DeviceInputSystem and other parts
  50184. */
  50185. dispose(): void;
  50186. /**
  50187. * Function to add device name to device list
  50188. * @param deviceType Enum specifying device type
  50189. * @param deviceSlot "Slot" or index that device is referenced in
  50190. */
  50191. private _addDevice;
  50192. /**
  50193. * Function to remove device name to device list
  50194. * @param deviceType Enum specifying device type
  50195. * @param deviceSlot "Slot" or index that device is referenced in
  50196. */
  50197. private _removeDevice;
  50198. /**
  50199. * Updates array storing first connected device of each type
  50200. * @param type Type of Device
  50201. */
  50202. private _updateFirstDevices;
  50203. }
  50204. }
  50205. declare module BABYLON {
  50206. /**
  50207. * Options to create the null engine
  50208. */
  50209. export class NullEngineOptions {
  50210. /**
  50211. * Render width (Default: 512)
  50212. */
  50213. renderWidth: number;
  50214. /**
  50215. * Render height (Default: 256)
  50216. */
  50217. renderHeight: number;
  50218. /**
  50219. * Texture size (Default: 512)
  50220. */
  50221. textureSize: number;
  50222. /**
  50223. * If delta time between frames should be constant
  50224. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50225. */
  50226. deterministicLockstep: boolean;
  50227. /**
  50228. * Maximum about of steps between frames (Default: 4)
  50229. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50230. */
  50231. lockstepMaxSteps: number;
  50232. }
  50233. /**
  50234. * The null engine class provides support for headless version of babylon.js.
  50235. * This can be used in server side scenario or for testing purposes
  50236. */
  50237. export class NullEngine extends Engine {
  50238. private _options;
  50239. /**
  50240. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50241. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50242. * @returns true if engine is in deterministic lock step mode
  50243. */
  50244. isDeterministicLockStep(): boolean;
  50245. /**
  50246. * Gets the max steps when engine is running in deterministic lock step
  50247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50248. * @returns the max steps
  50249. */
  50250. getLockstepMaxSteps(): number;
  50251. /**
  50252. * Gets the current hardware scaling level.
  50253. * By default the hardware scaling level is computed from the window device ratio.
  50254. * 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.
  50255. * @returns a number indicating the current hardware scaling level
  50256. */
  50257. getHardwareScalingLevel(): number;
  50258. constructor(options?: NullEngineOptions);
  50259. /**
  50260. * Creates a vertex buffer
  50261. * @param vertices the data for the vertex buffer
  50262. * @returns the new WebGL static buffer
  50263. */
  50264. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50265. /**
  50266. * Creates a new index buffer
  50267. * @param indices defines the content of the index buffer
  50268. * @param updatable defines if the index buffer must be updatable
  50269. * @returns a new webGL buffer
  50270. */
  50271. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50272. /**
  50273. * Clear the current render buffer or the current render target (if any is set up)
  50274. * @param color defines the color to use
  50275. * @param backBuffer defines if the back buffer must be cleared
  50276. * @param depth defines if the depth buffer must be cleared
  50277. * @param stencil defines if the stencil buffer must be cleared
  50278. */
  50279. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50280. /**
  50281. * Gets the current render width
  50282. * @param useScreen defines if screen size must be used (or the current render target if any)
  50283. * @returns a number defining the current render width
  50284. */
  50285. getRenderWidth(useScreen?: boolean): number;
  50286. /**
  50287. * Gets the current render height
  50288. * @param useScreen defines if screen size must be used (or the current render target if any)
  50289. * @returns a number defining the current render height
  50290. */
  50291. getRenderHeight(useScreen?: boolean): number;
  50292. /**
  50293. * Set the WebGL's viewport
  50294. * @param viewport defines the viewport element to be used
  50295. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50296. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50297. */
  50298. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50299. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50300. /**
  50301. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50302. * @param pipelineContext defines the pipeline context to use
  50303. * @param uniformsNames defines the list of uniform names
  50304. * @returns an array of webGL uniform locations
  50305. */
  50306. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50307. /**
  50308. * Gets the lsit of active attributes for a given webGL program
  50309. * @param pipelineContext defines the pipeline context to use
  50310. * @param attributesNames defines the list of attribute names to get
  50311. * @returns an array of indices indicating the offset of each attribute
  50312. */
  50313. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50314. /**
  50315. * Binds an effect to the webGL context
  50316. * @param effect defines the effect to bind
  50317. */
  50318. bindSamplers(effect: Effect): void;
  50319. /**
  50320. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50321. * @param effect defines the effect to activate
  50322. */
  50323. enableEffect(effect: Effect): void;
  50324. /**
  50325. * Set various states to the webGL context
  50326. * @param culling defines backface culling state
  50327. * @param zOffset defines the value to apply to zOffset (0 by default)
  50328. * @param force defines if states must be applied even if cache is up to date
  50329. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50330. */
  50331. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50332. /**
  50333. * Set the value of an uniform to an array of int32
  50334. * @param uniform defines the webGL uniform location where to store the value
  50335. * @param array defines the array of int32 to store
  50336. */
  50337. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50338. /**
  50339. * Set the value of an uniform to an array of int32 (stored as vec2)
  50340. * @param uniform defines the webGL uniform location where to store the value
  50341. * @param array defines the array of int32 to store
  50342. */
  50343. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50344. /**
  50345. * Set the value of an uniform to an array of int32 (stored as vec3)
  50346. * @param uniform defines the webGL uniform location where to store the value
  50347. * @param array defines the array of int32 to store
  50348. */
  50349. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50350. /**
  50351. * Set the value of an uniform to an array of int32 (stored as vec4)
  50352. * @param uniform defines the webGL uniform location where to store the value
  50353. * @param array defines the array of int32 to store
  50354. */
  50355. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50356. /**
  50357. * Set the value of an uniform to an array of float32
  50358. * @param uniform defines the webGL uniform location where to store the value
  50359. * @param array defines the array of float32 to store
  50360. */
  50361. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50362. /**
  50363. * Set the value of an uniform to an array of float32 (stored as vec2)
  50364. * @param uniform defines the webGL uniform location where to store the value
  50365. * @param array defines the array of float32 to store
  50366. */
  50367. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50368. /**
  50369. * Set the value of an uniform to an array of float32 (stored as vec3)
  50370. * @param uniform defines the webGL uniform location where to store the value
  50371. * @param array defines the array of float32 to store
  50372. */
  50373. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50374. /**
  50375. * Set the value of an uniform to an array of float32 (stored as vec4)
  50376. * @param uniform defines the webGL uniform location where to store the value
  50377. * @param array defines the array of float32 to store
  50378. */
  50379. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50380. /**
  50381. * Set the value of an uniform to an array of number
  50382. * @param uniform defines the webGL uniform location where to store the value
  50383. * @param array defines the array of number to store
  50384. */
  50385. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50386. /**
  50387. * Set the value of an uniform to an array of number (stored as vec2)
  50388. * @param uniform defines the webGL uniform location where to store the value
  50389. * @param array defines the array of number to store
  50390. */
  50391. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50392. /**
  50393. * Set the value of an uniform to an array of number (stored as vec3)
  50394. * @param uniform defines the webGL uniform location where to store the value
  50395. * @param array defines the array of number to store
  50396. */
  50397. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50398. /**
  50399. * Set the value of an uniform to an array of number (stored as vec4)
  50400. * @param uniform defines the webGL uniform location where to store the value
  50401. * @param array defines the array of number to store
  50402. */
  50403. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50404. /**
  50405. * Set the value of an uniform to an array of float32 (stored as matrices)
  50406. * @param uniform defines the webGL uniform location where to store the value
  50407. * @param matrices defines the array of float32 to store
  50408. */
  50409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50410. /**
  50411. * Set the value of an uniform to a matrix (3x3)
  50412. * @param uniform defines the webGL uniform location where to store the value
  50413. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50414. */
  50415. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50416. /**
  50417. * Set the value of an uniform to a matrix (2x2)
  50418. * @param uniform defines the webGL uniform location where to store the value
  50419. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50420. */
  50421. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50422. /**
  50423. * Set the value of an uniform to a number (float)
  50424. * @param uniform defines the webGL uniform location where to store the value
  50425. * @param value defines the float number to store
  50426. */
  50427. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50428. /**
  50429. * Set the value of an uniform to a vec2
  50430. * @param uniform defines the webGL uniform location where to store the value
  50431. * @param x defines the 1st component of the value
  50432. * @param y defines the 2nd component of the value
  50433. */
  50434. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50435. /**
  50436. * Set the value of an uniform to a vec3
  50437. * @param uniform defines the webGL uniform location where to store the value
  50438. * @param x defines the 1st component of the value
  50439. * @param y defines the 2nd component of the value
  50440. * @param z defines the 3rd component of the value
  50441. */
  50442. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50443. /**
  50444. * Set the value of an uniform to a boolean
  50445. * @param uniform defines the webGL uniform location where to store the value
  50446. * @param bool defines the boolean to store
  50447. */
  50448. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50449. /**
  50450. * Set the value of an uniform to a vec4
  50451. * @param uniform defines the webGL uniform location where to store the value
  50452. * @param x defines the 1st component of the value
  50453. * @param y defines the 2nd component of the value
  50454. * @param z defines the 3rd component of the value
  50455. * @param w defines the 4th component of the value
  50456. */
  50457. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50458. /**
  50459. * Sets the current alpha mode
  50460. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50461. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50462. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50463. */
  50464. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50465. /**
  50466. * Bind webGl buffers directly to the webGL context
  50467. * @param vertexBuffers defines the vertex buffer to bind
  50468. * @param indexBuffer defines the index buffer to bind
  50469. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50470. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50471. * @param effect defines the effect associated with the vertex buffer
  50472. */
  50473. bindBuffers(vertexBuffers: {
  50474. [key: string]: VertexBuffer;
  50475. }, indexBuffer: DataBuffer, effect: Effect): void;
  50476. /**
  50477. * Force the entire cache to be cleared
  50478. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50479. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50480. */
  50481. wipeCaches(bruteForce?: boolean): void;
  50482. /**
  50483. * Send a draw order
  50484. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50485. * @param indexStart defines the starting index
  50486. * @param indexCount defines the number of index to draw
  50487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50488. */
  50489. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50490. /**
  50491. * Draw a list of indexed primitives
  50492. * @param fillMode defines the primitive to use
  50493. * @param indexStart defines the starting index
  50494. * @param indexCount defines the number of index to draw
  50495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50496. */
  50497. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50498. /**
  50499. * Draw a list of unindexed primitives
  50500. * @param fillMode defines the primitive to use
  50501. * @param verticesStart defines the index of first vertex to draw
  50502. * @param verticesCount defines the count of vertices to draw
  50503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50504. */
  50505. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50506. /** @hidden */
  50507. _createTexture(): WebGLTexture;
  50508. /** @hidden */
  50509. _releaseTexture(texture: InternalTexture): void;
  50510. /**
  50511. * Usually called from Texture.ts.
  50512. * Passed information to create a WebGLTexture
  50513. * @param urlArg defines a value which contains one of the following:
  50514. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50515. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50516. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50518. * @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)
  50519. * @param scene needed for loading to the correct scene
  50520. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50521. * @param onLoad optional callback to be called upon successful completion
  50522. * @param onError optional callback to be called upon failure
  50523. * @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
  50524. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50525. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50526. * @param forcedExtension defines the extension to use to pick the right loader
  50527. * @param mimeType defines an optional mime type
  50528. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50529. */
  50530. 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;
  50531. /**
  50532. * Creates a new render target texture
  50533. * @param size defines the size of the texture
  50534. * @param options defines the options used to create the texture
  50535. * @returns a new render target texture stored in an InternalTexture
  50536. */
  50537. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50538. /**
  50539. * Update the sampling mode of a given texture
  50540. * @param samplingMode defines the required sampling mode
  50541. * @param texture defines the texture to update
  50542. */
  50543. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50544. /**
  50545. * Binds the frame buffer to the specified texture.
  50546. * @param texture The texture to render to or null for the default canvas
  50547. * @param faceIndex The face of the texture to render to in case of cube texture
  50548. * @param requiredWidth The width of the target to render to
  50549. * @param requiredHeight The height of the target to render to
  50550. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50551. * @param lodLevel defines le lod level to bind to the frame buffer
  50552. */
  50553. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50554. /**
  50555. * Unbind the current render target texture from the webGL context
  50556. * @param texture defines the render target texture to unbind
  50557. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50558. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50559. */
  50560. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50561. /**
  50562. * Creates a dynamic vertex buffer
  50563. * @param vertices the data for the dynamic vertex buffer
  50564. * @returns the new WebGL dynamic buffer
  50565. */
  50566. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50567. /**
  50568. * Update the content of a dynamic texture
  50569. * @param texture defines the texture to update
  50570. * @param canvas defines the canvas containing the source
  50571. * @param invertY defines if data must be stored with Y axis inverted
  50572. * @param premulAlpha defines if alpha is stored as premultiplied
  50573. * @param format defines the format of the data
  50574. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50575. */
  50576. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50577. /**
  50578. * Gets a boolean indicating if all created effects are ready
  50579. * @returns true if all effects are ready
  50580. */
  50581. areAllEffectsReady(): boolean;
  50582. /**
  50583. * @hidden
  50584. * Get the current error code of the webGL context
  50585. * @returns the error code
  50586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50587. */
  50588. getError(): number;
  50589. /** @hidden */
  50590. _getUnpackAlignement(): number;
  50591. /** @hidden */
  50592. _unpackFlipY(value: boolean): void;
  50593. /**
  50594. * Update a dynamic index buffer
  50595. * @param indexBuffer defines the target index buffer
  50596. * @param indices defines the data to update
  50597. * @param offset defines the offset in the target index buffer where update should start
  50598. */
  50599. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50600. /**
  50601. * Updates a dynamic vertex buffer.
  50602. * @param vertexBuffer the vertex buffer to update
  50603. * @param vertices the data used to update the vertex buffer
  50604. * @param byteOffset the byte offset of the data (optional)
  50605. * @param byteLength the byte length of the data (optional)
  50606. */
  50607. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50608. /** @hidden */
  50609. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50610. /** @hidden */
  50611. _bindTexture(channel: number, texture: InternalTexture): void;
  50612. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50613. /**
  50614. * 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
  50615. */
  50616. releaseEffects(): void;
  50617. displayLoadingUI(): void;
  50618. hideLoadingUI(): void;
  50619. /** @hidden */
  50620. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50621. /** @hidden */
  50622. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50623. /** @hidden */
  50624. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50625. /** @hidden */
  50626. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50627. }
  50628. }
  50629. declare module BABYLON {
  50630. /**
  50631. * @hidden
  50632. **/
  50633. export class _TimeToken {
  50634. _startTimeQuery: Nullable<WebGLQuery>;
  50635. _endTimeQuery: Nullable<WebGLQuery>;
  50636. _timeElapsedQuery: Nullable<WebGLQuery>;
  50637. _timeElapsedQueryEnded: boolean;
  50638. }
  50639. }
  50640. declare module BABYLON {
  50641. /** @hidden */
  50642. export class _OcclusionDataStorage {
  50643. /** @hidden */
  50644. occlusionInternalRetryCounter: number;
  50645. /** @hidden */
  50646. isOcclusionQueryInProgress: boolean;
  50647. /** @hidden */
  50648. isOccluded: boolean;
  50649. /** @hidden */
  50650. occlusionRetryCount: number;
  50651. /** @hidden */
  50652. occlusionType: number;
  50653. /** @hidden */
  50654. occlusionQueryAlgorithmType: number;
  50655. }
  50656. interface Engine {
  50657. /**
  50658. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50659. * @return the new query
  50660. */
  50661. createQuery(): WebGLQuery;
  50662. /**
  50663. * Delete and release a webGL query
  50664. * @param query defines the query to delete
  50665. * @return the current engine
  50666. */
  50667. deleteQuery(query: WebGLQuery): Engine;
  50668. /**
  50669. * Check if a given query has resolved and got its value
  50670. * @param query defines the query to check
  50671. * @returns true if the query got its value
  50672. */
  50673. isQueryResultAvailable(query: WebGLQuery): boolean;
  50674. /**
  50675. * Gets the value of a given query
  50676. * @param query defines the query to check
  50677. * @returns the value of the query
  50678. */
  50679. getQueryResult(query: WebGLQuery): number;
  50680. /**
  50681. * Initiates an occlusion query
  50682. * @param algorithmType defines the algorithm to use
  50683. * @param query defines the query to use
  50684. * @returns the current engine
  50685. * @see http://doc.babylonjs.com/features/occlusionquery
  50686. */
  50687. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50688. /**
  50689. * Ends an occlusion query
  50690. * @see http://doc.babylonjs.com/features/occlusionquery
  50691. * @param algorithmType defines the algorithm to use
  50692. * @returns the current engine
  50693. */
  50694. endOcclusionQuery(algorithmType: number): Engine;
  50695. /**
  50696. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50697. * Please note that only one query can be issued at a time
  50698. * @returns a time token used to track the time span
  50699. */
  50700. startTimeQuery(): Nullable<_TimeToken>;
  50701. /**
  50702. * Ends a time query
  50703. * @param token defines the token used to measure the time span
  50704. * @returns the time spent (in ns)
  50705. */
  50706. endTimeQuery(token: _TimeToken): int;
  50707. /** @hidden */
  50708. _currentNonTimestampToken: Nullable<_TimeToken>;
  50709. /** @hidden */
  50710. _createTimeQuery(): WebGLQuery;
  50711. /** @hidden */
  50712. _deleteTimeQuery(query: WebGLQuery): void;
  50713. /** @hidden */
  50714. _getGlAlgorithmType(algorithmType: number): number;
  50715. /** @hidden */
  50716. _getTimeQueryResult(query: WebGLQuery): any;
  50717. /** @hidden */
  50718. _getTimeQueryAvailability(query: WebGLQuery): any;
  50719. }
  50720. interface AbstractMesh {
  50721. /**
  50722. * Backing filed
  50723. * @hidden
  50724. */
  50725. __occlusionDataStorage: _OcclusionDataStorage;
  50726. /**
  50727. * Access property
  50728. * @hidden
  50729. */
  50730. _occlusionDataStorage: _OcclusionDataStorage;
  50731. /**
  50732. * 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.
  50733. * The default value is -1 which means don't break the query and wait till the result
  50734. * @see http://doc.babylonjs.com/features/occlusionquery
  50735. */
  50736. occlusionRetryCount: number;
  50737. /**
  50738. * 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:
  50739. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50740. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50741. * * 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.
  50742. * @see http://doc.babylonjs.com/features/occlusionquery
  50743. */
  50744. occlusionType: number;
  50745. /**
  50746. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50747. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50748. * * 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.
  50749. * @see http://doc.babylonjs.com/features/occlusionquery
  50750. */
  50751. occlusionQueryAlgorithmType: number;
  50752. /**
  50753. * 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
  50754. * @see http://doc.babylonjs.com/features/occlusionquery
  50755. */
  50756. isOccluded: boolean;
  50757. /**
  50758. * Flag to check the progress status of the query
  50759. * @see http://doc.babylonjs.com/features/occlusionquery
  50760. */
  50761. isOcclusionQueryInProgress: boolean;
  50762. }
  50763. }
  50764. declare module BABYLON {
  50765. /** @hidden */
  50766. export var _forceTransformFeedbackToBundle: boolean;
  50767. interface Engine {
  50768. /**
  50769. * Creates a webGL transform feedback object
  50770. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50771. * @returns the webGL transform feedback object
  50772. */
  50773. createTransformFeedback(): WebGLTransformFeedback;
  50774. /**
  50775. * Delete a webGL transform feedback object
  50776. * @param value defines the webGL transform feedback object to delete
  50777. */
  50778. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50779. /**
  50780. * Bind a webGL transform feedback object to the webgl context
  50781. * @param value defines the webGL transform feedback object to bind
  50782. */
  50783. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50784. /**
  50785. * Begins a transform feedback operation
  50786. * @param usePoints defines if points or triangles must be used
  50787. */
  50788. beginTransformFeedback(usePoints: boolean): void;
  50789. /**
  50790. * Ends a transform feedback operation
  50791. */
  50792. endTransformFeedback(): void;
  50793. /**
  50794. * Specify the varyings to use with transform feedback
  50795. * @param program defines the associated webGL program
  50796. * @param value defines the list of strings representing the varying names
  50797. */
  50798. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50799. /**
  50800. * Bind a webGL buffer for a transform feedback operation
  50801. * @param value defines the webGL buffer to bind
  50802. */
  50803. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50804. }
  50805. }
  50806. declare module BABYLON {
  50807. /**
  50808. * Creation options of the multi render target texture.
  50809. */
  50810. export interface IMultiRenderTargetOptions {
  50811. /**
  50812. * Define if the texture needs to create mip maps after render.
  50813. */
  50814. generateMipMaps?: boolean;
  50815. /**
  50816. * Define the types of all the draw buffers we want to create
  50817. */
  50818. types?: number[];
  50819. /**
  50820. * Define the sampling modes of all the draw buffers we want to create
  50821. */
  50822. samplingModes?: number[];
  50823. /**
  50824. * Define if a depth buffer is required
  50825. */
  50826. generateDepthBuffer?: boolean;
  50827. /**
  50828. * Define if a stencil buffer is required
  50829. */
  50830. generateStencilBuffer?: boolean;
  50831. /**
  50832. * Define if a depth texture is required instead of a depth buffer
  50833. */
  50834. generateDepthTexture?: boolean;
  50835. /**
  50836. * Define the number of desired draw buffers
  50837. */
  50838. textureCount?: number;
  50839. /**
  50840. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50841. */
  50842. doNotChangeAspectRatio?: boolean;
  50843. /**
  50844. * Define the default type of the buffers we are creating
  50845. */
  50846. defaultType?: number;
  50847. }
  50848. /**
  50849. * A multi render target, like a render target provides the ability to render to a texture.
  50850. * Unlike the render target, it can render to several draw buffers in one draw.
  50851. * This is specially interesting in deferred rendering or for any effects requiring more than
  50852. * just one color from a single pass.
  50853. */
  50854. export class MultiRenderTarget extends RenderTargetTexture {
  50855. private _internalTextures;
  50856. private _textures;
  50857. private _multiRenderTargetOptions;
  50858. /**
  50859. * Get if draw buffers are currently supported by the used hardware and browser.
  50860. */
  50861. get isSupported(): boolean;
  50862. /**
  50863. * Get the list of textures generated by the multi render target.
  50864. */
  50865. get textures(): Texture[];
  50866. /**
  50867. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50868. */
  50869. get depthTexture(): Texture;
  50870. /**
  50871. * Set the wrapping mode on U of all the textures we are rendering to.
  50872. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50873. */
  50874. set wrapU(wrap: number);
  50875. /**
  50876. * Set the wrapping mode on V of all the textures we are rendering to.
  50877. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50878. */
  50879. set wrapV(wrap: number);
  50880. /**
  50881. * Instantiate a new multi render target texture.
  50882. * A multi render target, like a render target provides the ability to render to a texture.
  50883. * Unlike the render target, it can render to several draw buffers in one draw.
  50884. * This is specially interesting in deferred rendering or for any effects requiring more than
  50885. * just one color from a single pass.
  50886. * @param name Define the name of the texture
  50887. * @param size Define the size of the buffers to render to
  50888. * @param count Define the number of target we are rendering into
  50889. * @param scene Define the scene the texture belongs to
  50890. * @param options Define the options used to create the multi render target
  50891. */
  50892. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50893. /** @hidden */
  50894. _rebuild(): void;
  50895. private _createInternalTextures;
  50896. private _createTextures;
  50897. /**
  50898. * Define the number of samples used if MSAA is enabled.
  50899. */
  50900. get samples(): number;
  50901. set samples(value: number);
  50902. /**
  50903. * Resize all the textures in the multi render target.
  50904. * Be carrefull as it will recreate all the data in the new texture.
  50905. * @param size Define the new size
  50906. */
  50907. resize(size: any): void;
  50908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50909. /**
  50910. * Dispose the render targets and their associated resources
  50911. */
  50912. dispose(): void;
  50913. /**
  50914. * Release all the underlying texture used as draw buffers.
  50915. */
  50916. releaseInternalTextures(): void;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. interface ThinEngine {
  50921. /**
  50922. * Unbind a list of render target textures from the webGL context
  50923. * This is used only when drawBuffer extension or webGL2 are active
  50924. * @param textures defines the render target textures to unbind
  50925. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50926. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50927. */
  50928. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50929. /**
  50930. * Create a multi render target texture
  50931. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50932. * @param size defines the size of the texture
  50933. * @param options defines the creation options
  50934. * @returns the cube texture as an InternalTexture
  50935. */
  50936. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50937. /**
  50938. * Update the sample count for a given multiple render target texture
  50939. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50940. * @param textures defines the textures to update
  50941. * @param samples defines the sample count to set
  50942. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50943. */
  50944. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50945. }
  50946. }
  50947. declare module BABYLON {
  50948. /**
  50949. * Class used to define an additional view for the engine
  50950. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50951. */
  50952. export class EngineView {
  50953. /** Defines the canvas where to render the view */
  50954. target: HTMLCanvasElement;
  50955. /** Defines an optional camera used to render the view (will use active camera else) */
  50956. camera?: Camera;
  50957. }
  50958. interface Engine {
  50959. /**
  50960. * Gets or sets the HTML element to use for attaching events
  50961. */
  50962. inputElement: Nullable<HTMLElement>;
  50963. /**
  50964. * Gets the current engine view
  50965. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50966. */
  50967. activeView: Nullable<EngineView>;
  50968. /** Gets or sets the list of views */
  50969. views: EngineView[];
  50970. /**
  50971. * Register a new child canvas
  50972. * @param canvas defines the canvas to register
  50973. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50974. * @returns the associated view
  50975. */
  50976. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50977. /**
  50978. * Remove a registered child canvas
  50979. * @param canvas defines the canvas to remove
  50980. * @returns the current engine
  50981. */
  50982. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50983. }
  50984. }
  50985. declare module BABYLON {
  50986. interface Engine {
  50987. /** @hidden */
  50988. _excludedCompressedTextures: string[];
  50989. /** @hidden */
  50990. _textureFormatInUse: string;
  50991. /**
  50992. * Gets the list of texture formats supported
  50993. */
  50994. readonly texturesSupported: Array<string>;
  50995. /**
  50996. * Gets the texture format in use
  50997. */
  50998. readonly textureFormatInUse: Nullable<string>;
  50999. /**
  51000. * Set the compressed texture extensions or file names to skip.
  51001. *
  51002. * @param skippedFiles defines the list of those texture files you want to skip
  51003. * Example: [".dds", ".env", "myfile.png"]
  51004. */
  51005. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51006. /**
  51007. * Set the compressed texture format to use, based on the formats you have, and the formats
  51008. * supported by the hardware / browser.
  51009. *
  51010. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51011. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51012. * to API arguments needed to compressed textures. This puts the burden on the container
  51013. * generator to house the arcane code for determining these for current & future formats.
  51014. *
  51015. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51016. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51017. *
  51018. * Note: The result of this call is not taken into account when a texture is base64.
  51019. *
  51020. * @param formatsAvailable defines the list of those format families you have created
  51021. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51022. *
  51023. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51024. * @returns The extension selected.
  51025. */
  51026. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51027. }
  51028. }
  51029. declare module BABYLON {
  51030. /**
  51031. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51032. */
  51033. export interface CubeMapInfo {
  51034. /**
  51035. * The pixel array for the front face.
  51036. * This is stored in format, left to right, up to down format.
  51037. */
  51038. front: Nullable<ArrayBufferView>;
  51039. /**
  51040. * The pixel array for the back face.
  51041. * This is stored in format, left to right, up to down format.
  51042. */
  51043. back: Nullable<ArrayBufferView>;
  51044. /**
  51045. * The pixel array for the left face.
  51046. * This is stored in format, left to right, up to down format.
  51047. */
  51048. left: Nullable<ArrayBufferView>;
  51049. /**
  51050. * The pixel array for the right face.
  51051. * This is stored in format, left to right, up to down format.
  51052. */
  51053. right: Nullable<ArrayBufferView>;
  51054. /**
  51055. * The pixel array for the up face.
  51056. * This is stored in format, left to right, up to down format.
  51057. */
  51058. up: Nullable<ArrayBufferView>;
  51059. /**
  51060. * The pixel array for the down face.
  51061. * This is stored in format, left to right, up to down format.
  51062. */
  51063. down: Nullable<ArrayBufferView>;
  51064. /**
  51065. * The size of the cubemap stored.
  51066. *
  51067. * Each faces will be size * size pixels.
  51068. */
  51069. size: number;
  51070. /**
  51071. * The format of the texture.
  51072. *
  51073. * RGBA, RGB.
  51074. */
  51075. format: number;
  51076. /**
  51077. * The type of the texture data.
  51078. *
  51079. * UNSIGNED_INT, FLOAT.
  51080. */
  51081. type: number;
  51082. /**
  51083. * Specifies whether the texture is in gamma space.
  51084. */
  51085. gammaSpace: boolean;
  51086. }
  51087. /**
  51088. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51089. */
  51090. export class PanoramaToCubeMapTools {
  51091. private static FACE_LEFT;
  51092. private static FACE_RIGHT;
  51093. private static FACE_FRONT;
  51094. private static FACE_BACK;
  51095. private static FACE_DOWN;
  51096. private static FACE_UP;
  51097. /**
  51098. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51099. *
  51100. * @param float32Array The source data.
  51101. * @param inputWidth The width of the input panorama.
  51102. * @param inputHeight The height of the input panorama.
  51103. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51104. * @return The cubemap data
  51105. */
  51106. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51107. private static CreateCubemapTexture;
  51108. private static CalcProjectionSpherical;
  51109. }
  51110. }
  51111. declare module BABYLON {
  51112. /**
  51113. * Helper class dealing with the extraction of spherical polynomial dataArray
  51114. * from a cube map.
  51115. */
  51116. export class CubeMapToSphericalPolynomialTools {
  51117. private static FileFaces;
  51118. /**
  51119. * Converts a texture to the according Spherical Polynomial data.
  51120. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51121. *
  51122. * @param texture The texture to extract the information from.
  51123. * @return The Spherical Polynomial data.
  51124. */
  51125. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51126. /**
  51127. * Converts a cubemap to the according Spherical Polynomial data.
  51128. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51129. *
  51130. * @param cubeInfo The Cube map to extract the information from.
  51131. * @return The Spherical Polynomial data.
  51132. */
  51133. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51134. }
  51135. }
  51136. declare module BABYLON {
  51137. interface BaseTexture {
  51138. /**
  51139. * Get the polynomial representation of the texture data.
  51140. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51141. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51142. */
  51143. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51144. }
  51145. }
  51146. declare module BABYLON {
  51147. /** @hidden */
  51148. export var rgbdEncodePixelShader: {
  51149. name: string;
  51150. shader: string;
  51151. };
  51152. }
  51153. declare module BABYLON {
  51154. /** @hidden */
  51155. export var rgbdDecodePixelShader: {
  51156. name: string;
  51157. shader: string;
  51158. };
  51159. }
  51160. declare module BABYLON {
  51161. /**
  51162. * Raw texture data and descriptor sufficient for WebGL texture upload
  51163. */
  51164. export interface EnvironmentTextureInfo {
  51165. /**
  51166. * Version of the environment map
  51167. */
  51168. version: number;
  51169. /**
  51170. * Width of image
  51171. */
  51172. width: number;
  51173. /**
  51174. * Irradiance information stored in the file.
  51175. */
  51176. irradiance: any;
  51177. /**
  51178. * Specular information stored in the file.
  51179. */
  51180. specular: any;
  51181. }
  51182. /**
  51183. * Defines One Image in the file. It requires only the position in the file
  51184. * as well as the length.
  51185. */
  51186. interface BufferImageData {
  51187. /**
  51188. * Length of the image data.
  51189. */
  51190. length: number;
  51191. /**
  51192. * Position of the data from the null terminator delimiting the end of the JSON.
  51193. */
  51194. position: number;
  51195. }
  51196. /**
  51197. * Defines the specular data enclosed in the file.
  51198. * This corresponds to the version 1 of the data.
  51199. */
  51200. export interface EnvironmentTextureSpecularInfoV1 {
  51201. /**
  51202. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51203. */
  51204. specularDataPosition?: number;
  51205. /**
  51206. * This contains all the images data needed to reconstruct the cubemap.
  51207. */
  51208. mipmaps: Array<BufferImageData>;
  51209. /**
  51210. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51211. */
  51212. lodGenerationScale: number;
  51213. }
  51214. /**
  51215. * Sets of helpers addressing the serialization and deserialization of environment texture
  51216. * stored in a BabylonJS env file.
  51217. * Those files are usually stored as .env files.
  51218. */
  51219. export class EnvironmentTextureTools {
  51220. /**
  51221. * Magic number identifying the env file.
  51222. */
  51223. private static _MagicBytes;
  51224. /**
  51225. * Gets the environment info from an env file.
  51226. * @param data The array buffer containing the .env bytes.
  51227. * @returns the environment file info (the json header) if successfully parsed.
  51228. */
  51229. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51230. /**
  51231. * Creates an environment texture from a loaded cube texture.
  51232. * @param texture defines the cube texture to convert in env file
  51233. * @return a promise containing the environment data if succesfull.
  51234. */
  51235. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51236. /**
  51237. * Creates a JSON representation of the spherical data.
  51238. * @param texture defines the texture containing the polynomials
  51239. * @return the JSON representation of the spherical info
  51240. */
  51241. private static _CreateEnvTextureIrradiance;
  51242. /**
  51243. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51244. * @param data the image data
  51245. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51246. * @return the views described by info providing access to the underlying buffer
  51247. */
  51248. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51249. /**
  51250. * Uploads the texture info contained in the env file to the GPU.
  51251. * @param texture defines the internal texture to upload to
  51252. * @param data defines the data to load
  51253. * @param info defines the texture info retrieved through the GetEnvInfo method
  51254. * @returns a promise
  51255. */
  51256. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51257. private static _OnImageReadyAsync;
  51258. /**
  51259. * Uploads the levels of image data to the GPU.
  51260. * @param texture defines the internal texture to upload to
  51261. * @param imageData defines the array buffer views of image data [mipmap][face]
  51262. * @returns a promise
  51263. */
  51264. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51265. /**
  51266. * Uploads spherical polynomials information to the texture.
  51267. * @param texture defines the texture we are trying to upload the information to
  51268. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51269. */
  51270. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51271. /** @hidden */
  51272. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51273. }
  51274. }
  51275. declare module BABYLON {
  51276. /** @hidden */
  51277. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51278. private _genericAttributeLocation;
  51279. private _varyingLocationCount;
  51280. private _varyingLocationMap;
  51281. private _replacements;
  51282. private _textureCount;
  51283. private _uniforms;
  51284. lineProcessor(line: string): string;
  51285. attributeProcessor(attribute: string): string;
  51286. varyingProcessor(varying: string, isFragment: boolean): string;
  51287. uniformProcessor(uniform: string): string;
  51288. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51289. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51290. }
  51291. }
  51292. declare module BABYLON {
  51293. /**
  51294. * Class used to inline functions in shader code
  51295. */
  51296. export class ShaderCodeInliner {
  51297. private static readonly _RegexpFindFunctionNameAndType;
  51298. private _sourceCode;
  51299. private _functionDescr;
  51300. private _numMaxIterations;
  51301. /** Gets or sets the token used to mark the functions to inline */
  51302. inlineToken: string;
  51303. /** Gets or sets the debug mode */
  51304. debug: boolean;
  51305. /** Gets the code after the inlining process */
  51306. get code(): string;
  51307. /**
  51308. * Initializes the inliner
  51309. * @param sourceCode shader code source to inline
  51310. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51311. */
  51312. constructor(sourceCode: string, numMaxIterations?: number);
  51313. /**
  51314. * Start the processing of the shader code
  51315. */
  51316. processCode(): void;
  51317. private _collectFunctions;
  51318. private _processInlining;
  51319. private _extractBetweenMarkers;
  51320. private _skipWhitespaces;
  51321. private _removeComments;
  51322. private _replaceFunctionCallsByCode;
  51323. private _findBackward;
  51324. private _escapeRegExp;
  51325. private _replaceNames;
  51326. }
  51327. }
  51328. declare module BABYLON {
  51329. /**
  51330. * Container for accessors for natively-stored mesh data buffers.
  51331. */
  51332. class NativeDataBuffer extends DataBuffer {
  51333. /**
  51334. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51335. */
  51336. nativeIndexBuffer?: any;
  51337. /**
  51338. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51339. */
  51340. nativeVertexBuffer?: any;
  51341. }
  51342. /** @hidden */
  51343. class NativeTexture extends InternalTexture {
  51344. getInternalTexture(): InternalTexture;
  51345. getViewCount(): number;
  51346. }
  51347. /** @hidden */
  51348. export class NativeEngine extends Engine {
  51349. private readonly _native;
  51350. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51351. private readonly INVALID_HANDLE;
  51352. getHardwareScalingLevel(): number;
  51353. constructor();
  51354. dispose(): void;
  51355. /**
  51356. * Can be used to override the current requestAnimationFrame requester.
  51357. * @hidden
  51358. */
  51359. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51360. /**
  51361. * Override default engine behavior.
  51362. * @param color
  51363. * @param backBuffer
  51364. * @param depth
  51365. * @param stencil
  51366. */
  51367. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51368. /**
  51369. * Gets host document
  51370. * @returns the host document object
  51371. */
  51372. getHostDocument(): Nullable<Document>;
  51373. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51374. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51375. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51376. recordVertexArrayObject(vertexBuffers: {
  51377. [key: string]: VertexBuffer;
  51378. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51379. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51380. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51382. /**
  51383. * Draw a list of indexed primitives
  51384. * @param fillMode defines the primitive to use
  51385. * @param indexStart defines the starting index
  51386. * @param indexCount defines the number of index to draw
  51387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51388. */
  51389. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51390. /**
  51391. * Draw a list of unindexed primitives
  51392. * @param fillMode defines the primitive to use
  51393. * @param verticesStart defines the index of first vertex to draw
  51394. * @param verticesCount defines the count of vertices to draw
  51395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51396. */
  51397. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51398. createPipelineContext(): IPipelineContext;
  51399. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51400. /** @hidden */
  51401. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51402. /** @hidden */
  51403. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51404. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51406. protected _setProgram(program: WebGLProgram): void;
  51407. _releaseEffect(effect: Effect): void;
  51408. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51409. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51410. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51411. bindSamplers(effect: Effect): void;
  51412. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51413. getRenderWidth(useScreen?: boolean): number;
  51414. getRenderHeight(useScreen?: boolean): number;
  51415. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51416. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51417. /**
  51418. * Set the z offset to apply to current rendering
  51419. * @param value defines the offset to apply
  51420. */
  51421. setZOffset(value: number): void;
  51422. /**
  51423. * Gets the current value of the zOffset
  51424. * @returns the current zOffset state
  51425. */
  51426. getZOffset(): number;
  51427. /**
  51428. * Enable or disable depth buffering
  51429. * @param enable defines the state to set
  51430. */
  51431. setDepthBuffer(enable: boolean): void;
  51432. /**
  51433. * Gets a boolean indicating if depth writing is enabled
  51434. * @returns the current depth writing state
  51435. */
  51436. getDepthWrite(): boolean;
  51437. /**
  51438. * Enable or disable depth writing
  51439. * @param enable defines the state to set
  51440. */
  51441. setDepthWrite(enable: boolean): void;
  51442. /**
  51443. * Enable or disable color writing
  51444. * @param enable defines the state to set
  51445. */
  51446. setColorWrite(enable: boolean): void;
  51447. /**
  51448. * Gets a boolean indicating if color writing is enabled
  51449. * @returns the current color writing state
  51450. */
  51451. getColorWrite(): boolean;
  51452. /**
  51453. * Sets alpha constants used by some alpha blending modes
  51454. * @param r defines the red component
  51455. * @param g defines the green component
  51456. * @param b defines the blue component
  51457. * @param a defines the alpha component
  51458. */
  51459. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51460. /**
  51461. * Sets the current alpha mode
  51462. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51463. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51465. */
  51466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51467. /**
  51468. * Gets the current alpha mode
  51469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51470. * @returns the current alpha mode
  51471. */
  51472. getAlphaMode(): number;
  51473. setInt(uniform: WebGLUniformLocation, int: number): void;
  51474. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51475. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51476. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51477. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51478. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51479. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51480. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51481. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51482. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51483. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51484. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51485. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51486. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51487. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51488. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51489. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51490. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51491. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51492. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51493. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51494. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51495. wipeCaches(bruteForce?: boolean): void;
  51496. _createTexture(): WebGLTexture;
  51497. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51498. /**
  51499. * Usually called from Texture.ts.
  51500. * Passed information to create a WebGLTexture
  51501. * @param url defines a value which contains one of the following:
  51502. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51503. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51504. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51506. * @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)
  51507. * @param scene needed for loading to the correct scene
  51508. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51509. * @param onLoad optional callback to be called upon successful completion
  51510. * @param onError optional callback to be called upon failure
  51511. * @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
  51512. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51513. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51514. * @param forcedExtension defines the extension to use to pick the right loader
  51515. * @param mimeType defines an optional mime type
  51516. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51517. */
  51518. 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;
  51519. /**
  51520. * Creates a cube texture
  51521. * @param rootUrl defines the url where the files to load is located
  51522. * @param scene defines the current scene
  51523. * @param files defines the list of files to load (1 per face)
  51524. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51525. * @param onLoad defines an optional callback raised when the texture is loaded
  51526. * @param onError defines an optional callback raised if there is an issue to load the texture
  51527. * @param format defines the format of the data
  51528. * @param forcedExtension defines the extension to use to pick the right loader
  51529. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51530. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51531. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51532. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51533. * @returns the cube texture as an InternalTexture
  51534. */
  51535. 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;
  51536. private _getSamplingFilter;
  51537. private static _GetNativeTextureFormat;
  51538. createRenderTargetTexture(size: number | {
  51539. width: number;
  51540. height: number;
  51541. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51542. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51543. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51544. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51545. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51546. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51547. /**
  51548. * Updates a dynamic vertex buffer.
  51549. * @param vertexBuffer the vertex buffer to update
  51550. * @param data the data used to update the vertex buffer
  51551. * @param byteOffset the byte offset of the data (optional)
  51552. * @param byteLength the byte length of the data (optional)
  51553. */
  51554. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51555. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51556. private _updateAnisotropicLevel;
  51557. private _getAddressMode;
  51558. /** @hidden */
  51559. _bindTexture(channel: number, texture: InternalTexture): void;
  51560. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51561. releaseEffects(): void;
  51562. /** @hidden */
  51563. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51564. /** @hidden */
  51565. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51566. /** @hidden */
  51567. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51568. /** @hidden */
  51569. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51570. }
  51571. }
  51572. declare module BABYLON {
  51573. /**
  51574. * Gather the list of clipboard event types as constants.
  51575. */
  51576. export class ClipboardEventTypes {
  51577. /**
  51578. * The clipboard event is fired when a copy command is active (pressed).
  51579. */
  51580. static readonly COPY: number;
  51581. /**
  51582. * The clipboard event is fired when a cut command is active (pressed).
  51583. */
  51584. static readonly CUT: number;
  51585. /**
  51586. * The clipboard event is fired when a paste command is active (pressed).
  51587. */
  51588. static readonly PASTE: number;
  51589. }
  51590. /**
  51591. * This class is used to store clipboard related info for the onClipboardObservable event.
  51592. */
  51593. export class ClipboardInfo {
  51594. /**
  51595. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51596. */
  51597. type: number;
  51598. /**
  51599. * Defines the related dom event
  51600. */
  51601. event: ClipboardEvent;
  51602. /**
  51603. *Creates an instance of ClipboardInfo.
  51604. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51605. * @param event Defines the related dom event
  51606. */
  51607. constructor(
  51608. /**
  51609. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51610. */
  51611. type: number,
  51612. /**
  51613. * Defines the related dom event
  51614. */
  51615. event: ClipboardEvent);
  51616. /**
  51617. * Get the clipboard event's type from the keycode.
  51618. * @param keyCode Defines the keyCode for the current keyboard event.
  51619. * @return {number}
  51620. */
  51621. static GetTypeFromCharacter(keyCode: number): number;
  51622. }
  51623. }
  51624. declare module BABYLON {
  51625. /**
  51626. * Google Daydream controller
  51627. */
  51628. export class DaydreamController extends WebVRController {
  51629. /**
  51630. * Base Url for the controller model.
  51631. */
  51632. static MODEL_BASE_URL: string;
  51633. /**
  51634. * File name for the controller model.
  51635. */
  51636. static MODEL_FILENAME: string;
  51637. /**
  51638. * Gamepad Id prefix used to identify Daydream Controller.
  51639. */
  51640. static readonly GAMEPAD_ID_PREFIX: string;
  51641. /**
  51642. * Creates a new DaydreamController from a gamepad
  51643. * @param vrGamepad the gamepad that the controller should be created from
  51644. */
  51645. constructor(vrGamepad: any);
  51646. /**
  51647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51648. * @param scene scene in which to add meshes
  51649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51650. */
  51651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51652. /**
  51653. * Called once for each button that changed state since the last frame
  51654. * @param buttonIdx Which button index changed
  51655. * @param state New state of the button
  51656. * @param changes Which properties on the state changed since last frame
  51657. */
  51658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /**
  51663. * Gear VR Controller
  51664. */
  51665. export class GearVRController extends WebVRController {
  51666. /**
  51667. * Base Url for the controller model.
  51668. */
  51669. static MODEL_BASE_URL: string;
  51670. /**
  51671. * File name for the controller model.
  51672. */
  51673. static MODEL_FILENAME: string;
  51674. /**
  51675. * Gamepad Id prefix used to identify this controller.
  51676. */
  51677. static readonly GAMEPAD_ID_PREFIX: string;
  51678. private readonly _buttonIndexToObservableNameMap;
  51679. /**
  51680. * Creates a new GearVRController from a gamepad
  51681. * @param vrGamepad the gamepad that the controller should be created from
  51682. */
  51683. constructor(vrGamepad: any);
  51684. /**
  51685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51686. * @param scene scene in which to add meshes
  51687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51688. */
  51689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51690. /**
  51691. * Called once for each button that changed state since the last frame
  51692. * @param buttonIdx Which button index changed
  51693. * @param state New state of the button
  51694. * @param changes Which properties on the state changed since last frame
  51695. */
  51696. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51697. }
  51698. }
  51699. declare module BABYLON {
  51700. /**
  51701. * Generic Controller
  51702. */
  51703. export class GenericController extends WebVRController {
  51704. /**
  51705. * Base Url for the controller model.
  51706. */
  51707. static readonly MODEL_BASE_URL: string;
  51708. /**
  51709. * File name for the controller model.
  51710. */
  51711. static readonly MODEL_FILENAME: string;
  51712. /**
  51713. * Creates a new GenericController from a gamepad
  51714. * @param vrGamepad the gamepad that the controller should be created from
  51715. */
  51716. constructor(vrGamepad: any);
  51717. /**
  51718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51719. * @param scene scene in which to add meshes
  51720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51721. */
  51722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51723. /**
  51724. * Called once for each button that changed state since the last frame
  51725. * @param buttonIdx Which button index changed
  51726. * @param state New state of the button
  51727. * @param changes Which properties on the state changed since last frame
  51728. */
  51729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51730. }
  51731. }
  51732. declare module BABYLON {
  51733. /**
  51734. * Oculus Touch Controller
  51735. */
  51736. export class OculusTouchController extends WebVRController {
  51737. /**
  51738. * Base Url for the controller model.
  51739. */
  51740. static MODEL_BASE_URL: string;
  51741. /**
  51742. * File name for the left controller model.
  51743. */
  51744. static MODEL_LEFT_FILENAME: string;
  51745. /**
  51746. * File name for the right controller model.
  51747. */
  51748. static MODEL_RIGHT_FILENAME: string;
  51749. /**
  51750. * Base Url for the Quest controller model.
  51751. */
  51752. static QUEST_MODEL_BASE_URL: string;
  51753. /**
  51754. * @hidden
  51755. * If the controllers are running on a device that needs the updated Quest controller models
  51756. */
  51757. static _IsQuest: boolean;
  51758. /**
  51759. * Fired when the secondary trigger on this controller is modified
  51760. */
  51761. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51762. /**
  51763. * Fired when the thumb rest on this controller is modified
  51764. */
  51765. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51766. /**
  51767. * Creates a new OculusTouchController from a gamepad
  51768. * @param vrGamepad the gamepad that the controller should be created from
  51769. */
  51770. constructor(vrGamepad: any);
  51771. /**
  51772. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51773. * @param scene scene in which to add meshes
  51774. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51775. */
  51776. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51777. /**
  51778. * Fired when the A button on this controller is modified
  51779. */
  51780. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51781. /**
  51782. * Fired when the B button on this controller is modified
  51783. */
  51784. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51785. /**
  51786. * Fired when the X button on this controller is modified
  51787. */
  51788. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51789. /**
  51790. * Fired when the Y button on this controller is modified
  51791. */
  51792. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51793. /**
  51794. * Called once for each button that changed state since the last frame
  51795. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51796. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51797. * 2) secondary trigger (same)
  51798. * 3) A (right) X (left), touch, pressed = value
  51799. * 4) B / Y
  51800. * 5) thumb rest
  51801. * @param buttonIdx Which button index changed
  51802. * @param state New state of the button
  51803. * @param changes Which properties on the state changed since last frame
  51804. */
  51805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51806. }
  51807. }
  51808. declare module BABYLON {
  51809. /**
  51810. * Vive Controller
  51811. */
  51812. export class ViveController extends WebVRController {
  51813. /**
  51814. * Base Url for the controller model.
  51815. */
  51816. static MODEL_BASE_URL: string;
  51817. /**
  51818. * File name for the controller model.
  51819. */
  51820. static MODEL_FILENAME: string;
  51821. /**
  51822. * Creates a new ViveController from a gamepad
  51823. * @param vrGamepad the gamepad that the controller should be created from
  51824. */
  51825. constructor(vrGamepad: any);
  51826. /**
  51827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51828. * @param scene scene in which to add meshes
  51829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51830. */
  51831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51832. /**
  51833. * Fired when the left button on this controller is modified
  51834. */
  51835. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51836. /**
  51837. * Fired when the right button on this controller is modified
  51838. */
  51839. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51840. /**
  51841. * Fired when the menu button on this controller is modified
  51842. */
  51843. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51844. /**
  51845. * Called once for each button that changed state since the last frame
  51846. * Vive mapping:
  51847. * 0: touchpad
  51848. * 1: trigger
  51849. * 2: left AND right buttons
  51850. * 3: menu button
  51851. * @param buttonIdx Which button index changed
  51852. * @param state New state of the button
  51853. * @param changes Which properties on the state changed since last frame
  51854. */
  51855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51856. }
  51857. }
  51858. declare module BABYLON {
  51859. /**
  51860. * Defines the WindowsMotionController object that the state of the windows motion controller
  51861. */
  51862. export class WindowsMotionController extends WebVRController {
  51863. /**
  51864. * The base url used to load the left and right controller models
  51865. */
  51866. static MODEL_BASE_URL: string;
  51867. /**
  51868. * The name of the left controller model file
  51869. */
  51870. static MODEL_LEFT_FILENAME: string;
  51871. /**
  51872. * The name of the right controller model file
  51873. */
  51874. static MODEL_RIGHT_FILENAME: string;
  51875. /**
  51876. * The controller name prefix for this controller type
  51877. */
  51878. static readonly GAMEPAD_ID_PREFIX: string;
  51879. /**
  51880. * The controller id pattern for this controller type
  51881. */
  51882. private static readonly GAMEPAD_ID_PATTERN;
  51883. private _loadedMeshInfo;
  51884. protected readonly _mapping: {
  51885. buttons: string[];
  51886. buttonMeshNames: {
  51887. trigger: string;
  51888. menu: string;
  51889. grip: string;
  51890. thumbstick: string;
  51891. trackpad: string;
  51892. };
  51893. buttonObservableNames: {
  51894. trigger: string;
  51895. menu: string;
  51896. grip: string;
  51897. thumbstick: string;
  51898. trackpad: string;
  51899. };
  51900. axisMeshNames: string[];
  51901. pointingPoseMeshName: string;
  51902. };
  51903. /**
  51904. * Fired when the trackpad on this controller is clicked
  51905. */
  51906. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51907. /**
  51908. * Fired when the trackpad on this controller is modified
  51909. */
  51910. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51911. /**
  51912. * The current x and y values of this controller's trackpad
  51913. */
  51914. trackpad: StickValues;
  51915. /**
  51916. * Creates a new WindowsMotionController from a gamepad
  51917. * @param vrGamepad the gamepad that the controller should be created from
  51918. */
  51919. constructor(vrGamepad: any);
  51920. /**
  51921. * Fired when the trigger on this controller is modified
  51922. */
  51923. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51924. /**
  51925. * Fired when the menu button on this controller is modified
  51926. */
  51927. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51928. /**
  51929. * Fired when the grip button on this controller is modified
  51930. */
  51931. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51932. /**
  51933. * Fired when the thumbstick button on this controller is modified
  51934. */
  51935. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51936. /**
  51937. * Fired when the touchpad button on this controller is modified
  51938. */
  51939. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51940. /**
  51941. * Fired when the touchpad values on this controller are modified
  51942. */
  51943. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51944. protected _updateTrackpad(): void;
  51945. /**
  51946. * Called once per frame by the engine.
  51947. */
  51948. update(): void;
  51949. /**
  51950. * Called once for each button that changed state since the last frame
  51951. * @param buttonIdx Which button index changed
  51952. * @param state New state of the button
  51953. * @param changes Which properties on the state changed since last frame
  51954. */
  51955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51956. /**
  51957. * Moves the buttons on the controller mesh based on their current state
  51958. * @param buttonName the name of the button to move
  51959. * @param buttonValue the value of the button which determines the buttons new position
  51960. */
  51961. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51962. /**
  51963. * Moves the axis on the controller mesh based on its current state
  51964. * @param axis the index of the axis
  51965. * @param axisValue the value of the axis which determines the meshes new position
  51966. * @hidden
  51967. */
  51968. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51969. /**
  51970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51971. * @param scene scene in which to add meshes
  51972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51973. */
  51974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51975. /**
  51976. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51977. * can be transformed by button presses and axes values, based on this._mapping.
  51978. *
  51979. * @param scene scene in which the meshes exist
  51980. * @param meshes list of meshes that make up the controller model to process
  51981. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51982. */
  51983. private processModel;
  51984. private createMeshInfo;
  51985. /**
  51986. * Gets the ray of the controller in the direction the controller is pointing
  51987. * @param length the length the resulting ray should be
  51988. * @returns a ray in the direction the controller is pointing
  51989. */
  51990. getForwardRay(length?: number): Ray;
  51991. /**
  51992. * Disposes of the controller
  51993. */
  51994. dispose(): void;
  51995. }
  51996. /**
  51997. * This class represents a new windows motion controller in XR.
  51998. */
  51999. export class XRWindowsMotionController extends WindowsMotionController {
  52000. /**
  52001. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52002. */
  52003. protected readonly _mapping: {
  52004. buttons: string[];
  52005. buttonMeshNames: {
  52006. trigger: string;
  52007. menu: string;
  52008. grip: string;
  52009. thumbstick: string;
  52010. trackpad: string;
  52011. };
  52012. buttonObservableNames: {
  52013. trigger: string;
  52014. menu: string;
  52015. grip: string;
  52016. thumbstick: string;
  52017. trackpad: string;
  52018. };
  52019. axisMeshNames: string[];
  52020. pointingPoseMeshName: string;
  52021. };
  52022. /**
  52023. * Construct a new XR-Based windows motion controller
  52024. *
  52025. * @param gamepadInfo the gamepad object from the browser
  52026. */
  52027. constructor(gamepadInfo: any);
  52028. /**
  52029. * holds the thumbstick values (X,Y)
  52030. */
  52031. thumbstickValues: StickValues;
  52032. /**
  52033. * Fired when the thumbstick on this controller is clicked
  52034. */
  52035. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52036. /**
  52037. * Fired when the thumbstick on this controller is modified
  52038. */
  52039. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52040. /**
  52041. * Fired when the touchpad button on this controller is modified
  52042. */
  52043. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52044. /**
  52045. * Fired when the touchpad values on this controller are modified
  52046. */
  52047. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52048. /**
  52049. * Fired when the thumbstick button on this controller is modified
  52050. * here to prevent breaking changes
  52051. */
  52052. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52053. /**
  52054. * updating the thumbstick(!) and not the trackpad.
  52055. * This is named this way due to the difference between WebVR and XR and to avoid
  52056. * changing the parent class.
  52057. */
  52058. protected _updateTrackpad(): void;
  52059. /**
  52060. * Disposes the class with joy
  52061. */
  52062. dispose(): void;
  52063. }
  52064. }
  52065. declare module BABYLON {
  52066. /**
  52067. * Class containing static functions to help procedurally build meshes
  52068. */
  52069. export class PolyhedronBuilder {
  52070. /**
  52071. * Creates a polyhedron mesh
  52072. * * 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
  52073. * * The parameter `size` (positive float, default 1) sets the polygon size
  52074. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52075. * * 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`
  52076. * * 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
  52077. * * 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)`)
  52078. * * 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
  52079. * * 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
  52080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52081. * * 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
  52082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52083. * @param name defines the name of the mesh
  52084. * @param options defines the options used to create the mesh
  52085. * @param scene defines the hosting scene
  52086. * @returns the polyhedron mesh
  52087. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52088. */
  52089. static CreatePolyhedron(name: string, options: {
  52090. type?: number;
  52091. size?: number;
  52092. sizeX?: number;
  52093. sizeY?: number;
  52094. sizeZ?: number;
  52095. custom?: any;
  52096. faceUV?: Vector4[];
  52097. faceColors?: Color4[];
  52098. flat?: boolean;
  52099. updatable?: boolean;
  52100. sideOrientation?: number;
  52101. frontUVs?: Vector4;
  52102. backUVs?: Vector4;
  52103. }, scene?: Nullable<Scene>): Mesh;
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * Gizmo that enables scaling a mesh along 3 axis
  52109. */
  52110. export class ScaleGizmo extends Gizmo {
  52111. /**
  52112. * Internal gizmo used for interactions on the x axis
  52113. */
  52114. xGizmo: AxisScaleGizmo;
  52115. /**
  52116. * Internal gizmo used for interactions on the y axis
  52117. */
  52118. yGizmo: AxisScaleGizmo;
  52119. /**
  52120. * Internal gizmo used for interactions on the z axis
  52121. */
  52122. zGizmo: AxisScaleGizmo;
  52123. /**
  52124. * Internal gizmo used to scale all axis equally
  52125. */
  52126. uniformScaleGizmo: AxisScaleGizmo;
  52127. private _meshAttached;
  52128. private _updateGizmoRotationToMatchAttachedMesh;
  52129. private _snapDistance;
  52130. private _scaleRatio;
  52131. private _uniformScalingMesh;
  52132. private _octahedron;
  52133. private _sensitivity;
  52134. /** Fires an event when any of it's sub gizmos are dragged */
  52135. onDragStartObservable: Observable<unknown>;
  52136. /** Fires an event when any of it's sub gizmos are released from dragging */
  52137. onDragEndObservable: Observable<unknown>;
  52138. get attachedMesh(): Nullable<AbstractMesh>;
  52139. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52140. /**
  52141. * Creates a ScaleGizmo
  52142. * @param gizmoLayer The utility layer the gizmo will be added to
  52143. */
  52144. constructor(gizmoLayer?: UtilityLayerRenderer);
  52145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52147. /**
  52148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52149. */
  52150. set snapDistance(value: number);
  52151. get snapDistance(): number;
  52152. /**
  52153. * Ratio for the scale of the gizmo (Default: 1)
  52154. */
  52155. set scaleRatio(value: number);
  52156. get scaleRatio(): number;
  52157. /**
  52158. * Sensitivity factor for dragging (Default: 1)
  52159. */
  52160. set sensitivity(value: number);
  52161. get sensitivity(): number;
  52162. /**
  52163. * Disposes of the gizmo
  52164. */
  52165. dispose(): void;
  52166. }
  52167. }
  52168. declare module BABYLON {
  52169. /**
  52170. * Single axis scale gizmo
  52171. */
  52172. export class AxisScaleGizmo extends Gizmo {
  52173. /**
  52174. * Drag behavior responsible for the gizmos dragging interactions
  52175. */
  52176. dragBehavior: PointerDragBehavior;
  52177. private _pointerObserver;
  52178. /**
  52179. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52180. */
  52181. snapDistance: number;
  52182. /**
  52183. * Event that fires each time the gizmo snaps to a new location.
  52184. * * snapDistance is the the change in distance
  52185. */
  52186. onSnapObservable: Observable<{
  52187. snapDistance: number;
  52188. }>;
  52189. /**
  52190. * If the scaling operation should be done on all axis (default: false)
  52191. */
  52192. uniformScaling: boolean;
  52193. /**
  52194. * Custom sensitivity value for the drag strength
  52195. */
  52196. sensitivity: number;
  52197. private _isEnabled;
  52198. private _parent;
  52199. private _arrow;
  52200. private _coloredMaterial;
  52201. private _hoverMaterial;
  52202. /**
  52203. * Creates an AxisScaleGizmo
  52204. * @param gizmoLayer The utility layer the gizmo will be added to
  52205. * @param dragAxis The axis which the gizmo will be able to scale on
  52206. * @param color The color of the gizmo
  52207. */
  52208. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52210. /**
  52211. * If the gizmo is enabled
  52212. */
  52213. set isEnabled(value: boolean);
  52214. get isEnabled(): boolean;
  52215. /**
  52216. * Disposes of the gizmo
  52217. */
  52218. dispose(): void;
  52219. /**
  52220. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52221. * @param mesh The mesh to replace the default mesh of the gizmo
  52222. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52223. */
  52224. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52225. }
  52226. }
  52227. declare module BABYLON {
  52228. /**
  52229. * Bounding box gizmo
  52230. */
  52231. export class BoundingBoxGizmo extends Gizmo {
  52232. private _lineBoundingBox;
  52233. private _rotateSpheresParent;
  52234. private _scaleBoxesParent;
  52235. private _boundingDimensions;
  52236. private _renderObserver;
  52237. private _pointerObserver;
  52238. private _scaleDragSpeed;
  52239. private _tmpQuaternion;
  52240. private _tmpVector;
  52241. private _tmpRotationMatrix;
  52242. /**
  52243. * 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)
  52244. */
  52245. ignoreChildren: boolean;
  52246. /**
  52247. * 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)
  52248. */
  52249. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52250. /**
  52251. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52252. */
  52253. rotationSphereSize: number;
  52254. /**
  52255. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52256. */
  52257. scaleBoxSize: number;
  52258. /**
  52259. * 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)
  52260. */
  52261. fixedDragMeshScreenSize: boolean;
  52262. /**
  52263. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52264. */
  52265. fixedDragMeshScreenSizeDistanceFactor: number;
  52266. /**
  52267. * Fired when a rotation sphere or scale box is dragged
  52268. */
  52269. onDragStartObservable: Observable<{}>;
  52270. /**
  52271. * Fired when a scale box is dragged
  52272. */
  52273. onScaleBoxDragObservable: Observable<{}>;
  52274. /**
  52275. * Fired when a scale box drag is ended
  52276. */
  52277. onScaleBoxDragEndObservable: Observable<{}>;
  52278. /**
  52279. * Fired when a rotation sphere is dragged
  52280. */
  52281. onRotationSphereDragObservable: Observable<{}>;
  52282. /**
  52283. * Fired when a rotation sphere drag is ended
  52284. */
  52285. onRotationSphereDragEndObservable: Observable<{}>;
  52286. /**
  52287. * 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)
  52288. */
  52289. scalePivot: Nullable<Vector3>;
  52290. /**
  52291. * Mesh used as a pivot to rotate the attached mesh
  52292. */
  52293. private _anchorMesh;
  52294. private _existingMeshScale;
  52295. private _dragMesh;
  52296. private pointerDragBehavior;
  52297. private coloredMaterial;
  52298. private hoverColoredMaterial;
  52299. /**
  52300. * Sets the color of the bounding box gizmo
  52301. * @param color the color to set
  52302. */
  52303. setColor(color: Color3): void;
  52304. /**
  52305. * Creates an BoundingBoxGizmo
  52306. * @param gizmoLayer The utility layer the gizmo will be added to
  52307. * @param color The color of the gizmo
  52308. */
  52309. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52311. private _selectNode;
  52312. /**
  52313. * Updates the bounding box information for the Gizmo
  52314. */
  52315. updateBoundingBox(): void;
  52316. private _updateRotationSpheres;
  52317. private _updateScaleBoxes;
  52318. /**
  52319. * Enables rotation on the specified axis and disables rotation on the others
  52320. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52321. */
  52322. setEnabledRotationAxis(axis: string): void;
  52323. /**
  52324. * Enables/disables scaling
  52325. * @param enable if scaling should be enabled
  52326. * @param homogeneousScaling defines if scaling should only be homogeneous
  52327. */
  52328. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52329. private _updateDummy;
  52330. /**
  52331. * Enables a pointer drag behavior on the bounding box of the gizmo
  52332. */
  52333. enableDragBehavior(): void;
  52334. /**
  52335. * Disposes of the gizmo
  52336. */
  52337. dispose(): void;
  52338. /**
  52339. * 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)
  52340. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52341. * @returns the bounding box mesh with the passed in mesh as a child
  52342. */
  52343. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52344. /**
  52345. * CustomMeshes are not supported by this gizmo
  52346. * @param mesh The mesh to replace the default mesh of the gizmo
  52347. */
  52348. setCustomMesh(mesh: Mesh): void;
  52349. }
  52350. }
  52351. declare module BABYLON {
  52352. /**
  52353. * Single plane rotation gizmo
  52354. */
  52355. export class PlaneRotationGizmo extends Gizmo {
  52356. /**
  52357. * Drag behavior responsible for the gizmos dragging interactions
  52358. */
  52359. dragBehavior: PointerDragBehavior;
  52360. private _pointerObserver;
  52361. /**
  52362. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52363. */
  52364. snapDistance: number;
  52365. /**
  52366. * Event that fires each time the gizmo snaps to a new location.
  52367. * * snapDistance is the the change in distance
  52368. */
  52369. onSnapObservable: Observable<{
  52370. snapDistance: number;
  52371. }>;
  52372. private _isEnabled;
  52373. private _parent;
  52374. /**
  52375. * Creates a PlaneRotationGizmo
  52376. * @param gizmoLayer The utility layer the gizmo will be added to
  52377. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52378. * @param color The color of the gizmo
  52379. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52380. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52381. */
  52382. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52383. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52384. /**
  52385. * If the gizmo is enabled
  52386. */
  52387. set isEnabled(value: boolean);
  52388. get isEnabled(): boolean;
  52389. /**
  52390. * Disposes of the gizmo
  52391. */
  52392. dispose(): void;
  52393. }
  52394. }
  52395. declare module BABYLON {
  52396. /**
  52397. * Gizmo that enables rotating a mesh along 3 axis
  52398. */
  52399. export class RotationGizmo extends Gizmo {
  52400. /**
  52401. * Internal gizmo used for interactions on the x axis
  52402. */
  52403. xGizmo: PlaneRotationGizmo;
  52404. /**
  52405. * Internal gizmo used for interactions on the y axis
  52406. */
  52407. yGizmo: PlaneRotationGizmo;
  52408. /**
  52409. * Internal gizmo used for interactions on the z axis
  52410. */
  52411. zGizmo: PlaneRotationGizmo;
  52412. /** Fires an event when any of it's sub gizmos are dragged */
  52413. onDragStartObservable: Observable<unknown>;
  52414. /** Fires an event when any of it's sub gizmos are released from dragging */
  52415. onDragEndObservable: Observable<unknown>;
  52416. private _meshAttached;
  52417. get attachedMesh(): Nullable<AbstractMesh>;
  52418. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52419. /**
  52420. * Creates a RotationGizmo
  52421. * @param gizmoLayer The utility layer the gizmo will be added to
  52422. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52423. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52424. */
  52425. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52426. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52427. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52428. /**
  52429. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52430. */
  52431. set snapDistance(value: number);
  52432. get snapDistance(): number;
  52433. /**
  52434. * Ratio for the scale of the gizmo (Default: 1)
  52435. */
  52436. set scaleRatio(value: number);
  52437. get scaleRatio(): number;
  52438. /**
  52439. * Disposes of the gizmo
  52440. */
  52441. dispose(): void;
  52442. /**
  52443. * CustomMeshes are not supported by this gizmo
  52444. * @param mesh The mesh to replace the default mesh of the gizmo
  52445. */
  52446. setCustomMesh(mesh: Mesh): void;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52452. */
  52453. export class GizmoManager implements IDisposable {
  52454. private scene;
  52455. /**
  52456. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52457. */
  52458. gizmos: {
  52459. positionGizmo: Nullable<PositionGizmo>;
  52460. rotationGizmo: Nullable<RotationGizmo>;
  52461. scaleGizmo: Nullable<ScaleGizmo>;
  52462. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52463. };
  52464. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52465. clearGizmoOnEmptyPointerEvent: boolean;
  52466. /** Fires an event when the manager is attached to a mesh */
  52467. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52468. private _gizmosEnabled;
  52469. private _pointerObserver;
  52470. private _attachedMesh;
  52471. private _boundingBoxColor;
  52472. private _defaultUtilityLayer;
  52473. private _defaultKeepDepthUtilityLayer;
  52474. /**
  52475. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52476. */
  52477. boundingBoxDragBehavior: SixDofDragBehavior;
  52478. /**
  52479. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52480. */
  52481. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52482. /**
  52483. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52484. */
  52485. usePointerToAttachGizmos: boolean;
  52486. /**
  52487. * Utility layer that the bounding box gizmo belongs to
  52488. */
  52489. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52490. /**
  52491. * Utility layer that all gizmos besides bounding box belong to
  52492. */
  52493. get utilityLayer(): UtilityLayerRenderer;
  52494. /**
  52495. * Instatiates a gizmo manager
  52496. * @param scene the scene to overlay the gizmos on top of
  52497. */
  52498. constructor(scene: Scene);
  52499. /**
  52500. * Attaches a set of gizmos to the specified mesh
  52501. * @param mesh The mesh the gizmo's should be attached to
  52502. */
  52503. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52504. /**
  52505. * If the position gizmo is enabled
  52506. */
  52507. set positionGizmoEnabled(value: boolean);
  52508. get positionGizmoEnabled(): boolean;
  52509. /**
  52510. * If the rotation gizmo is enabled
  52511. */
  52512. set rotationGizmoEnabled(value: boolean);
  52513. get rotationGizmoEnabled(): boolean;
  52514. /**
  52515. * If the scale gizmo is enabled
  52516. */
  52517. set scaleGizmoEnabled(value: boolean);
  52518. get scaleGizmoEnabled(): boolean;
  52519. /**
  52520. * If the boundingBox gizmo is enabled
  52521. */
  52522. set boundingBoxGizmoEnabled(value: boolean);
  52523. get boundingBoxGizmoEnabled(): boolean;
  52524. /**
  52525. * Disposes of the gizmo manager
  52526. */
  52527. dispose(): void;
  52528. }
  52529. }
  52530. declare module BABYLON {
  52531. /**
  52532. * A directional light is defined by a direction (what a surprise!).
  52533. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52534. * 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.
  52535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52536. */
  52537. export class DirectionalLight extends ShadowLight {
  52538. private _shadowFrustumSize;
  52539. /**
  52540. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52541. */
  52542. get shadowFrustumSize(): number;
  52543. /**
  52544. * Specifies a fix frustum size for the shadow generation.
  52545. */
  52546. set shadowFrustumSize(value: number);
  52547. private _shadowOrthoScale;
  52548. /**
  52549. * Gets the shadow projection scale against the optimal computed one.
  52550. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52551. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52552. */
  52553. get shadowOrthoScale(): number;
  52554. /**
  52555. * Sets the shadow projection scale against the optimal computed one.
  52556. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52557. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52558. */
  52559. set shadowOrthoScale(value: number);
  52560. /**
  52561. * Automatically compute the projection matrix to best fit (including all the casters)
  52562. * on each frame.
  52563. */
  52564. autoUpdateExtends: boolean;
  52565. /**
  52566. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52567. * on each frame. autoUpdateExtends must be set to true for this to work
  52568. */
  52569. autoCalcShadowZBounds: boolean;
  52570. private _orthoLeft;
  52571. private _orthoRight;
  52572. private _orthoTop;
  52573. private _orthoBottom;
  52574. /**
  52575. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52576. * The directional light is emitted from everywhere in the given direction.
  52577. * It can cast shadows.
  52578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52579. * @param name The friendly name of the light
  52580. * @param direction The direction of the light
  52581. * @param scene The scene the light belongs to
  52582. */
  52583. constructor(name: string, direction: Vector3, scene: Scene);
  52584. /**
  52585. * Returns the string "DirectionalLight".
  52586. * @return The class name
  52587. */
  52588. getClassName(): string;
  52589. /**
  52590. * Returns the integer 1.
  52591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52592. */
  52593. getTypeID(): number;
  52594. /**
  52595. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52596. * Returns the DirectionalLight Shadow projection matrix.
  52597. */
  52598. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52599. /**
  52600. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52601. * Returns the DirectionalLight Shadow projection matrix.
  52602. */
  52603. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52604. /**
  52605. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52606. * Returns the DirectionalLight Shadow projection matrix.
  52607. */
  52608. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52609. protected _buildUniformLayout(): void;
  52610. /**
  52611. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52612. * @param effect The effect to update
  52613. * @param lightIndex The index of the light in the effect to update
  52614. * @returns The directional light
  52615. */
  52616. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52617. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52618. /**
  52619. * Gets the minZ used for shadow according to both the scene and the light.
  52620. *
  52621. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52622. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52623. * @param activeCamera The camera we are returning the min for
  52624. * @returns the depth min z
  52625. */
  52626. getDepthMinZ(activeCamera: Camera): number;
  52627. /**
  52628. * Gets the maxZ used for shadow according to both the scene and the light.
  52629. *
  52630. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52631. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52632. * @param activeCamera The camera we are returning the max for
  52633. * @returns the depth max z
  52634. */
  52635. getDepthMaxZ(activeCamera: Camera): number;
  52636. /**
  52637. * Prepares the list of defines specific to the light type.
  52638. * @param defines the list of defines
  52639. * @param lightIndex defines the index of the light for the effect
  52640. */
  52641. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52642. }
  52643. }
  52644. declare module BABYLON {
  52645. /**
  52646. * Class containing static functions to help procedurally build meshes
  52647. */
  52648. export class HemisphereBuilder {
  52649. /**
  52650. * Creates a hemisphere mesh
  52651. * @param name defines the name of the mesh
  52652. * @param options defines the options used to create the mesh
  52653. * @param scene defines the hosting scene
  52654. * @returns the hemisphere mesh
  52655. */
  52656. static CreateHemisphere(name: string, options: {
  52657. segments?: number;
  52658. diameter?: number;
  52659. sideOrientation?: number;
  52660. }, scene: any): Mesh;
  52661. }
  52662. }
  52663. declare module BABYLON {
  52664. /**
  52665. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52666. * These values define a cone of light starting from the position, emitting toward the direction.
  52667. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52668. * and the exponent defines the speed of the decay of the light with distance (reach).
  52669. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52670. */
  52671. export class SpotLight extends ShadowLight {
  52672. private _angle;
  52673. private _innerAngle;
  52674. private _cosHalfAngle;
  52675. private _lightAngleScale;
  52676. private _lightAngleOffset;
  52677. /**
  52678. * Gets the cone angle of the spot light in Radians.
  52679. */
  52680. get angle(): number;
  52681. /**
  52682. * Sets the cone angle of the spot light in Radians.
  52683. */
  52684. set angle(value: number);
  52685. /**
  52686. * Only used in gltf falloff mode, this defines the angle where
  52687. * the directional falloff will start before cutting at angle which could be seen
  52688. * as outer angle.
  52689. */
  52690. get innerAngle(): number;
  52691. /**
  52692. * Only used in gltf falloff mode, this defines the angle where
  52693. * the directional falloff will start before cutting at angle which could be seen
  52694. * as outer angle.
  52695. */
  52696. set innerAngle(value: number);
  52697. private _shadowAngleScale;
  52698. /**
  52699. * Allows scaling the angle of the light for shadow generation only.
  52700. */
  52701. get shadowAngleScale(): number;
  52702. /**
  52703. * Allows scaling the angle of the light for shadow generation only.
  52704. */
  52705. set shadowAngleScale(value: number);
  52706. /**
  52707. * The light decay speed with the distance from the emission spot.
  52708. */
  52709. exponent: number;
  52710. private _projectionTextureMatrix;
  52711. /**
  52712. * Allows reading the projecton texture
  52713. */
  52714. get projectionTextureMatrix(): Matrix;
  52715. protected _projectionTextureLightNear: number;
  52716. /**
  52717. * Gets the near clip of the Spotlight for texture projection.
  52718. */
  52719. get projectionTextureLightNear(): number;
  52720. /**
  52721. * Sets the near clip of the Spotlight for texture projection.
  52722. */
  52723. set projectionTextureLightNear(value: number);
  52724. protected _projectionTextureLightFar: number;
  52725. /**
  52726. * Gets the far clip of the Spotlight for texture projection.
  52727. */
  52728. get projectionTextureLightFar(): number;
  52729. /**
  52730. * Sets the far clip of the Spotlight for texture projection.
  52731. */
  52732. set projectionTextureLightFar(value: number);
  52733. protected _projectionTextureUpDirection: Vector3;
  52734. /**
  52735. * Gets the Up vector of the Spotlight for texture projection.
  52736. */
  52737. get projectionTextureUpDirection(): Vector3;
  52738. /**
  52739. * Sets the Up vector of the Spotlight for texture projection.
  52740. */
  52741. set projectionTextureUpDirection(value: Vector3);
  52742. private _projectionTexture;
  52743. /**
  52744. * Gets the projection texture of the light.
  52745. */
  52746. get projectionTexture(): Nullable<BaseTexture>;
  52747. /**
  52748. * Sets the projection texture of the light.
  52749. */
  52750. set projectionTexture(value: Nullable<BaseTexture>);
  52751. private _projectionTextureViewLightDirty;
  52752. private _projectionTextureProjectionLightDirty;
  52753. private _projectionTextureDirty;
  52754. private _projectionTextureViewTargetVector;
  52755. private _projectionTextureViewLightMatrix;
  52756. private _projectionTextureProjectionLightMatrix;
  52757. private _projectionTextureScalingMatrix;
  52758. /**
  52759. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52760. * It can cast shadows.
  52761. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52762. * @param name The light friendly name
  52763. * @param position The position of the spot light in the scene
  52764. * @param direction The direction of the light in the scene
  52765. * @param angle The cone angle of the light in Radians
  52766. * @param exponent The light decay speed with the distance from the emission spot
  52767. * @param scene The scene the lights belongs to
  52768. */
  52769. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52770. /**
  52771. * Returns the string "SpotLight".
  52772. * @returns the class name
  52773. */
  52774. getClassName(): string;
  52775. /**
  52776. * Returns the integer 2.
  52777. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52778. */
  52779. getTypeID(): number;
  52780. /**
  52781. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52782. */
  52783. protected _setDirection(value: Vector3): void;
  52784. /**
  52785. * Overrides the position setter to recompute the projection texture view light Matrix.
  52786. */
  52787. protected _setPosition(value: Vector3): void;
  52788. /**
  52789. * 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.
  52790. * Returns the SpotLight.
  52791. */
  52792. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52793. protected _computeProjectionTextureViewLightMatrix(): void;
  52794. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52795. /**
  52796. * Main function for light texture projection matrix computing.
  52797. */
  52798. protected _computeProjectionTextureMatrix(): void;
  52799. protected _buildUniformLayout(): void;
  52800. private _computeAngleValues;
  52801. /**
  52802. * Sets the passed Effect "effect" with the Light textures.
  52803. * @param effect The effect to update
  52804. * @param lightIndex The index of the light in the effect to update
  52805. * @returns The light
  52806. */
  52807. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52808. /**
  52809. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52810. * @param effect The effect to update
  52811. * @param lightIndex The index of the light in the effect to update
  52812. * @returns The spot light
  52813. */
  52814. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52815. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52816. /**
  52817. * Disposes the light and the associated resources.
  52818. */
  52819. dispose(): void;
  52820. /**
  52821. * Prepares the list of defines specific to the light type.
  52822. * @param defines the list of defines
  52823. * @param lightIndex defines the index of the light for the effect
  52824. */
  52825. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /**
  52830. * Gizmo that enables viewing a light
  52831. */
  52832. export class LightGizmo extends Gizmo {
  52833. private _lightMesh;
  52834. private _material;
  52835. private _cachedPosition;
  52836. private _cachedForward;
  52837. private _attachedMeshParent;
  52838. /**
  52839. * Creates a LightGizmo
  52840. * @param gizmoLayer The utility layer the gizmo will be added to
  52841. */
  52842. constructor(gizmoLayer?: UtilityLayerRenderer);
  52843. private _light;
  52844. /**
  52845. * The light that the gizmo is attached to
  52846. */
  52847. set light(light: Nullable<Light>);
  52848. get light(): Nullable<Light>;
  52849. /**
  52850. * Gets the material used to render the light gizmo
  52851. */
  52852. get material(): StandardMaterial;
  52853. /**
  52854. * @hidden
  52855. * Updates the gizmo to match the attached mesh's position/rotation
  52856. */
  52857. protected _update(): void;
  52858. private static _Scale;
  52859. /**
  52860. * Creates the lines for a light mesh
  52861. */
  52862. private static _CreateLightLines;
  52863. /**
  52864. * Disposes of the light gizmo
  52865. */
  52866. dispose(): void;
  52867. private static _CreateHemisphericLightMesh;
  52868. private static _CreatePointLightMesh;
  52869. private static _CreateSpotLightMesh;
  52870. private static _CreateDirectionalLightMesh;
  52871. }
  52872. }
  52873. declare module BABYLON {
  52874. /** @hidden */
  52875. export var backgroundFragmentDeclaration: {
  52876. name: string;
  52877. shader: string;
  52878. };
  52879. }
  52880. declare module BABYLON {
  52881. /** @hidden */
  52882. export var backgroundUboDeclaration: {
  52883. name: string;
  52884. shader: string;
  52885. };
  52886. }
  52887. declare module BABYLON {
  52888. /** @hidden */
  52889. export var backgroundPixelShader: {
  52890. name: string;
  52891. shader: string;
  52892. };
  52893. }
  52894. declare module BABYLON {
  52895. /** @hidden */
  52896. export var backgroundVertexDeclaration: {
  52897. name: string;
  52898. shader: string;
  52899. };
  52900. }
  52901. declare module BABYLON {
  52902. /** @hidden */
  52903. export var backgroundVertexShader: {
  52904. name: string;
  52905. shader: string;
  52906. };
  52907. }
  52908. declare module BABYLON {
  52909. /**
  52910. * Background material used to create an efficient environement around your scene.
  52911. */
  52912. export class BackgroundMaterial extends PushMaterial {
  52913. /**
  52914. * Standard reflectance value at parallel view angle.
  52915. */
  52916. static StandardReflectance0: number;
  52917. /**
  52918. * Standard reflectance value at grazing angle.
  52919. */
  52920. static StandardReflectance90: number;
  52921. protected _primaryColor: Color3;
  52922. /**
  52923. * Key light Color (multiply against the environement texture)
  52924. */
  52925. primaryColor: Color3;
  52926. protected __perceptualColor: Nullable<Color3>;
  52927. /**
  52928. * Experimental Internal Use Only.
  52929. *
  52930. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52931. * This acts as a helper to set the primary color to a more "human friendly" value.
  52932. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52933. * output color as close as possible from the chosen value.
  52934. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52935. * part of lighting setup.)
  52936. */
  52937. get _perceptualColor(): Nullable<Color3>;
  52938. set _perceptualColor(value: Nullable<Color3>);
  52939. protected _primaryColorShadowLevel: float;
  52940. /**
  52941. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52942. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52943. */
  52944. get primaryColorShadowLevel(): float;
  52945. set primaryColorShadowLevel(value: float);
  52946. protected _primaryColorHighlightLevel: float;
  52947. /**
  52948. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52949. * The primary color is used at the level chosen to define what the white area would look.
  52950. */
  52951. get primaryColorHighlightLevel(): float;
  52952. set primaryColorHighlightLevel(value: float);
  52953. protected _reflectionTexture: Nullable<BaseTexture>;
  52954. /**
  52955. * Reflection Texture used in the material.
  52956. * Should be author in a specific way for the best result (refer to the documentation).
  52957. */
  52958. reflectionTexture: Nullable<BaseTexture>;
  52959. protected _reflectionBlur: float;
  52960. /**
  52961. * Reflection Texture level of blur.
  52962. *
  52963. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52964. * texture twice.
  52965. */
  52966. reflectionBlur: float;
  52967. protected _diffuseTexture: Nullable<BaseTexture>;
  52968. /**
  52969. * Diffuse Texture used in the material.
  52970. * Should be author in a specific way for the best result (refer to the documentation).
  52971. */
  52972. diffuseTexture: Nullable<BaseTexture>;
  52973. protected _shadowLights: Nullable<IShadowLight[]>;
  52974. /**
  52975. * Specify the list of lights casting shadow on the material.
  52976. * All scene shadow lights will be included if null.
  52977. */
  52978. shadowLights: Nullable<IShadowLight[]>;
  52979. protected _shadowLevel: float;
  52980. /**
  52981. * Helps adjusting the shadow to a softer level if required.
  52982. * 0 means black shadows and 1 means no shadows.
  52983. */
  52984. shadowLevel: float;
  52985. protected _sceneCenter: Vector3;
  52986. /**
  52987. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52988. * It is usually zero but might be interesting to modify according to your setup.
  52989. */
  52990. sceneCenter: Vector3;
  52991. protected _opacityFresnel: boolean;
  52992. /**
  52993. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52994. * This helps ensuring a nice transition when the camera goes under the ground.
  52995. */
  52996. opacityFresnel: boolean;
  52997. protected _reflectionFresnel: boolean;
  52998. /**
  52999. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53000. * This helps adding a mirror texture on the ground.
  53001. */
  53002. reflectionFresnel: boolean;
  53003. protected _reflectionFalloffDistance: number;
  53004. /**
  53005. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53006. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53007. */
  53008. reflectionFalloffDistance: number;
  53009. protected _reflectionAmount: number;
  53010. /**
  53011. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53012. */
  53013. reflectionAmount: number;
  53014. protected _reflectionReflectance0: number;
  53015. /**
  53016. * This specifies the weight of the reflection at grazing angle.
  53017. */
  53018. reflectionReflectance0: number;
  53019. protected _reflectionReflectance90: number;
  53020. /**
  53021. * This specifies the weight of the reflection at a perpendicular point of view.
  53022. */
  53023. reflectionReflectance90: number;
  53024. /**
  53025. * Sets the reflection reflectance fresnel values according to the default standard
  53026. * empirically know to work well :-)
  53027. */
  53028. set reflectionStandardFresnelWeight(value: number);
  53029. protected _useRGBColor: boolean;
  53030. /**
  53031. * Helps to directly use the maps channels instead of their level.
  53032. */
  53033. useRGBColor: boolean;
  53034. protected _enableNoise: boolean;
  53035. /**
  53036. * This helps reducing the banding effect that could occur on the background.
  53037. */
  53038. enableNoise: boolean;
  53039. /**
  53040. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53041. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53042. * Recommended to be keep at 1.0 except for special cases.
  53043. */
  53044. get fovMultiplier(): number;
  53045. set fovMultiplier(value: number);
  53046. private _fovMultiplier;
  53047. /**
  53048. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53049. */
  53050. useEquirectangularFOV: boolean;
  53051. private _maxSimultaneousLights;
  53052. /**
  53053. * Number of Simultaneous lights allowed on the material.
  53054. */
  53055. maxSimultaneousLights: int;
  53056. /**
  53057. * Default configuration related to image processing available in the Background Material.
  53058. */
  53059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53060. /**
  53061. * Keep track of the image processing observer to allow dispose and replace.
  53062. */
  53063. private _imageProcessingObserver;
  53064. /**
  53065. * Attaches a new image processing configuration to the PBR Material.
  53066. * @param configuration (if null the scene configuration will be use)
  53067. */
  53068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53069. /**
  53070. * Gets the image processing configuration used either in this material.
  53071. */
  53072. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53073. /**
  53074. * Sets the Default image processing configuration used either in the this material.
  53075. *
  53076. * If sets to null, the scene one is in use.
  53077. */
  53078. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53079. /**
  53080. * Gets wether the color curves effect is enabled.
  53081. */
  53082. get cameraColorCurvesEnabled(): boolean;
  53083. /**
  53084. * Sets wether the color curves effect is enabled.
  53085. */
  53086. set cameraColorCurvesEnabled(value: boolean);
  53087. /**
  53088. * Gets wether the color grading effect is enabled.
  53089. */
  53090. get cameraColorGradingEnabled(): boolean;
  53091. /**
  53092. * Gets wether the color grading effect is enabled.
  53093. */
  53094. set cameraColorGradingEnabled(value: boolean);
  53095. /**
  53096. * Gets wether tonemapping is enabled or not.
  53097. */
  53098. get cameraToneMappingEnabled(): boolean;
  53099. /**
  53100. * Sets wether tonemapping is enabled or not
  53101. */
  53102. set cameraToneMappingEnabled(value: boolean);
  53103. /**
  53104. * The camera exposure used on this material.
  53105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53106. * This corresponds to a photographic exposure.
  53107. */
  53108. get cameraExposure(): float;
  53109. /**
  53110. * The camera exposure used on this material.
  53111. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53112. * This corresponds to a photographic exposure.
  53113. */
  53114. set cameraExposure(value: float);
  53115. /**
  53116. * Gets The camera contrast used on this material.
  53117. */
  53118. get cameraContrast(): float;
  53119. /**
  53120. * Sets The camera contrast used on this material.
  53121. */
  53122. set cameraContrast(value: float);
  53123. /**
  53124. * Gets the Color Grading 2D Lookup Texture.
  53125. */
  53126. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53127. /**
  53128. * Sets the Color Grading 2D Lookup Texture.
  53129. */
  53130. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53131. /**
  53132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53134. * 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;
  53135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53136. */
  53137. get cameraColorCurves(): Nullable<ColorCurves>;
  53138. /**
  53139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53141. * 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;
  53142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53143. */
  53144. set cameraColorCurves(value: Nullable<ColorCurves>);
  53145. /**
  53146. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53147. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53148. */
  53149. switchToBGR: boolean;
  53150. private _renderTargets;
  53151. private _reflectionControls;
  53152. private _white;
  53153. private _primaryShadowColor;
  53154. private _primaryHighlightColor;
  53155. /**
  53156. * Instantiates a Background Material in the given scene
  53157. * @param name The friendly name of the material
  53158. * @param scene The scene to add the material to
  53159. */
  53160. constructor(name: string, scene: Scene);
  53161. /**
  53162. * Gets a boolean indicating that current material needs to register RTT
  53163. */
  53164. get hasRenderTargetTextures(): boolean;
  53165. /**
  53166. * The entire material has been created in order to prevent overdraw.
  53167. * @returns false
  53168. */
  53169. needAlphaTesting(): boolean;
  53170. /**
  53171. * The entire material has been created in order to prevent overdraw.
  53172. * @returns true if blending is enable
  53173. */
  53174. needAlphaBlending(): boolean;
  53175. /**
  53176. * Checks wether the material is ready to be rendered for a given mesh.
  53177. * @param mesh The mesh to render
  53178. * @param subMesh The submesh to check against
  53179. * @param useInstances Specify wether or not the material is used with instances
  53180. * @returns true if all the dependencies are ready (Textures, Effects...)
  53181. */
  53182. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53183. /**
  53184. * Compute the primary color according to the chosen perceptual color.
  53185. */
  53186. private _computePrimaryColorFromPerceptualColor;
  53187. /**
  53188. * Compute the highlights and shadow colors according to their chosen levels.
  53189. */
  53190. private _computePrimaryColors;
  53191. /**
  53192. * Build the uniform buffer used in the material.
  53193. */
  53194. buildUniformLayout(): void;
  53195. /**
  53196. * Unbind the material.
  53197. */
  53198. unbind(): void;
  53199. /**
  53200. * Bind only the world matrix to the material.
  53201. * @param world The world matrix to bind.
  53202. */
  53203. bindOnlyWorldMatrix(world: Matrix): void;
  53204. /**
  53205. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53206. * @param world The world matrix to bind.
  53207. * @param subMesh The submesh to bind for.
  53208. */
  53209. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53210. /**
  53211. * Checks to see if a texture is used in the material.
  53212. * @param texture - Base texture to use.
  53213. * @returns - Boolean specifying if a texture is used in the material.
  53214. */
  53215. hasTexture(texture: BaseTexture): boolean;
  53216. /**
  53217. * Dispose the material.
  53218. * @param forceDisposeEffect Force disposal of the associated effect.
  53219. * @param forceDisposeTextures Force disposal of the associated textures.
  53220. */
  53221. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53222. /**
  53223. * Clones the material.
  53224. * @param name The cloned name.
  53225. * @returns The cloned material.
  53226. */
  53227. clone(name: string): BackgroundMaterial;
  53228. /**
  53229. * Serializes the current material to its JSON representation.
  53230. * @returns The JSON representation.
  53231. */
  53232. serialize(): any;
  53233. /**
  53234. * Gets the class name of the material
  53235. * @returns "BackgroundMaterial"
  53236. */
  53237. getClassName(): string;
  53238. /**
  53239. * Parse a JSON input to create back a background material.
  53240. * @param source The JSON data to parse
  53241. * @param scene The scene to create the parsed material in
  53242. * @param rootUrl The root url of the assets the material depends upon
  53243. * @returns the instantiated BackgroundMaterial.
  53244. */
  53245. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53246. }
  53247. }
  53248. declare module BABYLON {
  53249. /**
  53250. * Represents the different options available during the creation of
  53251. * a Environment helper.
  53252. *
  53253. * This can control the default ground, skybox and image processing setup of your scene.
  53254. */
  53255. export interface IEnvironmentHelperOptions {
  53256. /**
  53257. * Specifies whether or not to create a ground.
  53258. * True by default.
  53259. */
  53260. createGround: boolean;
  53261. /**
  53262. * Specifies the ground size.
  53263. * 15 by default.
  53264. */
  53265. groundSize: number;
  53266. /**
  53267. * The texture used on the ground for the main color.
  53268. * Comes from the BabylonJS CDN by default.
  53269. *
  53270. * Remarks: Can be either a texture or a url.
  53271. */
  53272. groundTexture: string | BaseTexture;
  53273. /**
  53274. * The color mixed in the ground texture by default.
  53275. * BabylonJS clearColor by default.
  53276. */
  53277. groundColor: Color3;
  53278. /**
  53279. * Specifies the ground opacity.
  53280. * 1 by default.
  53281. */
  53282. groundOpacity: number;
  53283. /**
  53284. * Enables the ground to receive shadows.
  53285. * True by default.
  53286. */
  53287. enableGroundShadow: boolean;
  53288. /**
  53289. * Helps preventing the shadow to be fully black on the ground.
  53290. * 0.5 by default.
  53291. */
  53292. groundShadowLevel: number;
  53293. /**
  53294. * Creates a mirror texture attach to the ground.
  53295. * false by default.
  53296. */
  53297. enableGroundMirror: boolean;
  53298. /**
  53299. * Specifies the ground mirror size ratio.
  53300. * 0.3 by default as the default kernel is 64.
  53301. */
  53302. groundMirrorSizeRatio: number;
  53303. /**
  53304. * Specifies the ground mirror blur kernel size.
  53305. * 64 by default.
  53306. */
  53307. groundMirrorBlurKernel: number;
  53308. /**
  53309. * Specifies the ground mirror visibility amount.
  53310. * 1 by default
  53311. */
  53312. groundMirrorAmount: number;
  53313. /**
  53314. * Specifies the ground mirror reflectance weight.
  53315. * This uses the standard weight of the background material to setup the fresnel effect
  53316. * of the mirror.
  53317. * 1 by default.
  53318. */
  53319. groundMirrorFresnelWeight: number;
  53320. /**
  53321. * Specifies the ground mirror Falloff distance.
  53322. * This can helps reducing the size of the reflection.
  53323. * 0 by Default.
  53324. */
  53325. groundMirrorFallOffDistance: number;
  53326. /**
  53327. * Specifies the ground mirror texture type.
  53328. * Unsigned Int by Default.
  53329. */
  53330. groundMirrorTextureType: number;
  53331. /**
  53332. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53333. * the shown objects.
  53334. */
  53335. groundYBias: number;
  53336. /**
  53337. * Specifies whether or not to create a skybox.
  53338. * True by default.
  53339. */
  53340. createSkybox: boolean;
  53341. /**
  53342. * Specifies the skybox size.
  53343. * 20 by default.
  53344. */
  53345. skyboxSize: number;
  53346. /**
  53347. * The texture used on the skybox for the main color.
  53348. * Comes from the BabylonJS CDN by default.
  53349. *
  53350. * Remarks: Can be either a texture or a url.
  53351. */
  53352. skyboxTexture: string | BaseTexture;
  53353. /**
  53354. * The color mixed in the skybox texture by default.
  53355. * BabylonJS clearColor by default.
  53356. */
  53357. skyboxColor: Color3;
  53358. /**
  53359. * The background rotation around the Y axis of the scene.
  53360. * This helps aligning the key lights of your scene with the background.
  53361. * 0 by default.
  53362. */
  53363. backgroundYRotation: number;
  53364. /**
  53365. * Compute automatically the size of the elements to best fit with the scene.
  53366. */
  53367. sizeAuto: boolean;
  53368. /**
  53369. * Default position of the rootMesh if autoSize is not true.
  53370. */
  53371. rootPosition: Vector3;
  53372. /**
  53373. * Sets up the image processing in the scene.
  53374. * true by default.
  53375. */
  53376. setupImageProcessing: boolean;
  53377. /**
  53378. * The texture used as your environment texture in the scene.
  53379. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53380. *
  53381. * Remarks: Can be either a texture or a url.
  53382. */
  53383. environmentTexture: string | BaseTexture;
  53384. /**
  53385. * The value of the exposure to apply to the scene.
  53386. * 0.6 by default if setupImageProcessing is true.
  53387. */
  53388. cameraExposure: number;
  53389. /**
  53390. * The value of the contrast to apply to the scene.
  53391. * 1.6 by default if setupImageProcessing is true.
  53392. */
  53393. cameraContrast: number;
  53394. /**
  53395. * Specifies whether or not tonemapping should be enabled in the scene.
  53396. * true by default if setupImageProcessing is true.
  53397. */
  53398. toneMappingEnabled: boolean;
  53399. }
  53400. /**
  53401. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53402. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53403. * It also helps with the default setup of your imageProcessing configuration.
  53404. */
  53405. export class EnvironmentHelper {
  53406. /**
  53407. * Default ground texture URL.
  53408. */
  53409. private static _groundTextureCDNUrl;
  53410. /**
  53411. * Default skybox texture URL.
  53412. */
  53413. private static _skyboxTextureCDNUrl;
  53414. /**
  53415. * Default environment texture URL.
  53416. */
  53417. private static _environmentTextureCDNUrl;
  53418. /**
  53419. * Creates the default options for the helper.
  53420. */
  53421. private static _getDefaultOptions;
  53422. private _rootMesh;
  53423. /**
  53424. * Gets the root mesh created by the helper.
  53425. */
  53426. get rootMesh(): Mesh;
  53427. private _skybox;
  53428. /**
  53429. * Gets the skybox created by the helper.
  53430. */
  53431. get skybox(): Nullable<Mesh>;
  53432. private _skyboxTexture;
  53433. /**
  53434. * Gets the skybox texture created by the helper.
  53435. */
  53436. get skyboxTexture(): Nullable<BaseTexture>;
  53437. private _skyboxMaterial;
  53438. /**
  53439. * Gets the skybox material created by the helper.
  53440. */
  53441. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53442. private _ground;
  53443. /**
  53444. * Gets the ground mesh created by the helper.
  53445. */
  53446. get ground(): Nullable<Mesh>;
  53447. private _groundTexture;
  53448. /**
  53449. * Gets the ground texture created by the helper.
  53450. */
  53451. get groundTexture(): Nullable<BaseTexture>;
  53452. private _groundMirror;
  53453. /**
  53454. * Gets the ground mirror created by the helper.
  53455. */
  53456. get groundMirror(): Nullable<MirrorTexture>;
  53457. /**
  53458. * Gets the ground mirror render list to helps pushing the meshes
  53459. * you wish in the ground reflection.
  53460. */
  53461. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53462. private _groundMaterial;
  53463. /**
  53464. * Gets the ground material created by the helper.
  53465. */
  53466. get groundMaterial(): Nullable<BackgroundMaterial>;
  53467. /**
  53468. * Stores the creation options.
  53469. */
  53470. private readonly _scene;
  53471. private _options;
  53472. /**
  53473. * This observable will be notified with any error during the creation of the environment,
  53474. * mainly texture creation errors.
  53475. */
  53476. onErrorObservable: Observable<{
  53477. message?: string;
  53478. exception?: any;
  53479. }>;
  53480. /**
  53481. * constructor
  53482. * @param options Defines the options we want to customize the helper
  53483. * @param scene The scene to add the material to
  53484. */
  53485. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53486. /**
  53487. * Updates the background according to the new options
  53488. * @param options
  53489. */
  53490. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53491. /**
  53492. * Sets the primary color of all the available elements.
  53493. * @param color the main color to affect to the ground and the background
  53494. */
  53495. setMainColor(color: Color3): void;
  53496. /**
  53497. * Setup the image processing according to the specified options.
  53498. */
  53499. private _setupImageProcessing;
  53500. /**
  53501. * Setup the environment texture according to the specified options.
  53502. */
  53503. private _setupEnvironmentTexture;
  53504. /**
  53505. * Setup the background according to the specified options.
  53506. */
  53507. private _setupBackground;
  53508. /**
  53509. * Get the scene sizes according to the setup.
  53510. */
  53511. private _getSceneSize;
  53512. /**
  53513. * Setup the ground according to the specified options.
  53514. */
  53515. private _setupGround;
  53516. /**
  53517. * Setup the ground material according to the specified options.
  53518. */
  53519. private _setupGroundMaterial;
  53520. /**
  53521. * Setup the ground diffuse texture according to the specified options.
  53522. */
  53523. private _setupGroundDiffuseTexture;
  53524. /**
  53525. * Setup the ground mirror texture according to the specified options.
  53526. */
  53527. private _setupGroundMirrorTexture;
  53528. /**
  53529. * Setup the ground to receive the mirror texture.
  53530. */
  53531. private _setupMirrorInGroundMaterial;
  53532. /**
  53533. * Setup the skybox according to the specified options.
  53534. */
  53535. private _setupSkybox;
  53536. /**
  53537. * Setup the skybox material according to the specified options.
  53538. */
  53539. private _setupSkyboxMaterial;
  53540. /**
  53541. * Setup the skybox reflection texture according to the specified options.
  53542. */
  53543. private _setupSkyboxReflectionTexture;
  53544. private _errorHandler;
  53545. /**
  53546. * Dispose all the elements created by the Helper.
  53547. */
  53548. dispose(): void;
  53549. }
  53550. }
  53551. declare module BABYLON {
  53552. /**
  53553. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53554. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53555. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53556. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53557. */
  53558. export class PhotoDome extends TransformNode {
  53559. /**
  53560. * Define the image as a Monoscopic panoramic 360 image.
  53561. */
  53562. static readonly MODE_MONOSCOPIC: number;
  53563. /**
  53564. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53565. */
  53566. static readonly MODE_TOPBOTTOM: number;
  53567. /**
  53568. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53569. */
  53570. static readonly MODE_SIDEBYSIDE: number;
  53571. private _useDirectMapping;
  53572. /**
  53573. * The texture being displayed on the sphere
  53574. */
  53575. protected _photoTexture: Texture;
  53576. /**
  53577. * Gets or sets the texture being displayed on the sphere
  53578. */
  53579. get photoTexture(): Texture;
  53580. set photoTexture(value: Texture);
  53581. /**
  53582. * Observable raised when an error occured while loading the 360 image
  53583. */
  53584. onLoadErrorObservable: Observable<string>;
  53585. /**
  53586. * The skybox material
  53587. */
  53588. protected _material: BackgroundMaterial;
  53589. /**
  53590. * The surface used for the skybox
  53591. */
  53592. protected _mesh: Mesh;
  53593. /**
  53594. * Gets the mesh used for the skybox.
  53595. */
  53596. get mesh(): Mesh;
  53597. /**
  53598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53599. * Also see the options.resolution property.
  53600. */
  53601. get fovMultiplier(): number;
  53602. set fovMultiplier(value: number);
  53603. private _imageMode;
  53604. /**
  53605. * Gets or set the current video mode for the video. It can be:
  53606. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53607. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53608. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53609. */
  53610. get imageMode(): number;
  53611. set imageMode(value: number);
  53612. /**
  53613. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53614. * @param name Element's name, child elements will append suffixes for their own names.
  53615. * @param urlsOfPhoto defines the url of the photo to display
  53616. * @param options defines an object containing optional or exposed sub element properties
  53617. * @param onError defines a callback called when an error occured while loading the texture
  53618. */
  53619. constructor(name: string, urlOfPhoto: string, options: {
  53620. resolution?: number;
  53621. size?: number;
  53622. useDirectMapping?: boolean;
  53623. faceForward?: boolean;
  53624. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53625. private _onBeforeCameraRenderObserver;
  53626. private _changeImageMode;
  53627. /**
  53628. * Releases resources associated with this node.
  53629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53631. */
  53632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53633. }
  53634. }
  53635. declare module BABYLON {
  53636. /**
  53637. * Class used to host RGBD texture specific utilities
  53638. */
  53639. export class RGBDTextureTools {
  53640. /**
  53641. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53642. * @param texture the texture to expand.
  53643. */
  53644. static ExpandRGBDTexture(texture: Texture): void;
  53645. }
  53646. }
  53647. declare module BABYLON {
  53648. /**
  53649. * Class used to host texture specific utilities
  53650. */
  53651. export class BRDFTextureTools {
  53652. /**
  53653. * Prevents texture cache collision
  53654. */
  53655. private static _instanceNumber;
  53656. /**
  53657. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53658. * @param scene defines the hosting scene
  53659. * @returns the environment BRDF texture
  53660. */
  53661. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53662. private static _environmentBRDFBase64Texture;
  53663. }
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * @hidden
  53668. */
  53669. export interface IMaterialClearCoatDefines {
  53670. CLEARCOAT: boolean;
  53671. CLEARCOAT_DEFAULTIOR: boolean;
  53672. CLEARCOAT_TEXTURE: boolean;
  53673. CLEARCOAT_TEXTUREDIRECTUV: number;
  53674. CLEARCOAT_BUMP: boolean;
  53675. CLEARCOAT_BUMPDIRECTUV: number;
  53676. CLEARCOAT_TINT: boolean;
  53677. CLEARCOAT_TINT_TEXTURE: boolean;
  53678. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53679. /** @hidden */
  53680. _areTexturesDirty: boolean;
  53681. }
  53682. /**
  53683. * Define the code related to the clear coat parameters of the pbr material.
  53684. */
  53685. export class PBRClearCoatConfiguration {
  53686. /**
  53687. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53688. * The default fits with a polyurethane material.
  53689. */
  53690. private static readonly _DefaultIndexOfRefraction;
  53691. private _isEnabled;
  53692. /**
  53693. * Defines if the clear coat is enabled in the material.
  53694. */
  53695. isEnabled: boolean;
  53696. /**
  53697. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53698. */
  53699. intensity: number;
  53700. /**
  53701. * Defines the clear coat layer roughness.
  53702. */
  53703. roughness: number;
  53704. private _indexOfRefraction;
  53705. /**
  53706. * Defines the index of refraction of the clear coat.
  53707. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53708. * The default fits with a polyurethane material.
  53709. * Changing the default value is more performance intensive.
  53710. */
  53711. indexOfRefraction: number;
  53712. private _texture;
  53713. /**
  53714. * Stores the clear coat values in a texture.
  53715. */
  53716. texture: Nullable<BaseTexture>;
  53717. private _bumpTexture;
  53718. /**
  53719. * Define the clear coat specific bump texture.
  53720. */
  53721. bumpTexture: Nullable<BaseTexture>;
  53722. private _isTintEnabled;
  53723. /**
  53724. * Defines if the clear coat tint is enabled in the material.
  53725. */
  53726. isTintEnabled: boolean;
  53727. /**
  53728. * Defines the clear coat tint of the material.
  53729. * This is only use if tint is enabled
  53730. */
  53731. tintColor: Color3;
  53732. /**
  53733. * Defines the distance at which the tint color should be found in the
  53734. * clear coat media.
  53735. * This is only use if tint is enabled
  53736. */
  53737. tintColorAtDistance: number;
  53738. /**
  53739. * Defines the clear coat layer thickness.
  53740. * This is only use if tint is enabled
  53741. */
  53742. tintThickness: number;
  53743. private _tintTexture;
  53744. /**
  53745. * Stores the clear tint values in a texture.
  53746. * rgb is tint
  53747. * a is a thickness factor
  53748. */
  53749. tintTexture: Nullable<BaseTexture>;
  53750. /** @hidden */
  53751. private _internalMarkAllSubMeshesAsTexturesDirty;
  53752. /** @hidden */
  53753. _markAllSubMeshesAsTexturesDirty(): void;
  53754. /**
  53755. * Instantiate a new istance of clear coat configuration.
  53756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53757. */
  53758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53759. /**
  53760. * Gets wehter the submesh is ready to be used or not.
  53761. * @param defines the list of "defines" to update.
  53762. * @param scene defines the scene the material belongs to.
  53763. * @param engine defines the engine the material belongs to.
  53764. * @param disableBumpMap defines wether the material disables bump or not.
  53765. * @returns - boolean indicating that the submesh is ready or not.
  53766. */
  53767. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53768. /**
  53769. * Checks to see if a texture is used in the material.
  53770. * @param defines the list of "defines" to update.
  53771. * @param scene defines the scene to the material belongs to.
  53772. */
  53773. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53774. /**
  53775. * Binds the material data.
  53776. * @param uniformBuffer defines the Uniform buffer to fill in.
  53777. * @param scene defines the scene the material belongs to.
  53778. * @param engine defines the engine the material belongs to.
  53779. * @param disableBumpMap defines wether the material disables bump or not.
  53780. * @param isFrozen defines wether the material is frozen or not.
  53781. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53782. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53783. */
  53784. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53785. /**
  53786. * Checks to see if a texture is used in the material.
  53787. * @param texture - Base texture to use.
  53788. * @returns - Boolean specifying if a texture is used in the material.
  53789. */
  53790. hasTexture(texture: BaseTexture): boolean;
  53791. /**
  53792. * Returns an array of the actively used textures.
  53793. * @param activeTextures Array of BaseTextures
  53794. */
  53795. getActiveTextures(activeTextures: BaseTexture[]): void;
  53796. /**
  53797. * Returns the animatable textures.
  53798. * @param animatables Array of animatable textures.
  53799. */
  53800. getAnimatables(animatables: IAnimatable[]): void;
  53801. /**
  53802. * Disposes the resources of the material.
  53803. * @param forceDisposeTextures - Forces the disposal of all textures.
  53804. */
  53805. dispose(forceDisposeTextures?: boolean): void;
  53806. /**
  53807. * Get the current class name of the texture useful for serialization or dynamic coding.
  53808. * @returns "PBRClearCoatConfiguration"
  53809. */
  53810. getClassName(): string;
  53811. /**
  53812. * Add fallbacks to the effect fallbacks list.
  53813. * @param defines defines the Base texture to use.
  53814. * @param fallbacks defines the current fallback list.
  53815. * @param currentRank defines the current fallback rank.
  53816. * @returns the new fallback rank.
  53817. */
  53818. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53819. /**
  53820. * Add the required uniforms to the current list.
  53821. * @param uniforms defines the current uniform list.
  53822. */
  53823. static AddUniforms(uniforms: string[]): void;
  53824. /**
  53825. * Add the required samplers to the current list.
  53826. * @param samplers defines the current sampler list.
  53827. */
  53828. static AddSamplers(samplers: string[]): void;
  53829. /**
  53830. * Add the required uniforms to the current buffer.
  53831. * @param uniformBuffer defines the current uniform buffer.
  53832. */
  53833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53834. /**
  53835. * Makes a duplicate of the current configuration into another one.
  53836. * @param clearCoatConfiguration define the config where to copy the info
  53837. */
  53838. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53839. /**
  53840. * Serializes this clear coat configuration.
  53841. * @returns - An object with the serialized config.
  53842. */
  53843. serialize(): any;
  53844. /**
  53845. * Parses a anisotropy Configuration from a serialized object.
  53846. * @param source - Serialized object.
  53847. * @param scene Defines the scene we are parsing for
  53848. * @param rootUrl Defines the rootUrl to load from
  53849. */
  53850. parse(source: any, scene: Scene, rootUrl: string): void;
  53851. }
  53852. }
  53853. declare module BABYLON {
  53854. /**
  53855. * @hidden
  53856. */
  53857. export interface IMaterialAnisotropicDefines {
  53858. ANISOTROPIC: boolean;
  53859. ANISOTROPIC_TEXTURE: boolean;
  53860. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53861. MAINUV1: boolean;
  53862. _areTexturesDirty: boolean;
  53863. _needUVs: boolean;
  53864. }
  53865. /**
  53866. * Define the code related to the anisotropic parameters of the pbr material.
  53867. */
  53868. export class PBRAnisotropicConfiguration {
  53869. private _isEnabled;
  53870. /**
  53871. * Defines if the anisotropy is enabled in the material.
  53872. */
  53873. isEnabled: boolean;
  53874. /**
  53875. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53876. */
  53877. intensity: number;
  53878. /**
  53879. * Defines if the effect is along the tangents, bitangents or in between.
  53880. * By default, the effect is "strectching" the highlights along the tangents.
  53881. */
  53882. direction: Vector2;
  53883. private _texture;
  53884. /**
  53885. * Stores the anisotropy values in a texture.
  53886. * rg is direction (like normal from -1 to 1)
  53887. * b is a intensity
  53888. */
  53889. texture: Nullable<BaseTexture>;
  53890. /** @hidden */
  53891. private _internalMarkAllSubMeshesAsTexturesDirty;
  53892. /** @hidden */
  53893. _markAllSubMeshesAsTexturesDirty(): void;
  53894. /**
  53895. * Instantiate a new istance of anisotropy configuration.
  53896. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53897. */
  53898. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53899. /**
  53900. * Specifies that the submesh is ready to be used.
  53901. * @param defines the list of "defines" to update.
  53902. * @param scene defines the scene the material belongs to.
  53903. * @returns - boolean indicating that the submesh is ready or not.
  53904. */
  53905. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53906. /**
  53907. * Checks to see if a texture is used in the material.
  53908. * @param defines the list of "defines" to update.
  53909. * @param mesh the mesh we are preparing the defines for.
  53910. * @param scene defines the scene the material belongs to.
  53911. */
  53912. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53913. /**
  53914. * Binds the material data.
  53915. * @param uniformBuffer defines the Uniform buffer to fill in.
  53916. * @param scene defines the scene the material belongs to.
  53917. * @param isFrozen defines wether the material is frozen or not.
  53918. */
  53919. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53920. /**
  53921. * Checks to see if a texture is used in the material.
  53922. * @param texture - Base texture to use.
  53923. * @returns - Boolean specifying if a texture is used in the material.
  53924. */
  53925. hasTexture(texture: BaseTexture): boolean;
  53926. /**
  53927. * Returns an array of the actively used textures.
  53928. * @param activeTextures Array of BaseTextures
  53929. */
  53930. getActiveTextures(activeTextures: BaseTexture[]): void;
  53931. /**
  53932. * Returns the animatable textures.
  53933. * @param animatables Array of animatable textures.
  53934. */
  53935. getAnimatables(animatables: IAnimatable[]): void;
  53936. /**
  53937. * Disposes the resources of the material.
  53938. * @param forceDisposeTextures - Forces the disposal of all textures.
  53939. */
  53940. dispose(forceDisposeTextures?: boolean): void;
  53941. /**
  53942. * Get the current class name of the texture useful for serialization or dynamic coding.
  53943. * @returns "PBRAnisotropicConfiguration"
  53944. */
  53945. getClassName(): string;
  53946. /**
  53947. * Add fallbacks to the effect fallbacks list.
  53948. * @param defines defines the Base texture to use.
  53949. * @param fallbacks defines the current fallback list.
  53950. * @param currentRank defines the current fallback rank.
  53951. * @returns the new fallback rank.
  53952. */
  53953. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53954. /**
  53955. * Add the required uniforms to the current list.
  53956. * @param uniforms defines the current uniform list.
  53957. */
  53958. static AddUniforms(uniforms: string[]): void;
  53959. /**
  53960. * Add the required uniforms to the current buffer.
  53961. * @param uniformBuffer defines the current uniform buffer.
  53962. */
  53963. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53964. /**
  53965. * Add the required samplers to the current list.
  53966. * @param samplers defines the current sampler list.
  53967. */
  53968. static AddSamplers(samplers: string[]): void;
  53969. /**
  53970. * Makes a duplicate of the current configuration into another one.
  53971. * @param anisotropicConfiguration define the config where to copy the info
  53972. */
  53973. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53974. /**
  53975. * Serializes this anisotropy configuration.
  53976. * @returns - An object with the serialized config.
  53977. */
  53978. serialize(): any;
  53979. /**
  53980. * Parses a anisotropy Configuration from a serialized object.
  53981. * @param source - Serialized object.
  53982. * @param scene Defines the scene we are parsing for
  53983. * @param rootUrl Defines the rootUrl to load from
  53984. */
  53985. parse(source: any, scene: Scene, rootUrl: string): void;
  53986. }
  53987. }
  53988. declare module BABYLON {
  53989. /**
  53990. * @hidden
  53991. */
  53992. export interface IMaterialBRDFDefines {
  53993. BRDF_V_HEIGHT_CORRELATED: boolean;
  53994. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53995. SPHERICAL_HARMONICS: boolean;
  53996. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53997. /** @hidden */
  53998. _areMiscDirty: boolean;
  53999. }
  54000. /**
  54001. * Define the code related to the BRDF parameters of the pbr material.
  54002. */
  54003. export class PBRBRDFConfiguration {
  54004. /**
  54005. * Default value used for the energy conservation.
  54006. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54007. */
  54008. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54009. /**
  54010. * Default value used for the Smith Visibility Height Correlated mode.
  54011. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54012. */
  54013. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54014. /**
  54015. * Default value used for the IBL diffuse part.
  54016. * This can help switching back to the polynomials mode globally which is a tiny bit
  54017. * less GPU intensive at the drawback of a lower quality.
  54018. */
  54019. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54020. /**
  54021. * Default value used for activating energy conservation for the specular workflow.
  54022. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54023. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54024. */
  54025. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54026. private _useEnergyConservation;
  54027. /**
  54028. * Defines if the material uses energy conservation.
  54029. */
  54030. useEnergyConservation: boolean;
  54031. private _useSmithVisibilityHeightCorrelated;
  54032. /**
  54033. * LEGACY Mode set to false
  54034. * Defines if the material uses height smith correlated visibility term.
  54035. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54036. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54037. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54038. * Not relying on height correlated will also disable energy conservation.
  54039. */
  54040. useSmithVisibilityHeightCorrelated: boolean;
  54041. private _useSphericalHarmonics;
  54042. /**
  54043. * LEGACY Mode set to false
  54044. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54045. * diffuse part of the IBL.
  54046. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54047. * to the ground truth.
  54048. */
  54049. useSphericalHarmonics: boolean;
  54050. private _useSpecularGlossinessInputEnergyConservation;
  54051. /**
  54052. * Defines if the material uses energy conservation, when the specular workflow is active.
  54053. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54054. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54055. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54056. */
  54057. useSpecularGlossinessInputEnergyConservation: boolean;
  54058. /** @hidden */
  54059. private _internalMarkAllSubMeshesAsMiscDirty;
  54060. /** @hidden */
  54061. _markAllSubMeshesAsMiscDirty(): void;
  54062. /**
  54063. * Instantiate a new istance of clear coat configuration.
  54064. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54065. */
  54066. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54067. /**
  54068. * Checks to see if a texture is used in the material.
  54069. * @param defines the list of "defines" to update.
  54070. */
  54071. prepareDefines(defines: IMaterialBRDFDefines): void;
  54072. /**
  54073. * Get the current class name of the texture useful for serialization or dynamic coding.
  54074. * @returns "PBRClearCoatConfiguration"
  54075. */
  54076. getClassName(): string;
  54077. /**
  54078. * Makes a duplicate of the current configuration into another one.
  54079. * @param brdfConfiguration define the config where to copy the info
  54080. */
  54081. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54082. /**
  54083. * Serializes this BRDF configuration.
  54084. * @returns - An object with the serialized config.
  54085. */
  54086. serialize(): any;
  54087. /**
  54088. * Parses a anisotropy Configuration from a serialized object.
  54089. * @param source - Serialized object.
  54090. * @param scene Defines the scene we are parsing for
  54091. * @param rootUrl Defines the rootUrl to load from
  54092. */
  54093. parse(source: any, scene: Scene, rootUrl: string): void;
  54094. }
  54095. }
  54096. declare module BABYLON {
  54097. /**
  54098. * @hidden
  54099. */
  54100. export interface IMaterialSheenDefines {
  54101. SHEEN: boolean;
  54102. SHEEN_TEXTURE: boolean;
  54103. SHEEN_TEXTUREDIRECTUV: number;
  54104. SHEEN_LINKWITHALBEDO: boolean;
  54105. SHEEN_ROUGHNESS: boolean;
  54106. SHEEN_ALBEDOSCALING: boolean;
  54107. /** @hidden */
  54108. _areTexturesDirty: boolean;
  54109. }
  54110. /**
  54111. * Define the code related to the Sheen parameters of the pbr material.
  54112. */
  54113. export class PBRSheenConfiguration {
  54114. private _isEnabled;
  54115. /**
  54116. * Defines if the material uses sheen.
  54117. */
  54118. isEnabled: boolean;
  54119. private _linkSheenWithAlbedo;
  54120. /**
  54121. * Defines if the sheen is linked to the sheen color.
  54122. */
  54123. linkSheenWithAlbedo: boolean;
  54124. /**
  54125. * Defines the sheen intensity.
  54126. */
  54127. intensity: number;
  54128. /**
  54129. * Defines the sheen color.
  54130. */
  54131. color: Color3;
  54132. private _texture;
  54133. /**
  54134. * Stores the sheen tint values in a texture.
  54135. * rgb is tint
  54136. * a is a intensity
  54137. */
  54138. texture: Nullable<BaseTexture>;
  54139. private _roughness;
  54140. /**
  54141. * Defines the sheen roughness.
  54142. * It is not taken into account if linkSheenWithAlbedo is true.
  54143. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54144. */
  54145. roughness: Nullable<number>;
  54146. private _albedoScaling;
  54147. /**
  54148. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54149. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54150. * making it easier to setup and tweak the effect
  54151. */
  54152. albedoScaling: boolean;
  54153. /** @hidden */
  54154. private _internalMarkAllSubMeshesAsTexturesDirty;
  54155. /** @hidden */
  54156. _markAllSubMeshesAsTexturesDirty(): void;
  54157. /**
  54158. * Instantiate a new istance of clear coat configuration.
  54159. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54160. */
  54161. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54162. /**
  54163. * Specifies that the submesh is ready to be used.
  54164. * @param defines the list of "defines" to update.
  54165. * @param scene defines the scene the material belongs to.
  54166. * @returns - boolean indicating that the submesh is ready or not.
  54167. */
  54168. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54169. /**
  54170. * Checks to see if a texture is used in the material.
  54171. * @param defines the list of "defines" to update.
  54172. * @param scene defines the scene the material belongs to.
  54173. */
  54174. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54175. /**
  54176. * Binds the material data.
  54177. * @param uniformBuffer defines the Uniform buffer to fill in.
  54178. * @param scene defines the scene the material belongs to.
  54179. * @param isFrozen defines wether the material is frozen or not.
  54180. */
  54181. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54182. /**
  54183. * Checks to see if a texture is used in the material.
  54184. * @param texture - Base texture to use.
  54185. * @returns - Boolean specifying if a texture is used in the material.
  54186. */
  54187. hasTexture(texture: BaseTexture): boolean;
  54188. /**
  54189. * Returns an array of the actively used textures.
  54190. * @param activeTextures Array of BaseTextures
  54191. */
  54192. getActiveTextures(activeTextures: BaseTexture[]): void;
  54193. /**
  54194. * Returns the animatable textures.
  54195. * @param animatables Array of animatable textures.
  54196. */
  54197. getAnimatables(animatables: IAnimatable[]): void;
  54198. /**
  54199. * Disposes the resources of the material.
  54200. * @param forceDisposeTextures - Forces the disposal of all textures.
  54201. */
  54202. dispose(forceDisposeTextures?: boolean): void;
  54203. /**
  54204. * Get the current class name of the texture useful for serialization or dynamic coding.
  54205. * @returns "PBRSheenConfiguration"
  54206. */
  54207. getClassName(): string;
  54208. /**
  54209. * Add fallbacks to the effect fallbacks list.
  54210. * @param defines defines the Base texture to use.
  54211. * @param fallbacks defines the current fallback list.
  54212. * @param currentRank defines the current fallback rank.
  54213. * @returns the new fallback rank.
  54214. */
  54215. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54216. /**
  54217. * Add the required uniforms to the current list.
  54218. * @param uniforms defines the current uniform list.
  54219. */
  54220. static AddUniforms(uniforms: string[]): void;
  54221. /**
  54222. * Add the required uniforms to the current buffer.
  54223. * @param uniformBuffer defines the current uniform buffer.
  54224. */
  54225. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54226. /**
  54227. * Add the required samplers to the current list.
  54228. * @param samplers defines the current sampler list.
  54229. */
  54230. static AddSamplers(samplers: string[]): void;
  54231. /**
  54232. * Makes a duplicate of the current configuration into another one.
  54233. * @param sheenConfiguration define the config where to copy the info
  54234. */
  54235. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54236. /**
  54237. * Serializes this BRDF configuration.
  54238. * @returns - An object with the serialized config.
  54239. */
  54240. serialize(): any;
  54241. /**
  54242. * Parses a anisotropy Configuration from a serialized object.
  54243. * @param source - Serialized object.
  54244. * @param scene Defines the scene we are parsing for
  54245. * @param rootUrl Defines the rootUrl to load from
  54246. */
  54247. parse(source: any, scene: Scene, rootUrl: string): void;
  54248. }
  54249. }
  54250. declare module BABYLON {
  54251. /**
  54252. * @hidden
  54253. */
  54254. export interface IMaterialSubSurfaceDefines {
  54255. SUBSURFACE: boolean;
  54256. SS_REFRACTION: boolean;
  54257. SS_TRANSLUCENCY: boolean;
  54258. SS_SCATTERING: boolean;
  54259. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54260. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54261. SS_REFRACTIONMAP_3D: boolean;
  54262. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54263. SS_LODINREFRACTIONALPHA: boolean;
  54264. SS_GAMMAREFRACTION: boolean;
  54265. SS_RGBDREFRACTION: boolean;
  54266. SS_LINEARSPECULARREFRACTION: boolean;
  54267. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54268. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54269. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54270. /** @hidden */
  54271. _areTexturesDirty: boolean;
  54272. }
  54273. /**
  54274. * Define the code related to the sub surface parameters of the pbr material.
  54275. */
  54276. export class PBRSubSurfaceConfiguration {
  54277. private _isRefractionEnabled;
  54278. /**
  54279. * Defines if the refraction is enabled in the material.
  54280. */
  54281. isRefractionEnabled: boolean;
  54282. private _isTranslucencyEnabled;
  54283. /**
  54284. * Defines if the translucency is enabled in the material.
  54285. */
  54286. isTranslucencyEnabled: boolean;
  54287. private _isScatteringEnabled;
  54288. /**
  54289. * Defines the refraction intensity of the material.
  54290. * The refraction when enabled replaces the Diffuse part of the material.
  54291. * The intensity helps transitionning between diffuse and refraction.
  54292. */
  54293. refractionIntensity: number;
  54294. /**
  54295. * Defines the translucency intensity of the material.
  54296. * When translucency has been enabled, this defines how much of the "translucency"
  54297. * is addded to the diffuse part of the material.
  54298. */
  54299. translucencyIntensity: number;
  54300. /**
  54301. * Defines the scattering intensity of the material.
  54302. * When scattering has been enabled, this defines how much of the "scattered light"
  54303. * is addded to the diffuse part of the material.
  54304. */
  54305. scatteringIntensity: number;
  54306. /**
  54307. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54308. */
  54309. useAlbedoToTintRefraction: boolean;
  54310. private _thicknessTexture;
  54311. /**
  54312. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54313. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54314. * 0 would mean minimumThickness
  54315. * 1 would mean maximumThickness
  54316. * The other channels might be use as a mask to vary the different effects intensity.
  54317. */
  54318. thicknessTexture: Nullable<BaseTexture>;
  54319. private _refractionTexture;
  54320. /**
  54321. * Defines the texture to use for refraction.
  54322. */
  54323. refractionTexture: Nullable<BaseTexture>;
  54324. private _indexOfRefraction;
  54325. /**
  54326. * Index of refraction of the material base layer.
  54327. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54328. *
  54329. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54330. *
  54331. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54332. */
  54333. indexOfRefraction: number;
  54334. private _volumeIndexOfRefraction;
  54335. /**
  54336. * Index of refraction of the material's volume.
  54337. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54338. *
  54339. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54340. * the volume will use the same IOR as the surface.
  54341. */
  54342. get volumeIndexOfRefraction(): number;
  54343. set volumeIndexOfRefraction(value: number);
  54344. private _invertRefractionY;
  54345. /**
  54346. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54347. */
  54348. invertRefractionY: boolean;
  54349. private _linkRefractionWithTransparency;
  54350. /**
  54351. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54352. * Materials half opaque for instance using refraction could benefit from this control.
  54353. */
  54354. linkRefractionWithTransparency: boolean;
  54355. /**
  54356. * Defines the minimum thickness stored in the thickness map.
  54357. * If no thickness map is defined, this value will be used to simulate thickness.
  54358. */
  54359. minimumThickness: number;
  54360. /**
  54361. * Defines the maximum thickness stored in the thickness map.
  54362. */
  54363. maximumThickness: number;
  54364. /**
  54365. * Defines the volume tint of the material.
  54366. * This is used for both translucency and scattering.
  54367. */
  54368. tintColor: Color3;
  54369. /**
  54370. * Defines the distance at which the tint color should be found in the media.
  54371. * This is used for refraction only.
  54372. */
  54373. tintColorAtDistance: number;
  54374. /**
  54375. * Defines how far each channel transmit through the media.
  54376. * It is defined as a color to simplify it selection.
  54377. */
  54378. diffusionDistance: Color3;
  54379. private _useMaskFromThicknessTexture;
  54380. /**
  54381. * Stores the intensity of the different subsurface effects in the thickness texture.
  54382. * * the green channel is the translucency intensity.
  54383. * * the blue channel is the scattering intensity.
  54384. * * the alpha channel is the refraction intensity.
  54385. */
  54386. useMaskFromThicknessTexture: boolean;
  54387. /** @hidden */
  54388. private _internalMarkAllSubMeshesAsTexturesDirty;
  54389. /** @hidden */
  54390. _markAllSubMeshesAsTexturesDirty(): void;
  54391. /**
  54392. * Instantiate a new istance of sub surface configuration.
  54393. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54394. */
  54395. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54396. /**
  54397. * Gets wehter the submesh is ready to be used or not.
  54398. * @param defines the list of "defines" to update.
  54399. * @param scene defines the scene the material belongs to.
  54400. * @returns - boolean indicating that the submesh is ready or not.
  54401. */
  54402. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54403. /**
  54404. * Checks to see if a texture is used in the material.
  54405. * @param defines the list of "defines" to update.
  54406. * @param scene defines the scene to the material belongs to.
  54407. */
  54408. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54409. /**
  54410. * Binds the material data.
  54411. * @param uniformBuffer defines the Uniform buffer to fill in.
  54412. * @param scene defines the scene the material belongs to.
  54413. * @param engine defines the engine the material belongs to.
  54414. * @param isFrozen defines whether the material is frozen or not.
  54415. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54416. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54417. */
  54418. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54419. /**
  54420. * Unbinds the material from the mesh.
  54421. * @param activeEffect defines the effect that should be unbound from.
  54422. * @returns true if unbound, otherwise false
  54423. */
  54424. unbind(activeEffect: Effect): boolean;
  54425. /**
  54426. * Returns the texture used for refraction or null if none is used.
  54427. * @param scene defines the scene the material belongs to.
  54428. * @returns - Refraction texture if present. If no refraction texture and refraction
  54429. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54430. */
  54431. private _getRefractionTexture;
  54432. /**
  54433. * Returns true if alpha blending should be disabled.
  54434. */
  54435. get disableAlphaBlending(): boolean;
  54436. /**
  54437. * Fills the list of render target textures.
  54438. * @param renderTargets the list of render targets to update
  54439. */
  54440. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54441. /**
  54442. * Checks to see if a texture is used in the material.
  54443. * @param texture - Base texture to use.
  54444. * @returns - Boolean specifying if a texture is used in the material.
  54445. */
  54446. hasTexture(texture: BaseTexture): boolean;
  54447. /**
  54448. * Gets a boolean indicating that current material needs to register RTT
  54449. * @returns true if this uses a render target otherwise false.
  54450. */
  54451. hasRenderTargetTextures(): boolean;
  54452. /**
  54453. * Returns an array of the actively used textures.
  54454. * @param activeTextures Array of BaseTextures
  54455. */
  54456. getActiveTextures(activeTextures: BaseTexture[]): void;
  54457. /**
  54458. * Returns the animatable textures.
  54459. * @param animatables Array of animatable textures.
  54460. */
  54461. getAnimatables(animatables: IAnimatable[]): void;
  54462. /**
  54463. * Disposes the resources of the material.
  54464. * @param forceDisposeTextures - Forces the disposal of all textures.
  54465. */
  54466. dispose(forceDisposeTextures?: boolean): void;
  54467. /**
  54468. * Get the current class name of the texture useful for serialization or dynamic coding.
  54469. * @returns "PBRSubSurfaceConfiguration"
  54470. */
  54471. getClassName(): string;
  54472. /**
  54473. * Add fallbacks to the effect fallbacks list.
  54474. * @param defines defines the Base texture to use.
  54475. * @param fallbacks defines the current fallback list.
  54476. * @param currentRank defines the current fallback rank.
  54477. * @returns the new fallback rank.
  54478. */
  54479. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54480. /**
  54481. * Add the required uniforms to the current list.
  54482. * @param uniforms defines the current uniform list.
  54483. */
  54484. static AddUniforms(uniforms: string[]): void;
  54485. /**
  54486. * Add the required samplers to the current list.
  54487. * @param samplers defines the current sampler list.
  54488. */
  54489. static AddSamplers(samplers: string[]): void;
  54490. /**
  54491. * Add the required uniforms to the current buffer.
  54492. * @param uniformBuffer defines the current uniform buffer.
  54493. */
  54494. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54495. /**
  54496. * Makes a duplicate of the current configuration into another one.
  54497. * @param configuration define the config where to copy the info
  54498. */
  54499. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54500. /**
  54501. * Serializes this Sub Surface configuration.
  54502. * @returns - An object with the serialized config.
  54503. */
  54504. serialize(): any;
  54505. /**
  54506. * Parses a anisotropy Configuration from a serialized object.
  54507. * @param source - Serialized object.
  54508. * @param scene Defines the scene we are parsing for
  54509. * @param rootUrl Defines the rootUrl to load from
  54510. */
  54511. parse(source: any, scene: Scene, rootUrl: string): void;
  54512. }
  54513. }
  54514. declare module BABYLON {
  54515. /** @hidden */
  54516. export var pbrFragmentDeclaration: {
  54517. name: string;
  54518. shader: string;
  54519. };
  54520. }
  54521. declare module BABYLON {
  54522. /** @hidden */
  54523. export var pbrUboDeclaration: {
  54524. name: string;
  54525. shader: string;
  54526. };
  54527. }
  54528. declare module BABYLON {
  54529. /** @hidden */
  54530. export var pbrFragmentExtraDeclaration: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module BABYLON {
  54536. /** @hidden */
  54537. export var pbrFragmentSamplersDeclaration: {
  54538. name: string;
  54539. shader: string;
  54540. };
  54541. }
  54542. declare module BABYLON {
  54543. /** @hidden */
  54544. export var importanceSampling: {
  54545. name: string;
  54546. shader: string;
  54547. };
  54548. }
  54549. declare module BABYLON {
  54550. /** @hidden */
  54551. export var pbrHelperFunctions: {
  54552. name: string;
  54553. shader: string;
  54554. };
  54555. }
  54556. declare module BABYLON {
  54557. /** @hidden */
  54558. export var harmonicsFunctions: {
  54559. name: string;
  54560. shader: string;
  54561. };
  54562. }
  54563. declare module BABYLON {
  54564. /** @hidden */
  54565. export var pbrDirectLightingSetupFunctions: {
  54566. name: string;
  54567. shader: string;
  54568. };
  54569. }
  54570. declare module BABYLON {
  54571. /** @hidden */
  54572. export var pbrDirectLightingFalloffFunctions: {
  54573. name: string;
  54574. shader: string;
  54575. };
  54576. }
  54577. declare module BABYLON {
  54578. /** @hidden */
  54579. export var pbrBRDFFunctions: {
  54580. name: string;
  54581. shader: string;
  54582. };
  54583. }
  54584. declare module BABYLON {
  54585. /** @hidden */
  54586. export var hdrFilteringFunctions: {
  54587. name: string;
  54588. shader: string;
  54589. };
  54590. }
  54591. declare module BABYLON {
  54592. /** @hidden */
  54593. export var pbrDirectLightingFunctions: {
  54594. name: string;
  54595. shader: string;
  54596. };
  54597. }
  54598. declare module BABYLON {
  54599. /** @hidden */
  54600. export var pbrIBLFunctions: {
  54601. name: string;
  54602. shader: string;
  54603. };
  54604. }
  54605. declare module BABYLON {
  54606. /** @hidden */
  54607. export var pbrBlockAlbedoOpacity: {
  54608. name: string;
  54609. shader: string;
  54610. };
  54611. }
  54612. declare module BABYLON {
  54613. /** @hidden */
  54614. export var pbrBlockReflectivity: {
  54615. name: string;
  54616. shader: string;
  54617. };
  54618. }
  54619. declare module BABYLON {
  54620. /** @hidden */
  54621. export var pbrBlockAmbientOcclusion: {
  54622. name: string;
  54623. shader: string;
  54624. };
  54625. }
  54626. declare module BABYLON {
  54627. /** @hidden */
  54628. export var pbrBlockAlphaFresnel: {
  54629. name: string;
  54630. shader: string;
  54631. };
  54632. }
  54633. declare module BABYLON {
  54634. /** @hidden */
  54635. export var pbrBlockAnisotropic: {
  54636. name: string;
  54637. shader: string;
  54638. };
  54639. }
  54640. declare module BABYLON {
  54641. /** @hidden */
  54642. export var pbrBlockReflection: {
  54643. name: string;
  54644. shader: string;
  54645. };
  54646. }
  54647. declare module BABYLON {
  54648. /** @hidden */
  54649. export var pbrBlockSheen: {
  54650. name: string;
  54651. shader: string;
  54652. };
  54653. }
  54654. declare module BABYLON {
  54655. /** @hidden */
  54656. export var pbrBlockClearcoat: {
  54657. name: string;
  54658. shader: string;
  54659. };
  54660. }
  54661. declare module BABYLON {
  54662. /** @hidden */
  54663. export var pbrBlockSubSurface: {
  54664. name: string;
  54665. shader: string;
  54666. };
  54667. }
  54668. declare module BABYLON {
  54669. /** @hidden */
  54670. export var pbrBlockNormalGeometric: {
  54671. name: string;
  54672. shader: string;
  54673. };
  54674. }
  54675. declare module BABYLON {
  54676. /** @hidden */
  54677. export var pbrBlockNormalFinal: {
  54678. name: string;
  54679. shader: string;
  54680. };
  54681. }
  54682. declare module BABYLON {
  54683. /** @hidden */
  54684. export var pbrBlockGeometryInfo: {
  54685. name: string;
  54686. shader: string;
  54687. };
  54688. }
  54689. declare module BABYLON {
  54690. /** @hidden */
  54691. export var pbrBlockReflectance0: {
  54692. name: string;
  54693. shader: string;
  54694. };
  54695. }
  54696. declare module BABYLON {
  54697. /** @hidden */
  54698. export var pbrBlockReflectance: {
  54699. name: string;
  54700. shader: string;
  54701. };
  54702. }
  54703. declare module BABYLON {
  54704. /** @hidden */
  54705. export var pbrBlockDirectLighting: {
  54706. name: string;
  54707. shader: string;
  54708. };
  54709. }
  54710. declare module BABYLON {
  54711. /** @hidden */
  54712. export var pbrBlockFinalLitComponents: {
  54713. name: string;
  54714. shader: string;
  54715. };
  54716. }
  54717. declare module BABYLON {
  54718. /** @hidden */
  54719. export var pbrBlockFinalUnlitComponents: {
  54720. name: string;
  54721. shader: string;
  54722. };
  54723. }
  54724. declare module BABYLON {
  54725. /** @hidden */
  54726. export var pbrBlockFinalColorComposition: {
  54727. name: string;
  54728. shader: string;
  54729. };
  54730. }
  54731. declare module BABYLON {
  54732. /** @hidden */
  54733. export var pbrBlockImageProcessing: {
  54734. name: string;
  54735. shader: string;
  54736. };
  54737. }
  54738. declare module BABYLON {
  54739. /** @hidden */
  54740. export var pbrDebug: {
  54741. name: string;
  54742. shader: string;
  54743. };
  54744. }
  54745. declare module BABYLON {
  54746. /** @hidden */
  54747. export var pbrPixelShader: {
  54748. name: string;
  54749. shader: string;
  54750. };
  54751. }
  54752. declare module BABYLON {
  54753. /** @hidden */
  54754. export var pbrVertexDeclaration: {
  54755. name: string;
  54756. shader: string;
  54757. };
  54758. }
  54759. declare module BABYLON {
  54760. /** @hidden */
  54761. export var pbrVertexShader: {
  54762. name: string;
  54763. shader: string;
  54764. };
  54765. }
  54766. declare module BABYLON {
  54767. /**
  54768. * Manages the defines for the PBR Material.
  54769. * @hidden
  54770. */
  54771. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54772. PBR: boolean;
  54773. NUM_SAMPLES: string;
  54774. REALTIME_FILTERING: boolean;
  54775. MAINUV1: boolean;
  54776. MAINUV2: boolean;
  54777. UV1: boolean;
  54778. UV2: boolean;
  54779. ALBEDO: boolean;
  54780. GAMMAALBEDO: boolean;
  54781. ALBEDODIRECTUV: number;
  54782. VERTEXCOLOR: boolean;
  54783. AMBIENT: boolean;
  54784. AMBIENTDIRECTUV: number;
  54785. AMBIENTINGRAYSCALE: boolean;
  54786. OPACITY: boolean;
  54787. VERTEXALPHA: boolean;
  54788. OPACITYDIRECTUV: number;
  54789. OPACITYRGB: boolean;
  54790. ALPHATEST: boolean;
  54791. DEPTHPREPASS: boolean;
  54792. ALPHABLEND: boolean;
  54793. ALPHAFROMALBEDO: boolean;
  54794. ALPHATESTVALUE: string;
  54795. SPECULAROVERALPHA: boolean;
  54796. RADIANCEOVERALPHA: boolean;
  54797. ALPHAFRESNEL: boolean;
  54798. LINEARALPHAFRESNEL: boolean;
  54799. PREMULTIPLYALPHA: boolean;
  54800. EMISSIVE: boolean;
  54801. EMISSIVEDIRECTUV: number;
  54802. REFLECTIVITY: boolean;
  54803. REFLECTIVITYDIRECTUV: number;
  54804. SPECULARTERM: boolean;
  54805. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54806. MICROSURFACEAUTOMATIC: boolean;
  54807. LODBASEDMICROSFURACE: boolean;
  54808. MICROSURFACEMAP: boolean;
  54809. MICROSURFACEMAPDIRECTUV: number;
  54810. METALLICWORKFLOW: boolean;
  54811. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54812. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54813. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54814. AOSTOREINMETALMAPRED: boolean;
  54815. METALLIC_REFLECTANCE: boolean;
  54816. METALLIC_REFLECTANCEDIRECTUV: number;
  54817. ENVIRONMENTBRDF: boolean;
  54818. ENVIRONMENTBRDF_RGBD: boolean;
  54819. NORMAL: boolean;
  54820. TANGENT: boolean;
  54821. BUMP: boolean;
  54822. BUMPDIRECTUV: number;
  54823. OBJECTSPACE_NORMALMAP: boolean;
  54824. PARALLAX: boolean;
  54825. PARALLAXOCCLUSION: boolean;
  54826. NORMALXYSCALE: boolean;
  54827. LIGHTMAP: boolean;
  54828. LIGHTMAPDIRECTUV: number;
  54829. USELIGHTMAPASSHADOWMAP: boolean;
  54830. GAMMALIGHTMAP: boolean;
  54831. RGBDLIGHTMAP: boolean;
  54832. REFLECTION: boolean;
  54833. REFLECTIONMAP_3D: boolean;
  54834. REFLECTIONMAP_SPHERICAL: boolean;
  54835. REFLECTIONMAP_PLANAR: boolean;
  54836. REFLECTIONMAP_CUBIC: boolean;
  54837. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54838. REFLECTIONMAP_PROJECTION: boolean;
  54839. REFLECTIONMAP_SKYBOX: boolean;
  54840. REFLECTIONMAP_EXPLICIT: boolean;
  54841. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54842. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54843. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54844. INVERTCUBICMAP: boolean;
  54845. USESPHERICALFROMREFLECTIONMAP: boolean;
  54846. USEIRRADIANCEMAP: boolean;
  54847. SPHERICAL_HARMONICS: boolean;
  54848. USESPHERICALINVERTEX: boolean;
  54849. REFLECTIONMAP_OPPOSITEZ: boolean;
  54850. LODINREFLECTIONALPHA: boolean;
  54851. GAMMAREFLECTION: boolean;
  54852. RGBDREFLECTION: boolean;
  54853. LINEARSPECULARREFLECTION: boolean;
  54854. RADIANCEOCCLUSION: boolean;
  54855. HORIZONOCCLUSION: boolean;
  54856. INSTANCES: boolean;
  54857. THIN_INSTANCES: boolean;
  54858. NUM_BONE_INFLUENCERS: number;
  54859. BonesPerMesh: number;
  54860. BONETEXTURE: boolean;
  54861. NONUNIFORMSCALING: boolean;
  54862. MORPHTARGETS: boolean;
  54863. MORPHTARGETS_NORMAL: boolean;
  54864. MORPHTARGETS_TANGENT: boolean;
  54865. MORPHTARGETS_UV: boolean;
  54866. NUM_MORPH_INFLUENCERS: number;
  54867. IMAGEPROCESSING: boolean;
  54868. VIGNETTE: boolean;
  54869. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54870. VIGNETTEBLENDMODEOPAQUE: boolean;
  54871. TONEMAPPING: boolean;
  54872. TONEMAPPING_ACES: boolean;
  54873. CONTRAST: boolean;
  54874. COLORCURVES: boolean;
  54875. COLORGRADING: boolean;
  54876. COLORGRADING3D: boolean;
  54877. SAMPLER3DGREENDEPTH: boolean;
  54878. SAMPLER3DBGRMAP: boolean;
  54879. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54880. EXPOSURE: boolean;
  54881. MULTIVIEW: boolean;
  54882. USEPHYSICALLIGHTFALLOFF: boolean;
  54883. USEGLTFLIGHTFALLOFF: boolean;
  54884. TWOSIDEDLIGHTING: boolean;
  54885. SHADOWFLOAT: boolean;
  54886. CLIPPLANE: boolean;
  54887. CLIPPLANE2: boolean;
  54888. CLIPPLANE3: boolean;
  54889. CLIPPLANE4: boolean;
  54890. CLIPPLANE5: boolean;
  54891. CLIPPLANE6: boolean;
  54892. POINTSIZE: boolean;
  54893. FOG: boolean;
  54894. LOGARITHMICDEPTH: boolean;
  54895. FORCENORMALFORWARD: boolean;
  54896. SPECULARAA: boolean;
  54897. CLEARCOAT: boolean;
  54898. CLEARCOAT_DEFAULTIOR: boolean;
  54899. CLEARCOAT_TEXTURE: boolean;
  54900. CLEARCOAT_TEXTUREDIRECTUV: number;
  54901. CLEARCOAT_BUMP: boolean;
  54902. CLEARCOAT_BUMPDIRECTUV: number;
  54903. CLEARCOAT_TINT: boolean;
  54904. CLEARCOAT_TINT_TEXTURE: boolean;
  54905. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54906. ANISOTROPIC: boolean;
  54907. ANISOTROPIC_TEXTURE: boolean;
  54908. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54909. BRDF_V_HEIGHT_CORRELATED: boolean;
  54910. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54911. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54912. SHEEN: boolean;
  54913. SHEEN_TEXTURE: boolean;
  54914. SHEEN_TEXTUREDIRECTUV: number;
  54915. SHEEN_LINKWITHALBEDO: boolean;
  54916. SHEEN_ROUGHNESS: boolean;
  54917. SHEEN_ALBEDOSCALING: boolean;
  54918. SUBSURFACE: boolean;
  54919. SS_REFRACTION: boolean;
  54920. SS_TRANSLUCENCY: boolean;
  54921. SS_SCATTERING: boolean;
  54922. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54923. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54924. SS_REFRACTIONMAP_3D: boolean;
  54925. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54926. SS_LODINREFRACTIONALPHA: boolean;
  54927. SS_GAMMAREFRACTION: boolean;
  54928. SS_RGBDREFRACTION: boolean;
  54929. SS_LINEARSPECULARREFRACTION: boolean;
  54930. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54931. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54932. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54933. UNLIT: boolean;
  54934. DEBUGMODE: number;
  54935. /**
  54936. * Initializes the PBR Material defines.
  54937. */
  54938. constructor();
  54939. /**
  54940. * Resets the PBR Material defines.
  54941. */
  54942. reset(): void;
  54943. }
  54944. /**
  54945. * The Physically based material base class of BJS.
  54946. *
  54947. * This offers the main features of a standard PBR material.
  54948. * For more information, please refer to the documentation :
  54949. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54950. */
  54951. export abstract class PBRBaseMaterial extends PushMaterial {
  54952. /**
  54953. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54954. */
  54955. static readonly PBRMATERIAL_OPAQUE: number;
  54956. /**
  54957. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54958. */
  54959. static readonly PBRMATERIAL_ALPHATEST: number;
  54960. /**
  54961. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54962. */
  54963. static readonly PBRMATERIAL_ALPHABLEND: number;
  54964. /**
  54965. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54966. * They are also discarded below the alpha cutoff threshold to improve performances.
  54967. */
  54968. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54969. /**
  54970. * Defines the default value of how much AO map is occluding the analytical lights
  54971. * (point spot...).
  54972. */
  54973. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54974. /**
  54975. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54976. */
  54977. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54978. /**
  54979. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54980. * to enhance interoperability with other engines.
  54981. */
  54982. static readonly LIGHTFALLOFF_GLTF: number;
  54983. /**
  54984. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54985. * to enhance interoperability with other materials.
  54986. */
  54987. static readonly LIGHTFALLOFF_STANDARD: number;
  54988. /**
  54989. * Intensity of the direct lights e.g. the four lights available in your scene.
  54990. * This impacts both the direct diffuse and specular highlights.
  54991. */
  54992. protected _directIntensity: number;
  54993. /**
  54994. * Intensity of the emissive part of the material.
  54995. * This helps controlling the emissive effect without modifying the emissive color.
  54996. */
  54997. protected _emissiveIntensity: number;
  54998. /**
  54999. * Intensity of the environment e.g. how much the environment will light the object
  55000. * either through harmonics for rough material or through the refelction for shiny ones.
  55001. */
  55002. protected _environmentIntensity: number;
  55003. /**
  55004. * This is a special control allowing the reduction of the specular highlights coming from the
  55005. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55006. */
  55007. protected _specularIntensity: number;
  55008. /**
  55009. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55010. */
  55011. private _lightingInfos;
  55012. /**
  55013. * Debug Control allowing disabling the bump map on this material.
  55014. */
  55015. protected _disableBumpMap: boolean;
  55016. /**
  55017. * AKA Diffuse Texture in standard nomenclature.
  55018. */
  55019. protected _albedoTexture: Nullable<BaseTexture>;
  55020. /**
  55021. * AKA Occlusion Texture in other nomenclature.
  55022. */
  55023. protected _ambientTexture: Nullable<BaseTexture>;
  55024. /**
  55025. * AKA Occlusion Texture Intensity in other nomenclature.
  55026. */
  55027. protected _ambientTextureStrength: number;
  55028. /**
  55029. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55030. * 1 means it completely occludes it
  55031. * 0 mean it has no impact
  55032. */
  55033. protected _ambientTextureImpactOnAnalyticalLights: number;
  55034. /**
  55035. * Stores the alpha values in a texture.
  55036. */
  55037. protected _opacityTexture: Nullable<BaseTexture>;
  55038. /**
  55039. * Stores the reflection values in a texture.
  55040. */
  55041. protected _reflectionTexture: Nullable<BaseTexture>;
  55042. /**
  55043. * Stores the emissive values in a texture.
  55044. */
  55045. protected _emissiveTexture: Nullable<BaseTexture>;
  55046. /**
  55047. * AKA Specular texture in other nomenclature.
  55048. */
  55049. protected _reflectivityTexture: Nullable<BaseTexture>;
  55050. /**
  55051. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55052. */
  55053. protected _metallicTexture: Nullable<BaseTexture>;
  55054. /**
  55055. * Specifies the metallic scalar of the metallic/roughness workflow.
  55056. * Can also be used to scale the metalness values of the metallic texture.
  55057. */
  55058. protected _metallic: Nullable<number>;
  55059. /**
  55060. * Specifies the roughness scalar of the metallic/roughness workflow.
  55061. * Can also be used to scale the roughness values of the metallic texture.
  55062. */
  55063. protected _roughness: Nullable<number>;
  55064. /**
  55065. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55066. * By default the indexOfrefraction is used to compute F0;
  55067. *
  55068. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55069. *
  55070. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55071. * F90 = metallicReflectanceColor;
  55072. */
  55073. protected _metallicF0Factor: number;
  55074. /**
  55075. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55076. * By default the F90 is always 1;
  55077. *
  55078. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55079. *
  55080. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55081. * F90 = metallicReflectanceColor;
  55082. */
  55083. protected _metallicReflectanceColor: Color3;
  55084. /**
  55085. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55086. * This is multiply against the scalar values defined in the material.
  55087. */
  55088. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55089. /**
  55090. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55091. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55092. */
  55093. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55094. /**
  55095. * Stores surface normal data used to displace a mesh in a texture.
  55096. */
  55097. protected _bumpTexture: Nullable<BaseTexture>;
  55098. /**
  55099. * Stores the pre-calculated light information of a mesh in a texture.
  55100. */
  55101. protected _lightmapTexture: Nullable<BaseTexture>;
  55102. /**
  55103. * The color of a material in ambient lighting.
  55104. */
  55105. protected _ambientColor: Color3;
  55106. /**
  55107. * AKA Diffuse Color in other nomenclature.
  55108. */
  55109. protected _albedoColor: Color3;
  55110. /**
  55111. * AKA Specular Color in other nomenclature.
  55112. */
  55113. protected _reflectivityColor: Color3;
  55114. /**
  55115. * The color applied when light is reflected from a material.
  55116. */
  55117. protected _reflectionColor: Color3;
  55118. /**
  55119. * The color applied when light is emitted from a material.
  55120. */
  55121. protected _emissiveColor: Color3;
  55122. /**
  55123. * AKA Glossiness in other nomenclature.
  55124. */
  55125. protected _microSurface: number;
  55126. /**
  55127. * Specifies that the material will use the light map as a show map.
  55128. */
  55129. protected _useLightmapAsShadowmap: boolean;
  55130. /**
  55131. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55132. * makes the reflect vector face the model (under horizon).
  55133. */
  55134. protected _useHorizonOcclusion: boolean;
  55135. /**
  55136. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55137. * too much the area relying on ambient texture to define their ambient occlusion.
  55138. */
  55139. protected _useRadianceOcclusion: boolean;
  55140. /**
  55141. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55142. */
  55143. protected _useAlphaFromAlbedoTexture: boolean;
  55144. /**
  55145. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55146. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55147. */
  55148. protected _useSpecularOverAlpha: boolean;
  55149. /**
  55150. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55151. */
  55152. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55153. /**
  55154. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55155. */
  55156. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55157. /**
  55158. * Specifies if the metallic texture contains the roughness information in its green channel.
  55159. */
  55160. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55161. /**
  55162. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55163. */
  55164. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55165. /**
  55166. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55167. */
  55168. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55169. /**
  55170. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55171. */
  55172. protected _useAmbientInGrayScale: boolean;
  55173. /**
  55174. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55175. * The material will try to infer what glossiness each pixel should be.
  55176. */
  55177. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55178. /**
  55179. * Defines the falloff type used in this material.
  55180. * It by default is Physical.
  55181. */
  55182. protected _lightFalloff: number;
  55183. /**
  55184. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55185. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55186. */
  55187. protected _useRadianceOverAlpha: boolean;
  55188. /**
  55189. * Allows using an object space normal map (instead of tangent space).
  55190. */
  55191. protected _useObjectSpaceNormalMap: boolean;
  55192. /**
  55193. * Allows using the bump map in parallax mode.
  55194. */
  55195. protected _useParallax: boolean;
  55196. /**
  55197. * Allows using the bump map in parallax occlusion mode.
  55198. */
  55199. protected _useParallaxOcclusion: boolean;
  55200. /**
  55201. * Controls the scale bias of the parallax mode.
  55202. */
  55203. protected _parallaxScaleBias: number;
  55204. /**
  55205. * If sets to true, disables all the lights affecting the material.
  55206. */
  55207. protected _disableLighting: boolean;
  55208. /**
  55209. * Number of Simultaneous lights allowed on the material.
  55210. */
  55211. protected _maxSimultaneousLights: number;
  55212. /**
  55213. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55214. */
  55215. protected _invertNormalMapX: boolean;
  55216. /**
  55217. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55218. */
  55219. protected _invertNormalMapY: boolean;
  55220. /**
  55221. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55222. */
  55223. protected _twoSidedLighting: boolean;
  55224. /**
  55225. * Defines the alpha limits in alpha test mode.
  55226. */
  55227. protected _alphaCutOff: number;
  55228. /**
  55229. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55230. */
  55231. protected _forceAlphaTest: boolean;
  55232. /**
  55233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55234. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55235. */
  55236. protected _useAlphaFresnel: boolean;
  55237. /**
  55238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55239. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55240. */
  55241. protected _useLinearAlphaFresnel: boolean;
  55242. /**
  55243. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55244. * from cos thetav and roughness:
  55245. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55246. */
  55247. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55248. /**
  55249. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55250. */
  55251. protected _forceIrradianceInFragment: boolean;
  55252. private _realTimeFiltering;
  55253. /**
  55254. * Enables realtime filtering on the texture.
  55255. */
  55256. get realTimeFiltering(): boolean;
  55257. set realTimeFiltering(b: boolean);
  55258. private _realTimeFilteringQuality;
  55259. /**
  55260. * Quality switch for realtime filtering
  55261. */
  55262. get realTimeFilteringQuality(): number;
  55263. set realTimeFilteringQuality(n: number);
  55264. /**
  55265. * Force normal to face away from face.
  55266. */
  55267. protected _forceNormalForward: boolean;
  55268. /**
  55269. * Enables specular anti aliasing in the PBR shader.
  55270. * It will both interacts on the Geometry for analytical and IBL lighting.
  55271. * It also prefilter the roughness map based on the bump values.
  55272. */
  55273. protected _enableSpecularAntiAliasing: boolean;
  55274. /**
  55275. * Default configuration related to image processing available in the PBR Material.
  55276. */
  55277. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55278. /**
  55279. * Keep track of the image processing observer to allow dispose and replace.
  55280. */
  55281. private _imageProcessingObserver;
  55282. /**
  55283. * Attaches a new image processing configuration to the PBR Material.
  55284. * @param configuration
  55285. */
  55286. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55287. /**
  55288. * Stores the available render targets.
  55289. */
  55290. private _renderTargets;
  55291. /**
  55292. * Sets the global ambient color for the material used in lighting calculations.
  55293. */
  55294. private _globalAmbientColor;
  55295. /**
  55296. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55297. */
  55298. private _useLogarithmicDepth;
  55299. /**
  55300. * If set to true, no lighting calculations will be applied.
  55301. */
  55302. private _unlit;
  55303. private _debugMode;
  55304. /**
  55305. * @hidden
  55306. * This is reserved for the inspector.
  55307. * Defines the material debug mode.
  55308. * It helps seeing only some components of the material while troubleshooting.
  55309. */
  55310. debugMode: number;
  55311. /**
  55312. * @hidden
  55313. * This is reserved for the inspector.
  55314. * Specify from where on screen the debug mode should start.
  55315. * The value goes from -1 (full screen) to 1 (not visible)
  55316. * It helps with side by side comparison against the final render
  55317. * This defaults to -1
  55318. */
  55319. private debugLimit;
  55320. /**
  55321. * @hidden
  55322. * This is reserved for the inspector.
  55323. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55324. * You can use the factor to better multiply the final value.
  55325. */
  55326. private debugFactor;
  55327. /**
  55328. * Defines the clear coat layer parameters for the material.
  55329. */
  55330. readonly clearCoat: PBRClearCoatConfiguration;
  55331. /**
  55332. * Defines the anisotropic parameters for the material.
  55333. */
  55334. readonly anisotropy: PBRAnisotropicConfiguration;
  55335. /**
  55336. * Defines the BRDF parameters for the material.
  55337. */
  55338. readonly brdf: PBRBRDFConfiguration;
  55339. /**
  55340. * Defines the Sheen parameters for the material.
  55341. */
  55342. readonly sheen: PBRSheenConfiguration;
  55343. /**
  55344. * Defines the SubSurface parameters for the material.
  55345. */
  55346. readonly subSurface: PBRSubSurfaceConfiguration;
  55347. protected _rebuildInParallel: boolean;
  55348. /**
  55349. * Instantiates a new PBRMaterial instance.
  55350. *
  55351. * @param name The material name
  55352. * @param scene The scene the material will be use in.
  55353. */
  55354. constructor(name: string, scene: Scene);
  55355. /**
  55356. * Gets a boolean indicating that current material needs to register RTT
  55357. */
  55358. get hasRenderTargetTextures(): boolean;
  55359. /**
  55360. * Gets the name of the material class.
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55365. */
  55366. get useLogarithmicDepth(): boolean;
  55367. /**
  55368. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55369. */
  55370. set useLogarithmicDepth(value: boolean);
  55371. /**
  55372. * Returns true if alpha blending should be disabled.
  55373. */
  55374. protected get _disableAlphaBlending(): boolean;
  55375. /**
  55376. * Specifies whether or not this material should be rendered in alpha blend mode.
  55377. */
  55378. needAlphaBlending(): boolean;
  55379. /**
  55380. * Specifies whether or not this material should be rendered in alpha test mode.
  55381. */
  55382. needAlphaTesting(): boolean;
  55383. /**
  55384. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55385. */
  55386. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55387. /**
  55388. * Gets the texture used for the alpha test.
  55389. */
  55390. getAlphaTestTexture(): Nullable<BaseTexture>;
  55391. /**
  55392. * Specifies that the submesh is ready to be used.
  55393. * @param mesh - BJS mesh.
  55394. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55395. * @param useInstances - Specifies that instances should be used.
  55396. * @returns - boolean indicating that the submesh is ready or not.
  55397. */
  55398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55399. /**
  55400. * Specifies if the material uses metallic roughness workflow.
  55401. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55402. */
  55403. isMetallicWorkflow(): boolean;
  55404. private _prepareEffect;
  55405. private _prepareDefines;
  55406. /**
  55407. * Force shader compilation
  55408. */
  55409. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55410. /**
  55411. * Initializes the uniform buffer layout for the shader.
  55412. */
  55413. buildUniformLayout(): void;
  55414. /**
  55415. * Unbinds the material from the mesh
  55416. */
  55417. unbind(): void;
  55418. /**
  55419. * Binds the submesh data.
  55420. * @param world - The world matrix.
  55421. * @param mesh - The BJS mesh.
  55422. * @param subMesh - A submesh of the BJS mesh.
  55423. */
  55424. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55425. /**
  55426. * Returns the animatable textures.
  55427. * @returns - Array of animatable textures.
  55428. */
  55429. getAnimatables(): IAnimatable[];
  55430. /**
  55431. * Returns the texture used for reflections.
  55432. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55433. */
  55434. private _getReflectionTexture;
  55435. /**
  55436. * Returns an array of the actively used textures.
  55437. * @returns - Array of BaseTextures
  55438. */
  55439. getActiveTextures(): BaseTexture[];
  55440. /**
  55441. * Checks to see if a texture is used in the material.
  55442. * @param texture - Base texture to use.
  55443. * @returns - Boolean specifying if a texture is used in the material.
  55444. */
  55445. hasTexture(texture: BaseTexture): boolean;
  55446. /**
  55447. * Disposes the resources of the material.
  55448. * @param forceDisposeEffect - Forces the disposal of effects.
  55449. * @param forceDisposeTextures - Forces the disposal of all textures.
  55450. */
  55451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55452. }
  55453. }
  55454. declare module BABYLON {
  55455. /**
  55456. * The Physically based material of BJS.
  55457. *
  55458. * This offers the main features of a standard PBR material.
  55459. * For more information, please refer to the documentation :
  55460. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55461. */
  55462. export class PBRMaterial extends PBRBaseMaterial {
  55463. /**
  55464. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55465. */
  55466. static readonly PBRMATERIAL_OPAQUE: number;
  55467. /**
  55468. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55469. */
  55470. static readonly PBRMATERIAL_ALPHATEST: number;
  55471. /**
  55472. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55473. */
  55474. static readonly PBRMATERIAL_ALPHABLEND: number;
  55475. /**
  55476. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55477. * They are also discarded below the alpha cutoff threshold to improve performances.
  55478. */
  55479. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55480. /**
  55481. * Defines the default value of how much AO map is occluding the analytical lights
  55482. * (point spot...).
  55483. */
  55484. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55485. /**
  55486. * Intensity of the direct lights e.g. the four lights available in your scene.
  55487. * This impacts both the direct diffuse and specular highlights.
  55488. */
  55489. directIntensity: number;
  55490. /**
  55491. * Intensity of the emissive part of the material.
  55492. * This helps controlling the emissive effect without modifying the emissive color.
  55493. */
  55494. emissiveIntensity: number;
  55495. /**
  55496. * Intensity of the environment e.g. how much the environment will light the object
  55497. * either through harmonics for rough material or through the refelction for shiny ones.
  55498. */
  55499. environmentIntensity: number;
  55500. /**
  55501. * This is a special control allowing the reduction of the specular highlights coming from the
  55502. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55503. */
  55504. specularIntensity: number;
  55505. /**
  55506. * Debug Control allowing disabling the bump map on this material.
  55507. */
  55508. disableBumpMap: boolean;
  55509. /**
  55510. * AKA Diffuse Texture in standard nomenclature.
  55511. */
  55512. albedoTexture: BaseTexture;
  55513. /**
  55514. * AKA Occlusion Texture in other nomenclature.
  55515. */
  55516. ambientTexture: BaseTexture;
  55517. /**
  55518. * AKA Occlusion Texture Intensity in other nomenclature.
  55519. */
  55520. ambientTextureStrength: number;
  55521. /**
  55522. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55523. * 1 means it completely occludes it
  55524. * 0 mean it has no impact
  55525. */
  55526. ambientTextureImpactOnAnalyticalLights: number;
  55527. /**
  55528. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55529. */
  55530. opacityTexture: BaseTexture;
  55531. /**
  55532. * Stores the reflection values in a texture.
  55533. */
  55534. reflectionTexture: Nullable<BaseTexture>;
  55535. /**
  55536. * Stores the emissive values in a texture.
  55537. */
  55538. emissiveTexture: BaseTexture;
  55539. /**
  55540. * AKA Specular texture in other nomenclature.
  55541. */
  55542. reflectivityTexture: BaseTexture;
  55543. /**
  55544. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55545. */
  55546. metallicTexture: BaseTexture;
  55547. /**
  55548. * Specifies the metallic scalar of the metallic/roughness workflow.
  55549. * Can also be used to scale the metalness values of the metallic texture.
  55550. */
  55551. metallic: Nullable<number>;
  55552. /**
  55553. * Specifies the roughness scalar of the metallic/roughness workflow.
  55554. * Can also be used to scale the roughness values of the metallic texture.
  55555. */
  55556. roughness: Nullable<number>;
  55557. /**
  55558. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55559. * By default the indexOfrefraction is used to compute F0;
  55560. *
  55561. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55562. *
  55563. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55564. * F90 = metallicReflectanceColor;
  55565. */
  55566. metallicF0Factor: number;
  55567. /**
  55568. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55569. * By default the F90 is always 1;
  55570. *
  55571. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55572. *
  55573. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55574. * F90 = metallicReflectanceColor;
  55575. */
  55576. metallicReflectanceColor: Color3;
  55577. /**
  55578. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55579. * This is multiply against the scalar values defined in the material.
  55580. */
  55581. metallicReflectanceTexture: Nullable<BaseTexture>;
  55582. /**
  55583. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55584. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55585. */
  55586. microSurfaceTexture: BaseTexture;
  55587. /**
  55588. * Stores surface normal data used to displace a mesh in a texture.
  55589. */
  55590. bumpTexture: BaseTexture;
  55591. /**
  55592. * Stores the pre-calculated light information of a mesh in a texture.
  55593. */
  55594. lightmapTexture: BaseTexture;
  55595. /**
  55596. * Stores the refracted light information in a texture.
  55597. */
  55598. get refractionTexture(): Nullable<BaseTexture>;
  55599. set refractionTexture(value: Nullable<BaseTexture>);
  55600. /**
  55601. * The color of a material in ambient lighting.
  55602. */
  55603. ambientColor: Color3;
  55604. /**
  55605. * AKA Diffuse Color in other nomenclature.
  55606. */
  55607. albedoColor: Color3;
  55608. /**
  55609. * AKA Specular Color in other nomenclature.
  55610. */
  55611. reflectivityColor: Color3;
  55612. /**
  55613. * The color reflected from the material.
  55614. */
  55615. reflectionColor: Color3;
  55616. /**
  55617. * The color emitted from the material.
  55618. */
  55619. emissiveColor: Color3;
  55620. /**
  55621. * AKA Glossiness in other nomenclature.
  55622. */
  55623. microSurface: number;
  55624. /**
  55625. * Index of refraction of the material base layer.
  55626. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55627. *
  55628. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55629. *
  55630. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55631. */
  55632. get indexOfRefraction(): number;
  55633. set indexOfRefraction(value: number);
  55634. /**
  55635. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55636. */
  55637. get invertRefractionY(): boolean;
  55638. set invertRefractionY(value: boolean);
  55639. /**
  55640. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55641. * Materials half opaque for instance using refraction could benefit from this control.
  55642. */
  55643. get linkRefractionWithTransparency(): boolean;
  55644. set linkRefractionWithTransparency(value: boolean);
  55645. /**
  55646. * If true, the light map contains occlusion information instead of lighting info.
  55647. */
  55648. useLightmapAsShadowmap: boolean;
  55649. /**
  55650. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55651. */
  55652. useAlphaFromAlbedoTexture: boolean;
  55653. /**
  55654. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55655. */
  55656. forceAlphaTest: boolean;
  55657. /**
  55658. * Defines the alpha limits in alpha test mode.
  55659. */
  55660. alphaCutOff: number;
  55661. /**
  55662. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55663. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55664. */
  55665. useSpecularOverAlpha: boolean;
  55666. /**
  55667. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55668. */
  55669. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55670. /**
  55671. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55672. */
  55673. useRoughnessFromMetallicTextureAlpha: boolean;
  55674. /**
  55675. * Specifies if the metallic texture contains the roughness information in its green channel.
  55676. */
  55677. useRoughnessFromMetallicTextureGreen: boolean;
  55678. /**
  55679. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55680. */
  55681. useMetallnessFromMetallicTextureBlue: boolean;
  55682. /**
  55683. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55684. */
  55685. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55686. /**
  55687. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55688. */
  55689. useAmbientInGrayScale: boolean;
  55690. /**
  55691. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55692. * The material will try to infer what glossiness each pixel should be.
  55693. */
  55694. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55695. /**
  55696. * BJS is using an harcoded light falloff based on a manually sets up range.
  55697. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55698. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55699. */
  55700. get usePhysicalLightFalloff(): boolean;
  55701. /**
  55702. * BJS is using an harcoded light falloff based on a manually sets up range.
  55703. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55704. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55705. */
  55706. set usePhysicalLightFalloff(value: boolean);
  55707. /**
  55708. * In order to support the falloff compatibility with gltf, a special mode has been added
  55709. * to reproduce the gltf light falloff.
  55710. */
  55711. get useGLTFLightFalloff(): boolean;
  55712. /**
  55713. * In order to support the falloff compatibility with gltf, a special mode has been added
  55714. * to reproduce the gltf light falloff.
  55715. */
  55716. set useGLTFLightFalloff(value: boolean);
  55717. /**
  55718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55720. */
  55721. useRadianceOverAlpha: boolean;
  55722. /**
  55723. * Allows using an object space normal map (instead of tangent space).
  55724. */
  55725. useObjectSpaceNormalMap: boolean;
  55726. /**
  55727. * Allows using the bump map in parallax mode.
  55728. */
  55729. useParallax: boolean;
  55730. /**
  55731. * Allows using the bump map in parallax occlusion mode.
  55732. */
  55733. useParallaxOcclusion: boolean;
  55734. /**
  55735. * Controls the scale bias of the parallax mode.
  55736. */
  55737. parallaxScaleBias: number;
  55738. /**
  55739. * If sets to true, disables all the lights affecting the material.
  55740. */
  55741. disableLighting: boolean;
  55742. /**
  55743. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55744. */
  55745. forceIrradianceInFragment: boolean;
  55746. /**
  55747. * Number of Simultaneous lights allowed on the material.
  55748. */
  55749. maxSimultaneousLights: number;
  55750. /**
  55751. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55752. */
  55753. invertNormalMapX: boolean;
  55754. /**
  55755. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55756. */
  55757. invertNormalMapY: boolean;
  55758. /**
  55759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55760. */
  55761. twoSidedLighting: boolean;
  55762. /**
  55763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55764. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55765. */
  55766. useAlphaFresnel: boolean;
  55767. /**
  55768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55769. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55770. */
  55771. useLinearAlphaFresnel: boolean;
  55772. /**
  55773. * Let user defines the brdf lookup texture used for IBL.
  55774. * A default 8bit version is embedded but you could point at :
  55775. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55776. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55777. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55778. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55779. */
  55780. environmentBRDFTexture: Nullable<BaseTexture>;
  55781. /**
  55782. * Force normal to face away from face.
  55783. */
  55784. forceNormalForward: boolean;
  55785. /**
  55786. * Enables specular anti aliasing in the PBR shader.
  55787. * It will both interacts on the Geometry for analytical and IBL lighting.
  55788. * It also prefilter the roughness map based on the bump values.
  55789. */
  55790. enableSpecularAntiAliasing: boolean;
  55791. /**
  55792. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55793. * makes the reflect vector face the model (under horizon).
  55794. */
  55795. useHorizonOcclusion: boolean;
  55796. /**
  55797. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55798. * too much the area relying on ambient texture to define their ambient occlusion.
  55799. */
  55800. useRadianceOcclusion: boolean;
  55801. /**
  55802. * If set to true, no lighting calculations will be applied.
  55803. */
  55804. unlit: boolean;
  55805. /**
  55806. * Gets the image processing configuration used either in this material.
  55807. */
  55808. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55809. /**
  55810. * Sets the Default image processing configuration used either in the this material.
  55811. *
  55812. * If sets to null, the scene one is in use.
  55813. */
  55814. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55815. /**
  55816. * Gets wether the color curves effect is enabled.
  55817. */
  55818. get cameraColorCurvesEnabled(): boolean;
  55819. /**
  55820. * Sets wether the color curves effect is enabled.
  55821. */
  55822. set cameraColorCurvesEnabled(value: boolean);
  55823. /**
  55824. * Gets wether the color grading effect is enabled.
  55825. */
  55826. get cameraColorGradingEnabled(): boolean;
  55827. /**
  55828. * Gets wether the color grading effect is enabled.
  55829. */
  55830. set cameraColorGradingEnabled(value: boolean);
  55831. /**
  55832. * Gets wether tonemapping is enabled or not.
  55833. */
  55834. get cameraToneMappingEnabled(): boolean;
  55835. /**
  55836. * Sets wether tonemapping is enabled or not
  55837. */
  55838. set cameraToneMappingEnabled(value: boolean);
  55839. /**
  55840. * The camera exposure used on this material.
  55841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55842. * This corresponds to a photographic exposure.
  55843. */
  55844. get cameraExposure(): number;
  55845. /**
  55846. * The camera exposure used on this material.
  55847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55848. * This corresponds to a photographic exposure.
  55849. */
  55850. set cameraExposure(value: number);
  55851. /**
  55852. * Gets The camera contrast used on this material.
  55853. */
  55854. get cameraContrast(): number;
  55855. /**
  55856. * Sets The camera contrast used on this material.
  55857. */
  55858. set cameraContrast(value: number);
  55859. /**
  55860. * Gets the Color Grading 2D Lookup Texture.
  55861. */
  55862. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55863. /**
  55864. * Sets the Color Grading 2D Lookup Texture.
  55865. */
  55866. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55867. /**
  55868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55870. * 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;
  55871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55872. */
  55873. get cameraColorCurves(): Nullable<ColorCurves>;
  55874. /**
  55875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55877. * 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;
  55878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55879. */
  55880. set cameraColorCurves(value: Nullable<ColorCurves>);
  55881. /**
  55882. * Instantiates a new PBRMaterial instance.
  55883. *
  55884. * @param name The material name
  55885. * @param scene The scene the material will be use in.
  55886. */
  55887. constructor(name: string, scene: Scene);
  55888. /**
  55889. * Returns the name of this material class.
  55890. */
  55891. getClassName(): string;
  55892. /**
  55893. * Makes a duplicate of the current material.
  55894. * @param name - name to use for the new material.
  55895. */
  55896. clone(name: string): PBRMaterial;
  55897. /**
  55898. * Serializes this PBR Material.
  55899. * @returns - An object with the serialized material.
  55900. */
  55901. serialize(): any;
  55902. /**
  55903. * Parses a PBR Material from a serialized object.
  55904. * @param source - Serialized object.
  55905. * @param scene - BJS scene instance.
  55906. * @param rootUrl - url for the scene object
  55907. * @returns - PBRMaterial
  55908. */
  55909. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55910. }
  55911. }
  55912. declare module BABYLON {
  55913. /**
  55914. * Direct draw surface info
  55915. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55916. */
  55917. export interface DDSInfo {
  55918. /**
  55919. * Width of the texture
  55920. */
  55921. width: number;
  55922. /**
  55923. * Width of the texture
  55924. */
  55925. height: number;
  55926. /**
  55927. * Number of Mipmaps for the texture
  55928. * @see https://en.wikipedia.org/wiki/Mipmap
  55929. */
  55930. mipmapCount: number;
  55931. /**
  55932. * If the textures format is a known fourCC format
  55933. * @see https://www.fourcc.org/
  55934. */
  55935. isFourCC: boolean;
  55936. /**
  55937. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55938. */
  55939. isRGB: boolean;
  55940. /**
  55941. * If the texture is a lumincance format
  55942. */
  55943. isLuminance: boolean;
  55944. /**
  55945. * If this is a cube texture
  55946. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55947. */
  55948. isCube: boolean;
  55949. /**
  55950. * If the texture is a compressed format eg. FOURCC_DXT1
  55951. */
  55952. isCompressed: boolean;
  55953. /**
  55954. * The dxgiFormat of the texture
  55955. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55956. */
  55957. dxgiFormat: number;
  55958. /**
  55959. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55960. */
  55961. textureType: number;
  55962. /**
  55963. * Sphericle polynomial created for the dds texture
  55964. */
  55965. sphericalPolynomial?: SphericalPolynomial;
  55966. }
  55967. /**
  55968. * Class used to provide DDS decompression tools
  55969. */
  55970. export class DDSTools {
  55971. /**
  55972. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55973. */
  55974. static StoreLODInAlphaChannel: boolean;
  55975. /**
  55976. * Gets DDS information from an array buffer
  55977. * @param data defines the array buffer view to read data from
  55978. * @returns the DDS information
  55979. */
  55980. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55981. private static _FloatView;
  55982. private static _Int32View;
  55983. private static _ToHalfFloat;
  55984. private static _FromHalfFloat;
  55985. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55986. private static _GetHalfFloatRGBAArrayBuffer;
  55987. private static _GetFloatRGBAArrayBuffer;
  55988. private static _GetFloatAsUIntRGBAArrayBuffer;
  55989. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55990. private static _GetRGBAArrayBuffer;
  55991. private static _ExtractLongWordOrder;
  55992. private static _GetRGBArrayBuffer;
  55993. private static _GetLuminanceArrayBuffer;
  55994. /**
  55995. * Uploads DDS Levels to a Babylon Texture
  55996. * @hidden
  55997. */
  55998. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55999. }
  56000. interface ThinEngine {
  56001. /**
  56002. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56003. * @param rootUrl defines the url where the file to load is located
  56004. * @param scene defines the current scene
  56005. * @param lodScale defines scale to apply to the mip map selection
  56006. * @param lodOffset defines offset to apply to the mip map selection
  56007. * @param onLoad defines an optional callback raised when the texture is loaded
  56008. * @param onError defines an optional callback raised if there is an issue to load the texture
  56009. * @param format defines the format of the data
  56010. * @param forcedExtension defines the extension to use to pick the right loader
  56011. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56012. * @returns the cube texture as an InternalTexture
  56013. */
  56014. 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;
  56015. }
  56016. }
  56017. declare module BABYLON {
  56018. /**
  56019. * Implementation of the DDS Texture Loader.
  56020. * @hidden
  56021. */
  56022. export class _DDSTextureLoader implements IInternalTextureLoader {
  56023. /**
  56024. * Defines wether the loader supports cascade loading the different faces.
  56025. */
  56026. readonly supportCascades: boolean;
  56027. /**
  56028. * This returns if the loader support the current file information.
  56029. * @param extension defines the file extension of the file being loaded
  56030. * @returns true if the loader can load the specified file
  56031. */
  56032. canLoad(extension: string): boolean;
  56033. /**
  56034. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56035. * @param data contains the texture data
  56036. * @param texture defines the BabylonJS internal texture
  56037. * @param createPolynomials will be true if polynomials have been requested
  56038. * @param onLoad defines the callback to trigger once the texture is ready
  56039. * @param onError defines the callback to trigger in case of error
  56040. */
  56041. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56042. /**
  56043. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56044. * @param data contains the texture data
  56045. * @param texture defines the BabylonJS internal texture
  56046. * @param callback defines the method to call once ready to upload
  56047. */
  56048. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /**
  56053. * Implementation of the ENV Texture Loader.
  56054. * @hidden
  56055. */
  56056. export class _ENVTextureLoader implements IInternalTextureLoader {
  56057. /**
  56058. * Defines wether the loader supports cascade loading the different faces.
  56059. */
  56060. readonly supportCascades: boolean;
  56061. /**
  56062. * This returns if the loader support the current file information.
  56063. * @param extension defines the file extension of the file being loaded
  56064. * @returns true if the loader can load the specified file
  56065. */
  56066. canLoad(extension: string): boolean;
  56067. /**
  56068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56069. * @param data contains the texture data
  56070. * @param texture defines the BabylonJS internal texture
  56071. * @param createPolynomials will be true if polynomials have been requested
  56072. * @param onLoad defines the callback to trigger once the texture is ready
  56073. * @param onError defines the callback to trigger in case of error
  56074. */
  56075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56076. /**
  56077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56078. * @param data contains the texture data
  56079. * @param texture defines the BabylonJS internal texture
  56080. * @param callback defines the method to call once ready to upload
  56081. */
  56082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56083. }
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56089. */
  56090. export class KhronosTextureContainer {
  56091. /** contents of the KTX container file */
  56092. data: ArrayBufferView;
  56093. private static HEADER_LEN;
  56094. private static COMPRESSED_2D;
  56095. private static COMPRESSED_3D;
  56096. private static TEX_2D;
  56097. private static TEX_3D;
  56098. /**
  56099. * Gets the openGL type
  56100. */
  56101. glType: number;
  56102. /**
  56103. * Gets the openGL type size
  56104. */
  56105. glTypeSize: number;
  56106. /**
  56107. * Gets the openGL format
  56108. */
  56109. glFormat: number;
  56110. /**
  56111. * Gets the openGL internal format
  56112. */
  56113. glInternalFormat: number;
  56114. /**
  56115. * Gets the base internal format
  56116. */
  56117. glBaseInternalFormat: number;
  56118. /**
  56119. * Gets image width in pixel
  56120. */
  56121. pixelWidth: number;
  56122. /**
  56123. * Gets image height in pixel
  56124. */
  56125. pixelHeight: number;
  56126. /**
  56127. * Gets image depth in pixels
  56128. */
  56129. pixelDepth: number;
  56130. /**
  56131. * Gets the number of array elements
  56132. */
  56133. numberOfArrayElements: number;
  56134. /**
  56135. * Gets the number of faces
  56136. */
  56137. numberOfFaces: number;
  56138. /**
  56139. * Gets the number of mipmap levels
  56140. */
  56141. numberOfMipmapLevels: number;
  56142. /**
  56143. * Gets the bytes of key value data
  56144. */
  56145. bytesOfKeyValueData: number;
  56146. /**
  56147. * Gets the load type
  56148. */
  56149. loadType: number;
  56150. /**
  56151. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56152. */
  56153. isInvalid: boolean;
  56154. /**
  56155. * Creates a new KhronosTextureContainer
  56156. * @param data contents of the KTX container file
  56157. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56158. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56159. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56160. */
  56161. constructor(
  56162. /** contents of the KTX container file */
  56163. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56164. /**
  56165. * Uploads KTX content to a Babylon Texture.
  56166. * It is assumed that the texture has already been created & is currently bound
  56167. * @hidden
  56168. */
  56169. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56170. private _upload2DCompressedLevels;
  56171. /**
  56172. * Checks if the given data starts with a KTX file identifier.
  56173. * @param data the data to check
  56174. * @returns true if the data is a KTX file or false otherwise
  56175. */
  56176. static IsValid(data: ArrayBufferView): boolean;
  56177. }
  56178. }
  56179. declare module BABYLON {
  56180. /**
  56181. * Class for loading KTX2 files
  56182. * !!! Experimental Extension Subject to Changes !!!
  56183. * @hidden
  56184. */
  56185. export class KhronosTextureContainer2 {
  56186. private static _ModulePromise;
  56187. private static _TranscodeFormat;
  56188. constructor(engine: ThinEngine);
  56189. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56190. private _determineTranscodeFormat;
  56191. /**
  56192. * Checks if the given data starts with a KTX2 file identifier.
  56193. * @param data the data to check
  56194. * @returns true if the data is a KTX2 file or false otherwise
  56195. */
  56196. static IsValid(data: ArrayBufferView): boolean;
  56197. }
  56198. }
  56199. declare module BABYLON {
  56200. /**
  56201. * Implementation of the KTX Texture Loader.
  56202. * @hidden
  56203. */
  56204. export class _KTXTextureLoader implements IInternalTextureLoader {
  56205. /**
  56206. * Defines wether the loader supports cascade loading the different faces.
  56207. */
  56208. readonly supportCascades: boolean;
  56209. /**
  56210. * This returns if the loader support the current file information.
  56211. * @param extension defines the file extension of the file being loaded
  56212. * @returns true if the loader can load the specified file
  56213. */
  56214. canLoad(extension: string): boolean;
  56215. /**
  56216. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56217. * @param data contains the texture data
  56218. * @param texture defines the BabylonJS internal texture
  56219. * @param createPolynomials will be true if polynomials have been requested
  56220. * @param onLoad defines the callback to trigger once the texture is ready
  56221. * @param onError defines the callback to trigger in case of error
  56222. */
  56223. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56224. /**
  56225. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56226. * @param data contains the texture data
  56227. * @param texture defines the BabylonJS internal texture
  56228. * @param callback defines the method to call once ready to upload
  56229. */
  56230. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56231. }
  56232. }
  56233. declare module BABYLON {
  56234. /** @hidden */
  56235. export var _forceSceneHelpersToBundle: boolean;
  56236. interface Scene {
  56237. /**
  56238. * Creates a default light for the scene.
  56239. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56240. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56241. */
  56242. createDefaultLight(replace?: boolean): void;
  56243. /**
  56244. * Creates a default camera for the scene.
  56245. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56246. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56247. * @param replace has default false, when true replaces the active camera in the scene
  56248. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56249. */
  56250. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56251. /**
  56252. * Creates a default camera and a default light.
  56253. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56254. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56255. * @param replace has the default false, when true replaces the active camera/light in the scene
  56256. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56257. */
  56258. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56259. /**
  56260. * Creates a new sky box
  56261. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56262. * @param environmentTexture defines the texture to use as environment texture
  56263. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56264. * @param scale defines the overall scale of the skybox
  56265. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56266. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56267. * @returns a new mesh holding the sky box
  56268. */
  56269. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56270. /**
  56271. * Creates a new environment
  56272. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56273. * @param options defines the options you can use to configure the environment
  56274. * @returns the new EnvironmentHelper
  56275. */
  56276. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56277. /**
  56278. * Creates a new VREXperienceHelper
  56279. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56280. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56281. * @returns a new VREXperienceHelper
  56282. */
  56283. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56284. /**
  56285. * Creates a new WebXRDefaultExperience
  56286. * @see http://doc.babylonjs.com/how_to/webxr
  56287. * @param options experience options
  56288. * @returns a promise for a new WebXRDefaultExperience
  56289. */
  56290. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56291. }
  56292. }
  56293. declare module BABYLON {
  56294. /**
  56295. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56296. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56297. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56298. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56299. */
  56300. export class VideoDome extends TransformNode {
  56301. /**
  56302. * Define the video source as a Monoscopic panoramic 360 video.
  56303. */
  56304. static readonly MODE_MONOSCOPIC: number;
  56305. /**
  56306. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56307. */
  56308. static readonly MODE_TOPBOTTOM: number;
  56309. /**
  56310. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56311. */
  56312. static readonly MODE_SIDEBYSIDE: number;
  56313. private _halfDome;
  56314. private _useDirectMapping;
  56315. /**
  56316. * The video texture being displayed on the sphere
  56317. */
  56318. protected _videoTexture: VideoTexture;
  56319. /**
  56320. * Gets the video texture being displayed on the sphere
  56321. */
  56322. get videoTexture(): VideoTexture;
  56323. /**
  56324. * The skybox material
  56325. */
  56326. protected _material: BackgroundMaterial;
  56327. /**
  56328. * The surface used for the skybox
  56329. */
  56330. protected _mesh: Mesh;
  56331. /**
  56332. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56333. */
  56334. private _halfDomeMask;
  56335. /**
  56336. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56337. * Also see the options.resolution property.
  56338. */
  56339. get fovMultiplier(): number;
  56340. set fovMultiplier(value: number);
  56341. private _videoMode;
  56342. /**
  56343. * Gets or set the current video mode for the video. It can be:
  56344. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56345. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56346. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56347. */
  56348. get videoMode(): number;
  56349. set videoMode(value: number);
  56350. /**
  56351. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56352. *
  56353. */
  56354. get halfDome(): boolean;
  56355. /**
  56356. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56357. */
  56358. set halfDome(enabled: boolean);
  56359. /**
  56360. * Oberserver used in Stereoscopic VR Mode.
  56361. */
  56362. private _onBeforeCameraRenderObserver;
  56363. /**
  56364. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56365. * @param name Element's name, child elements will append suffixes for their own names.
  56366. * @param urlsOrVideo defines the url(s) or the video element to use
  56367. * @param options An object containing optional or exposed sub element properties
  56368. */
  56369. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56370. resolution?: number;
  56371. clickToPlay?: boolean;
  56372. autoPlay?: boolean;
  56373. loop?: boolean;
  56374. size?: number;
  56375. poster?: string;
  56376. faceForward?: boolean;
  56377. useDirectMapping?: boolean;
  56378. halfDomeMode?: boolean;
  56379. }, scene: Scene);
  56380. private _changeVideoMode;
  56381. /**
  56382. * Releases resources associated with this node.
  56383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56385. */
  56386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56387. }
  56388. }
  56389. declare module BABYLON {
  56390. /**
  56391. * This class can be used to get instrumentation data from a Babylon engine
  56392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56393. */
  56394. export class EngineInstrumentation implements IDisposable {
  56395. /**
  56396. * Define the instrumented engine.
  56397. */
  56398. engine: Engine;
  56399. private _captureGPUFrameTime;
  56400. private _gpuFrameTimeToken;
  56401. private _gpuFrameTime;
  56402. private _captureShaderCompilationTime;
  56403. private _shaderCompilationTime;
  56404. private _onBeginFrameObserver;
  56405. private _onEndFrameObserver;
  56406. private _onBeforeShaderCompilationObserver;
  56407. private _onAfterShaderCompilationObserver;
  56408. /**
  56409. * Gets the perf counter used for GPU frame time
  56410. */
  56411. get gpuFrameTimeCounter(): PerfCounter;
  56412. /**
  56413. * Gets the GPU frame time capture status
  56414. */
  56415. get captureGPUFrameTime(): boolean;
  56416. /**
  56417. * Enable or disable the GPU frame time capture
  56418. */
  56419. set captureGPUFrameTime(value: boolean);
  56420. /**
  56421. * Gets the perf counter used for shader compilation time
  56422. */
  56423. get shaderCompilationTimeCounter(): PerfCounter;
  56424. /**
  56425. * Gets the shader compilation time capture status
  56426. */
  56427. get captureShaderCompilationTime(): boolean;
  56428. /**
  56429. * Enable or disable the shader compilation time capture
  56430. */
  56431. set captureShaderCompilationTime(value: boolean);
  56432. /**
  56433. * Instantiates a new engine instrumentation.
  56434. * This class can be used to get instrumentation data from a Babylon engine
  56435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56436. * @param engine Defines the engine to instrument
  56437. */
  56438. constructor(
  56439. /**
  56440. * Define the instrumented engine.
  56441. */
  56442. engine: Engine);
  56443. /**
  56444. * Dispose and release associated resources.
  56445. */
  56446. dispose(): void;
  56447. }
  56448. }
  56449. declare module BABYLON {
  56450. /**
  56451. * This class can be used to get instrumentation data from a Babylon engine
  56452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56453. */
  56454. export class SceneInstrumentation implements IDisposable {
  56455. /**
  56456. * Defines the scene to instrument
  56457. */
  56458. scene: Scene;
  56459. private _captureActiveMeshesEvaluationTime;
  56460. private _activeMeshesEvaluationTime;
  56461. private _captureRenderTargetsRenderTime;
  56462. private _renderTargetsRenderTime;
  56463. private _captureFrameTime;
  56464. private _frameTime;
  56465. private _captureRenderTime;
  56466. private _renderTime;
  56467. private _captureInterFrameTime;
  56468. private _interFrameTime;
  56469. private _captureParticlesRenderTime;
  56470. private _particlesRenderTime;
  56471. private _captureSpritesRenderTime;
  56472. private _spritesRenderTime;
  56473. private _capturePhysicsTime;
  56474. private _physicsTime;
  56475. private _captureAnimationsTime;
  56476. private _animationsTime;
  56477. private _captureCameraRenderTime;
  56478. private _cameraRenderTime;
  56479. private _onBeforeActiveMeshesEvaluationObserver;
  56480. private _onAfterActiveMeshesEvaluationObserver;
  56481. private _onBeforeRenderTargetsRenderObserver;
  56482. private _onAfterRenderTargetsRenderObserver;
  56483. private _onAfterRenderObserver;
  56484. private _onBeforeDrawPhaseObserver;
  56485. private _onAfterDrawPhaseObserver;
  56486. private _onBeforeAnimationsObserver;
  56487. private _onBeforeParticlesRenderingObserver;
  56488. private _onAfterParticlesRenderingObserver;
  56489. private _onBeforeSpritesRenderingObserver;
  56490. private _onAfterSpritesRenderingObserver;
  56491. private _onBeforePhysicsObserver;
  56492. private _onAfterPhysicsObserver;
  56493. private _onAfterAnimationsObserver;
  56494. private _onBeforeCameraRenderObserver;
  56495. private _onAfterCameraRenderObserver;
  56496. /**
  56497. * Gets the perf counter used for active meshes evaluation time
  56498. */
  56499. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56500. /**
  56501. * Gets the active meshes evaluation time capture status
  56502. */
  56503. get captureActiveMeshesEvaluationTime(): boolean;
  56504. /**
  56505. * Enable or disable the active meshes evaluation time capture
  56506. */
  56507. set captureActiveMeshesEvaluationTime(value: boolean);
  56508. /**
  56509. * Gets the perf counter used for render targets render time
  56510. */
  56511. get renderTargetsRenderTimeCounter(): PerfCounter;
  56512. /**
  56513. * Gets the render targets render time capture status
  56514. */
  56515. get captureRenderTargetsRenderTime(): boolean;
  56516. /**
  56517. * Enable or disable the render targets render time capture
  56518. */
  56519. set captureRenderTargetsRenderTime(value: boolean);
  56520. /**
  56521. * Gets the perf counter used for particles render time
  56522. */
  56523. get particlesRenderTimeCounter(): PerfCounter;
  56524. /**
  56525. * Gets the particles render time capture status
  56526. */
  56527. get captureParticlesRenderTime(): boolean;
  56528. /**
  56529. * Enable or disable the particles render time capture
  56530. */
  56531. set captureParticlesRenderTime(value: boolean);
  56532. /**
  56533. * Gets the perf counter used for sprites render time
  56534. */
  56535. get spritesRenderTimeCounter(): PerfCounter;
  56536. /**
  56537. * Gets the sprites render time capture status
  56538. */
  56539. get captureSpritesRenderTime(): boolean;
  56540. /**
  56541. * Enable or disable the sprites render time capture
  56542. */
  56543. set captureSpritesRenderTime(value: boolean);
  56544. /**
  56545. * Gets the perf counter used for physics time
  56546. */
  56547. get physicsTimeCounter(): PerfCounter;
  56548. /**
  56549. * Gets the physics time capture status
  56550. */
  56551. get capturePhysicsTime(): boolean;
  56552. /**
  56553. * Enable or disable the physics time capture
  56554. */
  56555. set capturePhysicsTime(value: boolean);
  56556. /**
  56557. * Gets the perf counter used for animations time
  56558. */
  56559. get animationsTimeCounter(): PerfCounter;
  56560. /**
  56561. * Gets the animations time capture status
  56562. */
  56563. get captureAnimationsTime(): boolean;
  56564. /**
  56565. * Enable or disable the animations time capture
  56566. */
  56567. set captureAnimationsTime(value: boolean);
  56568. /**
  56569. * Gets the perf counter used for frame time capture
  56570. */
  56571. get frameTimeCounter(): PerfCounter;
  56572. /**
  56573. * Gets the frame time capture status
  56574. */
  56575. get captureFrameTime(): boolean;
  56576. /**
  56577. * Enable or disable the frame time capture
  56578. */
  56579. set captureFrameTime(value: boolean);
  56580. /**
  56581. * Gets the perf counter used for inter-frames time capture
  56582. */
  56583. get interFrameTimeCounter(): PerfCounter;
  56584. /**
  56585. * Gets the inter-frames time capture status
  56586. */
  56587. get captureInterFrameTime(): boolean;
  56588. /**
  56589. * Enable or disable the inter-frames time capture
  56590. */
  56591. set captureInterFrameTime(value: boolean);
  56592. /**
  56593. * Gets the perf counter used for render time capture
  56594. */
  56595. get renderTimeCounter(): PerfCounter;
  56596. /**
  56597. * Gets the render time capture status
  56598. */
  56599. get captureRenderTime(): boolean;
  56600. /**
  56601. * Enable or disable the render time capture
  56602. */
  56603. set captureRenderTime(value: boolean);
  56604. /**
  56605. * Gets the perf counter used for camera render time capture
  56606. */
  56607. get cameraRenderTimeCounter(): PerfCounter;
  56608. /**
  56609. * Gets the camera render time capture status
  56610. */
  56611. get captureCameraRenderTime(): boolean;
  56612. /**
  56613. * Enable or disable the camera render time capture
  56614. */
  56615. set captureCameraRenderTime(value: boolean);
  56616. /**
  56617. * Gets the perf counter used for draw calls
  56618. */
  56619. get drawCallsCounter(): PerfCounter;
  56620. /**
  56621. * Instantiates a new scene instrumentation.
  56622. * This class can be used to get instrumentation data from a Babylon engine
  56623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56624. * @param scene Defines the scene to instrument
  56625. */
  56626. constructor(
  56627. /**
  56628. * Defines the scene to instrument
  56629. */
  56630. scene: Scene);
  56631. /**
  56632. * Dispose and release associated resources.
  56633. */
  56634. dispose(): void;
  56635. }
  56636. }
  56637. declare module BABYLON {
  56638. /** @hidden */
  56639. export var glowMapGenerationPixelShader: {
  56640. name: string;
  56641. shader: string;
  56642. };
  56643. }
  56644. declare module BABYLON {
  56645. /** @hidden */
  56646. export var glowMapGenerationVertexShader: {
  56647. name: string;
  56648. shader: string;
  56649. };
  56650. }
  56651. declare module BABYLON {
  56652. /**
  56653. * Effect layer options. This helps customizing the behaviour
  56654. * of the effect layer.
  56655. */
  56656. export interface IEffectLayerOptions {
  56657. /**
  56658. * Multiplication factor apply to the canvas size to compute the render target size
  56659. * used to generated the objects (the smaller the faster).
  56660. */
  56661. mainTextureRatio: number;
  56662. /**
  56663. * Enforces a fixed size texture to ensure effect stability across devices.
  56664. */
  56665. mainTextureFixedSize?: number;
  56666. /**
  56667. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56668. */
  56669. alphaBlendingMode: number;
  56670. /**
  56671. * The camera attached to the layer.
  56672. */
  56673. camera: Nullable<Camera>;
  56674. /**
  56675. * The rendering group to draw the layer in.
  56676. */
  56677. renderingGroupId: number;
  56678. }
  56679. /**
  56680. * The effect layer Helps adding post process effect blended with the main pass.
  56681. *
  56682. * This can be for instance use to generate glow or higlight effects on the scene.
  56683. *
  56684. * The effect layer class can not be used directly and is intented to inherited from to be
  56685. * customized per effects.
  56686. */
  56687. export abstract class EffectLayer {
  56688. private _vertexBuffers;
  56689. private _indexBuffer;
  56690. private _cachedDefines;
  56691. private _effectLayerMapGenerationEffect;
  56692. private _effectLayerOptions;
  56693. private _mergeEffect;
  56694. protected _scene: Scene;
  56695. protected _engine: Engine;
  56696. protected _maxSize: number;
  56697. protected _mainTextureDesiredSize: ISize;
  56698. protected _mainTexture: RenderTargetTexture;
  56699. protected _shouldRender: boolean;
  56700. protected _postProcesses: PostProcess[];
  56701. protected _textures: BaseTexture[];
  56702. protected _emissiveTextureAndColor: {
  56703. texture: Nullable<BaseTexture>;
  56704. color: Color4;
  56705. };
  56706. /**
  56707. * The name of the layer
  56708. */
  56709. name: string;
  56710. /**
  56711. * The clear color of the texture used to generate the glow map.
  56712. */
  56713. neutralColor: Color4;
  56714. /**
  56715. * Specifies whether the highlight layer is enabled or not.
  56716. */
  56717. isEnabled: boolean;
  56718. /**
  56719. * Gets the camera attached to the layer.
  56720. */
  56721. get camera(): Nullable<Camera>;
  56722. /**
  56723. * Gets the rendering group id the layer should render in.
  56724. */
  56725. get renderingGroupId(): number;
  56726. set renderingGroupId(renderingGroupId: number);
  56727. /**
  56728. * An event triggered when the effect layer has been disposed.
  56729. */
  56730. onDisposeObservable: Observable<EffectLayer>;
  56731. /**
  56732. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56733. */
  56734. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56735. /**
  56736. * An event triggered when the generated texture is being merged in the scene.
  56737. */
  56738. onBeforeComposeObservable: Observable<EffectLayer>;
  56739. /**
  56740. * An event triggered when the mesh is rendered into the effect render target.
  56741. */
  56742. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56743. /**
  56744. * An event triggered after the mesh has been rendered into the effect render target.
  56745. */
  56746. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56747. /**
  56748. * An event triggered when the generated texture has been merged in the scene.
  56749. */
  56750. onAfterComposeObservable: Observable<EffectLayer>;
  56751. /**
  56752. * An event triggered when the efffect layer changes its size.
  56753. */
  56754. onSizeChangedObservable: Observable<EffectLayer>;
  56755. /** @hidden */
  56756. static _SceneComponentInitialization: (scene: Scene) => void;
  56757. /**
  56758. * Instantiates a new effect Layer and references it in the scene.
  56759. * @param name The name of the layer
  56760. * @param scene The scene to use the layer in
  56761. */
  56762. constructor(
  56763. /** The Friendly of the effect in the scene */
  56764. name: string, scene: Scene);
  56765. /**
  56766. * Get the effect name of the layer.
  56767. * @return The effect name
  56768. */
  56769. abstract getEffectName(): string;
  56770. /**
  56771. * Checks for the readiness of the element composing the layer.
  56772. * @param subMesh the mesh to check for
  56773. * @param useInstances specify whether or not to use instances to render the mesh
  56774. * @return true if ready otherwise, false
  56775. */
  56776. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56777. /**
  56778. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56779. * @returns true if the effect requires stencil during the main canvas render pass.
  56780. */
  56781. abstract needStencil(): boolean;
  56782. /**
  56783. * Create the merge effect. This is the shader use to blit the information back
  56784. * to the main canvas at the end of the scene rendering.
  56785. * @returns The effect containing the shader used to merge the effect on the main canvas
  56786. */
  56787. protected abstract _createMergeEffect(): Effect;
  56788. /**
  56789. * Creates the render target textures and post processes used in the effect layer.
  56790. */
  56791. protected abstract _createTextureAndPostProcesses(): void;
  56792. /**
  56793. * Implementation specific of rendering the generating effect on the main canvas.
  56794. * @param effect The effect used to render through
  56795. */
  56796. protected abstract _internalRender(effect: Effect): void;
  56797. /**
  56798. * Sets the required values for both the emissive texture and and the main color.
  56799. */
  56800. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56801. /**
  56802. * Free any resources and references associated to a mesh.
  56803. * Internal use
  56804. * @param mesh The mesh to free.
  56805. */
  56806. abstract _disposeMesh(mesh: Mesh): void;
  56807. /**
  56808. * Serializes this layer (Glow or Highlight for example)
  56809. * @returns a serialized layer object
  56810. */
  56811. abstract serialize?(): any;
  56812. /**
  56813. * Initializes the effect layer with the required options.
  56814. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56815. */
  56816. protected _init(options: Partial<IEffectLayerOptions>): void;
  56817. /**
  56818. * Generates the index buffer of the full screen quad blending to the main canvas.
  56819. */
  56820. private _generateIndexBuffer;
  56821. /**
  56822. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56823. */
  56824. private _generateVertexBuffer;
  56825. /**
  56826. * Sets the main texture desired size which is the closest power of two
  56827. * of the engine canvas size.
  56828. */
  56829. private _setMainTextureSize;
  56830. /**
  56831. * Creates the main texture for the effect layer.
  56832. */
  56833. protected _createMainTexture(): void;
  56834. /**
  56835. * Adds specific effects defines.
  56836. * @param defines The defines to add specifics to.
  56837. */
  56838. protected _addCustomEffectDefines(defines: string[]): void;
  56839. /**
  56840. * Checks for the readiness of the element composing the layer.
  56841. * @param subMesh the mesh to check for
  56842. * @param useInstances specify whether or not to use instances to render the mesh
  56843. * @param emissiveTexture the associated emissive texture used to generate the glow
  56844. * @return true if ready otherwise, false
  56845. */
  56846. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56847. /**
  56848. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56849. */
  56850. render(): void;
  56851. /**
  56852. * Determine if a given mesh will be used in the current effect.
  56853. * @param mesh mesh to test
  56854. * @returns true if the mesh will be used
  56855. */
  56856. hasMesh(mesh: AbstractMesh): boolean;
  56857. /**
  56858. * Returns true if the layer contains information to display, otherwise false.
  56859. * @returns true if the glow layer should be rendered
  56860. */
  56861. shouldRender(): boolean;
  56862. /**
  56863. * Returns true if the mesh should render, otherwise false.
  56864. * @param mesh The mesh to render
  56865. * @returns true if it should render otherwise false
  56866. */
  56867. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56868. /**
  56869. * Returns true if the mesh can be rendered, otherwise false.
  56870. * @param mesh The mesh to render
  56871. * @param material The material used on the mesh
  56872. * @returns true if it can be rendered otherwise false
  56873. */
  56874. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56875. /**
  56876. * Returns true if the mesh should render, otherwise false.
  56877. * @param mesh The mesh to render
  56878. * @returns true if it should render otherwise false
  56879. */
  56880. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56881. /**
  56882. * Renders the submesh passed in parameter to the generation map.
  56883. */
  56884. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56885. /**
  56886. * Defines whether the current material of the mesh should be use to render the effect.
  56887. * @param mesh defines the current mesh to render
  56888. */
  56889. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56890. /**
  56891. * Rebuild the required buffers.
  56892. * @hidden Internal use only.
  56893. */
  56894. _rebuild(): void;
  56895. /**
  56896. * Dispose only the render target textures and post process.
  56897. */
  56898. private _disposeTextureAndPostProcesses;
  56899. /**
  56900. * Dispose the highlight layer and free resources.
  56901. */
  56902. dispose(): void;
  56903. /**
  56904. * Gets the class name of the effect layer
  56905. * @returns the string with the class name of the effect layer
  56906. */
  56907. getClassName(): string;
  56908. /**
  56909. * Creates an effect layer from parsed effect layer data
  56910. * @param parsedEffectLayer defines effect layer data
  56911. * @param scene defines the current scene
  56912. * @param rootUrl defines the root URL containing the effect layer information
  56913. * @returns a parsed effect Layer
  56914. */
  56915. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56916. }
  56917. }
  56918. declare module BABYLON {
  56919. interface AbstractScene {
  56920. /**
  56921. * The list of effect layers (highlights/glow) added to the scene
  56922. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56923. * @see http://doc.babylonjs.com/how_to/glow_layer
  56924. */
  56925. effectLayers: Array<EffectLayer>;
  56926. /**
  56927. * Removes the given effect layer from this scene.
  56928. * @param toRemove defines the effect layer to remove
  56929. * @returns the index of the removed effect layer
  56930. */
  56931. removeEffectLayer(toRemove: EffectLayer): number;
  56932. /**
  56933. * Adds the given effect layer to this scene
  56934. * @param newEffectLayer defines the effect layer to add
  56935. */
  56936. addEffectLayer(newEffectLayer: EffectLayer): void;
  56937. }
  56938. /**
  56939. * Defines the layer scene component responsible to manage any effect layers
  56940. * in a given scene.
  56941. */
  56942. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56943. /**
  56944. * The component name helpfull to identify the component in the list of scene components.
  56945. */
  56946. readonly name: string;
  56947. /**
  56948. * The scene the component belongs to.
  56949. */
  56950. scene: Scene;
  56951. private _engine;
  56952. private _renderEffects;
  56953. private _needStencil;
  56954. private _previousStencilState;
  56955. /**
  56956. * Creates a new instance of the component for the given scene
  56957. * @param scene Defines the scene to register the component in
  56958. */
  56959. constructor(scene: Scene);
  56960. /**
  56961. * Registers the component in a given scene
  56962. */
  56963. register(): void;
  56964. /**
  56965. * Rebuilds the elements related to this component in case of
  56966. * context lost for instance.
  56967. */
  56968. rebuild(): void;
  56969. /**
  56970. * Serializes the component data to the specified json object
  56971. * @param serializationObject The object to serialize to
  56972. */
  56973. serialize(serializationObject: any): void;
  56974. /**
  56975. * Adds all the elements from the container to the scene
  56976. * @param container the container holding the elements
  56977. */
  56978. addFromContainer(container: AbstractScene): void;
  56979. /**
  56980. * Removes all the elements in the container from the scene
  56981. * @param container contains the elements to remove
  56982. * @param dispose if the removed element should be disposed (default: false)
  56983. */
  56984. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56985. /**
  56986. * Disposes the component and the associated ressources.
  56987. */
  56988. dispose(): void;
  56989. private _isReadyForMesh;
  56990. private _renderMainTexture;
  56991. private _setStencil;
  56992. private _setStencilBack;
  56993. private _draw;
  56994. private _drawCamera;
  56995. private _drawRenderingGroup;
  56996. }
  56997. }
  56998. declare module BABYLON {
  56999. /** @hidden */
  57000. export var glowMapMergePixelShader: {
  57001. name: string;
  57002. shader: string;
  57003. };
  57004. }
  57005. declare module BABYLON {
  57006. /** @hidden */
  57007. export var glowMapMergeVertexShader: {
  57008. name: string;
  57009. shader: string;
  57010. };
  57011. }
  57012. declare module BABYLON {
  57013. interface AbstractScene {
  57014. /**
  57015. * Return a the first highlight layer of the scene with a given name.
  57016. * @param name The name of the highlight layer to look for.
  57017. * @return The highlight layer if found otherwise null.
  57018. */
  57019. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57020. }
  57021. /**
  57022. * Glow layer options. This helps customizing the behaviour
  57023. * of the glow layer.
  57024. */
  57025. export interface IGlowLayerOptions {
  57026. /**
  57027. * Multiplication factor apply to the canvas size to compute the render target size
  57028. * used to generated the glowing objects (the smaller the faster).
  57029. */
  57030. mainTextureRatio: number;
  57031. /**
  57032. * Enforces a fixed size texture to ensure resize independant blur.
  57033. */
  57034. mainTextureFixedSize?: number;
  57035. /**
  57036. * How big is the kernel of the blur texture.
  57037. */
  57038. blurKernelSize: number;
  57039. /**
  57040. * The camera attached to the layer.
  57041. */
  57042. camera: Nullable<Camera>;
  57043. /**
  57044. * Enable MSAA by chosing the number of samples.
  57045. */
  57046. mainTextureSamples?: number;
  57047. /**
  57048. * The rendering group to draw the layer in.
  57049. */
  57050. renderingGroupId: number;
  57051. }
  57052. /**
  57053. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57054. *
  57055. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57056. *
  57057. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57058. */
  57059. export class GlowLayer extends EffectLayer {
  57060. /**
  57061. * Effect Name of the layer.
  57062. */
  57063. static readonly EffectName: string;
  57064. /**
  57065. * The default blur kernel size used for the glow.
  57066. */
  57067. static DefaultBlurKernelSize: number;
  57068. /**
  57069. * The default texture size ratio used for the glow.
  57070. */
  57071. static DefaultTextureRatio: number;
  57072. /**
  57073. * Sets the kernel size of the blur.
  57074. */
  57075. set blurKernelSize(value: number);
  57076. /**
  57077. * Gets the kernel size of the blur.
  57078. */
  57079. get blurKernelSize(): number;
  57080. /**
  57081. * Sets the glow intensity.
  57082. */
  57083. set intensity(value: number);
  57084. /**
  57085. * Gets the glow intensity.
  57086. */
  57087. get intensity(): number;
  57088. private _options;
  57089. private _intensity;
  57090. private _horizontalBlurPostprocess1;
  57091. private _verticalBlurPostprocess1;
  57092. private _horizontalBlurPostprocess2;
  57093. private _verticalBlurPostprocess2;
  57094. private _blurTexture1;
  57095. private _blurTexture2;
  57096. private _postProcesses1;
  57097. private _postProcesses2;
  57098. private _includedOnlyMeshes;
  57099. private _excludedMeshes;
  57100. private _meshesUsingTheirOwnMaterials;
  57101. /**
  57102. * Callback used to let the user override the color selection on a per mesh basis
  57103. */
  57104. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57105. /**
  57106. * Callback used to let the user override the texture selection on a per mesh basis
  57107. */
  57108. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57109. /**
  57110. * Instantiates a new glow Layer and references it to the scene.
  57111. * @param name The name of the layer
  57112. * @param scene The scene to use the layer in
  57113. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57114. */
  57115. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57116. /**
  57117. * Get the effect name of the layer.
  57118. * @return The effect name
  57119. */
  57120. getEffectName(): string;
  57121. /**
  57122. * Create the merge effect. This is the shader use to blit the information back
  57123. * to the main canvas at the end of the scene rendering.
  57124. */
  57125. protected _createMergeEffect(): Effect;
  57126. /**
  57127. * Creates the render target textures and post processes used in the glow layer.
  57128. */
  57129. protected _createTextureAndPostProcesses(): void;
  57130. /**
  57131. * Checks for the readiness of the element composing the layer.
  57132. * @param subMesh the mesh to check for
  57133. * @param useInstances specify wether or not to use instances to render the mesh
  57134. * @param emissiveTexture the associated emissive texture used to generate the glow
  57135. * @return true if ready otherwise, false
  57136. */
  57137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57138. /**
  57139. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57140. */
  57141. needStencil(): boolean;
  57142. /**
  57143. * Returns true if the mesh can be rendered, otherwise false.
  57144. * @param mesh The mesh to render
  57145. * @param material The material used on the mesh
  57146. * @returns true if it can be rendered otherwise false
  57147. */
  57148. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57149. /**
  57150. * Implementation specific of rendering the generating effect on the main canvas.
  57151. * @param effect The effect used to render through
  57152. */
  57153. protected _internalRender(effect: Effect): void;
  57154. /**
  57155. * Sets the required values for both the emissive texture and and the main color.
  57156. */
  57157. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57158. /**
  57159. * Returns true if the mesh should render, otherwise false.
  57160. * @param mesh The mesh to render
  57161. * @returns true if it should render otherwise false
  57162. */
  57163. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57164. /**
  57165. * Adds specific effects defines.
  57166. * @param defines The defines to add specifics to.
  57167. */
  57168. protected _addCustomEffectDefines(defines: string[]): void;
  57169. /**
  57170. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57171. * @param mesh The mesh to exclude from the glow layer
  57172. */
  57173. addExcludedMesh(mesh: Mesh): void;
  57174. /**
  57175. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57176. * @param mesh The mesh to remove
  57177. */
  57178. removeExcludedMesh(mesh: Mesh): void;
  57179. /**
  57180. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57181. * @param mesh The mesh to include in the glow layer
  57182. */
  57183. addIncludedOnlyMesh(mesh: Mesh): void;
  57184. /**
  57185. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57186. * @param mesh The mesh to remove
  57187. */
  57188. removeIncludedOnlyMesh(mesh: Mesh): void;
  57189. /**
  57190. * Determine if a given mesh will be used in the glow layer
  57191. * @param mesh The mesh to test
  57192. * @returns true if the mesh will be highlighted by the current glow layer
  57193. */
  57194. hasMesh(mesh: AbstractMesh): boolean;
  57195. /**
  57196. * Defines whether the current material of the mesh should be use to render the effect.
  57197. * @param mesh defines the current mesh to render
  57198. */
  57199. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57200. /**
  57201. * Add a mesh to be rendered through its own material and not with emissive only.
  57202. * @param mesh The mesh for which we need to use its material
  57203. */
  57204. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57205. /**
  57206. * Remove a mesh from being rendered through its own material and not with emissive only.
  57207. * @param mesh The mesh for which we need to not use its material
  57208. */
  57209. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57210. /**
  57211. * Free any resources and references associated to a mesh.
  57212. * Internal use
  57213. * @param mesh The mesh to free.
  57214. * @hidden
  57215. */
  57216. _disposeMesh(mesh: Mesh): 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 glow layer
  57224. * @returns a serialized glow layer object
  57225. */
  57226. serialize(): any;
  57227. /**
  57228. * Creates a Glow Layer from parsed glow layer data
  57229. * @param parsedGlowLayer defines glow layer data
  57230. * @param scene defines the current scene
  57231. * @param rootUrl defines the root URL containing the glow layer information
  57232. * @returns a parsed Glow Layer
  57233. */
  57234. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57235. }
  57236. }
  57237. declare module BABYLON {
  57238. /** @hidden */
  57239. export var glowBlurPostProcessPixelShader: {
  57240. name: string;
  57241. shader: string;
  57242. };
  57243. }
  57244. declare module BABYLON {
  57245. interface AbstractScene {
  57246. /**
  57247. * Return a the first highlight layer of the scene with a given name.
  57248. * @param name The name of the highlight layer to look for.
  57249. * @return The highlight layer if found otherwise null.
  57250. */
  57251. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57252. }
  57253. /**
  57254. * Highlight layer options. This helps customizing the behaviour
  57255. * of the highlight layer.
  57256. */
  57257. export interface IHighlightLayerOptions {
  57258. /**
  57259. * Multiplication factor apply to the canvas size to compute the render target size
  57260. * used to generated the glowing objects (the smaller the faster).
  57261. */
  57262. mainTextureRatio: number;
  57263. /**
  57264. * Enforces a fixed size texture to ensure resize independant blur.
  57265. */
  57266. mainTextureFixedSize?: number;
  57267. /**
  57268. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57269. * of the picture to blur (the smaller the faster).
  57270. */
  57271. blurTextureSizeRatio: number;
  57272. /**
  57273. * How big in texel of the blur texture is the vertical blur.
  57274. */
  57275. blurVerticalSize: number;
  57276. /**
  57277. * How big in texel of the blur texture is the horizontal blur.
  57278. */
  57279. blurHorizontalSize: number;
  57280. /**
  57281. * Alpha blending mode used to apply the blur. Default is combine.
  57282. */
  57283. alphaBlendingMode: number;
  57284. /**
  57285. * The camera attached to the layer.
  57286. */
  57287. camera: Nullable<Camera>;
  57288. /**
  57289. * Should we display highlight as a solid stroke?
  57290. */
  57291. isStroke?: boolean;
  57292. /**
  57293. * The rendering group to draw the layer in.
  57294. */
  57295. renderingGroupId: number;
  57296. }
  57297. /**
  57298. * The highlight layer Helps adding a glow effect around a mesh.
  57299. *
  57300. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57301. * glowy meshes to your scene.
  57302. *
  57303. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57304. */
  57305. export class HighlightLayer extends EffectLayer {
  57306. name: string;
  57307. /**
  57308. * Effect Name of the highlight layer.
  57309. */
  57310. static readonly EffectName: string;
  57311. /**
  57312. * The neutral color used during the preparation of the glow effect.
  57313. * This is black by default as the blend operation is a blend operation.
  57314. */
  57315. static NeutralColor: Color4;
  57316. /**
  57317. * Stencil value used for glowing meshes.
  57318. */
  57319. static GlowingMeshStencilReference: number;
  57320. /**
  57321. * Stencil value used for the other meshes in the scene.
  57322. */
  57323. static NormalMeshStencilReference: number;
  57324. /**
  57325. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57326. */
  57327. innerGlow: boolean;
  57328. /**
  57329. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57330. */
  57331. outerGlow: boolean;
  57332. /**
  57333. * Specifies the horizontal size of the blur.
  57334. */
  57335. set blurHorizontalSize(value: number);
  57336. /**
  57337. * Specifies the vertical size of the blur.
  57338. */
  57339. set blurVerticalSize(value: number);
  57340. /**
  57341. * Gets the horizontal size of the blur.
  57342. */
  57343. get blurHorizontalSize(): number;
  57344. /**
  57345. * Gets the vertical size of the blur.
  57346. */
  57347. get blurVerticalSize(): number;
  57348. /**
  57349. * An event triggered when the highlight layer is being blurred.
  57350. */
  57351. onBeforeBlurObservable: Observable<HighlightLayer>;
  57352. /**
  57353. * An event triggered when the highlight layer has been blurred.
  57354. */
  57355. onAfterBlurObservable: Observable<HighlightLayer>;
  57356. private _instanceGlowingMeshStencilReference;
  57357. private _options;
  57358. private _downSamplePostprocess;
  57359. private _horizontalBlurPostprocess;
  57360. private _verticalBlurPostprocess;
  57361. private _blurTexture;
  57362. private _meshes;
  57363. private _excludedMeshes;
  57364. /**
  57365. * Instantiates a new highlight Layer and references it to the scene..
  57366. * @param name The name of the layer
  57367. * @param scene The scene to use the layer in
  57368. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57369. */
  57370. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57371. /**
  57372. * Get the effect name of the layer.
  57373. * @return The effect name
  57374. */
  57375. getEffectName(): string;
  57376. /**
  57377. * Create the merge effect. This is the shader use to blit the information back
  57378. * to the main canvas at the end of the scene rendering.
  57379. */
  57380. protected _createMergeEffect(): Effect;
  57381. /**
  57382. * Creates the render target textures and post processes used in the highlight layer.
  57383. */
  57384. protected _createTextureAndPostProcesses(): void;
  57385. /**
  57386. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57387. */
  57388. needStencil(): boolean;
  57389. /**
  57390. * Checks for the readiness of the element composing the layer.
  57391. * @param subMesh the mesh to check for
  57392. * @param useInstances specify wether or not to use instances to render the mesh
  57393. * @param emissiveTexture the associated emissive texture used to generate the glow
  57394. * @return true if ready otherwise, false
  57395. */
  57396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57397. /**
  57398. * Implementation specific of rendering the generating effect on the main canvas.
  57399. * @param effect The effect used to render through
  57400. */
  57401. protected _internalRender(effect: Effect): void;
  57402. /**
  57403. * Returns true if the layer contains information to display, otherwise false.
  57404. */
  57405. shouldRender(): boolean;
  57406. /**
  57407. * Returns true if the mesh should render, otherwise false.
  57408. * @param mesh The mesh to render
  57409. * @returns true if it should render otherwise false
  57410. */
  57411. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57412. /**
  57413. * Adds specific effects defines.
  57414. * @param defines The defines to add specifics to.
  57415. */
  57416. protected _addCustomEffectDefines(defines: string[]): void;
  57417. /**
  57418. * Sets the required values for both the emissive texture and and the main color.
  57419. */
  57420. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57421. /**
  57422. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57423. * @param mesh The mesh to exclude from the highlight layer
  57424. */
  57425. addExcludedMesh(mesh: Mesh): void;
  57426. /**
  57427. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57428. * @param mesh The mesh to highlight
  57429. */
  57430. removeExcludedMesh(mesh: Mesh): void;
  57431. /**
  57432. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57433. * @param mesh mesh to test
  57434. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57435. */
  57436. hasMesh(mesh: AbstractMesh): boolean;
  57437. /**
  57438. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57439. * @param mesh The mesh to highlight
  57440. * @param color The color of the highlight
  57441. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57442. */
  57443. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57444. /**
  57445. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57446. * @param mesh The mesh to highlight
  57447. */
  57448. removeMesh(mesh: Mesh): void;
  57449. /**
  57450. * Remove all the meshes currently referenced in the highlight layer
  57451. */
  57452. removeAllMeshes(): void;
  57453. /**
  57454. * Force the stencil to the normal expected value for none glowing parts
  57455. */
  57456. private _defaultStencilReference;
  57457. /**
  57458. * Free any resources and references associated to a mesh.
  57459. * Internal use
  57460. * @param mesh The mesh to free.
  57461. * @hidden
  57462. */
  57463. _disposeMesh(mesh: Mesh): void;
  57464. /**
  57465. * Dispose the highlight layer and free resources.
  57466. */
  57467. dispose(): void;
  57468. /**
  57469. * Gets the class name of the effect layer
  57470. * @returns the string with the class name of the effect layer
  57471. */
  57472. getClassName(): string;
  57473. /**
  57474. * Serializes this Highlight layer
  57475. * @returns a serialized Highlight layer object
  57476. */
  57477. serialize(): any;
  57478. /**
  57479. * Creates a Highlight layer from parsed Highlight layer data
  57480. * @param parsedHightlightLayer defines the Highlight layer data
  57481. * @param scene defines the current scene
  57482. * @param rootUrl defines the root URL containing the Highlight layer information
  57483. * @returns a parsed Highlight layer
  57484. */
  57485. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57486. }
  57487. }
  57488. declare module BABYLON {
  57489. interface AbstractScene {
  57490. /**
  57491. * The list of layers (background and foreground) of the scene
  57492. */
  57493. layers: Array<Layer>;
  57494. }
  57495. /**
  57496. * Defines the layer scene component responsible to manage any layers
  57497. * in a given scene.
  57498. */
  57499. export class LayerSceneComponent implements ISceneComponent {
  57500. /**
  57501. * The component name helpfull to identify the component in the list of scene components.
  57502. */
  57503. readonly name: string;
  57504. /**
  57505. * The scene the component belongs to.
  57506. */
  57507. scene: Scene;
  57508. private _engine;
  57509. /**
  57510. * Creates a new instance of the component for the given scene
  57511. * @param scene Defines the scene to register the component in
  57512. */
  57513. constructor(scene: Scene);
  57514. /**
  57515. * Registers the component in a given scene
  57516. */
  57517. register(): void;
  57518. /**
  57519. * Rebuilds the elements related to this component in case of
  57520. * context lost for instance.
  57521. */
  57522. rebuild(): void;
  57523. /**
  57524. * Disposes the component and the associated ressources.
  57525. */
  57526. dispose(): void;
  57527. private _draw;
  57528. private _drawCameraPredicate;
  57529. private _drawCameraBackground;
  57530. private _drawCameraForeground;
  57531. private _drawRenderTargetPredicate;
  57532. private _drawRenderTargetBackground;
  57533. private _drawRenderTargetForeground;
  57534. /**
  57535. * Adds all the elements from the container to the scene
  57536. * @param container the container holding the elements
  57537. */
  57538. addFromContainer(container: AbstractScene): void;
  57539. /**
  57540. * Removes all the elements in the container from the scene
  57541. * @param container contains the elements to remove
  57542. * @param dispose if the removed element should be disposed (default: false)
  57543. */
  57544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57545. }
  57546. }
  57547. declare module BABYLON {
  57548. /** @hidden */
  57549. export var layerPixelShader: {
  57550. name: string;
  57551. shader: string;
  57552. };
  57553. }
  57554. declare module BABYLON {
  57555. /** @hidden */
  57556. export var layerVertexShader: {
  57557. name: string;
  57558. shader: string;
  57559. };
  57560. }
  57561. declare module BABYLON {
  57562. /**
  57563. * This represents a full screen 2d layer.
  57564. * This can be useful to display a picture in the background of your scene for instance.
  57565. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57566. */
  57567. export class Layer {
  57568. /**
  57569. * Define the name of the layer.
  57570. */
  57571. name: string;
  57572. /**
  57573. * Define the texture the layer should display.
  57574. */
  57575. texture: Nullable<Texture>;
  57576. /**
  57577. * Is the layer in background or foreground.
  57578. */
  57579. isBackground: boolean;
  57580. /**
  57581. * Define the color of the layer (instead of texture).
  57582. */
  57583. color: Color4;
  57584. /**
  57585. * Define the scale of the layer in order to zoom in out of the texture.
  57586. */
  57587. scale: Vector2;
  57588. /**
  57589. * Define an offset for the layer in order to shift the texture.
  57590. */
  57591. offset: Vector2;
  57592. /**
  57593. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57594. */
  57595. alphaBlendingMode: number;
  57596. /**
  57597. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57598. * Alpha test will not mix with the background color in case of transparency.
  57599. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57600. */
  57601. alphaTest: boolean;
  57602. /**
  57603. * Define a mask to restrict the layer to only some of the scene cameras.
  57604. */
  57605. layerMask: number;
  57606. /**
  57607. * Define the list of render target the layer is visible into.
  57608. */
  57609. renderTargetTextures: RenderTargetTexture[];
  57610. /**
  57611. * Define if the layer is only used in renderTarget or if it also
  57612. * renders in the main frame buffer of the canvas.
  57613. */
  57614. renderOnlyInRenderTargetTextures: boolean;
  57615. private _scene;
  57616. private _vertexBuffers;
  57617. private _indexBuffer;
  57618. private _effect;
  57619. private _previousDefines;
  57620. /**
  57621. * An event triggered when the layer is disposed.
  57622. */
  57623. onDisposeObservable: Observable<Layer>;
  57624. private _onDisposeObserver;
  57625. /**
  57626. * Back compatibility with callback before the onDisposeObservable existed.
  57627. * The set callback will be triggered when the layer has been disposed.
  57628. */
  57629. set onDispose(callback: () => void);
  57630. /**
  57631. * An event triggered before rendering the scene
  57632. */
  57633. onBeforeRenderObservable: Observable<Layer>;
  57634. private _onBeforeRenderObserver;
  57635. /**
  57636. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57637. * The set callback will be triggered just before rendering the layer.
  57638. */
  57639. set onBeforeRender(callback: () => void);
  57640. /**
  57641. * An event triggered after rendering the scene
  57642. */
  57643. onAfterRenderObservable: Observable<Layer>;
  57644. private _onAfterRenderObserver;
  57645. /**
  57646. * Back compatibility with callback before the onAfterRenderObservable existed.
  57647. * The set callback will be triggered just after rendering the layer.
  57648. */
  57649. set onAfterRender(callback: () => void);
  57650. /**
  57651. * Instantiates a new layer.
  57652. * This represents a full screen 2d layer.
  57653. * This can be useful to display a picture in the background of your scene for instance.
  57654. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57655. * @param name Define the name of the layer in the scene
  57656. * @param imgUrl Define the url of the texture to display in the layer
  57657. * @param scene Define the scene the layer belongs to
  57658. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57659. * @param color Defines a color for the layer
  57660. */
  57661. constructor(
  57662. /**
  57663. * Define the name of the layer.
  57664. */
  57665. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57666. private _createIndexBuffer;
  57667. /** @hidden */
  57668. _rebuild(): void;
  57669. /**
  57670. * Renders the layer in the scene.
  57671. */
  57672. render(): void;
  57673. /**
  57674. * Disposes and releases the associated ressources.
  57675. */
  57676. dispose(): void;
  57677. }
  57678. }
  57679. declare module BABYLON {
  57680. /** @hidden */
  57681. export var lensFlarePixelShader: {
  57682. name: string;
  57683. shader: string;
  57684. };
  57685. }
  57686. declare module BABYLON {
  57687. /** @hidden */
  57688. export var lensFlareVertexShader: {
  57689. name: string;
  57690. shader: string;
  57691. };
  57692. }
  57693. declare module BABYLON {
  57694. /**
  57695. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57696. * It is usually composed of several `lensFlare`.
  57697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57698. */
  57699. export class LensFlareSystem {
  57700. /**
  57701. * Define the name of the lens flare system
  57702. */
  57703. name: string;
  57704. /**
  57705. * List of lens flares used in this system.
  57706. */
  57707. lensFlares: LensFlare[];
  57708. /**
  57709. * Define a limit from the border the lens flare can be visible.
  57710. */
  57711. borderLimit: number;
  57712. /**
  57713. * Define a viewport border we do not want to see the lens flare in.
  57714. */
  57715. viewportBorder: number;
  57716. /**
  57717. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57718. */
  57719. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57720. /**
  57721. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57722. */
  57723. layerMask: number;
  57724. /**
  57725. * Define the id of the lens flare system in the scene.
  57726. * (equal to name by default)
  57727. */
  57728. id: string;
  57729. private _scene;
  57730. private _emitter;
  57731. private _vertexBuffers;
  57732. private _indexBuffer;
  57733. private _effect;
  57734. private _positionX;
  57735. private _positionY;
  57736. private _isEnabled;
  57737. /** @hidden */
  57738. static _SceneComponentInitialization: (scene: Scene) => void;
  57739. /**
  57740. * Instantiates a lens flare system.
  57741. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57742. * It is usually composed of several `lensFlare`.
  57743. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57744. * @param name Define the name of the lens flare system in the scene
  57745. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57746. * @param scene Define the scene the lens flare system belongs to
  57747. */
  57748. constructor(
  57749. /**
  57750. * Define the name of the lens flare system
  57751. */
  57752. name: string, emitter: any, scene: Scene);
  57753. /**
  57754. * Define if the lens flare system is enabled.
  57755. */
  57756. get isEnabled(): boolean;
  57757. set isEnabled(value: boolean);
  57758. /**
  57759. * Get the scene the effects belongs to.
  57760. * @returns the scene holding the lens flare system
  57761. */
  57762. getScene(): Scene;
  57763. /**
  57764. * Get the emitter of the lens flare system.
  57765. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57766. * @returns the emitter of the lens flare system
  57767. */
  57768. getEmitter(): any;
  57769. /**
  57770. * Set the emitter of the lens flare system.
  57771. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57772. * @param newEmitter Define the new emitter of the system
  57773. */
  57774. setEmitter(newEmitter: any): void;
  57775. /**
  57776. * Get the lens flare system emitter position.
  57777. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57778. * @returns the position
  57779. */
  57780. getEmitterPosition(): Vector3;
  57781. /**
  57782. * @hidden
  57783. */
  57784. computeEffectivePosition(globalViewport: Viewport): boolean;
  57785. /** @hidden */
  57786. _isVisible(): boolean;
  57787. /**
  57788. * @hidden
  57789. */
  57790. render(): boolean;
  57791. /**
  57792. * Dispose and release the lens flare with its associated resources.
  57793. */
  57794. dispose(): void;
  57795. /**
  57796. * Parse a lens flare system from a JSON repressentation
  57797. * @param parsedLensFlareSystem Define the JSON to parse
  57798. * @param scene Define the scene the parsed system should be instantiated in
  57799. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57800. * @returns the parsed system
  57801. */
  57802. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57803. /**
  57804. * Serialize the current Lens Flare System into a JSON representation.
  57805. * @returns the serialized JSON
  57806. */
  57807. serialize(): any;
  57808. }
  57809. }
  57810. declare module BABYLON {
  57811. /**
  57812. * This represents one of the lens effect in a `lensFlareSystem`.
  57813. * It controls one of the indiviual texture used in the effect.
  57814. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57815. */
  57816. export class LensFlare {
  57817. /**
  57818. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57819. */
  57820. size: number;
  57821. /**
  57822. * 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.
  57823. */
  57824. position: number;
  57825. /**
  57826. * Define the lens color.
  57827. */
  57828. color: Color3;
  57829. /**
  57830. * Define the lens texture.
  57831. */
  57832. texture: Nullable<Texture>;
  57833. /**
  57834. * Define the alpha mode to render this particular lens.
  57835. */
  57836. alphaMode: number;
  57837. private _system;
  57838. /**
  57839. * Creates a new Lens Flare.
  57840. * This represents one of the lens effect in a `lensFlareSystem`.
  57841. * It controls one of the indiviual texture used in the effect.
  57842. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57843. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57844. * @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.
  57845. * @param color Define the lens color
  57846. * @param imgUrl Define the lens texture url
  57847. * @param system Define the `lensFlareSystem` this flare is part of
  57848. * @returns The newly created Lens Flare
  57849. */
  57850. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57851. /**
  57852. * Instantiates a new Lens Flare.
  57853. * This represents one of the lens effect in a `lensFlareSystem`.
  57854. * It controls one of the indiviual texture used in the effect.
  57855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57856. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57857. * @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.
  57858. * @param color Define the lens color
  57859. * @param imgUrl Define the lens texture url
  57860. * @param system Define the `lensFlareSystem` this flare is part of
  57861. */
  57862. constructor(
  57863. /**
  57864. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57865. */
  57866. size: number,
  57867. /**
  57868. * 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.
  57869. */
  57870. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57871. /**
  57872. * Dispose and release the lens flare with its associated resources.
  57873. */
  57874. dispose(): void;
  57875. }
  57876. }
  57877. declare module BABYLON {
  57878. interface AbstractScene {
  57879. /**
  57880. * The list of lens flare system added to the scene
  57881. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57882. */
  57883. lensFlareSystems: Array<LensFlareSystem>;
  57884. /**
  57885. * Removes the given lens flare system from this scene.
  57886. * @param toRemove The lens flare system to remove
  57887. * @returns The index of the removed lens flare system
  57888. */
  57889. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57890. /**
  57891. * Adds the given lens flare system to this scene
  57892. * @param newLensFlareSystem The lens flare system to add
  57893. */
  57894. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57895. /**
  57896. * Gets a lens flare system using its name
  57897. * @param name defines the name to look for
  57898. * @returns the lens flare system or null if not found
  57899. */
  57900. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57901. /**
  57902. * Gets a lens flare system using its id
  57903. * @param id defines the id to look for
  57904. * @returns the lens flare system or null if not found
  57905. */
  57906. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57907. }
  57908. /**
  57909. * Defines the lens flare scene component responsible to manage any lens flares
  57910. * in a given scene.
  57911. */
  57912. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57913. /**
  57914. * The component name helpfull to identify the component in the list of scene components.
  57915. */
  57916. readonly name: string;
  57917. /**
  57918. * The scene the component belongs to.
  57919. */
  57920. scene: Scene;
  57921. /**
  57922. * Creates a new instance of the component for the given scene
  57923. * @param scene Defines the scene to register the component in
  57924. */
  57925. constructor(scene: Scene);
  57926. /**
  57927. * Registers the component in a given scene
  57928. */
  57929. register(): void;
  57930. /**
  57931. * Rebuilds the elements related to this component in case of
  57932. * context lost for instance.
  57933. */
  57934. rebuild(): void;
  57935. /**
  57936. * Adds all the elements from the container to the scene
  57937. * @param container the container holding the elements
  57938. */
  57939. addFromContainer(container: AbstractScene): void;
  57940. /**
  57941. * Removes all the elements in the container from the scene
  57942. * @param container contains the elements to remove
  57943. * @param dispose if the removed element should be disposed (default: false)
  57944. */
  57945. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57946. /**
  57947. * Serializes the component data to the specified json object
  57948. * @param serializationObject The object to serialize to
  57949. */
  57950. serialize(serializationObject: any): void;
  57951. /**
  57952. * Disposes the component and the associated ressources.
  57953. */
  57954. dispose(): void;
  57955. private _draw;
  57956. }
  57957. }
  57958. declare module BABYLON {
  57959. /** @hidden */
  57960. export var depthPixelShader: {
  57961. name: string;
  57962. shader: string;
  57963. };
  57964. }
  57965. declare module BABYLON {
  57966. /** @hidden */
  57967. export var depthVertexShader: {
  57968. name: string;
  57969. shader: string;
  57970. };
  57971. }
  57972. declare module BABYLON {
  57973. /**
  57974. * This represents a depth renderer in Babylon.
  57975. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57976. */
  57977. export class DepthRenderer {
  57978. private _scene;
  57979. private _depthMap;
  57980. private _effect;
  57981. private readonly _storeNonLinearDepth;
  57982. private readonly _clearColor;
  57983. /** Get if the depth renderer is using packed depth or not */
  57984. readonly isPacked: boolean;
  57985. private _cachedDefines;
  57986. private _camera;
  57987. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57988. enabled: boolean;
  57989. /**
  57990. * Specifiess that the depth renderer will only be used within
  57991. * the camera it is created for.
  57992. * This can help forcing its rendering during the camera processing.
  57993. */
  57994. useOnlyInActiveCamera: boolean;
  57995. /** @hidden */
  57996. static _SceneComponentInitialization: (scene: Scene) => void;
  57997. /**
  57998. * Instantiates a depth renderer
  57999. * @param scene The scene the renderer belongs to
  58000. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58001. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58002. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58003. */
  58004. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58005. /**
  58006. * Creates the depth rendering effect and checks if the effect is ready.
  58007. * @param subMesh The submesh to be used to render the depth map of
  58008. * @param useInstances If multiple world instances should be used
  58009. * @returns if the depth renderer is ready to render the depth map
  58010. */
  58011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58012. /**
  58013. * Gets the texture which the depth map will be written to.
  58014. * @returns The depth map texture
  58015. */
  58016. getDepthMap(): RenderTargetTexture;
  58017. /**
  58018. * Disposes of the depth renderer.
  58019. */
  58020. dispose(): void;
  58021. }
  58022. }
  58023. declare module BABYLON {
  58024. /** @hidden */
  58025. export var minmaxReduxPixelShader: {
  58026. name: string;
  58027. shader: string;
  58028. };
  58029. }
  58030. declare module BABYLON {
  58031. /**
  58032. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58033. * and maximum values from all values of the texture.
  58034. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58035. * The source values are read from the red channel of the texture.
  58036. */
  58037. export class MinMaxReducer {
  58038. /**
  58039. * Observable triggered when the computation has been performed
  58040. */
  58041. onAfterReductionPerformed: Observable<{
  58042. min: number;
  58043. max: number;
  58044. }>;
  58045. protected _camera: Camera;
  58046. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58047. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58048. protected _postProcessManager: PostProcessManager;
  58049. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58050. protected _forceFullscreenViewport: boolean;
  58051. /**
  58052. * Creates a min/max reducer
  58053. * @param camera The camera to use for the post processes
  58054. */
  58055. constructor(camera: Camera);
  58056. /**
  58057. * Gets the texture used to read the values from.
  58058. */
  58059. get sourceTexture(): Nullable<RenderTargetTexture>;
  58060. /**
  58061. * Sets the source texture to read the values from.
  58062. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58063. * because in such textures '1' value must not be taken into account to compute the maximum
  58064. * as this value is used to clear the texture.
  58065. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58066. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58067. * @param depthRedux Indicates if the texture is a depth texture or not
  58068. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58069. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58070. */
  58071. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58072. /**
  58073. * Defines the refresh rate of the computation.
  58074. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58075. */
  58076. get refreshRate(): number;
  58077. set refreshRate(value: number);
  58078. protected _activated: boolean;
  58079. /**
  58080. * Gets the activation status of the reducer
  58081. */
  58082. get activated(): boolean;
  58083. /**
  58084. * Activates the reduction computation.
  58085. * When activated, the observers registered in onAfterReductionPerformed are
  58086. * called after the compuation is performed
  58087. */
  58088. activate(): void;
  58089. /**
  58090. * Deactivates the reduction computation.
  58091. */
  58092. deactivate(): void;
  58093. /**
  58094. * Disposes the min/max reducer
  58095. * @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.
  58096. */
  58097. dispose(disposeAll?: boolean): void;
  58098. }
  58099. }
  58100. declare module BABYLON {
  58101. /**
  58102. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58103. */
  58104. export class DepthReducer extends MinMaxReducer {
  58105. private _depthRenderer;
  58106. private _depthRendererId;
  58107. /**
  58108. * Gets the depth renderer used for the computation.
  58109. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58110. */
  58111. get depthRenderer(): Nullable<DepthRenderer>;
  58112. /**
  58113. * Creates a depth reducer
  58114. * @param camera The camera used to render the depth texture
  58115. */
  58116. constructor(camera: Camera);
  58117. /**
  58118. * Sets the depth renderer to use to generate the depth map
  58119. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58120. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58121. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58122. */
  58123. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58124. /** @hidden */
  58125. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58126. /**
  58127. * Activates the reduction computation.
  58128. * When activated, the observers registered in onAfterReductionPerformed are
  58129. * called after the compuation is performed
  58130. */
  58131. activate(): void;
  58132. /**
  58133. * Deactivates the reduction computation.
  58134. */
  58135. deactivate(): void;
  58136. /**
  58137. * Disposes the depth reducer
  58138. * @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.
  58139. */
  58140. dispose(disposeAll?: boolean): void;
  58141. }
  58142. }
  58143. declare module BABYLON {
  58144. /**
  58145. * A CSM implementation allowing casting shadows on large scenes.
  58146. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58147. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58148. */
  58149. export class CascadedShadowGenerator extends ShadowGenerator {
  58150. private static readonly frustumCornersNDCSpace;
  58151. /**
  58152. * Name of the CSM class
  58153. */
  58154. static CLASSNAME: string;
  58155. /**
  58156. * Defines the default number of cascades used by the CSM.
  58157. */
  58158. static readonly DEFAULT_CASCADES_COUNT: number;
  58159. /**
  58160. * Defines the minimum number of cascades used by the CSM.
  58161. */
  58162. static readonly MIN_CASCADES_COUNT: number;
  58163. /**
  58164. * Defines the maximum number of cascades used by the CSM.
  58165. */
  58166. static readonly MAX_CASCADES_COUNT: number;
  58167. protected _validateFilter(filter: number): number;
  58168. /**
  58169. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58170. */
  58171. penumbraDarkness: number;
  58172. private _numCascades;
  58173. /**
  58174. * Gets or set the number of cascades used by the CSM.
  58175. */
  58176. get numCascades(): number;
  58177. set numCascades(value: number);
  58178. /**
  58179. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58180. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58181. */
  58182. stabilizeCascades: boolean;
  58183. private _freezeShadowCastersBoundingInfo;
  58184. private _freezeShadowCastersBoundingInfoObservable;
  58185. /**
  58186. * Enables or disables the shadow casters bounding info computation.
  58187. * If your shadow casters don't move, you can disable this feature.
  58188. * If it is enabled, the bounding box computation is done every frame.
  58189. */
  58190. get freezeShadowCastersBoundingInfo(): boolean;
  58191. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58192. private _scbiMin;
  58193. private _scbiMax;
  58194. protected _computeShadowCastersBoundingInfo(): void;
  58195. protected _shadowCastersBoundingInfo: BoundingInfo;
  58196. /**
  58197. * Gets or sets the shadow casters bounding info.
  58198. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58199. * so that the system won't overwrite the bounds you provide
  58200. */
  58201. get shadowCastersBoundingInfo(): BoundingInfo;
  58202. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58203. protected _breaksAreDirty: boolean;
  58204. protected _minDistance: number;
  58205. protected _maxDistance: number;
  58206. /**
  58207. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58208. *
  58209. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58210. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58211. * @param min minimal distance for the breaks (default to 0.)
  58212. * @param max maximal distance for the breaks (default to 1.)
  58213. */
  58214. setMinMaxDistance(min: number, max: number): void;
  58215. /** Gets the minimal distance used in the cascade break computation */
  58216. get minDistance(): number;
  58217. /** Gets the maximal distance used in the cascade break computation */
  58218. get maxDistance(): number;
  58219. /**
  58220. * Gets the class name of that object
  58221. * @returns "CascadedShadowGenerator"
  58222. */
  58223. getClassName(): string;
  58224. private _cascadeMinExtents;
  58225. private _cascadeMaxExtents;
  58226. /**
  58227. * Gets a cascade minimum extents
  58228. * @param cascadeIndex index of the cascade
  58229. * @returns the minimum cascade extents
  58230. */
  58231. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58232. /**
  58233. * Gets a cascade maximum extents
  58234. * @param cascadeIndex index of the cascade
  58235. * @returns the maximum cascade extents
  58236. */
  58237. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58238. private _cascades;
  58239. private _currentLayer;
  58240. private _viewSpaceFrustumsZ;
  58241. private _viewMatrices;
  58242. private _projectionMatrices;
  58243. private _transformMatrices;
  58244. private _transformMatricesAsArray;
  58245. private _frustumLengths;
  58246. private _lightSizeUVCorrection;
  58247. private _depthCorrection;
  58248. private _frustumCornersWorldSpace;
  58249. private _frustumCenter;
  58250. private _shadowCameraPos;
  58251. private _shadowMaxZ;
  58252. /**
  58253. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58254. * It defaults to camera.maxZ
  58255. */
  58256. get shadowMaxZ(): number;
  58257. /**
  58258. * Sets the shadow max z distance.
  58259. */
  58260. set shadowMaxZ(value: number);
  58261. protected _debug: boolean;
  58262. /**
  58263. * Gets or sets the debug flag.
  58264. * When enabled, the cascades are materialized by different colors on the screen.
  58265. */
  58266. get debug(): boolean;
  58267. set debug(dbg: boolean);
  58268. private _depthClamp;
  58269. /**
  58270. * Gets or sets the depth clamping value.
  58271. *
  58272. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58273. * to account for the shadow casters far away.
  58274. *
  58275. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58276. */
  58277. get depthClamp(): boolean;
  58278. set depthClamp(value: boolean);
  58279. private _cascadeBlendPercentage;
  58280. /**
  58281. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58282. * It defaults to 0.1 (10% blending).
  58283. */
  58284. get cascadeBlendPercentage(): number;
  58285. set cascadeBlendPercentage(value: number);
  58286. private _lambda;
  58287. /**
  58288. * Gets or set the lambda parameter.
  58289. * This parameter is used to split the camera frustum and create the cascades.
  58290. * 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.
  58291. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58292. */
  58293. get lambda(): number;
  58294. set lambda(value: number);
  58295. /**
  58296. * Gets the view matrix corresponding to a given cascade
  58297. * @param cascadeNum cascade to retrieve the view matrix from
  58298. * @returns the cascade view matrix
  58299. */
  58300. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58301. /**
  58302. * Gets the projection matrix corresponding to a given cascade
  58303. * @param cascadeNum cascade to retrieve the projection matrix from
  58304. * @returns the cascade projection matrix
  58305. */
  58306. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58307. /**
  58308. * Gets the transformation matrix corresponding to a given cascade
  58309. * @param cascadeNum cascade to retrieve the transformation matrix from
  58310. * @returns the cascade transformation matrix
  58311. */
  58312. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58313. private _depthRenderer;
  58314. /**
  58315. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58316. *
  58317. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58318. *
  58319. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58320. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58321. * @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
  58322. */
  58323. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58324. private _depthReducer;
  58325. private _autoCalcDepthBounds;
  58326. /**
  58327. * Gets or sets the autoCalcDepthBounds property.
  58328. *
  58329. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58330. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58331. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58332. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58333. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58334. */
  58335. get autoCalcDepthBounds(): boolean;
  58336. set autoCalcDepthBounds(value: boolean);
  58337. /**
  58338. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58339. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58340. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58341. * for setting the refresh rate on the renderer yourself!
  58342. */
  58343. get autoCalcDepthBoundsRefreshRate(): number;
  58344. set autoCalcDepthBoundsRefreshRate(value: number);
  58345. /**
  58346. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58347. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58348. * you change the camera near/far planes!
  58349. */
  58350. splitFrustum(): void;
  58351. private _splitFrustum;
  58352. private _computeMatrices;
  58353. private _computeFrustumInWorldSpace;
  58354. private _computeCascadeFrustum;
  58355. /**
  58356. * Support test.
  58357. */
  58358. static get IsSupported(): boolean;
  58359. /** @hidden */
  58360. static _SceneComponentInitialization: (scene: Scene) => void;
  58361. /**
  58362. * Creates a Cascaded Shadow Generator object.
  58363. * A ShadowGenerator is the required tool to use the shadows.
  58364. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58365. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58366. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58367. * @param light The directional light object generating the shadows.
  58368. * @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.
  58369. */
  58370. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58371. protected _initializeGenerator(): void;
  58372. protected _createTargetRenderTexture(): void;
  58373. protected _initializeShadowMap(): void;
  58374. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58375. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58376. /**
  58377. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58378. * @param defines Defines of the material we want to update
  58379. * @param lightIndex Index of the light in the enabled light list of the material
  58380. */
  58381. prepareDefines(defines: any, lightIndex: number): void;
  58382. /**
  58383. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58384. * defined in the generator but impacting the effect).
  58385. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58386. * @param effect The effect we are binfing the information for
  58387. */
  58388. bindShadowLight(lightIndex: string, effect: Effect): void;
  58389. /**
  58390. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58391. * (eq to view projection * shadow projection matrices)
  58392. * @returns The transform matrix used to create the shadow map
  58393. */
  58394. getTransformMatrix(): Matrix;
  58395. /**
  58396. * Disposes the ShadowGenerator.
  58397. * Returns nothing.
  58398. */
  58399. dispose(): void;
  58400. /**
  58401. * Serializes the shadow generator setup to a json object.
  58402. * @returns The serialized JSON object
  58403. */
  58404. serialize(): any;
  58405. /**
  58406. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58407. * @param parsedShadowGenerator The JSON object to parse
  58408. * @param scene The scene to create the shadow map for
  58409. * @returns The parsed shadow generator
  58410. */
  58411. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58412. }
  58413. }
  58414. declare module BABYLON {
  58415. /**
  58416. * Defines the shadow generator component responsible to manage any shadow generators
  58417. * in a given scene.
  58418. */
  58419. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58420. /**
  58421. * The component name helpfull to identify the component in the list of scene components.
  58422. */
  58423. readonly name: string;
  58424. /**
  58425. * The scene the component belongs to.
  58426. */
  58427. scene: Scene;
  58428. /**
  58429. * Creates a new instance of the component for the given scene
  58430. * @param scene Defines the scene to register the component in
  58431. */
  58432. constructor(scene: Scene);
  58433. /**
  58434. * Registers the component in a given scene
  58435. */
  58436. register(): void;
  58437. /**
  58438. * Rebuilds the elements related to this component in case of
  58439. * context lost for instance.
  58440. */
  58441. rebuild(): void;
  58442. /**
  58443. * Serializes the component data to the specified json object
  58444. * @param serializationObject The object to serialize to
  58445. */
  58446. serialize(serializationObject: any): void;
  58447. /**
  58448. * Adds all the elements from the container to the scene
  58449. * @param container the container holding the elements
  58450. */
  58451. addFromContainer(container: AbstractScene): void;
  58452. /**
  58453. * Removes all the elements in the container from the scene
  58454. * @param container contains the elements to remove
  58455. * @param dispose if the removed element should be disposed (default: false)
  58456. */
  58457. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58458. /**
  58459. * Rebuilds the elements related to this component in case of
  58460. * context lost for instance.
  58461. */
  58462. dispose(): void;
  58463. private _gatherRenderTargets;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * A point light is a light defined by an unique point in world space.
  58469. * The light is emitted in every direction from this point.
  58470. * A good example of a point light is a standard light bulb.
  58471. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58472. */
  58473. export class PointLight extends ShadowLight {
  58474. private _shadowAngle;
  58475. /**
  58476. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58477. * This specifies what angle the shadow will use to be created.
  58478. *
  58479. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58480. */
  58481. get shadowAngle(): number;
  58482. /**
  58483. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58484. * This specifies what angle the shadow will use to be created.
  58485. *
  58486. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58487. */
  58488. set shadowAngle(value: number);
  58489. /**
  58490. * Gets the direction if it has been set.
  58491. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58492. */
  58493. get direction(): Vector3;
  58494. /**
  58495. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58496. */
  58497. set direction(value: Vector3);
  58498. /**
  58499. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58500. * A PointLight emits the light in every direction.
  58501. * It can cast shadows.
  58502. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58503. * ```javascript
  58504. * var pointLight = new PointLight("pl", camera.position, scene);
  58505. * ```
  58506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58507. * @param name The light friendly name
  58508. * @param position The position of the point light in the scene
  58509. * @param scene The scene the lights belongs to
  58510. */
  58511. constructor(name: string, position: Vector3, scene: Scene);
  58512. /**
  58513. * Returns the string "PointLight"
  58514. * @returns the class name
  58515. */
  58516. getClassName(): string;
  58517. /**
  58518. * Returns the integer 0.
  58519. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58520. */
  58521. getTypeID(): number;
  58522. /**
  58523. * Specifies wether or not the shadowmap should be a cube texture.
  58524. * @returns true if the shadowmap needs to be a cube texture.
  58525. */
  58526. needCube(): boolean;
  58527. /**
  58528. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58529. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58530. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58531. */
  58532. getShadowDirection(faceIndex?: number): Vector3;
  58533. /**
  58534. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58535. * - fov = PI / 2
  58536. * - aspect ratio : 1.0
  58537. * - z-near and far equal to the active camera minZ and maxZ.
  58538. * Returns the PointLight.
  58539. */
  58540. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58541. protected _buildUniformLayout(): void;
  58542. /**
  58543. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58544. * @param effect The effect to update
  58545. * @param lightIndex The index of the light in the effect to update
  58546. * @returns The point light
  58547. */
  58548. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58549. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58550. /**
  58551. * Prepares the list of defines specific to the light type.
  58552. * @param defines the list of defines
  58553. * @param lightIndex defines the index of the light for the effect
  58554. */
  58555. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58556. }
  58557. }
  58558. declare module BABYLON {
  58559. /**
  58560. * Header information of HDR texture files.
  58561. */
  58562. export interface HDRInfo {
  58563. /**
  58564. * The height of the texture in pixels.
  58565. */
  58566. height: number;
  58567. /**
  58568. * The width of the texture in pixels.
  58569. */
  58570. width: number;
  58571. /**
  58572. * The index of the beginning of the data in the binary file.
  58573. */
  58574. dataPosition: number;
  58575. }
  58576. /**
  58577. * This groups tools to convert HDR texture to native colors array.
  58578. */
  58579. export class HDRTools {
  58580. private static Ldexp;
  58581. private static Rgbe2float;
  58582. private static readStringLine;
  58583. /**
  58584. * Reads header information from an RGBE texture stored in a native array.
  58585. * More information on this format are available here:
  58586. * https://en.wikipedia.org/wiki/RGBE_image_format
  58587. *
  58588. * @param uint8array The binary file stored in native array.
  58589. * @return The header information.
  58590. */
  58591. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58592. /**
  58593. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58594. * This RGBE texture needs to store the information as a panorama.
  58595. *
  58596. * More information on this format are available here:
  58597. * https://en.wikipedia.org/wiki/RGBE_image_format
  58598. *
  58599. * @param buffer The binary file stored in an array buffer.
  58600. * @param size The expected size of the extracted cubemap.
  58601. * @return The Cube Map information.
  58602. */
  58603. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58604. /**
  58605. * Returns the pixels data extracted from an RGBE texture.
  58606. * This pixels will be stored left to right up to down in the R G B order in one array.
  58607. *
  58608. * More information on this format are available here:
  58609. * https://en.wikipedia.org/wiki/RGBE_image_format
  58610. *
  58611. * @param uint8array The binary file stored in an array buffer.
  58612. * @param hdrInfo The header information of the file.
  58613. * @return The pixels data in RGB right to left up to down order.
  58614. */
  58615. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58616. private static RGBE_ReadPixels_RLE;
  58617. }
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * Effect Render Options
  58622. */
  58623. export interface IEffectRendererOptions {
  58624. /**
  58625. * Defines the vertices positions.
  58626. */
  58627. positions?: number[];
  58628. /**
  58629. * Defines the indices.
  58630. */
  58631. indices?: number[];
  58632. }
  58633. /**
  58634. * Helper class to render one or more effects.
  58635. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58636. */
  58637. export class EffectRenderer {
  58638. private engine;
  58639. private static _DefaultOptions;
  58640. private _vertexBuffers;
  58641. private _indexBuffer;
  58642. private _fullscreenViewport;
  58643. /**
  58644. * Creates an effect renderer
  58645. * @param engine the engine to use for rendering
  58646. * @param options defines the options of the effect renderer
  58647. */
  58648. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58649. /**
  58650. * Sets the current viewport in normalized coordinates 0-1
  58651. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58652. */
  58653. setViewport(viewport?: Viewport): void;
  58654. /**
  58655. * Binds the embedded attributes buffer to the effect.
  58656. * @param effect Defines the effect to bind the attributes for
  58657. */
  58658. bindBuffers(effect: Effect): void;
  58659. /**
  58660. * Sets the current effect wrapper to use during draw.
  58661. * The effect needs to be ready before calling this api.
  58662. * This also sets the default full screen position attribute.
  58663. * @param effectWrapper Defines the effect to draw with
  58664. */
  58665. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58666. /**
  58667. * Restores engine states
  58668. */
  58669. restoreStates(): void;
  58670. /**
  58671. * Draws a full screen quad.
  58672. */
  58673. draw(): void;
  58674. private isRenderTargetTexture;
  58675. /**
  58676. * renders one or more effects to a specified texture
  58677. * @param effectWrapper the effect to renderer
  58678. * @param outputTexture texture to draw to, if null it will render to the screen.
  58679. */
  58680. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58681. /**
  58682. * Disposes of the effect renderer
  58683. */
  58684. dispose(): void;
  58685. }
  58686. /**
  58687. * Options to create an EffectWrapper
  58688. */
  58689. interface EffectWrapperCreationOptions {
  58690. /**
  58691. * Engine to use to create the effect
  58692. */
  58693. engine: ThinEngine;
  58694. /**
  58695. * Fragment shader for the effect
  58696. */
  58697. fragmentShader: string;
  58698. /**
  58699. * Use the shader store instead of direct source code
  58700. */
  58701. useShaderStore?: boolean;
  58702. /**
  58703. * Vertex shader for the effect
  58704. */
  58705. vertexShader?: string;
  58706. /**
  58707. * Attributes to use in the shader
  58708. */
  58709. attributeNames?: Array<string>;
  58710. /**
  58711. * Uniforms to use in the shader
  58712. */
  58713. uniformNames?: Array<string>;
  58714. /**
  58715. * Texture sampler names to use in the shader
  58716. */
  58717. samplerNames?: Array<string>;
  58718. /**
  58719. * Defines to use in the shader
  58720. */
  58721. defines?: Array<string>;
  58722. /**
  58723. * Callback when effect is compiled
  58724. */
  58725. onCompiled?: Nullable<(effect: Effect) => void>;
  58726. /**
  58727. * The friendly name of the effect displayed in Spector.
  58728. */
  58729. name?: string;
  58730. }
  58731. /**
  58732. * Wraps an effect to be used for rendering
  58733. */
  58734. export class EffectWrapper {
  58735. /**
  58736. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58737. */
  58738. onApplyObservable: Observable<{}>;
  58739. /**
  58740. * The underlying effect
  58741. */
  58742. effect: Effect;
  58743. /**
  58744. * Creates an effect to be renderer
  58745. * @param creationOptions options to create the effect
  58746. */
  58747. constructor(creationOptions: EffectWrapperCreationOptions);
  58748. /**
  58749. * Disposes of the effect wrapper
  58750. */
  58751. dispose(): void;
  58752. }
  58753. }
  58754. declare module BABYLON {
  58755. /** @hidden */
  58756. export var hdrFilteringVertexShader: {
  58757. name: string;
  58758. shader: string;
  58759. };
  58760. }
  58761. declare module BABYLON {
  58762. /** @hidden */
  58763. export var hdrFilteringPixelShader: {
  58764. name: string;
  58765. shader: string;
  58766. };
  58767. }
  58768. declare module BABYLON {
  58769. /**
  58770. * Options for texture filtering
  58771. */
  58772. interface IHDRFilteringOptions {
  58773. /**
  58774. * Scales pixel intensity for the input HDR map.
  58775. */
  58776. hdrScale?: number;
  58777. /**
  58778. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58779. */
  58780. quality?: number;
  58781. }
  58782. /**
  58783. * Filters HDR maps to get correct renderings of PBR reflections
  58784. */
  58785. export class HDRFiltering {
  58786. private _engine;
  58787. private _effectRenderer;
  58788. private _effectWrapper;
  58789. private _lodGenerationOffset;
  58790. private _lodGenerationScale;
  58791. /**
  58792. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58793. * you care about baking speed.
  58794. */
  58795. quality: number;
  58796. /**
  58797. * Scales pixel intensity for the input HDR map.
  58798. */
  58799. hdrScale: number;
  58800. /**
  58801. * Instantiates HDR filter for reflection maps
  58802. *
  58803. * @param engine Thin engine
  58804. * @param options Options
  58805. */
  58806. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58807. private _createRenderTarget;
  58808. private _prefilterInternal;
  58809. private _createEffect;
  58810. /**
  58811. * Get a value indicating if the filter is ready to be used
  58812. * @param texture Texture to filter
  58813. * @returns true if the filter is ready
  58814. */
  58815. isReady(texture: BaseTexture): boolean;
  58816. /**
  58817. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58818. * Prefiltering will be invoked at the end of next rendering pass.
  58819. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58820. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58821. * @param texture Texture to filter
  58822. * @param onFinished Callback when filtering is done
  58823. * @return Promise called when prefiltering is done
  58824. */
  58825. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58826. }
  58827. }
  58828. declare module BABYLON {
  58829. /**
  58830. * This represents a texture coming from an HDR input.
  58831. *
  58832. * The only supported format is currently panorama picture stored in RGBE format.
  58833. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58834. */
  58835. export class HDRCubeTexture extends BaseTexture {
  58836. private static _facesMapping;
  58837. private _generateHarmonics;
  58838. private _noMipmap;
  58839. private _prefilterOnLoad;
  58840. private _textureMatrix;
  58841. private _size;
  58842. private _onLoad;
  58843. private _onError;
  58844. /**
  58845. * The texture URL.
  58846. */
  58847. url: string;
  58848. /**
  58849. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58850. */
  58851. coordinatesMode: number;
  58852. protected _isBlocking: boolean;
  58853. /**
  58854. * Sets wether or not the texture is blocking during loading.
  58855. */
  58856. set isBlocking(value: boolean);
  58857. /**
  58858. * Gets wether or not the texture is blocking during loading.
  58859. */
  58860. get isBlocking(): boolean;
  58861. protected _rotationY: number;
  58862. /**
  58863. * Sets texture matrix rotation angle around Y axis in radians.
  58864. */
  58865. set rotationY(value: number);
  58866. /**
  58867. * Gets texture matrix rotation angle around Y axis radians.
  58868. */
  58869. get rotationY(): number;
  58870. /**
  58871. * Gets or sets the center of the bounding box associated with the cube texture
  58872. * It must define where the camera used to render the texture was set
  58873. */
  58874. boundingBoxPosition: Vector3;
  58875. private _boundingBoxSize;
  58876. /**
  58877. * Gets or sets the size of the bounding box associated with the cube texture
  58878. * When defined, the cubemap will switch to local mode
  58879. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58880. * @example https://www.babylonjs-playground.com/#RNASML
  58881. */
  58882. set boundingBoxSize(value: Vector3);
  58883. get boundingBoxSize(): Vector3;
  58884. /**
  58885. * Instantiates an HDRTexture from the following parameters.
  58886. *
  58887. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58888. * @param sceneOrEngine The scene or engine the texture will be used in
  58889. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58890. * @param noMipmap Forces to not generate the mipmap if true
  58891. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58892. * @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)
  58893. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58894. */
  58895. 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>);
  58896. /**
  58897. * Get the current class name of the texture useful for serialization or dynamic coding.
  58898. * @returns "HDRCubeTexture"
  58899. */
  58900. getClassName(): string;
  58901. /**
  58902. * Occurs when the file is raw .hdr file.
  58903. */
  58904. private loadTexture;
  58905. clone(): HDRCubeTexture;
  58906. delayLoad(): void;
  58907. /**
  58908. * Get the texture reflection matrix used to rotate/transform the reflection.
  58909. * @returns the reflection matrix
  58910. */
  58911. getReflectionTextureMatrix(): Matrix;
  58912. /**
  58913. * Set the texture reflection matrix used to rotate/transform the reflection.
  58914. * @param value Define the reflection matrix to set
  58915. */
  58916. setReflectionTextureMatrix(value: Matrix): void;
  58917. /**
  58918. * Parses a JSON representation of an HDR Texture in order to create the texture
  58919. * @param parsedTexture Define the JSON representation
  58920. * @param scene Define the scene the texture should be created in
  58921. * @param rootUrl Define the root url in case we need to load relative dependencies
  58922. * @returns the newly created texture after parsing
  58923. */
  58924. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58925. serialize(): any;
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /**
  58930. * Class used to control physics engine
  58931. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58932. */
  58933. export class PhysicsEngine implements IPhysicsEngine {
  58934. private _physicsPlugin;
  58935. /**
  58936. * Global value used to control the smallest number supported by the simulation
  58937. */
  58938. static Epsilon: number;
  58939. private _impostors;
  58940. private _joints;
  58941. private _subTimeStep;
  58942. /**
  58943. * Gets the gravity vector used by the simulation
  58944. */
  58945. gravity: Vector3;
  58946. /**
  58947. * Factory used to create the default physics plugin.
  58948. * @returns The default physics plugin
  58949. */
  58950. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58951. /**
  58952. * Creates a new Physics Engine
  58953. * @param gravity defines the gravity vector used by the simulation
  58954. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58955. */
  58956. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58957. /**
  58958. * Sets the gravity vector used by the simulation
  58959. * @param gravity defines the gravity vector to use
  58960. */
  58961. setGravity(gravity: Vector3): void;
  58962. /**
  58963. * Set the time step of the physics engine.
  58964. * Default is 1/60.
  58965. * To slow it down, enter 1/600 for example.
  58966. * To speed it up, 1/30
  58967. * @param newTimeStep defines the new timestep to apply to this world.
  58968. */
  58969. setTimeStep(newTimeStep?: number): void;
  58970. /**
  58971. * Get the time step of the physics engine.
  58972. * @returns the current time step
  58973. */
  58974. getTimeStep(): number;
  58975. /**
  58976. * Set the sub time step of the physics engine.
  58977. * Default is 0 meaning there is no sub steps
  58978. * To increase physics resolution precision, set a small value (like 1 ms)
  58979. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58980. */
  58981. setSubTimeStep(subTimeStep?: number): void;
  58982. /**
  58983. * Get the sub time step of the physics engine.
  58984. * @returns the current sub time step
  58985. */
  58986. getSubTimeStep(): number;
  58987. /**
  58988. * Release all resources
  58989. */
  58990. dispose(): void;
  58991. /**
  58992. * Gets the name of the current physics plugin
  58993. * @returns the name of the plugin
  58994. */
  58995. getPhysicsPluginName(): string;
  58996. /**
  58997. * Adding a new impostor for the impostor tracking.
  58998. * This will be done by the impostor itself.
  58999. * @param impostor the impostor to add
  59000. */
  59001. addImpostor(impostor: PhysicsImpostor): void;
  59002. /**
  59003. * Remove an impostor from the engine.
  59004. * This impostor and its mesh will not longer be updated by the physics engine.
  59005. * @param impostor the impostor to remove
  59006. */
  59007. removeImpostor(impostor: PhysicsImpostor): void;
  59008. /**
  59009. * Add a joint to the physics engine
  59010. * @param mainImpostor defines the main impostor to which the joint is added.
  59011. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59012. * @param joint defines the joint that will connect both impostors.
  59013. */
  59014. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59015. /**
  59016. * Removes a joint from the simulation
  59017. * @param mainImpostor defines the impostor used with the joint
  59018. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59019. * @param joint defines the joint to remove
  59020. */
  59021. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59022. /**
  59023. * Called by the scene. No need to call it.
  59024. * @param delta defines the timespam between frames
  59025. */
  59026. _step(delta: number): void;
  59027. /**
  59028. * Gets the current plugin used to run the simulation
  59029. * @returns current plugin
  59030. */
  59031. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59032. /**
  59033. * Gets the list of physic impostors
  59034. * @returns an array of PhysicsImpostor
  59035. */
  59036. getImpostors(): Array<PhysicsImpostor>;
  59037. /**
  59038. * Gets the impostor for a physics enabled object
  59039. * @param object defines the object impersonated by the impostor
  59040. * @returns the PhysicsImpostor or null if not found
  59041. */
  59042. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59043. /**
  59044. * Gets the impostor for a physics body object
  59045. * @param body defines physics body used by the impostor
  59046. * @returns the PhysicsImpostor or null if not found
  59047. */
  59048. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59049. /**
  59050. * Does a raycast in the physics world
  59051. * @param from when should the ray start?
  59052. * @param to when should the ray end?
  59053. * @returns PhysicsRaycastResult
  59054. */
  59055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59056. }
  59057. }
  59058. declare module BABYLON {
  59059. /** @hidden */
  59060. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59061. private _useDeltaForWorldStep;
  59062. world: any;
  59063. name: string;
  59064. private _physicsMaterials;
  59065. private _fixedTimeStep;
  59066. private _cannonRaycastResult;
  59067. private _raycastResult;
  59068. private _physicsBodysToRemoveAfterStep;
  59069. private _firstFrame;
  59070. BJSCANNON: any;
  59071. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59072. setGravity(gravity: Vector3): void;
  59073. setTimeStep(timeStep: number): void;
  59074. getTimeStep(): number;
  59075. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59076. private _removeMarkedPhysicsBodiesFromWorld;
  59077. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59078. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59079. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59080. private _processChildMeshes;
  59081. removePhysicsBody(impostor: PhysicsImpostor): void;
  59082. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59083. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59084. private _addMaterial;
  59085. private _checkWithEpsilon;
  59086. private _createShape;
  59087. private _createHeightmap;
  59088. private _minus90X;
  59089. private _plus90X;
  59090. private _tmpPosition;
  59091. private _tmpDeltaPosition;
  59092. private _tmpUnityRotation;
  59093. private _updatePhysicsBodyTransformation;
  59094. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59095. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59096. isSupported(): boolean;
  59097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59102. getBodyMass(impostor: PhysicsImpostor): number;
  59103. getBodyFriction(impostor: PhysicsImpostor): number;
  59104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59105. getBodyRestitution(impostor: PhysicsImpostor): number;
  59106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59107. sleepBody(impostor: PhysicsImpostor): void;
  59108. wakeUpBody(impostor: PhysicsImpostor): void;
  59109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59110. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59111. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59112. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59113. getRadius(impostor: PhysicsImpostor): number;
  59114. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59115. dispose(): void;
  59116. private _extendNamespace;
  59117. /**
  59118. * Does a raycast in the physics world
  59119. * @param from when should the ray start?
  59120. * @param to when should the ray end?
  59121. * @returns PhysicsRaycastResult
  59122. */
  59123. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59124. }
  59125. }
  59126. declare module BABYLON {
  59127. /** @hidden */
  59128. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59129. private _useDeltaForWorldStep;
  59130. world: any;
  59131. name: string;
  59132. BJSOIMO: any;
  59133. private _raycastResult;
  59134. private _fixedTimeStep;
  59135. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59136. setGravity(gravity: Vector3): void;
  59137. setTimeStep(timeStep: number): void;
  59138. getTimeStep(): number;
  59139. private _tmpImpostorsArray;
  59140. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59142. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59143. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59144. private _tmpPositionVector;
  59145. removePhysicsBody(impostor: PhysicsImpostor): void;
  59146. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59147. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59148. isSupported(): boolean;
  59149. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59150. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59151. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59152. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59153. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59154. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59155. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59156. getBodyMass(impostor: PhysicsImpostor): number;
  59157. getBodyFriction(impostor: PhysicsImpostor): number;
  59158. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59159. getBodyRestitution(impostor: PhysicsImpostor): number;
  59160. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59161. sleepBody(impostor: PhysicsImpostor): void;
  59162. wakeUpBody(impostor: PhysicsImpostor): void;
  59163. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59164. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59165. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59166. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59167. getRadius(impostor: PhysicsImpostor): number;
  59168. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59169. dispose(): void;
  59170. /**
  59171. * Does a raycast in the physics world
  59172. * @param from when should the ray start?
  59173. * @param to when should the ray end?
  59174. * @returns PhysicsRaycastResult
  59175. */
  59176. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59177. }
  59178. }
  59179. declare module BABYLON {
  59180. /**
  59181. * Class containing static functions to help procedurally build meshes
  59182. */
  59183. export class RibbonBuilder {
  59184. /**
  59185. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59186. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59187. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59188. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59189. * * 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
  59190. * * 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
  59191. * * 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
  59192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59193. * * 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
  59194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59195. * * 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
  59196. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59197. * * 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
  59198. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59200. * @param name defines the name of the mesh
  59201. * @param options defines the options used to create the mesh
  59202. * @param scene defines the hosting scene
  59203. * @returns the ribbon mesh
  59204. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59206. */
  59207. static CreateRibbon(name: string, options: {
  59208. pathArray: Vector3[][];
  59209. closeArray?: boolean;
  59210. closePath?: boolean;
  59211. offset?: number;
  59212. updatable?: boolean;
  59213. sideOrientation?: number;
  59214. frontUVs?: Vector4;
  59215. backUVs?: Vector4;
  59216. instance?: Mesh;
  59217. invertUV?: boolean;
  59218. uvs?: Vector2[];
  59219. colors?: Color4[];
  59220. }, scene?: Nullable<Scene>): Mesh;
  59221. }
  59222. }
  59223. declare module BABYLON {
  59224. /**
  59225. * Class containing static functions to help procedurally build meshes
  59226. */
  59227. export class ShapeBuilder {
  59228. /**
  59229. * 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.
  59230. * * 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.
  59231. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59232. * * 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.
  59233. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59234. * * 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
  59235. * * 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
  59236. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59238. * * 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
  59239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59241. * @param name defines the name of the mesh
  59242. * @param options defines the options used to create the mesh
  59243. * @param scene defines the hosting scene
  59244. * @returns the extruded shape mesh
  59245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59247. */
  59248. static ExtrudeShape(name: string, options: {
  59249. shape: Vector3[];
  59250. path: Vector3[];
  59251. scale?: number;
  59252. rotation?: number;
  59253. cap?: number;
  59254. updatable?: boolean;
  59255. sideOrientation?: number;
  59256. frontUVs?: Vector4;
  59257. backUVs?: Vector4;
  59258. instance?: Mesh;
  59259. invertUV?: boolean;
  59260. }, scene?: Nullable<Scene>): Mesh;
  59261. /**
  59262. * Creates an custom extruded shape mesh.
  59263. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59264. * * 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.
  59265. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59266. * * 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
  59267. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59268. * * 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
  59269. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59270. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59271. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59272. * * 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
  59273. * * 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
  59274. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59276. * * 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
  59277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59279. * @param name defines the name of the mesh
  59280. * @param options defines the options used to create the mesh
  59281. * @param scene defines the hosting scene
  59282. * @returns the custom extruded shape mesh
  59283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59286. */
  59287. static ExtrudeShapeCustom(name: string, options: {
  59288. shape: Vector3[];
  59289. path: Vector3[];
  59290. scaleFunction?: any;
  59291. rotationFunction?: any;
  59292. ribbonCloseArray?: boolean;
  59293. ribbonClosePath?: boolean;
  59294. cap?: number;
  59295. updatable?: boolean;
  59296. sideOrientation?: number;
  59297. frontUVs?: Vector4;
  59298. backUVs?: Vector4;
  59299. instance?: Mesh;
  59300. invertUV?: boolean;
  59301. }, scene?: Nullable<Scene>): Mesh;
  59302. private static _ExtrudeShapeGeneric;
  59303. }
  59304. }
  59305. declare module BABYLON {
  59306. /**
  59307. * AmmoJS Physics plugin
  59308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59309. * @see https://github.com/kripken/ammo.js/
  59310. */
  59311. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59312. private _useDeltaForWorldStep;
  59313. /**
  59314. * Reference to the Ammo library
  59315. */
  59316. bjsAMMO: any;
  59317. /**
  59318. * Created ammoJS world which physics bodies are added to
  59319. */
  59320. world: any;
  59321. /**
  59322. * Name of the plugin
  59323. */
  59324. name: string;
  59325. private _timeStep;
  59326. private _fixedTimeStep;
  59327. private _maxSteps;
  59328. private _tmpQuaternion;
  59329. private _tmpAmmoTransform;
  59330. private _tmpAmmoQuaternion;
  59331. private _tmpAmmoConcreteContactResultCallback;
  59332. private _collisionConfiguration;
  59333. private _dispatcher;
  59334. private _overlappingPairCache;
  59335. private _solver;
  59336. private _softBodySolver;
  59337. private _tmpAmmoVectorA;
  59338. private _tmpAmmoVectorB;
  59339. private _tmpAmmoVectorC;
  59340. private _tmpAmmoVectorD;
  59341. private _tmpContactCallbackResult;
  59342. private _tmpAmmoVectorRCA;
  59343. private _tmpAmmoVectorRCB;
  59344. private _raycastResult;
  59345. private static readonly DISABLE_COLLISION_FLAG;
  59346. private static readonly KINEMATIC_FLAG;
  59347. private static readonly DISABLE_DEACTIVATION_FLAG;
  59348. /**
  59349. * Initializes the ammoJS plugin
  59350. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59351. * @param ammoInjection can be used to inject your own ammo reference
  59352. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59353. */
  59354. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59355. /**
  59356. * Sets the gravity of the physics world (m/(s^2))
  59357. * @param gravity Gravity to set
  59358. */
  59359. setGravity(gravity: Vector3): void;
  59360. /**
  59361. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59362. * @param timeStep timestep to use in seconds
  59363. */
  59364. setTimeStep(timeStep: number): void;
  59365. /**
  59366. * 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)
  59367. * @param fixedTimeStep fixedTimeStep to use in seconds
  59368. */
  59369. setFixedTimeStep(fixedTimeStep: number): void;
  59370. /**
  59371. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59372. * @param maxSteps the maximum number of steps by the physics engine per frame
  59373. */
  59374. setMaxSteps(maxSteps: number): void;
  59375. /**
  59376. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59377. * @returns the current timestep in seconds
  59378. */
  59379. getTimeStep(): number;
  59380. /**
  59381. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59382. */
  59383. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59384. private _isImpostorInContact;
  59385. private _isImpostorPairInContact;
  59386. private _stepSimulation;
  59387. /**
  59388. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59389. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59390. * After the step the babylon meshes are set to the position of the physics imposters
  59391. * @param delta amount of time to step forward
  59392. * @param impostors array of imposters to update before/after the step
  59393. */
  59394. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59395. /**
  59396. * Update babylon mesh to match physics world object
  59397. * @param impostor imposter to match
  59398. */
  59399. private _afterSoftStep;
  59400. /**
  59401. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59402. * @param impostor imposter to match
  59403. */
  59404. private _ropeStep;
  59405. /**
  59406. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59407. * @param impostor imposter to match
  59408. */
  59409. private _softbodyOrClothStep;
  59410. private _tmpMatrix;
  59411. /**
  59412. * Applies an impulse on the imposter
  59413. * @param impostor imposter to apply impulse to
  59414. * @param force amount of force to be applied to the imposter
  59415. * @param contactPoint the location to apply the impulse on the imposter
  59416. */
  59417. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59418. /**
  59419. * Applies a force on the imposter
  59420. * @param impostor imposter to apply force
  59421. * @param force amount of force to be applied to the imposter
  59422. * @param contactPoint the location to apply the force on the imposter
  59423. */
  59424. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59425. /**
  59426. * Creates a physics body using the plugin
  59427. * @param impostor the imposter to create the physics body on
  59428. */
  59429. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59430. /**
  59431. * Removes the physics body from the imposter and disposes of the body's memory
  59432. * @param impostor imposter to remove the physics body from
  59433. */
  59434. removePhysicsBody(impostor: PhysicsImpostor): void;
  59435. /**
  59436. * Generates a joint
  59437. * @param impostorJoint the imposter joint to create the joint with
  59438. */
  59439. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59440. /**
  59441. * Removes a joint
  59442. * @param impostorJoint the imposter joint to remove the joint from
  59443. */
  59444. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59445. private _addMeshVerts;
  59446. /**
  59447. * Initialise the soft body vertices to match its object's (mesh) vertices
  59448. * Softbody vertices (nodes) are in world space and to match this
  59449. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59450. * @param impostor to create the softbody for
  59451. */
  59452. private _softVertexData;
  59453. /**
  59454. * Create an impostor's soft body
  59455. * @param impostor to create the softbody for
  59456. */
  59457. private _createSoftbody;
  59458. /**
  59459. * Create cloth for an impostor
  59460. * @param impostor to create the softbody for
  59461. */
  59462. private _createCloth;
  59463. /**
  59464. * Create rope for an impostor
  59465. * @param impostor to create the softbody for
  59466. */
  59467. private _createRope;
  59468. /**
  59469. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59470. * @param impostor to create the custom physics shape for
  59471. */
  59472. private _createCustom;
  59473. private _addHullVerts;
  59474. private _createShape;
  59475. /**
  59476. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59477. * @param impostor imposter containing the physics body and babylon object
  59478. */
  59479. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59480. /**
  59481. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59482. * @param impostor imposter containing the physics body and babylon object
  59483. * @param newPosition new position
  59484. * @param newRotation new rotation
  59485. */
  59486. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59487. /**
  59488. * If this plugin is supported
  59489. * @returns true if its supported
  59490. */
  59491. isSupported(): boolean;
  59492. /**
  59493. * Sets the linear velocity of the physics body
  59494. * @param impostor imposter to set the velocity on
  59495. * @param velocity velocity to set
  59496. */
  59497. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59498. /**
  59499. * Sets the angular velocity of the physics body
  59500. * @param impostor imposter to set the velocity on
  59501. * @param velocity velocity to set
  59502. */
  59503. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59504. /**
  59505. * gets the linear velocity
  59506. * @param impostor imposter to get linear velocity from
  59507. * @returns linear velocity
  59508. */
  59509. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59510. /**
  59511. * gets the angular velocity
  59512. * @param impostor imposter to get angular velocity from
  59513. * @returns angular velocity
  59514. */
  59515. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59516. /**
  59517. * Sets the mass of physics body
  59518. * @param impostor imposter to set the mass on
  59519. * @param mass mass to set
  59520. */
  59521. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59522. /**
  59523. * Gets the mass of the physics body
  59524. * @param impostor imposter to get the mass from
  59525. * @returns mass
  59526. */
  59527. getBodyMass(impostor: PhysicsImpostor): number;
  59528. /**
  59529. * Gets friction of the impostor
  59530. * @param impostor impostor to get friction from
  59531. * @returns friction value
  59532. */
  59533. getBodyFriction(impostor: PhysicsImpostor): number;
  59534. /**
  59535. * Sets friction of the impostor
  59536. * @param impostor impostor to set friction on
  59537. * @param friction friction value
  59538. */
  59539. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59540. /**
  59541. * Gets restitution of the impostor
  59542. * @param impostor impostor to get restitution from
  59543. * @returns restitution value
  59544. */
  59545. getBodyRestitution(impostor: PhysicsImpostor): number;
  59546. /**
  59547. * Sets resitution of the impostor
  59548. * @param impostor impostor to set resitution on
  59549. * @param restitution resitution value
  59550. */
  59551. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59552. /**
  59553. * Gets pressure inside the impostor
  59554. * @param impostor impostor to get pressure from
  59555. * @returns pressure value
  59556. */
  59557. getBodyPressure(impostor: PhysicsImpostor): number;
  59558. /**
  59559. * Sets pressure inside a soft body impostor
  59560. * Cloth and rope must remain 0 pressure
  59561. * @param impostor impostor to set pressure on
  59562. * @param pressure pressure value
  59563. */
  59564. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59565. /**
  59566. * Gets stiffness of the impostor
  59567. * @param impostor impostor to get stiffness from
  59568. * @returns pressure value
  59569. */
  59570. getBodyStiffness(impostor: PhysicsImpostor): number;
  59571. /**
  59572. * Sets stiffness of the impostor
  59573. * @param impostor impostor to set stiffness on
  59574. * @param stiffness stiffness value from 0 to 1
  59575. */
  59576. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59577. /**
  59578. * Gets velocityIterations of the impostor
  59579. * @param impostor impostor to get velocity iterations from
  59580. * @returns velocityIterations value
  59581. */
  59582. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59583. /**
  59584. * Sets velocityIterations of the impostor
  59585. * @param impostor impostor to set velocity iterations on
  59586. * @param velocityIterations velocityIterations value
  59587. */
  59588. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59589. /**
  59590. * Gets positionIterations of the impostor
  59591. * @param impostor impostor to get position iterations from
  59592. * @returns positionIterations value
  59593. */
  59594. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59595. /**
  59596. * Sets positionIterations of the impostor
  59597. * @param impostor impostor to set position on
  59598. * @param positionIterations positionIterations value
  59599. */
  59600. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59601. /**
  59602. * Append an anchor to a cloth object
  59603. * @param impostor is the cloth impostor to add anchor to
  59604. * @param otherImpostor is the rigid impostor to anchor to
  59605. * @param width ratio across width from 0 to 1
  59606. * @param height ratio up height from 0 to 1
  59607. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59608. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59609. */
  59610. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59611. /**
  59612. * Append an hook to a rope object
  59613. * @param impostor is the rope impostor to add hook to
  59614. * @param otherImpostor is the rigid impostor to hook to
  59615. * @param length ratio along the rope from 0 to 1
  59616. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59617. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59618. */
  59619. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59620. /**
  59621. * Sleeps the physics body and stops it from being active
  59622. * @param impostor impostor to sleep
  59623. */
  59624. sleepBody(impostor: PhysicsImpostor): void;
  59625. /**
  59626. * Activates the physics body
  59627. * @param impostor impostor to activate
  59628. */
  59629. wakeUpBody(impostor: PhysicsImpostor): void;
  59630. /**
  59631. * Updates the distance parameters of the joint
  59632. * @param joint joint to update
  59633. * @param maxDistance maximum distance of the joint
  59634. * @param minDistance minimum distance of the joint
  59635. */
  59636. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59637. /**
  59638. * Sets a motor on the joint
  59639. * @param joint joint to set motor on
  59640. * @param speed speed of the motor
  59641. * @param maxForce maximum force of the motor
  59642. * @param motorIndex index of the motor
  59643. */
  59644. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59645. /**
  59646. * Sets the motors limit
  59647. * @param joint joint to set limit on
  59648. * @param upperLimit upper limit
  59649. * @param lowerLimit lower limit
  59650. */
  59651. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59652. /**
  59653. * Syncs the position and rotation of a mesh with the impostor
  59654. * @param mesh mesh to sync
  59655. * @param impostor impostor to update the mesh with
  59656. */
  59657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59658. /**
  59659. * Gets the radius of the impostor
  59660. * @param impostor impostor to get radius from
  59661. * @returns the radius
  59662. */
  59663. getRadius(impostor: PhysicsImpostor): number;
  59664. /**
  59665. * Gets the box size of the impostor
  59666. * @param impostor impostor to get box size from
  59667. * @param result the resulting box size
  59668. */
  59669. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59670. /**
  59671. * Disposes of the impostor
  59672. */
  59673. dispose(): void;
  59674. /**
  59675. * Does a raycast in the physics world
  59676. * @param from when should the ray start?
  59677. * @param to when should the ray end?
  59678. * @returns PhysicsRaycastResult
  59679. */
  59680. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59681. }
  59682. }
  59683. declare module BABYLON {
  59684. interface AbstractScene {
  59685. /**
  59686. * The list of reflection probes added to the scene
  59687. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59688. */
  59689. reflectionProbes: Array<ReflectionProbe>;
  59690. /**
  59691. * Removes the given reflection probe from this scene.
  59692. * @param toRemove The reflection probe to remove
  59693. * @returns The index of the removed reflection probe
  59694. */
  59695. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59696. /**
  59697. * Adds the given reflection probe to this scene.
  59698. * @param newReflectionProbe The reflection probe to add
  59699. */
  59700. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59701. }
  59702. /**
  59703. * Class used to generate realtime reflection / refraction cube textures
  59704. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59705. */
  59706. export class ReflectionProbe {
  59707. /** defines the name of the probe */
  59708. name: string;
  59709. private _scene;
  59710. private _renderTargetTexture;
  59711. private _projectionMatrix;
  59712. private _viewMatrix;
  59713. private _target;
  59714. private _add;
  59715. private _attachedMesh;
  59716. private _invertYAxis;
  59717. /** Gets or sets probe position (center of the cube map) */
  59718. position: Vector3;
  59719. /**
  59720. * Creates a new reflection probe
  59721. * @param name defines the name of the probe
  59722. * @param size defines the texture resolution (for each face)
  59723. * @param scene defines the hosting scene
  59724. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59725. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59726. */
  59727. constructor(
  59728. /** defines the name of the probe */
  59729. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59730. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59731. get samples(): number;
  59732. set samples(value: number);
  59733. /** Gets or sets the refresh rate to use (on every frame by default) */
  59734. get refreshRate(): number;
  59735. set refreshRate(value: number);
  59736. /**
  59737. * Gets the hosting scene
  59738. * @returns a Scene
  59739. */
  59740. getScene(): Scene;
  59741. /** Gets the internal CubeTexture used to render to */
  59742. get cubeTexture(): RenderTargetTexture;
  59743. /** Gets the list of meshes to render */
  59744. get renderList(): Nullable<AbstractMesh[]>;
  59745. /**
  59746. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59747. * @param mesh defines the mesh to attach to
  59748. */
  59749. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59750. /**
  59751. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59752. * @param renderingGroupId The rendering group id corresponding to its index
  59753. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59754. */
  59755. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59756. /**
  59757. * Clean all associated resources
  59758. */
  59759. dispose(): void;
  59760. /**
  59761. * Converts the reflection probe information to a readable string for debug purpose.
  59762. * @param fullDetails Supports for multiple levels of logging within scene loading
  59763. * @returns the human readable reflection probe info
  59764. */
  59765. toString(fullDetails?: boolean): string;
  59766. /**
  59767. * Get the class name of the relfection probe.
  59768. * @returns "ReflectionProbe"
  59769. */
  59770. getClassName(): string;
  59771. /**
  59772. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59773. * @returns The JSON representation of the texture
  59774. */
  59775. serialize(): any;
  59776. /**
  59777. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59778. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59779. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59780. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59781. * @returns The parsed reflection probe if successful
  59782. */
  59783. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59784. }
  59785. }
  59786. declare module BABYLON {
  59787. /** @hidden */
  59788. export var _BabylonLoaderRegistered: boolean;
  59789. /**
  59790. * Helps setting up some configuration for the babylon file loader.
  59791. */
  59792. export class BabylonFileLoaderConfiguration {
  59793. /**
  59794. * The loader does not allow injecting custom physix engine into the plugins.
  59795. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59796. * So you could set this variable to your engine import to make it work.
  59797. */
  59798. static LoaderInjectedPhysicsEngine: any;
  59799. }
  59800. }
  59801. declare module BABYLON {
  59802. /**
  59803. * The Physically based simple base material of BJS.
  59804. *
  59805. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59806. * It is used as the base class for both the specGloss and metalRough conventions.
  59807. */
  59808. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59809. /**
  59810. * Number of Simultaneous lights allowed on the material.
  59811. */
  59812. maxSimultaneousLights: number;
  59813. /**
  59814. * If sets to true, disables all the lights affecting the material.
  59815. */
  59816. disableLighting: boolean;
  59817. /**
  59818. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59819. */
  59820. environmentTexture: BaseTexture;
  59821. /**
  59822. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59823. */
  59824. invertNormalMapX: boolean;
  59825. /**
  59826. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59827. */
  59828. invertNormalMapY: boolean;
  59829. /**
  59830. * Normal map used in the model.
  59831. */
  59832. normalTexture: BaseTexture;
  59833. /**
  59834. * Emissivie color used to self-illuminate the model.
  59835. */
  59836. emissiveColor: Color3;
  59837. /**
  59838. * Emissivie texture used to self-illuminate the model.
  59839. */
  59840. emissiveTexture: BaseTexture;
  59841. /**
  59842. * Occlusion Channel Strenght.
  59843. */
  59844. occlusionStrength: number;
  59845. /**
  59846. * Occlusion Texture of the material (adding extra occlusion effects).
  59847. */
  59848. occlusionTexture: BaseTexture;
  59849. /**
  59850. * Defines the alpha limits in alpha test mode.
  59851. */
  59852. alphaCutOff: number;
  59853. /**
  59854. * Gets the current double sided mode.
  59855. */
  59856. get doubleSided(): boolean;
  59857. /**
  59858. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59859. */
  59860. set doubleSided(value: boolean);
  59861. /**
  59862. * Stores the pre-calculated light information of a mesh in a texture.
  59863. */
  59864. lightmapTexture: BaseTexture;
  59865. /**
  59866. * If true, the light map contains occlusion information instead of lighting info.
  59867. */
  59868. useLightmapAsShadowmap: boolean;
  59869. /**
  59870. * Instantiates a new PBRMaterial instance.
  59871. *
  59872. * @param name The material name
  59873. * @param scene The scene the material will be use in.
  59874. */
  59875. constructor(name: string, scene: Scene);
  59876. getClassName(): string;
  59877. }
  59878. }
  59879. declare module BABYLON {
  59880. /**
  59881. * The PBR material of BJS following the metal roughness convention.
  59882. *
  59883. * This fits to the PBR convention in the GLTF definition:
  59884. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59885. */
  59886. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59887. /**
  59888. * The base color has two different interpretations depending on the value of metalness.
  59889. * When the material is a metal, the base color is the specific measured reflectance value
  59890. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59891. * of the material.
  59892. */
  59893. baseColor: Color3;
  59894. /**
  59895. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59896. * well as opacity information in the alpha channel.
  59897. */
  59898. baseTexture: BaseTexture;
  59899. /**
  59900. * Specifies the metallic scalar value of the material.
  59901. * Can also be used to scale the metalness values of the metallic texture.
  59902. */
  59903. metallic: number;
  59904. /**
  59905. * Specifies the roughness scalar value of the material.
  59906. * Can also be used to scale the roughness values of the metallic texture.
  59907. */
  59908. roughness: number;
  59909. /**
  59910. * Texture containing both the metallic value in the B channel and the
  59911. * roughness value in the G channel to keep better precision.
  59912. */
  59913. metallicRoughnessTexture: BaseTexture;
  59914. /**
  59915. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59916. *
  59917. * @param name The material name
  59918. * @param scene The scene the material will be use in.
  59919. */
  59920. constructor(name: string, scene: Scene);
  59921. /**
  59922. * Return the currrent class name of the material.
  59923. */
  59924. getClassName(): string;
  59925. /**
  59926. * Makes a duplicate of the current material.
  59927. * @param name - name to use for the new material.
  59928. */
  59929. clone(name: string): PBRMetallicRoughnessMaterial;
  59930. /**
  59931. * Serialize the material to a parsable JSON object.
  59932. */
  59933. serialize(): any;
  59934. /**
  59935. * Parses a JSON object correponding to the serialize function.
  59936. */
  59937. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /**
  59942. * The PBR material of BJS following the specular glossiness convention.
  59943. *
  59944. * This fits to the PBR convention in the GLTF definition:
  59945. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59946. */
  59947. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59948. /**
  59949. * Specifies the diffuse color of the material.
  59950. */
  59951. diffuseColor: Color3;
  59952. /**
  59953. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59954. * channel.
  59955. */
  59956. diffuseTexture: BaseTexture;
  59957. /**
  59958. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59959. */
  59960. specularColor: Color3;
  59961. /**
  59962. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59963. */
  59964. glossiness: number;
  59965. /**
  59966. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59967. */
  59968. specularGlossinessTexture: BaseTexture;
  59969. /**
  59970. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59971. *
  59972. * @param name The material name
  59973. * @param scene The scene the material will be use in.
  59974. */
  59975. constructor(name: string, scene: Scene);
  59976. /**
  59977. * Return the currrent class name of the material.
  59978. */
  59979. getClassName(): string;
  59980. /**
  59981. * Makes a duplicate of the current material.
  59982. * @param name - name to use for the new material.
  59983. */
  59984. clone(name: string): PBRSpecularGlossinessMaterial;
  59985. /**
  59986. * Serialize the material to a parsable JSON object.
  59987. */
  59988. serialize(): any;
  59989. /**
  59990. * Parses a JSON object correponding to the serialize function.
  59991. */
  59992. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59993. }
  59994. }
  59995. declare module BABYLON {
  59996. /**
  59997. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59998. * It can help converting any input color in a desired output one. This can then be used to create effects
  59999. * from sepia, black and white to sixties or futuristic rendering...
  60000. *
  60001. * The only supported format is currently 3dl.
  60002. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60003. */
  60004. export class ColorGradingTexture extends BaseTexture {
  60005. /**
  60006. * The texture URL.
  60007. */
  60008. url: string;
  60009. /**
  60010. * Empty line regex stored for GC.
  60011. */
  60012. private static _noneEmptyLineRegex;
  60013. private _textureMatrix;
  60014. private _onLoad;
  60015. /**
  60016. * Instantiates a ColorGradingTexture from the following parameters.
  60017. *
  60018. * @param url The location of the color gradind data (currently only supporting 3dl)
  60019. * @param sceneOrEngine The scene or engine the texture will be used in
  60020. * @param onLoad defines a callback triggered when the texture has been loaded
  60021. */
  60022. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60023. /**
  60024. * Fires the onload event from the constructor if requested.
  60025. */
  60026. private _triggerOnLoad;
  60027. /**
  60028. * Returns the texture matrix used in most of the material.
  60029. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60030. */
  60031. getTextureMatrix(): Matrix;
  60032. /**
  60033. * Occurs when the file being loaded is a .3dl LUT file.
  60034. */
  60035. private load3dlTexture;
  60036. /**
  60037. * Starts the loading process of the texture.
  60038. */
  60039. private loadTexture;
  60040. /**
  60041. * Clones the color gradind texture.
  60042. */
  60043. clone(): ColorGradingTexture;
  60044. /**
  60045. * Called during delayed load for textures.
  60046. */
  60047. delayLoad(): void;
  60048. /**
  60049. * Parses a color grading texture serialized by Babylon.
  60050. * @param parsedTexture The texture information being parsedTexture
  60051. * @param scene The scene to load the texture in
  60052. * @param rootUrl The root url of the data assets to load
  60053. * @return A color gradind texture
  60054. */
  60055. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60056. /**
  60057. * Serializes the LUT texture to json format.
  60058. */
  60059. serialize(): any;
  60060. }
  60061. }
  60062. declare module BABYLON {
  60063. /**
  60064. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60065. */
  60066. export class EquiRectangularCubeTexture extends BaseTexture {
  60067. /** The six faces of the cube. */
  60068. private static _FacesMapping;
  60069. private _noMipmap;
  60070. private _onLoad;
  60071. private _onError;
  60072. /** The size of the cubemap. */
  60073. private _size;
  60074. /** The buffer of the image. */
  60075. private _buffer;
  60076. /** The width of the input image. */
  60077. private _width;
  60078. /** The height of the input image. */
  60079. private _height;
  60080. /** The URL to the image. */
  60081. url: string;
  60082. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60083. coordinatesMode: number;
  60084. /**
  60085. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60086. * @param url The location of the image
  60087. * @param scene The scene the texture will be used in
  60088. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60089. * @param noMipmap Forces to not generate the mipmap if true
  60090. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60091. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60092. * @param onLoad — defines a callback called when texture is loaded
  60093. * @param onError — defines a callback called if there is an error
  60094. */
  60095. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60096. /**
  60097. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60098. */
  60099. private loadImage;
  60100. /**
  60101. * Convert the image buffer into a cubemap and create a CubeTexture.
  60102. */
  60103. private loadTexture;
  60104. /**
  60105. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60106. * @param buffer The ArrayBuffer that should be converted.
  60107. * @returns The buffer as Float32Array.
  60108. */
  60109. private getFloat32ArrayFromArrayBuffer;
  60110. /**
  60111. * Get the current class name of the texture useful for serialization or dynamic coding.
  60112. * @returns "EquiRectangularCubeTexture"
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60117. * @returns A clone of the current EquiRectangularCubeTexture.
  60118. */
  60119. clone(): EquiRectangularCubeTexture;
  60120. }
  60121. }
  60122. declare module BABYLON {
  60123. /**
  60124. * Defines the options related to the creation of an HtmlElementTexture
  60125. */
  60126. export interface IHtmlElementTextureOptions {
  60127. /**
  60128. * Defines wether mip maps should be created or not.
  60129. */
  60130. generateMipMaps?: boolean;
  60131. /**
  60132. * Defines the sampling mode of the texture.
  60133. */
  60134. samplingMode?: number;
  60135. /**
  60136. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60137. */
  60138. engine: Nullable<ThinEngine>;
  60139. /**
  60140. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60141. */
  60142. scene: Nullable<Scene>;
  60143. }
  60144. /**
  60145. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60146. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60147. * is automatically managed.
  60148. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60149. * in your application.
  60150. *
  60151. * As the update is not automatic, you need to call them manually.
  60152. */
  60153. export class HtmlElementTexture extends BaseTexture {
  60154. /**
  60155. * The texture URL.
  60156. */
  60157. element: HTMLVideoElement | HTMLCanvasElement;
  60158. private static readonly DefaultOptions;
  60159. private _textureMatrix;
  60160. private _isVideo;
  60161. private _generateMipMaps;
  60162. private _samplingMode;
  60163. /**
  60164. * Instantiates a HtmlElementTexture from the following parameters.
  60165. *
  60166. * @param name Defines the name of the texture
  60167. * @param element Defines the video or canvas the texture is filled with
  60168. * @param options Defines the other none mandatory texture creation options
  60169. */
  60170. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60171. private _createInternalTexture;
  60172. /**
  60173. * Returns the texture matrix used in most of the material.
  60174. */
  60175. getTextureMatrix(): Matrix;
  60176. /**
  60177. * Updates the content of the texture.
  60178. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60179. */
  60180. update(invertY?: Nullable<boolean>): void;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Based on jsTGALoader - Javascript loader for TGA file
  60186. * By Vincent Thibault
  60187. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60188. */
  60189. export class TGATools {
  60190. private static _TYPE_INDEXED;
  60191. private static _TYPE_RGB;
  60192. private static _TYPE_GREY;
  60193. private static _TYPE_RLE_INDEXED;
  60194. private static _TYPE_RLE_RGB;
  60195. private static _TYPE_RLE_GREY;
  60196. private static _ORIGIN_MASK;
  60197. private static _ORIGIN_SHIFT;
  60198. private static _ORIGIN_BL;
  60199. private static _ORIGIN_BR;
  60200. private static _ORIGIN_UL;
  60201. private static _ORIGIN_UR;
  60202. /**
  60203. * Gets the header of a TGA file
  60204. * @param data defines the TGA data
  60205. * @returns the header
  60206. */
  60207. static GetTGAHeader(data: Uint8Array): any;
  60208. /**
  60209. * Uploads TGA content to a Babylon Texture
  60210. * @hidden
  60211. */
  60212. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60213. /** @hidden */
  60214. 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;
  60215. /** @hidden */
  60216. 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;
  60217. /** @hidden */
  60218. 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;
  60219. /** @hidden */
  60220. 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;
  60221. /** @hidden */
  60222. 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;
  60223. /** @hidden */
  60224. 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;
  60225. }
  60226. }
  60227. declare module BABYLON {
  60228. /**
  60229. * Implementation of the TGA Texture Loader.
  60230. * @hidden
  60231. */
  60232. export class _TGATextureLoader implements IInternalTextureLoader {
  60233. /**
  60234. * Defines wether the loader supports cascade loading the different faces.
  60235. */
  60236. readonly supportCascades: boolean;
  60237. /**
  60238. * This returns if the loader support the current file information.
  60239. * @param extension defines the file extension of the file being loaded
  60240. * @returns true if the loader can load the specified file
  60241. */
  60242. canLoad(extension: string): boolean;
  60243. /**
  60244. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60245. * @param data contains the texture data
  60246. * @param texture defines the BabylonJS internal texture
  60247. * @param createPolynomials will be true if polynomials have been requested
  60248. * @param onLoad defines the callback to trigger once the texture is ready
  60249. * @param onError defines the callback to trigger in case of error
  60250. */
  60251. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60252. /**
  60253. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60254. * @param data contains the texture data
  60255. * @param texture defines the BabylonJS internal texture
  60256. * @param callback defines the method to call once ready to upload
  60257. */
  60258. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60259. }
  60260. }
  60261. declare module BABYLON {
  60262. /**
  60263. * Info about the .basis files
  60264. */
  60265. class BasisFileInfo {
  60266. /**
  60267. * If the file has alpha
  60268. */
  60269. hasAlpha: boolean;
  60270. /**
  60271. * Info about each image of the basis file
  60272. */
  60273. images: Array<{
  60274. levels: Array<{
  60275. width: number;
  60276. height: number;
  60277. transcodedPixels: ArrayBufferView;
  60278. }>;
  60279. }>;
  60280. }
  60281. /**
  60282. * Result of transcoding a basis file
  60283. */
  60284. class TranscodeResult {
  60285. /**
  60286. * Info about the .basis file
  60287. */
  60288. fileInfo: BasisFileInfo;
  60289. /**
  60290. * Format to use when loading the file
  60291. */
  60292. format: number;
  60293. }
  60294. /**
  60295. * Configuration options for the Basis transcoder
  60296. */
  60297. export class BasisTranscodeConfiguration {
  60298. /**
  60299. * Supported compression formats used to determine the supported output format of the transcoder
  60300. */
  60301. supportedCompressionFormats?: {
  60302. /**
  60303. * etc1 compression format
  60304. */
  60305. etc1?: boolean;
  60306. /**
  60307. * s3tc compression format
  60308. */
  60309. s3tc?: boolean;
  60310. /**
  60311. * pvrtc compression format
  60312. */
  60313. pvrtc?: boolean;
  60314. /**
  60315. * etc2 compression format
  60316. */
  60317. etc2?: boolean;
  60318. };
  60319. /**
  60320. * If mipmap levels should be loaded for transcoded images (Default: true)
  60321. */
  60322. loadMipmapLevels?: boolean;
  60323. /**
  60324. * Index of a single image to load (Default: all images)
  60325. */
  60326. loadSingleImage?: number;
  60327. }
  60328. /**
  60329. * Used to load .Basis files
  60330. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60331. */
  60332. export class BasisTools {
  60333. private static _IgnoreSupportedFormats;
  60334. /**
  60335. * URL to use when loading the basis transcoder
  60336. */
  60337. static JSModuleURL: string;
  60338. /**
  60339. * URL to use when loading the wasm module for the transcoder
  60340. */
  60341. static WasmModuleURL: string;
  60342. /**
  60343. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60344. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60345. * @returns internal format corresponding to the Basis format
  60346. */
  60347. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60348. private static _WorkerPromise;
  60349. private static _Worker;
  60350. private static _actionId;
  60351. private static _CreateWorkerAsync;
  60352. /**
  60353. * Transcodes a loaded image file to compressed pixel data
  60354. * @param data image data to transcode
  60355. * @param config configuration options for the transcoding
  60356. * @returns a promise resulting in the transcoded image
  60357. */
  60358. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60359. /**
  60360. * Loads a texture from the transcode result
  60361. * @param texture texture load to
  60362. * @param transcodeResult the result of transcoding the basis file to load from
  60363. */
  60364. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60365. }
  60366. }
  60367. declare module BABYLON {
  60368. /**
  60369. * Loader for .basis file format
  60370. */
  60371. export class _BasisTextureLoader implements IInternalTextureLoader {
  60372. /**
  60373. * Defines whether the loader supports cascade loading the different faces.
  60374. */
  60375. readonly supportCascades: boolean;
  60376. /**
  60377. * This returns if the loader support the current file information.
  60378. * @param extension defines the file extension of the file being loaded
  60379. * @returns true if the loader can load the specified file
  60380. */
  60381. canLoad(extension: string): boolean;
  60382. /**
  60383. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60384. * @param data contains the texture data
  60385. * @param texture defines the BabylonJS internal texture
  60386. * @param createPolynomials will be true if polynomials have been requested
  60387. * @param onLoad defines the callback to trigger once the texture is ready
  60388. * @param onError defines the callback to trigger in case of error
  60389. */
  60390. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60391. /**
  60392. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60393. * @param data contains the texture data
  60394. * @param texture defines the BabylonJS internal texture
  60395. * @param callback defines the method to call once ready to upload
  60396. */
  60397. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60398. }
  60399. }
  60400. declare module BABYLON {
  60401. /**
  60402. * Defines the basic options interface of a TexturePacker Frame
  60403. */
  60404. export interface ITexturePackerFrame {
  60405. /**
  60406. * The frame ID
  60407. */
  60408. id: number;
  60409. /**
  60410. * The frames Scale
  60411. */
  60412. scale: Vector2;
  60413. /**
  60414. * The Frames offset
  60415. */
  60416. offset: Vector2;
  60417. }
  60418. /**
  60419. * This is a support class for frame Data on texture packer sets.
  60420. */
  60421. export class TexturePackerFrame implements ITexturePackerFrame {
  60422. /**
  60423. * The frame ID
  60424. */
  60425. id: number;
  60426. /**
  60427. * The frames Scale
  60428. */
  60429. scale: Vector2;
  60430. /**
  60431. * The Frames offset
  60432. */
  60433. offset: Vector2;
  60434. /**
  60435. * Initializes a texture package frame.
  60436. * @param id The numerical frame identifier
  60437. * @param scale Scalar Vector2 for UV frame
  60438. * @param offset Vector2 for the frame position in UV units.
  60439. * @returns TexturePackerFrame
  60440. */
  60441. constructor(id: number, scale: Vector2, offset: Vector2);
  60442. }
  60443. }
  60444. declare module BABYLON {
  60445. /**
  60446. * Defines the basic options interface of a TexturePacker
  60447. */
  60448. export interface ITexturePackerOptions {
  60449. /**
  60450. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60451. */
  60452. map?: string[];
  60453. /**
  60454. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60455. */
  60456. uvsIn?: string;
  60457. /**
  60458. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60459. */
  60460. uvsOut?: string;
  60461. /**
  60462. * number representing the layout style. Defaults to LAYOUT_STRIP
  60463. */
  60464. layout?: number;
  60465. /**
  60466. * number of columns if using custom column count layout(2). This defaults to 4.
  60467. */
  60468. colnum?: number;
  60469. /**
  60470. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60471. */
  60472. updateInputMeshes?: boolean;
  60473. /**
  60474. * boolean flag to dispose all the source textures. Defaults to true.
  60475. */
  60476. disposeSources?: boolean;
  60477. /**
  60478. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60479. */
  60480. fillBlanks?: boolean;
  60481. /**
  60482. * string value representing the context fill style color. Defaults to 'black'.
  60483. */
  60484. customFillColor?: string;
  60485. /**
  60486. * Width and Height Value of each Frame in the TexturePacker Sets
  60487. */
  60488. frameSize?: number;
  60489. /**
  60490. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60491. */
  60492. paddingRatio?: number;
  60493. /**
  60494. * Number that declares the fill method for the padding gutter.
  60495. */
  60496. paddingMode?: number;
  60497. /**
  60498. * If in SUBUV_COLOR padding mode what color to use.
  60499. */
  60500. paddingColor?: Color3 | Color4;
  60501. }
  60502. /**
  60503. * Defines the basic interface of a TexturePacker JSON File
  60504. */
  60505. export interface ITexturePackerJSON {
  60506. /**
  60507. * The frame ID
  60508. */
  60509. name: string;
  60510. /**
  60511. * The base64 channel data
  60512. */
  60513. sets: any;
  60514. /**
  60515. * The options of the Packer
  60516. */
  60517. options: ITexturePackerOptions;
  60518. /**
  60519. * The frame data of the Packer
  60520. */
  60521. frames: Array<number>;
  60522. }
  60523. /**
  60524. * This is a support class that generates a series of packed texture sets.
  60525. * @see https://doc.babylonjs.com/babylon101/materials
  60526. */
  60527. export class TexturePacker {
  60528. /** Packer Layout Constant 0 */
  60529. static readonly LAYOUT_STRIP: number;
  60530. /** Packer Layout Constant 1 */
  60531. static readonly LAYOUT_POWER2: number;
  60532. /** Packer Layout Constant 2 */
  60533. static readonly LAYOUT_COLNUM: number;
  60534. /** Packer Layout Constant 0 */
  60535. static readonly SUBUV_WRAP: number;
  60536. /** Packer Layout Constant 1 */
  60537. static readonly SUBUV_EXTEND: number;
  60538. /** Packer Layout Constant 2 */
  60539. static readonly SUBUV_COLOR: number;
  60540. /** The Name of the Texture Package */
  60541. name: string;
  60542. /** The scene scope of the TexturePacker */
  60543. scene: Scene;
  60544. /** The Meshes to target */
  60545. meshes: AbstractMesh[];
  60546. /** Arguments passed with the Constructor */
  60547. options: ITexturePackerOptions;
  60548. /** The promise that is started upon initialization */
  60549. promise: Nullable<Promise<TexturePacker | string>>;
  60550. /** The Container object for the channel sets that are generated */
  60551. sets: object;
  60552. /** The Container array for the frames that are generated */
  60553. frames: TexturePackerFrame[];
  60554. /** The expected number of textures the system is parsing. */
  60555. private _expecting;
  60556. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60557. private _paddingValue;
  60558. /**
  60559. * Initializes a texture package series from an array of meshes or a single mesh.
  60560. * @param name The name of the package
  60561. * @param meshes The target meshes to compose the package from
  60562. * @param options The arguments that texture packer should follow while building.
  60563. * @param scene The scene which the textures are scoped to.
  60564. * @returns TexturePacker
  60565. */
  60566. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60567. /**
  60568. * Starts the package process
  60569. * @param resolve The promises resolution function
  60570. * @returns TexturePacker
  60571. */
  60572. private _createFrames;
  60573. /**
  60574. * Calculates the Size of the Channel Sets
  60575. * @returns Vector2
  60576. */
  60577. private _calculateSize;
  60578. /**
  60579. * Calculates the UV data for the frames.
  60580. * @param baseSize the base frameSize
  60581. * @param padding the base frame padding
  60582. * @param dtSize size of the Dynamic Texture for that channel
  60583. * @param dtUnits is 1/dtSize
  60584. * @param update flag to update the input meshes
  60585. */
  60586. private _calculateMeshUVFrames;
  60587. /**
  60588. * Calculates the frames Offset.
  60589. * @param index of the frame
  60590. * @returns Vector2
  60591. */
  60592. private _getFrameOffset;
  60593. /**
  60594. * Updates a Mesh to the frame data
  60595. * @param mesh that is the target
  60596. * @param frameID or the frame index
  60597. */
  60598. private _updateMeshUV;
  60599. /**
  60600. * Updates a Meshes materials to use the texture packer channels
  60601. * @param m is the mesh to target
  60602. * @param force all channels on the packer to be set.
  60603. */
  60604. private _updateTextureReferences;
  60605. /**
  60606. * Public method to set a Mesh to a frame
  60607. * @param m that is the target
  60608. * @param frameID or the frame index
  60609. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60610. */
  60611. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60612. /**
  60613. * Starts the async promise to compile the texture packer.
  60614. * @returns Promise<void>
  60615. */
  60616. processAsync(): Promise<void>;
  60617. /**
  60618. * Disposes all textures associated with this packer
  60619. */
  60620. dispose(): void;
  60621. /**
  60622. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60623. * @param imageType is the image type to use.
  60624. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60625. */
  60626. download(imageType?: string, quality?: number): void;
  60627. /**
  60628. * Public method to load a texturePacker JSON file.
  60629. * @param data of the JSON file in string format.
  60630. */
  60631. updateFromJSON(data: string): void;
  60632. }
  60633. }
  60634. declare module BABYLON {
  60635. /**
  60636. * 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.
  60637. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60638. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60639. */
  60640. export class CustomProceduralTexture extends ProceduralTexture {
  60641. private _animate;
  60642. private _time;
  60643. private _config;
  60644. private _texturePath;
  60645. /**
  60646. * Instantiates a new Custom Procedural Texture.
  60647. * 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.
  60648. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60649. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60650. * @param name Define the name of the texture
  60651. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60652. * @param size Define the size of the texture to create
  60653. * @param scene Define the scene the texture belongs to
  60654. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60655. * @param generateMipMaps Define if the texture should creates mip maps or not
  60656. */
  60657. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60658. private _loadJson;
  60659. /**
  60660. * Is the texture ready to be used ? (rendered at least once)
  60661. * @returns true if ready, otherwise, false.
  60662. */
  60663. isReady(): boolean;
  60664. /**
  60665. * Render the texture to its associated render target.
  60666. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60667. */
  60668. render(useCameraPostProcess?: boolean): void;
  60669. /**
  60670. * Update the list of dependant textures samplers in the shader.
  60671. */
  60672. updateTextures(): void;
  60673. /**
  60674. * Update the uniform values of the procedural texture in the shader.
  60675. */
  60676. updateShaderUniforms(): void;
  60677. /**
  60678. * Define if the texture animates or not.
  60679. */
  60680. get animate(): boolean;
  60681. set animate(value: boolean);
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /** @hidden */
  60686. export var noisePixelShader: {
  60687. name: string;
  60688. shader: string;
  60689. };
  60690. }
  60691. declare module BABYLON {
  60692. /**
  60693. * Class used to generate noise procedural textures
  60694. */
  60695. export class NoiseProceduralTexture extends ProceduralTexture {
  60696. private _time;
  60697. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60698. brightness: number;
  60699. /** Defines the number of octaves to process */
  60700. octaves: number;
  60701. /** Defines the level of persistence (0.8 by default) */
  60702. persistence: number;
  60703. /** Gets or sets animation speed factor (default is 1) */
  60704. animationSpeedFactor: number;
  60705. /**
  60706. * Creates a new NoiseProceduralTexture
  60707. * @param name defines the name fo the texture
  60708. * @param size defines the size of the texture (default is 256)
  60709. * @param scene defines the hosting scene
  60710. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60711. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60712. */
  60713. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60714. private _updateShaderUniforms;
  60715. protected _getDefines(): string;
  60716. /** Generate the current state of the procedural texture */
  60717. render(useCameraPostProcess?: boolean): void;
  60718. /**
  60719. * Serializes this noise procedural texture
  60720. * @returns a serialized noise procedural texture object
  60721. */
  60722. serialize(): any;
  60723. /**
  60724. * Clone the texture.
  60725. * @returns the cloned texture
  60726. */
  60727. clone(): NoiseProceduralTexture;
  60728. /**
  60729. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60730. * @param parsedTexture defines parsed texture data
  60731. * @param scene defines the current scene
  60732. * @param rootUrl defines the root URL containing noise procedural texture information
  60733. * @returns a parsed NoiseProceduralTexture
  60734. */
  60735. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60736. }
  60737. }
  60738. declare module BABYLON {
  60739. /**
  60740. * Raw cube texture where the raw buffers are passed in
  60741. */
  60742. export class RawCubeTexture extends CubeTexture {
  60743. /**
  60744. * Creates a cube texture where the raw buffers are passed in.
  60745. * @param scene defines the scene the texture is attached to
  60746. * @param data defines the array of data to use to create each face
  60747. * @param size defines the size of the textures
  60748. * @param format defines the format of the data
  60749. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60750. * @param generateMipMaps defines if the engine should generate the mip levels
  60751. * @param invertY defines if data must be stored with Y axis inverted
  60752. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60753. * @param compression defines the compression used (null by default)
  60754. */
  60755. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60756. /**
  60757. * Updates the raw cube texture.
  60758. * @param data defines the data to store
  60759. * @param format defines the data format
  60760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60761. * @param invertY defines if data must be stored with Y axis inverted
  60762. * @param compression defines the compression used (null by default)
  60763. * @param level defines which level of the texture to update
  60764. */
  60765. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60766. /**
  60767. * Updates a raw cube texture with RGBD encoded data.
  60768. * @param data defines the array of data [mipmap][face] to use to create each face
  60769. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60772. * @returns a promsie that resolves when the operation is complete
  60773. */
  60774. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60775. /**
  60776. * Clones the raw cube texture.
  60777. * @return a new cube texture
  60778. */
  60779. clone(): CubeTexture;
  60780. /** @hidden */
  60781. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60782. }
  60783. }
  60784. declare module BABYLON {
  60785. /**
  60786. * Class used to store 2D array textures containing user data
  60787. */
  60788. export class RawTexture2DArray extends Texture {
  60789. /** Gets or sets the texture format to use */
  60790. format: number;
  60791. /**
  60792. * Create a new RawTexture2DArray
  60793. * @param data defines the data of the texture
  60794. * @param width defines the width of the texture
  60795. * @param height defines the height of the texture
  60796. * @param depth defines the number of layers of the texture
  60797. * @param format defines the texture format to use
  60798. * @param scene defines the hosting scene
  60799. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60800. * @param invertY defines if texture must be stored with Y axis inverted
  60801. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60803. */
  60804. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60805. /** Gets or sets the texture format to use */
  60806. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60807. /**
  60808. * Update the texture with new data
  60809. * @param data defines the data to store in the texture
  60810. */
  60811. update(data: ArrayBufferView): void;
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Class used to store 3D textures containing user data
  60817. */
  60818. export class RawTexture3D extends Texture {
  60819. /** Gets or sets the texture format to use */
  60820. format: number;
  60821. /**
  60822. * Create a new RawTexture3D
  60823. * @param data defines the data of the texture
  60824. * @param width defines the width of the texture
  60825. * @param height defines the height of the texture
  60826. * @param depth defines the depth of the texture
  60827. * @param format defines the texture format to use
  60828. * @param scene defines the hosting scene
  60829. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60830. * @param invertY defines if texture must be stored with Y axis inverted
  60831. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60832. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60833. */
  60834. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60835. /** Gets or sets the texture format to use */
  60836. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60837. /**
  60838. * Update the texture with new data
  60839. * @param data defines the data to store in the texture
  60840. */
  60841. update(data: ArrayBufferView): void;
  60842. }
  60843. }
  60844. declare module BABYLON {
  60845. /**
  60846. * Creates a refraction texture used by refraction channel of the standard material.
  60847. * It is like a mirror but to see through a material.
  60848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60849. */
  60850. export class RefractionTexture extends RenderTargetTexture {
  60851. /**
  60852. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60853. * 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.
  60854. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60855. */
  60856. refractionPlane: Plane;
  60857. /**
  60858. * Define how deep under the surface we should see.
  60859. */
  60860. depth: number;
  60861. /**
  60862. * Creates a refraction texture used by refraction channel of the standard material.
  60863. * It is like a mirror but to see through a material.
  60864. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60865. * @param name Define the texture name
  60866. * @param size Define the size of the underlying texture
  60867. * @param scene Define the scene the refraction belongs to
  60868. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60869. */
  60870. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60871. /**
  60872. * Clone the refraction texture.
  60873. * @returns the cloned texture
  60874. */
  60875. clone(): RefractionTexture;
  60876. /**
  60877. * Serialize the texture to a JSON representation you could use in Parse later on
  60878. * @returns the serialized JSON representation
  60879. */
  60880. serialize(): any;
  60881. }
  60882. }
  60883. declare module BABYLON {
  60884. /**
  60885. * Block used to add support for vertex skinning (bones)
  60886. */
  60887. export class BonesBlock extends NodeMaterialBlock {
  60888. /**
  60889. * Creates a new BonesBlock
  60890. * @param name defines the block name
  60891. */
  60892. constructor(name: string);
  60893. /**
  60894. * Initialize the block and prepare the context for build
  60895. * @param state defines the state that will be used for the build
  60896. */
  60897. initialize(state: NodeMaterialBuildState): void;
  60898. /**
  60899. * Gets the current class name
  60900. * @returns the class name
  60901. */
  60902. getClassName(): string;
  60903. /**
  60904. * Gets the matrix indices input component
  60905. */
  60906. get matricesIndices(): NodeMaterialConnectionPoint;
  60907. /**
  60908. * Gets the matrix weights input component
  60909. */
  60910. get matricesWeights(): NodeMaterialConnectionPoint;
  60911. /**
  60912. * Gets the extra matrix indices input component
  60913. */
  60914. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60915. /**
  60916. * Gets the extra matrix weights input component
  60917. */
  60918. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the world input component
  60921. */
  60922. get world(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the output component
  60925. */
  60926. get output(): NodeMaterialConnectionPoint;
  60927. autoConfigure(material: NodeMaterial): void;
  60928. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60931. protected _buildBlock(state: NodeMaterialBuildState): this;
  60932. }
  60933. }
  60934. declare module BABYLON {
  60935. /**
  60936. * Block used to add support for instances
  60937. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60938. */
  60939. export class InstancesBlock extends NodeMaterialBlock {
  60940. /**
  60941. * Creates a new InstancesBlock
  60942. * @param name defines the block name
  60943. */
  60944. constructor(name: string);
  60945. /**
  60946. * Gets the current class name
  60947. * @returns the class name
  60948. */
  60949. getClassName(): string;
  60950. /**
  60951. * Gets the first world row input component
  60952. */
  60953. get world0(): NodeMaterialConnectionPoint;
  60954. /**
  60955. * Gets the second world row input component
  60956. */
  60957. get world1(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the third world row input component
  60960. */
  60961. get world2(): NodeMaterialConnectionPoint;
  60962. /**
  60963. * Gets the forth world row input component
  60964. */
  60965. get world3(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the world input component
  60968. */
  60969. get world(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the output component
  60972. */
  60973. get output(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the isntanceID component
  60976. */
  60977. get instanceID(): NodeMaterialConnectionPoint;
  60978. autoConfigure(material: NodeMaterial): void;
  60979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60980. protected _buildBlock(state: NodeMaterialBuildState): this;
  60981. }
  60982. }
  60983. declare module BABYLON {
  60984. /**
  60985. * Block used to add morph targets support to vertex shader
  60986. */
  60987. export class MorphTargetsBlock extends NodeMaterialBlock {
  60988. private _repeatableContentAnchor;
  60989. /**
  60990. * Create a new MorphTargetsBlock
  60991. * @param name defines the block name
  60992. */
  60993. constructor(name: string);
  60994. /**
  60995. * Gets the current class name
  60996. * @returns the class name
  60997. */
  60998. getClassName(): string;
  60999. /**
  61000. * Gets the position input component
  61001. */
  61002. get position(): NodeMaterialConnectionPoint;
  61003. /**
  61004. * Gets the normal input component
  61005. */
  61006. get normal(): NodeMaterialConnectionPoint;
  61007. /**
  61008. * Gets the tangent input component
  61009. */
  61010. get tangent(): NodeMaterialConnectionPoint;
  61011. /**
  61012. * Gets the tangent input component
  61013. */
  61014. get uv(): NodeMaterialConnectionPoint;
  61015. /**
  61016. * Gets the position output component
  61017. */
  61018. get positionOutput(): NodeMaterialConnectionPoint;
  61019. /**
  61020. * Gets the normal output component
  61021. */
  61022. get normalOutput(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the tangent output component
  61025. */
  61026. get tangentOutput(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the tangent output component
  61029. */
  61030. get uvOutput(): NodeMaterialConnectionPoint;
  61031. initialize(state: NodeMaterialBuildState): void;
  61032. autoConfigure(material: NodeMaterial): void;
  61033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61035. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61036. protected _buildBlock(state: NodeMaterialBuildState): this;
  61037. }
  61038. }
  61039. declare module BABYLON {
  61040. /**
  61041. * Block used to get data information from a light
  61042. */
  61043. export class LightInformationBlock extends NodeMaterialBlock {
  61044. private _lightDataUniformName;
  61045. private _lightColorUniformName;
  61046. private _lightTypeDefineName;
  61047. /**
  61048. * Gets or sets the light associated with this block
  61049. */
  61050. light: Nullable<Light>;
  61051. /**
  61052. * Creates a new LightInformationBlock
  61053. * @param name defines the block name
  61054. */
  61055. constructor(name: string);
  61056. /**
  61057. * Gets the current class name
  61058. * @returns the class name
  61059. */
  61060. getClassName(): string;
  61061. /**
  61062. * Gets the world position input component
  61063. */
  61064. get worldPosition(): NodeMaterialConnectionPoint;
  61065. /**
  61066. * Gets the direction output component
  61067. */
  61068. get direction(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the direction output component
  61071. */
  61072. get color(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the direction output component
  61075. */
  61076. get intensity(): NodeMaterialConnectionPoint;
  61077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61079. protected _buildBlock(state: NodeMaterialBuildState): this;
  61080. serialize(): any;
  61081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61082. }
  61083. }
  61084. declare module BABYLON {
  61085. /**
  61086. * Block used to add image processing support to fragment shader
  61087. */
  61088. export class ImageProcessingBlock extends NodeMaterialBlock {
  61089. /**
  61090. * Create a new ImageProcessingBlock
  61091. * @param name defines the block name
  61092. */
  61093. constructor(name: string);
  61094. /**
  61095. * Gets the current class name
  61096. * @returns the class name
  61097. */
  61098. getClassName(): string;
  61099. /**
  61100. * Gets the color input component
  61101. */
  61102. get color(): NodeMaterialConnectionPoint;
  61103. /**
  61104. * Gets the output component
  61105. */
  61106. get output(): NodeMaterialConnectionPoint;
  61107. /**
  61108. * Initialize the block and prepare the context for build
  61109. * @param state defines the state that will be used for the build
  61110. */
  61111. initialize(state: NodeMaterialBuildState): void;
  61112. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61115. protected _buildBlock(state: NodeMaterialBuildState): this;
  61116. }
  61117. }
  61118. declare module BABYLON {
  61119. /**
  61120. * Block used to pertub normals based on a normal map
  61121. */
  61122. export class PerturbNormalBlock extends NodeMaterialBlock {
  61123. private _tangentSpaceParameterName;
  61124. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61125. invertX: boolean;
  61126. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61127. invertY: boolean;
  61128. /**
  61129. * Create a new PerturbNormalBlock
  61130. * @param name defines the block name
  61131. */
  61132. constructor(name: string);
  61133. /**
  61134. * Gets the current class name
  61135. * @returns the class name
  61136. */
  61137. getClassName(): string;
  61138. /**
  61139. * Gets the world position input component
  61140. */
  61141. get worldPosition(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the world normal input component
  61144. */
  61145. get worldNormal(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the world tangent input component
  61148. */
  61149. get worldTangent(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the uv input component
  61152. */
  61153. get uv(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the normal map color input component
  61156. */
  61157. get normalMapColor(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the strength input component
  61160. */
  61161. get strength(): NodeMaterialConnectionPoint;
  61162. /**
  61163. * Gets the output component
  61164. */
  61165. get output(): NodeMaterialConnectionPoint;
  61166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61168. autoConfigure(material: NodeMaterial): void;
  61169. protected _buildBlock(state: NodeMaterialBuildState): this;
  61170. protected _dumpPropertiesCode(): string;
  61171. serialize(): any;
  61172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61173. }
  61174. }
  61175. declare module BABYLON {
  61176. /**
  61177. * Block used to discard a pixel if a value is smaller than a cutoff
  61178. */
  61179. export class DiscardBlock extends NodeMaterialBlock {
  61180. /**
  61181. * Create a new DiscardBlock
  61182. * @param name defines the block name
  61183. */
  61184. constructor(name: string);
  61185. /**
  61186. * Gets the current class name
  61187. * @returns the class name
  61188. */
  61189. getClassName(): string;
  61190. /**
  61191. * Gets the color input component
  61192. */
  61193. get value(): NodeMaterialConnectionPoint;
  61194. /**
  61195. * Gets the cutoff input component
  61196. */
  61197. get cutoff(): NodeMaterialConnectionPoint;
  61198. protected _buildBlock(state: NodeMaterialBuildState): this;
  61199. }
  61200. }
  61201. declare module BABYLON {
  61202. /**
  61203. * Block used to test if the fragment shader is front facing
  61204. */
  61205. export class FrontFacingBlock extends NodeMaterialBlock {
  61206. /**
  61207. * Creates a new FrontFacingBlock
  61208. * @param name defines the block name
  61209. */
  61210. constructor(name: string);
  61211. /**
  61212. * Gets the current class name
  61213. * @returns the class name
  61214. */
  61215. getClassName(): string;
  61216. /**
  61217. * Gets the output component
  61218. */
  61219. get output(): NodeMaterialConnectionPoint;
  61220. protected _buildBlock(state: NodeMaterialBuildState): this;
  61221. }
  61222. }
  61223. declare module BABYLON {
  61224. /**
  61225. * Block used to get the derivative value on x and y of a given input
  61226. */
  61227. export class DerivativeBlock extends NodeMaterialBlock {
  61228. /**
  61229. * Create a new DerivativeBlock
  61230. * @param name defines the block name
  61231. */
  61232. constructor(name: string);
  61233. /**
  61234. * Gets the current class name
  61235. * @returns the class name
  61236. */
  61237. getClassName(): string;
  61238. /**
  61239. * Gets the input component
  61240. */
  61241. get input(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the derivative output on x
  61244. */
  61245. get dx(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the derivative output on y
  61248. */
  61249. get dy(): NodeMaterialConnectionPoint;
  61250. protected _buildBlock(state: NodeMaterialBuildState): this;
  61251. }
  61252. }
  61253. declare module BABYLON {
  61254. /**
  61255. * Block used to make gl_FragCoord available
  61256. */
  61257. export class FragCoordBlock extends NodeMaterialBlock {
  61258. /**
  61259. * Creates a new FragCoordBlock
  61260. * @param name defines the block name
  61261. */
  61262. constructor(name: string);
  61263. /**
  61264. * Gets the current class name
  61265. * @returns the class name
  61266. */
  61267. getClassName(): string;
  61268. /**
  61269. * Gets the xy component
  61270. */
  61271. get xy(): NodeMaterialConnectionPoint;
  61272. /**
  61273. * Gets the xyz component
  61274. */
  61275. get xyz(): NodeMaterialConnectionPoint;
  61276. /**
  61277. * Gets the xyzw component
  61278. */
  61279. get xyzw(): NodeMaterialConnectionPoint;
  61280. /**
  61281. * Gets the x component
  61282. */
  61283. get x(): NodeMaterialConnectionPoint;
  61284. /**
  61285. * Gets the y component
  61286. */
  61287. get y(): NodeMaterialConnectionPoint;
  61288. /**
  61289. * Gets the z component
  61290. */
  61291. get z(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the w component
  61294. */
  61295. get output(): NodeMaterialConnectionPoint;
  61296. protected writeOutputs(state: NodeMaterialBuildState): string;
  61297. protected _buildBlock(state: NodeMaterialBuildState): this;
  61298. }
  61299. }
  61300. declare module BABYLON {
  61301. /**
  61302. * Block used to get the screen sizes
  61303. */
  61304. export class ScreenSizeBlock extends NodeMaterialBlock {
  61305. private _varName;
  61306. private _scene;
  61307. /**
  61308. * Creates a new ScreenSizeBlock
  61309. * @param name defines the block name
  61310. */
  61311. constructor(name: string);
  61312. /**
  61313. * Gets the current class name
  61314. * @returns the class name
  61315. */
  61316. getClassName(): string;
  61317. /**
  61318. * Gets the xy component
  61319. */
  61320. get xy(): NodeMaterialConnectionPoint;
  61321. /**
  61322. * Gets the x component
  61323. */
  61324. get x(): NodeMaterialConnectionPoint;
  61325. /**
  61326. * Gets the y component
  61327. */
  61328. get y(): NodeMaterialConnectionPoint;
  61329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61330. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61331. protected _buildBlock(state: NodeMaterialBuildState): this;
  61332. }
  61333. }
  61334. declare module BABYLON {
  61335. /**
  61336. * Block used to add support for scene fog
  61337. */
  61338. export class FogBlock extends NodeMaterialBlock {
  61339. private _fogDistanceName;
  61340. private _fogParameters;
  61341. /**
  61342. * Create a new FogBlock
  61343. * @param name defines the block name
  61344. */
  61345. constructor(name: string);
  61346. /**
  61347. * Gets the current class name
  61348. * @returns the class name
  61349. */
  61350. getClassName(): string;
  61351. /**
  61352. * Gets the world position input component
  61353. */
  61354. get worldPosition(): NodeMaterialConnectionPoint;
  61355. /**
  61356. * Gets the view input component
  61357. */
  61358. get view(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the color input component
  61361. */
  61362. get input(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the fog color input component
  61365. */
  61366. get fogColor(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the output component
  61369. */
  61370. get output(): NodeMaterialConnectionPoint;
  61371. autoConfigure(material: NodeMaterial): void;
  61372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61374. protected _buildBlock(state: NodeMaterialBuildState): this;
  61375. }
  61376. }
  61377. declare module BABYLON {
  61378. /**
  61379. * Block used to add light in the fragment shader
  61380. */
  61381. export class LightBlock extends NodeMaterialBlock {
  61382. private _lightId;
  61383. /**
  61384. * Gets or sets the light associated with this block
  61385. */
  61386. light: Nullable<Light>;
  61387. /**
  61388. * Create a new LightBlock
  61389. * @param name defines the block name
  61390. */
  61391. constructor(name: string);
  61392. /**
  61393. * Gets the current class name
  61394. * @returns the class name
  61395. */
  61396. getClassName(): string;
  61397. /**
  61398. * Gets the world position input component
  61399. */
  61400. get worldPosition(): NodeMaterialConnectionPoint;
  61401. /**
  61402. * Gets the world normal input component
  61403. */
  61404. get worldNormal(): NodeMaterialConnectionPoint;
  61405. /**
  61406. * Gets the camera (or eye) position component
  61407. */
  61408. get cameraPosition(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the glossiness component
  61411. */
  61412. get glossiness(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the glossinness power component
  61415. */
  61416. get glossPower(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the diffuse color component
  61419. */
  61420. get diffuseColor(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the specular color component
  61423. */
  61424. get specularColor(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the diffuse output component
  61427. */
  61428. get diffuseOutput(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the specular output component
  61431. */
  61432. get specularOutput(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the shadow output component
  61435. */
  61436. get shadow(): NodeMaterialConnectionPoint;
  61437. autoConfigure(material: NodeMaterial): void;
  61438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61439. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61441. private _injectVertexCode;
  61442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61443. serialize(): any;
  61444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61445. }
  61446. }
  61447. declare module BABYLON {
  61448. /**
  61449. * Block used to read a reflection texture from a sampler
  61450. */
  61451. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61452. /**
  61453. * Create a new ReflectionTextureBlock
  61454. * @param name defines the block name
  61455. */
  61456. constructor(name: string);
  61457. /**
  61458. * Gets the current class name
  61459. * @returns the class name
  61460. */
  61461. getClassName(): string;
  61462. /**
  61463. * Gets the world position input component
  61464. */
  61465. get position(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the world position input component
  61468. */
  61469. get worldPosition(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the world normal input component
  61472. */
  61473. get worldNormal(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the world input component
  61476. */
  61477. get world(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the camera (or eye) position component
  61480. */
  61481. get cameraPosition(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the view input component
  61484. */
  61485. get view(): NodeMaterialConnectionPoint;
  61486. /**
  61487. * Gets the rgb output component
  61488. */
  61489. get rgb(): NodeMaterialConnectionPoint;
  61490. /**
  61491. * Gets the r output component
  61492. */
  61493. get r(): NodeMaterialConnectionPoint;
  61494. /**
  61495. * Gets the g output component
  61496. */
  61497. get g(): NodeMaterialConnectionPoint;
  61498. /**
  61499. * Gets the b output component
  61500. */
  61501. get b(): NodeMaterialConnectionPoint;
  61502. autoConfigure(material: NodeMaterial): void;
  61503. protected _buildBlock(state: NodeMaterialBuildState): this;
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /**
  61508. * Block used to add 2 vectors
  61509. */
  61510. export class AddBlock extends NodeMaterialBlock {
  61511. /**
  61512. * Creates a new AddBlock
  61513. * @param name defines the block name
  61514. */
  61515. constructor(name: string);
  61516. /**
  61517. * Gets the current class name
  61518. * @returns the class name
  61519. */
  61520. getClassName(): string;
  61521. /**
  61522. * Gets the left operand input component
  61523. */
  61524. get left(): NodeMaterialConnectionPoint;
  61525. /**
  61526. * Gets the right operand input component
  61527. */
  61528. get right(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the output component
  61531. */
  61532. get output(): NodeMaterialConnectionPoint;
  61533. protected _buildBlock(state: NodeMaterialBuildState): this;
  61534. }
  61535. }
  61536. declare module BABYLON {
  61537. /**
  61538. * Block used to scale a vector by a float
  61539. */
  61540. export class ScaleBlock extends NodeMaterialBlock {
  61541. /**
  61542. * Creates a new ScaleBlock
  61543. * @param name defines the block name
  61544. */
  61545. constructor(name: string);
  61546. /**
  61547. * Gets the current class name
  61548. * @returns the class name
  61549. */
  61550. getClassName(): string;
  61551. /**
  61552. * Gets the input component
  61553. */
  61554. get input(): NodeMaterialConnectionPoint;
  61555. /**
  61556. * Gets the factor input component
  61557. */
  61558. get factor(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the output component
  61561. */
  61562. get output(): NodeMaterialConnectionPoint;
  61563. protected _buildBlock(state: NodeMaterialBuildState): this;
  61564. }
  61565. }
  61566. declare module BABYLON {
  61567. /**
  61568. * Block used to clamp a float
  61569. */
  61570. export class ClampBlock extends NodeMaterialBlock {
  61571. /** Gets or sets the minimum range */
  61572. minimum: number;
  61573. /** Gets or sets the maximum range */
  61574. maximum: number;
  61575. /**
  61576. * Creates a new ClampBlock
  61577. * @param name defines the block name
  61578. */
  61579. constructor(name: string);
  61580. /**
  61581. * Gets the current class name
  61582. * @returns the class name
  61583. */
  61584. getClassName(): string;
  61585. /**
  61586. * Gets the value input component
  61587. */
  61588. get value(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the output component
  61591. */
  61592. get output(): NodeMaterialConnectionPoint;
  61593. protected _buildBlock(state: NodeMaterialBuildState): this;
  61594. protected _dumpPropertiesCode(): string;
  61595. serialize(): any;
  61596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61597. }
  61598. }
  61599. declare module BABYLON {
  61600. /**
  61601. * Block used to apply a cross product between 2 vectors
  61602. */
  61603. export class CrossBlock extends NodeMaterialBlock {
  61604. /**
  61605. * Creates a new CrossBlock
  61606. * @param name defines the block name
  61607. */
  61608. constructor(name: string);
  61609. /**
  61610. * Gets the current class name
  61611. * @returns the class name
  61612. */
  61613. getClassName(): string;
  61614. /**
  61615. * Gets the left operand input component
  61616. */
  61617. get left(): NodeMaterialConnectionPoint;
  61618. /**
  61619. * Gets the right operand input component
  61620. */
  61621. get right(): NodeMaterialConnectionPoint;
  61622. /**
  61623. * Gets the output component
  61624. */
  61625. get output(): NodeMaterialConnectionPoint;
  61626. protected _buildBlock(state: NodeMaterialBuildState): this;
  61627. }
  61628. }
  61629. declare module BABYLON {
  61630. /**
  61631. * Block used to apply a dot product between 2 vectors
  61632. */
  61633. export class DotBlock extends NodeMaterialBlock {
  61634. /**
  61635. * Creates a new DotBlock
  61636. * @param name defines the block name
  61637. */
  61638. constructor(name: string);
  61639. /**
  61640. * Gets the current class name
  61641. * @returns the class name
  61642. */
  61643. getClassName(): string;
  61644. /**
  61645. * Gets the left operand input component
  61646. */
  61647. get left(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the right operand input component
  61650. */
  61651. get right(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the output component
  61654. */
  61655. get output(): NodeMaterialConnectionPoint;
  61656. protected _buildBlock(state: NodeMaterialBuildState): this;
  61657. }
  61658. }
  61659. declare module BABYLON {
  61660. /**
  61661. * Block used to normalize a vector
  61662. */
  61663. export class NormalizeBlock extends NodeMaterialBlock {
  61664. /**
  61665. * Creates a new NormalizeBlock
  61666. * @param name defines the block name
  61667. */
  61668. constructor(name: string);
  61669. /**
  61670. * Gets the current class name
  61671. * @returns the class name
  61672. */
  61673. getClassName(): string;
  61674. /**
  61675. * Gets the input component
  61676. */
  61677. get input(): NodeMaterialConnectionPoint;
  61678. /**
  61679. * Gets the output component
  61680. */
  61681. get output(): NodeMaterialConnectionPoint;
  61682. protected _buildBlock(state: NodeMaterialBuildState): this;
  61683. }
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * Operations supported by the Trigonometry block
  61688. */
  61689. export enum TrigonometryBlockOperations {
  61690. /** Cos */
  61691. Cos = 0,
  61692. /** Sin */
  61693. Sin = 1,
  61694. /** Abs */
  61695. Abs = 2,
  61696. /** Exp */
  61697. Exp = 3,
  61698. /** Exp2 */
  61699. Exp2 = 4,
  61700. /** Round */
  61701. Round = 5,
  61702. /** Floor */
  61703. Floor = 6,
  61704. /** Ceiling */
  61705. Ceiling = 7,
  61706. /** Square root */
  61707. Sqrt = 8,
  61708. /** Log */
  61709. Log = 9,
  61710. /** Tangent */
  61711. Tan = 10,
  61712. /** Arc tangent */
  61713. ArcTan = 11,
  61714. /** Arc cosinus */
  61715. ArcCos = 12,
  61716. /** Arc sinus */
  61717. ArcSin = 13,
  61718. /** Fraction */
  61719. Fract = 14,
  61720. /** Sign */
  61721. Sign = 15,
  61722. /** To radians (from degrees) */
  61723. Radians = 16,
  61724. /** To degrees (from radians) */
  61725. Degrees = 17
  61726. }
  61727. /**
  61728. * Block used to apply trigonometry operation to floats
  61729. */
  61730. export class TrigonometryBlock extends NodeMaterialBlock {
  61731. /**
  61732. * Gets or sets the operation applied by the block
  61733. */
  61734. operation: TrigonometryBlockOperations;
  61735. /**
  61736. * Creates a new TrigonometryBlock
  61737. * @param name defines the block name
  61738. */
  61739. constructor(name: string);
  61740. /**
  61741. * Gets the current class name
  61742. * @returns the class name
  61743. */
  61744. getClassName(): string;
  61745. /**
  61746. * Gets the input component
  61747. */
  61748. get input(): NodeMaterialConnectionPoint;
  61749. /**
  61750. * Gets the output component
  61751. */
  61752. get output(): NodeMaterialConnectionPoint;
  61753. protected _buildBlock(state: NodeMaterialBuildState): this;
  61754. serialize(): any;
  61755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61756. protected _dumpPropertiesCode(): string;
  61757. }
  61758. }
  61759. declare module BABYLON {
  61760. /**
  61761. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61762. */
  61763. export class ColorMergerBlock extends NodeMaterialBlock {
  61764. /**
  61765. * Create a new ColorMergerBlock
  61766. * @param name defines the block name
  61767. */
  61768. constructor(name: string);
  61769. /**
  61770. * Gets the current class name
  61771. * @returns the class name
  61772. */
  61773. getClassName(): string;
  61774. /**
  61775. * Gets the rgb component (input)
  61776. */
  61777. get rgbIn(): NodeMaterialConnectionPoint;
  61778. /**
  61779. * Gets the r component (input)
  61780. */
  61781. get r(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the g component (input)
  61784. */
  61785. get g(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the b component (input)
  61788. */
  61789. get b(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the a component (input)
  61792. */
  61793. get a(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the rgba component (output)
  61796. */
  61797. get rgba(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the rgb component (output)
  61800. */
  61801. get rgbOut(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the rgb component (output)
  61804. * @deprecated Please use rgbOut instead.
  61805. */
  61806. get rgb(): NodeMaterialConnectionPoint;
  61807. protected _buildBlock(state: NodeMaterialBuildState): this;
  61808. }
  61809. }
  61810. declare module BABYLON {
  61811. /**
  61812. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61813. */
  61814. export class VectorSplitterBlock extends NodeMaterialBlock {
  61815. /**
  61816. * Create a new VectorSplitterBlock
  61817. * @param name defines the block name
  61818. */
  61819. constructor(name: string);
  61820. /**
  61821. * Gets the current class name
  61822. * @returns the class name
  61823. */
  61824. getClassName(): string;
  61825. /**
  61826. * Gets the xyzw component (input)
  61827. */
  61828. get xyzw(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the xyz component (input)
  61831. */
  61832. get xyzIn(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the xy component (input)
  61835. */
  61836. get xyIn(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the xyz component (output)
  61839. */
  61840. get xyzOut(): NodeMaterialConnectionPoint;
  61841. /**
  61842. * Gets the xy component (output)
  61843. */
  61844. get xyOut(): NodeMaterialConnectionPoint;
  61845. /**
  61846. * Gets the x component (output)
  61847. */
  61848. get x(): NodeMaterialConnectionPoint;
  61849. /**
  61850. * Gets the y component (output)
  61851. */
  61852. get y(): NodeMaterialConnectionPoint;
  61853. /**
  61854. * Gets the z component (output)
  61855. */
  61856. get z(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the w component (output)
  61859. */
  61860. get w(): NodeMaterialConnectionPoint;
  61861. protected _inputRename(name: string): string;
  61862. protected _outputRename(name: string): string;
  61863. protected _buildBlock(state: NodeMaterialBuildState): this;
  61864. }
  61865. }
  61866. declare module BABYLON {
  61867. /**
  61868. * Block used to lerp between 2 values
  61869. */
  61870. export class LerpBlock extends NodeMaterialBlock {
  61871. /**
  61872. * Creates a new LerpBlock
  61873. * @param name defines the block name
  61874. */
  61875. constructor(name: string);
  61876. /**
  61877. * Gets the current class name
  61878. * @returns the class name
  61879. */
  61880. getClassName(): string;
  61881. /**
  61882. * Gets the left operand input component
  61883. */
  61884. get left(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the right operand input component
  61887. */
  61888. get right(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the gradient operand input component
  61891. */
  61892. get gradient(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the output component
  61895. */
  61896. get output(): NodeMaterialConnectionPoint;
  61897. protected _buildBlock(state: NodeMaterialBuildState): this;
  61898. }
  61899. }
  61900. declare module BABYLON {
  61901. /**
  61902. * Block used to divide 2 vectors
  61903. */
  61904. export class DivideBlock extends NodeMaterialBlock {
  61905. /**
  61906. * Creates a new DivideBlock
  61907. * @param name defines the block name
  61908. */
  61909. constructor(name: string);
  61910. /**
  61911. * Gets the current class name
  61912. * @returns the class name
  61913. */
  61914. getClassName(): string;
  61915. /**
  61916. * Gets the left operand input component
  61917. */
  61918. get left(): NodeMaterialConnectionPoint;
  61919. /**
  61920. * Gets the right operand input component
  61921. */
  61922. get right(): NodeMaterialConnectionPoint;
  61923. /**
  61924. * Gets the output component
  61925. */
  61926. get output(): NodeMaterialConnectionPoint;
  61927. protected _buildBlock(state: NodeMaterialBuildState): this;
  61928. }
  61929. }
  61930. declare module BABYLON {
  61931. /**
  61932. * Block used to subtract 2 vectors
  61933. */
  61934. export class SubtractBlock extends NodeMaterialBlock {
  61935. /**
  61936. * Creates a new SubtractBlock
  61937. * @param name defines the block name
  61938. */
  61939. constructor(name: string);
  61940. /**
  61941. * Gets the current class name
  61942. * @returns the class name
  61943. */
  61944. getClassName(): string;
  61945. /**
  61946. * Gets the left operand input component
  61947. */
  61948. get left(): NodeMaterialConnectionPoint;
  61949. /**
  61950. * Gets the right operand input component
  61951. */
  61952. get right(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the output component
  61955. */
  61956. get output(): NodeMaterialConnectionPoint;
  61957. protected _buildBlock(state: NodeMaterialBuildState): this;
  61958. }
  61959. }
  61960. declare module BABYLON {
  61961. /**
  61962. * Block used to step a value
  61963. */
  61964. export class StepBlock extends NodeMaterialBlock {
  61965. /**
  61966. * Creates a new StepBlock
  61967. * @param name defines the block name
  61968. */
  61969. constructor(name: string);
  61970. /**
  61971. * Gets the current class name
  61972. * @returns the class name
  61973. */
  61974. getClassName(): string;
  61975. /**
  61976. * Gets the value operand input component
  61977. */
  61978. get value(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the edge operand input component
  61981. */
  61982. get edge(): NodeMaterialConnectionPoint;
  61983. /**
  61984. * Gets the output component
  61985. */
  61986. get output(): NodeMaterialConnectionPoint;
  61987. protected _buildBlock(state: NodeMaterialBuildState): this;
  61988. }
  61989. }
  61990. declare module BABYLON {
  61991. /**
  61992. * Block used to get the opposite (1 - x) of a value
  61993. */
  61994. export class OneMinusBlock extends NodeMaterialBlock {
  61995. /**
  61996. * Creates a new OneMinusBlock
  61997. * @param name defines the block name
  61998. */
  61999. constructor(name: string);
  62000. /**
  62001. * Gets the current class name
  62002. * @returns the class name
  62003. */
  62004. getClassName(): string;
  62005. /**
  62006. * Gets the input component
  62007. */
  62008. get input(): 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 view direction
  62019. */
  62020. export class ViewDirectionBlock extends NodeMaterialBlock {
  62021. /**
  62022. * Creates a new ViewDirectionBlock
  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 world position component
  62033. */
  62034. get worldPosition(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the camera position component
  62037. */
  62038. get cameraPosition(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the output component
  62041. */
  62042. get output(): NodeMaterialConnectionPoint;
  62043. autoConfigure(material: NodeMaterial): void;
  62044. protected _buildBlock(state: NodeMaterialBuildState): this;
  62045. }
  62046. }
  62047. declare module BABYLON {
  62048. /**
  62049. * Block used to compute fresnel value
  62050. */
  62051. export class FresnelBlock extends NodeMaterialBlock {
  62052. /**
  62053. * Create a new FresnelBlock
  62054. * @param name defines the block name
  62055. */
  62056. constructor(name: string);
  62057. /**
  62058. * Gets the current class name
  62059. * @returns the class name
  62060. */
  62061. getClassName(): string;
  62062. /**
  62063. * Gets the world normal input component
  62064. */
  62065. get worldNormal(): NodeMaterialConnectionPoint;
  62066. /**
  62067. * Gets the view direction input component
  62068. */
  62069. get viewDirection(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the bias input component
  62072. */
  62073. get bias(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the camera (or eye) position component
  62076. */
  62077. get power(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the fresnel output component
  62080. */
  62081. get fresnel(): NodeMaterialConnectionPoint;
  62082. autoConfigure(material: NodeMaterial): void;
  62083. protected _buildBlock(state: NodeMaterialBuildState): this;
  62084. }
  62085. }
  62086. declare module BABYLON {
  62087. /**
  62088. * Block used to get the max of 2 values
  62089. */
  62090. export class MaxBlock extends NodeMaterialBlock {
  62091. /**
  62092. * Creates a new MaxBlock
  62093. * @param name defines the block name
  62094. */
  62095. constructor(name: string);
  62096. /**
  62097. * Gets the current class name
  62098. * @returns the class name
  62099. */
  62100. getClassName(): string;
  62101. /**
  62102. * Gets the left operand input component
  62103. */
  62104. get left(): NodeMaterialConnectionPoint;
  62105. /**
  62106. * Gets the right operand input component
  62107. */
  62108. get right(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the output component
  62111. */
  62112. get output(): NodeMaterialConnectionPoint;
  62113. protected _buildBlock(state: NodeMaterialBuildState): this;
  62114. }
  62115. }
  62116. declare module BABYLON {
  62117. /**
  62118. * Block used to get the min of 2 values
  62119. */
  62120. export class MinBlock extends NodeMaterialBlock {
  62121. /**
  62122. * Creates a new MinBlock
  62123. * @param name defines the block name
  62124. */
  62125. constructor(name: string);
  62126. /**
  62127. * Gets the current class name
  62128. * @returns the class name
  62129. */
  62130. getClassName(): string;
  62131. /**
  62132. * Gets the left operand input component
  62133. */
  62134. get left(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Gets the right operand input component
  62137. */
  62138. get right(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the output component
  62141. */
  62142. get output(): NodeMaterialConnectionPoint;
  62143. protected _buildBlock(state: NodeMaterialBuildState): this;
  62144. }
  62145. }
  62146. declare module BABYLON {
  62147. /**
  62148. * Block used to get the distance between 2 values
  62149. */
  62150. export class DistanceBlock extends NodeMaterialBlock {
  62151. /**
  62152. * Creates a new DistanceBlock
  62153. * @param name defines the block name
  62154. */
  62155. constructor(name: string);
  62156. /**
  62157. * Gets the current class name
  62158. * @returns the class name
  62159. */
  62160. getClassName(): string;
  62161. /**
  62162. * Gets the left operand input component
  62163. */
  62164. get left(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the right operand input component
  62167. */
  62168. get right(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the output component
  62171. */
  62172. get output(): NodeMaterialConnectionPoint;
  62173. protected _buildBlock(state: NodeMaterialBuildState): this;
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /**
  62178. * Block used to get the length of a vector
  62179. */
  62180. export class LengthBlock extends NodeMaterialBlock {
  62181. /**
  62182. * Creates a new LengthBlock
  62183. * @param name defines the block name
  62184. */
  62185. constructor(name: string);
  62186. /**
  62187. * Gets the current class name
  62188. * @returns the class name
  62189. */
  62190. getClassName(): string;
  62191. /**
  62192. * Gets the value input component
  62193. */
  62194. get value(): NodeMaterialConnectionPoint;
  62195. /**
  62196. * Gets the output component
  62197. */
  62198. get output(): NodeMaterialConnectionPoint;
  62199. protected _buildBlock(state: NodeMaterialBuildState): this;
  62200. }
  62201. }
  62202. declare module BABYLON {
  62203. /**
  62204. * Block used to get negative version of a value (i.e. x * -1)
  62205. */
  62206. export class NegateBlock extends NodeMaterialBlock {
  62207. /**
  62208. * Creates a new NegateBlock
  62209. * @param name defines the block name
  62210. */
  62211. constructor(name: string);
  62212. /**
  62213. * Gets the current class name
  62214. * @returns the class name
  62215. */
  62216. getClassName(): string;
  62217. /**
  62218. * Gets the value input component
  62219. */
  62220. get value(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the output component
  62223. */
  62224. get output(): NodeMaterialConnectionPoint;
  62225. protected _buildBlock(state: NodeMaterialBuildState): this;
  62226. }
  62227. }
  62228. declare module BABYLON {
  62229. /**
  62230. * Block used to get the value of the first parameter raised to the power of the second
  62231. */
  62232. export class PowBlock extends NodeMaterialBlock {
  62233. /**
  62234. * Creates a new PowBlock
  62235. * @param name defines the block name
  62236. */
  62237. constructor(name: string);
  62238. /**
  62239. * Gets the current class name
  62240. * @returns the class name
  62241. */
  62242. getClassName(): string;
  62243. /**
  62244. * Gets the value operand input component
  62245. */
  62246. get value(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the power operand input component
  62249. */
  62250. get power(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the output component
  62253. */
  62254. get output(): NodeMaterialConnectionPoint;
  62255. protected _buildBlock(state: NodeMaterialBuildState): this;
  62256. }
  62257. }
  62258. declare module BABYLON {
  62259. /**
  62260. * Block used to get a random number
  62261. */
  62262. export class RandomNumberBlock extends NodeMaterialBlock {
  62263. /**
  62264. * Creates a new RandomNumberBlock
  62265. * @param name defines the block name
  62266. */
  62267. constructor(name: string);
  62268. /**
  62269. * Gets the current class name
  62270. * @returns the class name
  62271. */
  62272. getClassName(): string;
  62273. /**
  62274. * Gets the seed input component
  62275. */
  62276. get seed(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the output component
  62279. */
  62280. get output(): NodeMaterialConnectionPoint;
  62281. protected _buildBlock(state: NodeMaterialBuildState): this;
  62282. }
  62283. }
  62284. declare module BABYLON {
  62285. /**
  62286. * Block used to compute arc tangent of 2 values
  62287. */
  62288. export class ArcTan2Block extends NodeMaterialBlock {
  62289. /**
  62290. * Creates a new ArcTan2Block
  62291. * @param name defines the block name
  62292. */
  62293. constructor(name: string);
  62294. /**
  62295. * Gets the current class name
  62296. * @returns the class name
  62297. */
  62298. getClassName(): string;
  62299. /**
  62300. * Gets the x operand input component
  62301. */
  62302. get x(): NodeMaterialConnectionPoint;
  62303. /**
  62304. * Gets the y operand input component
  62305. */
  62306. get y(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the output component
  62309. */
  62310. get output(): NodeMaterialConnectionPoint;
  62311. protected _buildBlock(state: NodeMaterialBuildState): this;
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. /**
  62316. * Block used to smooth step a value
  62317. */
  62318. export class SmoothStepBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new SmoothStepBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the value operand input component
  62331. */
  62332. get value(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the first edge operand input component
  62335. */
  62336. get edge0(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the second edge operand input component
  62339. */
  62340. get edge1(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the output component
  62343. */
  62344. get output(): NodeMaterialConnectionPoint;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this;
  62346. }
  62347. }
  62348. declare module BABYLON {
  62349. /**
  62350. * Block used to get the reciprocal (1 / x) of a value
  62351. */
  62352. export class ReciprocalBlock extends NodeMaterialBlock {
  62353. /**
  62354. * Creates a new ReciprocalBlock
  62355. * @param name defines the block name
  62356. */
  62357. constructor(name: string);
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the input component
  62365. */
  62366. get input(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the output component
  62369. */
  62370. get output(): NodeMaterialConnectionPoint;
  62371. protected _buildBlock(state: NodeMaterialBuildState): this;
  62372. }
  62373. }
  62374. declare module BABYLON {
  62375. /**
  62376. * Block used to replace a color by another one
  62377. */
  62378. export class ReplaceColorBlock extends NodeMaterialBlock {
  62379. /**
  62380. * Creates a new ReplaceColorBlock
  62381. * @param name defines the block name
  62382. */
  62383. constructor(name: string);
  62384. /**
  62385. * Gets the current class name
  62386. * @returns the class name
  62387. */
  62388. getClassName(): string;
  62389. /**
  62390. * Gets the value input component
  62391. */
  62392. get value(): NodeMaterialConnectionPoint;
  62393. /**
  62394. * Gets the reference input component
  62395. */
  62396. get reference(): NodeMaterialConnectionPoint;
  62397. /**
  62398. * Gets the distance input component
  62399. */
  62400. get distance(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the replacement input component
  62403. */
  62404. get replacement(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the output component
  62407. */
  62408. get output(): NodeMaterialConnectionPoint;
  62409. protected _buildBlock(state: NodeMaterialBuildState): this;
  62410. }
  62411. }
  62412. declare module BABYLON {
  62413. /**
  62414. * Block used to posterize a value
  62415. * @see https://en.wikipedia.org/wiki/Posterization
  62416. */
  62417. export class PosterizeBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Creates a new PosterizeBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the value input component
  62430. */
  62431. get value(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the steps input component
  62434. */
  62435. get steps(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the output component
  62438. */
  62439. get output(): NodeMaterialConnectionPoint;
  62440. protected _buildBlock(state: NodeMaterialBuildState): this;
  62441. }
  62442. }
  62443. declare module BABYLON {
  62444. /**
  62445. * Operations supported by the Wave block
  62446. */
  62447. export enum WaveBlockKind {
  62448. /** SawTooth */
  62449. SawTooth = 0,
  62450. /** Square */
  62451. Square = 1,
  62452. /** Triangle */
  62453. Triangle = 2
  62454. }
  62455. /**
  62456. * Block used to apply wave operation to floats
  62457. */
  62458. export class WaveBlock extends NodeMaterialBlock {
  62459. /**
  62460. * Gets or sets the kibnd of wave to be applied by the block
  62461. */
  62462. kind: WaveBlockKind;
  62463. /**
  62464. * Creates a new WaveBlock
  62465. * @param name defines the block name
  62466. */
  62467. constructor(name: string);
  62468. /**
  62469. * Gets the current class name
  62470. * @returns the class name
  62471. */
  62472. getClassName(): string;
  62473. /**
  62474. * Gets the input component
  62475. */
  62476. get input(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the output component
  62479. */
  62480. get output(): NodeMaterialConnectionPoint;
  62481. protected _buildBlock(state: NodeMaterialBuildState): this;
  62482. serialize(): any;
  62483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62484. }
  62485. }
  62486. declare module BABYLON {
  62487. /**
  62488. * Class used to store a color step for the GradientBlock
  62489. */
  62490. export class GradientBlockColorStep {
  62491. /**
  62492. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62493. */
  62494. step: number;
  62495. /**
  62496. * Gets or sets the color associated with this step
  62497. */
  62498. color: Color3;
  62499. /**
  62500. * Creates a new GradientBlockColorStep
  62501. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62502. * @param color defines the color associated with this step
  62503. */
  62504. constructor(
  62505. /**
  62506. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62507. */
  62508. step: number,
  62509. /**
  62510. * Gets or sets the color associated with this step
  62511. */
  62512. color: Color3);
  62513. }
  62514. /**
  62515. * Block used to return a color from a gradient based on an input value between 0 and 1
  62516. */
  62517. export class GradientBlock extends NodeMaterialBlock {
  62518. /**
  62519. * Gets or sets the list of color steps
  62520. */
  62521. colorSteps: GradientBlockColorStep[];
  62522. /**
  62523. * Creates a new GradientBlock
  62524. * @param name defines the block name
  62525. */
  62526. constructor(name: string);
  62527. /**
  62528. * Gets the current class name
  62529. * @returns the class name
  62530. */
  62531. getClassName(): string;
  62532. /**
  62533. * Gets the gradient input component
  62534. */
  62535. get gradient(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the output component
  62538. */
  62539. get output(): NodeMaterialConnectionPoint;
  62540. private _writeColorConstant;
  62541. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62542. serialize(): any;
  62543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62544. protected _dumpPropertiesCode(): string;
  62545. }
  62546. }
  62547. declare module BABYLON {
  62548. /**
  62549. * Block used to normalize lerp between 2 values
  62550. */
  62551. export class NLerpBlock extends NodeMaterialBlock {
  62552. /**
  62553. * Creates a new NLerpBlock
  62554. * @param name defines the block name
  62555. */
  62556. constructor(name: string);
  62557. /**
  62558. * Gets the current class name
  62559. * @returns the class name
  62560. */
  62561. getClassName(): string;
  62562. /**
  62563. * Gets the left operand input component
  62564. */
  62565. get left(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the right operand input component
  62568. */
  62569. get right(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the gradient operand input component
  62572. */
  62573. get gradient(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the output component
  62576. */
  62577. get output(): NodeMaterialConnectionPoint;
  62578. protected _buildBlock(state: NodeMaterialBuildState): this;
  62579. }
  62580. }
  62581. declare module BABYLON {
  62582. /**
  62583. * block used to Generate a Worley Noise 3D Noise Pattern
  62584. */
  62585. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62586. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62587. manhattanDistance: boolean;
  62588. /**
  62589. * Creates a new WorleyNoise3DBlock
  62590. * @param name defines the block name
  62591. */
  62592. constructor(name: string);
  62593. /**
  62594. * Gets the current class name
  62595. * @returns the class name
  62596. */
  62597. getClassName(): string;
  62598. /**
  62599. * Gets the seed input component
  62600. */
  62601. get seed(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the jitter input component
  62604. */
  62605. get jitter(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the output component
  62608. */
  62609. get output(): NodeMaterialConnectionPoint;
  62610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62611. /**
  62612. * Exposes the properties to the UI?
  62613. */
  62614. protected _dumpPropertiesCode(): string;
  62615. /**
  62616. * Exposes the properties to the Seralize?
  62617. */
  62618. serialize(): any;
  62619. /**
  62620. * Exposes the properties to the deseralize?
  62621. */
  62622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62623. }
  62624. }
  62625. declare module BABYLON {
  62626. /**
  62627. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62628. */
  62629. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62630. /**
  62631. * Creates a new SimplexPerlin3DBlock
  62632. * @param name defines the block name
  62633. */
  62634. constructor(name: string);
  62635. /**
  62636. * Gets the current class name
  62637. * @returns the class name
  62638. */
  62639. getClassName(): string;
  62640. /**
  62641. * Gets the seed operand input component
  62642. */
  62643. get seed(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the output component
  62646. */
  62647. get output(): NodeMaterialConnectionPoint;
  62648. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62649. }
  62650. }
  62651. declare module BABYLON {
  62652. /**
  62653. * Block used to blend normals
  62654. */
  62655. export class NormalBlendBlock extends NodeMaterialBlock {
  62656. /**
  62657. * Creates a new NormalBlendBlock
  62658. * @param name defines the block name
  62659. */
  62660. constructor(name: string);
  62661. /**
  62662. * Gets the current class name
  62663. * @returns the class name
  62664. */
  62665. getClassName(): string;
  62666. /**
  62667. * Gets the first input component
  62668. */
  62669. get normalMap0(): NodeMaterialConnectionPoint;
  62670. /**
  62671. * Gets the second input component
  62672. */
  62673. get normalMap1(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the output component
  62676. */
  62677. get output(): NodeMaterialConnectionPoint;
  62678. protected _buildBlock(state: NodeMaterialBuildState): this;
  62679. }
  62680. }
  62681. declare module BABYLON {
  62682. /**
  62683. * Block used to rotate a 2d vector by a given angle
  62684. */
  62685. export class Rotate2dBlock extends NodeMaterialBlock {
  62686. /**
  62687. * Creates a new Rotate2dBlock
  62688. * @param name defines the block name
  62689. */
  62690. constructor(name: string);
  62691. /**
  62692. * Gets the current class name
  62693. * @returns the class name
  62694. */
  62695. getClassName(): string;
  62696. /**
  62697. * Gets the input vector
  62698. */
  62699. get input(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the input angle
  62702. */
  62703. get angle(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. autoConfigure(material: NodeMaterial): void;
  62709. protected _buildBlock(state: NodeMaterialBuildState): this;
  62710. }
  62711. }
  62712. declare module BABYLON {
  62713. /**
  62714. * Block used to get the reflected vector from a direction and a normal
  62715. */
  62716. export class ReflectBlock extends NodeMaterialBlock {
  62717. /**
  62718. * Creates a new ReflectBlock
  62719. * @param name defines the block name
  62720. */
  62721. constructor(name: string);
  62722. /**
  62723. * Gets the current class name
  62724. * @returns the class name
  62725. */
  62726. getClassName(): string;
  62727. /**
  62728. * Gets the incident component
  62729. */
  62730. get incident(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the normal component
  62733. */
  62734. get normal(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the output component
  62737. */
  62738. get output(): NodeMaterialConnectionPoint;
  62739. protected _buildBlock(state: NodeMaterialBuildState): this;
  62740. }
  62741. }
  62742. declare module BABYLON {
  62743. /**
  62744. * Block used to get the refracted vector from a direction and a normal
  62745. */
  62746. export class RefractBlock extends NodeMaterialBlock {
  62747. /**
  62748. * Creates a new RefractBlock
  62749. * @param name defines the block name
  62750. */
  62751. constructor(name: string);
  62752. /**
  62753. * Gets the current class name
  62754. * @returns the class name
  62755. */
  62756. getClassName(): string;
  62757. /**
  62758. * Gets the incident component
  62759. */
  62760. get incident(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the normal component
  62763. */
  62764. get normal(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the index of refraction component
  62767. */
  62768. get ior(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the output component
  62771. */
  62772. get output(): NodeMaterialConnectionPoint;
  62773. protected _buildBlock(state: NodeMaterialBuildState): this;
  62774. }
  62775. }
  62776. declare module BABYLON {
  62777. /**
  62778. * Block used to desaturate a color
  62779. */
  62780. export class DesaturateBlock extends NodeMaterialBlock {
  62781. /**
  62782. * Creates a new DesaturateBlock
  62783. * @param name defines the block name
  62784. */
  62785. constructor(name: string);
  62786. /**
  62787. * Gets the current class name
  62788. * @returns the class name
  62789. */
  62790. getClassName(): string;
  62791. /**
  62792. * Gets the color operand input component
  62793. */
  62794. get color(): NodeMaterialConnectionPoint;
  62795. /**
  62796. * Gets the level operand input component
  62797. */
  62798. get level(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the output component
  62801. */
  62802. get output(): NodeMaterialConnectionPoint;
  62803. protected _buildBlock(state: NodeMaterialBuildState): this;
  62804. }
  62805. }
  62806. declare module BABYLON {
  62807. /**
  62808. * Block used to implement the ambient occlusion module of the PBR material
  62809. */
  62810. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62811. /**
  62812. * Create a new AmbientOcclusionBlock
  62813. * @param name defines the block name
  62814. */
  62815. constructor(name: string);
  62816. /**
  62817. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62818. */
  62819. useAmbientInGrayScale: boolean;
  62820. /**
  62821. * Initialize the block and prepare the context for build
  62822. * @param state defines the state that will be used for the build
  62823. */
  62824. initialize(state: NodeMaterialBuildState): void;
  62825. /**
  62826. * Gets the current class name
  62827. * @returns the class name
  62828. */
  62829. getClassName(): string;
  62830. /**
  62831. * Gets the texture input component
  62832. */
  62833. get texture(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the texture intensity component
  62836. */
  62837. get intensity(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the direct light intensity input component
  62840. */
  62841. get directLightIntensity(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the ambient occlusion object output component
  62844. */
  62845. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the main code of the block (fragment side)
  62848. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62849. * @returns the shader code
  62850. */
  62851. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62853. protected _buildBlock(state: NodeMaterialBuildState): this;
  62854. protected _dumpPropertiesCode(): string;
  62855. serialize(): any;
  62856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62857. }
  62858. }
  62859. declare module BABYLON {
  62860. /**
  62861. * Block used to implement the reflection module of the PBR material
  62862. */
  62863. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62864. /** @hidden */
  62865. _defineLODReflectionAlpha: string;
  62866. /** @hidden */
  62867. _defineLinearSpecularReflection: string;
  62868. private _vEnvironmentIrradianceName;
  62869. /** @hidden */
  62870. _vReflectionMicrosurfaceInfosName: string;
  62871. /** @hidden */
  62872. _vReflectionInfosName: string;
  62873. /** @hidden */
  62874. _vReflectionFilteringInfoName: string;
  62875. private _scene;
  62876. /**
  62877. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62878. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62879. * It's less burden on the user side in the editor part.
  62880. */
  62881. /** @hidden */
  62882. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62883. /** @hidden */
  62884. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62885. /** @hidden */
  62886. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62887. /**
  62888. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62889. * diffuse part of the IBL.
  62890. */
  62891. useSphericalHarmonics: boolean;
  62892. /**
  62893. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62894. */
  62895. forceIrradianceInFragment: boolean;
  62896. /**
  62897. * Create a new ReflectionBlock
  62898. * @param name defines the block name
  62899. */
  62900. constructor(name: string);
  62901. /**
  62902. * Gets the current class name
  62903. * @returns the class name
  62904. */
  62905. getClassName(): string;
  62906. /**
  62907. * Gets the position input component
  62908. */
  62909. get position(): NodeMaterialConnectionPoint;
  62910. /**
  62911. * Gets the world position input component
  62912. */
  62913. get worldPosition(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the world normal input component
  62916. */
  62917. get worldNormal(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the world input component
  62920. */
  62921. get world(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the camera (or eye) position component
  62924. */
  62925. get cameraPosition(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the view input component
  62928. */
  62929. get view(): NodeMaterialConnectionPoint;
  62930. /**
  62931. * Gets the color input component
  62932. */
  62933. get color(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the reflection object output component
  62936. */
  62937. get reflection(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62940. */
  62941. get hasTexture(): boolean;
  62942. /**
  62943. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62944. */
  62945. get reflectionColor(): string;
  62946. protected _getTexture(): Nullable<BaseTexture>;
  62947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62949. /**
  62950. * Gets the code to inject in the vertex shader
  62951. * @param state current state of the node material building
  62952. * @returns the shader code
  62953. */
  62954. handleVertexSide(state: NodeMaterialBuildState): string;
  62955. /**
  62956. * Gets the main code of the block (fragment side)
  62957. * @param state current state of the node material building
  62958. * @param normalVarName name of the existing variable corresponding to the normal
  62959. * @returns the shader code
  62960. */
  62961. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62962. protected _buildBlock(state: NodeMaterialBuildState): this;
  62963. protected _dumpPropertiesCode(): string;
  62964. serialize(): any;
  62965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Block used to implement the sheen module of the PBR material
  62971. */
  62972. export class SheenBlock extends NodeMaterialBlock {
  62973. /**
  62974. * Create a new SheenBlock
  62975. * @param name defines the block name
  62976. */
  62977. constructor(name: string);
  62978. /**
  62979. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62980. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62981. * making it easier to setup and tweak the effect
  62982. */
  62983. albedoScaling: boolean;
  62984. /**
  62985. * Defines if the sheen is linked to the sheen color.
  62986. */
  62987. linkSheenWithAlbedo: boolean;
  62988. /**
  62989. * Initialize the block and prepare the context for build
  62990. * @param state defines the state that will be used for the build
  62991. */
  62992. initialize(state: NodeMaterialBuildState): void;
  62993. /**
  62994. * Gets the current class name
  62995. * @returns the class name
  62996. */
  62997. getClassName(): string;
  62998. /**
  62999. * Gets the intensity input component
  63000. */
  63001. get intensity(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the color input component
  63004. */
  63005. get color(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the roughness input component
  63008. */
  63009. get roughness(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the sheen object output component
  63012. */
  63013. get sheen(): NodeMaterialConnectionPoint;
  63014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63015. /**
  63016. * Gets the main code of the block (fragment side)
  63017. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63018. * @returns the shader code
  63019. */
  63020. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63021. protected _buildBlock(state: NodeMaterialBuildState): this;
  63022. protected _dumpPropertiesCode(): string;
  63023. serialize(): any;
  63024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Block used to implement the reflectivity module of the PBR material
  63030. */
  63031. export class ReflectivityBlock extends NodeMaterialBlock {
  63032. private _metallicReflectanceColor;
  63033. private _metallicF0Factor;
  63034. /** @hidden */
  63035. _vMetallicReflectanceFactorsName: string;
  63036. /**
  63037. * The property below is set by the main PBR block prior to calling methods of this class.
  63038. */
  63039. /** @hidden */
  63040. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63041. /**
  63042. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63043. */
  63044. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63045. /**
  63046. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63047. */
  63048. useMetallnessFromMetallicTextureBlue: boolean;
  63049. /**
  63050. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63051. */
  63052. useRoughnessFromMetallicTextureAlpha: boolean;
  63053. /**
  63054. * Specifies if the metallic texture contains the roughness information in its green channel.
  63055. */
  63056. useRoughnessFromMetallicTextureGreen: boolean;
  63057. /**
  63058. * Create a new ReflectivityBlock
  63059. * @param name defines the block name
  63060. */
  63061. constructor(name: string);
  63062. /**
  63063. * Initialize the block and prepare the context for build
  63064. * @param state defines the state that will be used for the build
  63065. */
  63066. initialize(state: NodeMaterialBuildState): void;
  63067. /**
  63068. * Gets the current class name
  63069. * @returns the class name
  63070. */
  63071. getClassName(): string;
  63072. /**
  63073. * Gets the metallic input component
  63074. */
  63075. get metallic(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the roughness input component
  63078. */
  63079. get roughness(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the texture input component
  63082. */
  63083. get texture(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the reflectivity object output component
  63086. */
  63087. get reflectivity(): NodeMaterialConnectionPoint;
  63088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63089. /**
  63090. * Gets the main code of the block (fragment side)
  63091. * @param state current state of the node material building
  63092. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63093. * @returns the shader code
  63094. */
  63095. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63097. protected _buildBlock(state: NodeMaterialBuildState): this;
  63098. protected _dumpPropertiesCode(): string;
  63099. serialize(): any;
  63100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63101. }
  63102. }
  63103. declare module BABYLON {
  63104. /**
  63105. * Block used to implement the anisotropy module of the PBR material
  63106. */
  63107. export class AnisotropyBlock extends NodeMaterialBlock {
  63108. /**
  63109. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63110. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63111. * It's less burden on the user side in the editor part.
  63112. */
  63113. /** @hidden */
  63114. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63115. /** @hidden */
  63116. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63117. /**
  63118. * Create a new AnisotropyBlock
  63119. * @param name defines the block name
  63120. */
  63121. constructor(name: string);
  63122. /**
  63123. * Initialize the block and prepare the context for build
  63124. * @param state defines the state that will be used for the build
  63125. */
  63126. initialize(state: NodeMaterialBuildState): void;
  63127. /**
  63128. * Gets the current class name
  63129. * @returns the class name
  63130. */
  63131. getClassName(): string;
  63132. /**
  63133. * Gets the intensity input component
  63134. */
  63135. get intensity(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the direction input component
  63138. */
  63139. get direction(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the texture input component
  63142. */
  63143. get texture(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the uv input component
  63146. */
  63147. get uv(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the worldTangent input component
  63150. */
  63151. get worldTangent(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the anisotropy object output component
  63154. */
  63155. get anisotropy(): NodeMaterialConnectionPoint;
  63156. private _generateTBNSpace;
  63157. /**
  63158. * Gets the main code of the block (fragment side)
  63159. * @param state current state of the node material building
  63160. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63161. * @returns the shader code
  63162. */
  63163. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63165. protected _buildBlock(state: NodeMaterialBuildState): this;
  63166. }
  63167. }
  63168. declare module BABYLON {
  63169. /**
  63170. * Block used to implement the clear coat module of the PBR material
  63171. */
  63172. export class ClearCoatBlock extends NodeMaterialBlock {
  63173. private _scene;
  63174. /**
  63175. * Create a new ClearCoatBlock
  63176. * @param name defines the block name
  63177. */
  63178. constructor(name: string);
  63179. /**
  63180. * Initialize the block and prepare the context for build
  63181. * @param state defines the state that will be used for the build
  63182. */
  63183. initialize(state: NodeMaterialBuildState): void;
  63184. /**
  63185. * Gets the current class name
  63186. * @returns the class name
  63187. */
  63188. getClassName(): string;
  63189. /**
  63190. * Gets the intensity input component
  63191. */
  63192. get intensity(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the roughness input component
  63195. */
  63196. get roughness(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the ior input component
  63199. */
  63200. get ior(): NodeMaterialConnectionPoint;
  63201. /**
  63202. * Gets the texture input component
  63203. */
  63204. get texture(): NodeMaterialConnectionPoint;
  63205. /**
  63206. * Gets the bump texture input component
  63207. */
  63208. get bumpTexture(): NodeMaterialConnectionPoint;
  63209. /**
  63210. * Gets the uv input component
  63211. */
  63212. get uv(): NodeMaterialConnectionPoint;
  63213. /**
  63214. * Gets the tint color input component
  63215. */
  63216. get tintColor(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the tint "at distance" input component
  63219. */
  63220. get tintAtDistance(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the tint thickness input component
  63223. */
  63224. get tintThickness(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the world tangent input component
  63227. */
  63228. get worldTangent(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the clear coat object output component
  63231. */
  63232. get clearcoat(): NodeMaterialConnectionPoint;
  63233. autoConfigure(material: NodeMaterial): void;
  63234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63236. private _generateTBNSpace;
  63237. /**
  63238. * Gets the main code of the block (fragment side)
  63239. * @param state current state of the node material building
  63240. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63241. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63242. * @param worldPosVarName name of the variable holding the world position
  63243. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63244. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63245. * @param worldNormalVarName name of the variable holding the world normal
  63246. * @returns the shader code
  63247. */
  63248. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63249. protected _buildBlock(state: NodeMaterialBuildState): this;
  63250. }
  63251. }
  63252. declare module BABYLON {
  63253. /**
  63254. * Block used to implement the sub surface module of the PBR material
  63255. */
  63256. export class SubSurfaceBlock extends NodeMaterialBlock {
  63257. /**
  63258. * Create a new SubSurfaceBlock
  63259. * @param name defines the block name
  63260. */
  63261. constructor(name: string);
  63262. /**
  63263. * Stores the intensity of the different subsurface effects in the thickness texture.
  63264. * * the green channel is the translucency intensity.
  63265. * * the blue channel is the scattering intensity.
  63266. * * the alpha channel is the refraction intensity.
  63267. */
  63268. useMaskFromThicknessTexture: boolean;
  63269. /**
  63270. * Initialize the block and prepare the context for build
  63271. * @param state defines the state that will be used for the build
  63272. */
  63273. initialize(state: NodeMaterialBuildState): void;
  63274. /**
  63275. * Gets the current class name
  63276. * @returns the class name
  63277. */
  63278. getClassName(): string;
  63279. /**
  63280. * Gets the min thickness input component
  63281. */
  63282. get minThickness(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the max thickness input component
  63285. */
  63286. get maxThickness(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the thickness texture component
  63289. */
  63290. get thicknessTexture(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the tint color input component
  63293. */
  63294. get tintColor(): NodeMaterialConnectionPoint;
  63295. /**
  63296. * Gets the translucency intensity input component
  63297. */
  63298. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63299. /**
  63300. * Gets the translucency diffusion distance input component
  63301. */
  63302. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63303. /**
  63304. * Gets the refraction object parameters
  63305. */
  63306. get refraction(): NodeMaterialConnectionPoint;
  63307. /**
  63308. * Gets the sub surface object output component
  63309. */
  63310. get subsurface(): NodeMaterialConnectionPoint;
  63311. autoConfigure(material: NodeMaterial): void;
  63312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63313. /**
  63314. * Gets the main code of the block (fragment side)
  63315. * @param state current state of the node material building
  63316. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63317. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63318. * @param worldPosVarName name of the variable holding the world position
  63319. * @returns the shader code
  63320. */
  63321. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63322. protected _buildBlock(state: NodeMaterialBuildState): this;
  63323. }
  63324. }
  63325. declare module BABYLON {
  63326. /**
  63327. * Block used to implement the PBR metallic/roughness model
  63328. */
  63329. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63330. /**
  63331. * Gets or sets the light associated with this block
  63332. */
  63333. light: Nullable<Light>;
  63334. private _lightId;
  63335. private _scene;
  63336. private _environmentBRDFTexture;
  63337. private _environmentBrdfSamplerName;
  63338. private _vNormalWName;
  63339. private _invertNormalName;
  63340. /**
  63341. * Create a new ReflectionBlock
  63342. * @param name defines the block name
  63343. */
  63344. constructor(name: string);
  63345. /**
  63346. * Intensity of the direct lights e.g. the four lights available in your scene.
  63347. * This impacts both the direct diffuse and specular highlights.
  63348. */
  63349. directIntensity: number;
  63350. /**
  63351. * Intensity of the environment e.g. how much the environment will light the object
  63352. * either through harmonics for rough material or through the refelction for shiny ones.
  63353. */
  63354. environmentIntensity: number;
  63355. /**
  63356. * This is a special control allowing the reduction of the specular highlights coming from the
  63357. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63358. */
  63359. specularIntensity: number;
  63360. /**
  63361. * Defines the falloff type used in this material.
  63362. * It by default is Physical.
  63363. */
  63364. lightFalloff: number;
  63365. /**
  63366. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63367. */
  63368. useAlphaFromAlbedoTexture: boolean;
  63369. /**
  63370. * Specifies that alpha test should be used
  63371. */
  63372. useAlphaTest: boolean;
  63373. /**
  63374. * Defines the alpha limits in alpha test mode.
  63375. */
  63376. alphaTestCutoff: number;
  63377. /**
  63378. * Specifies that alpha blending should be used
  63379. */
  63380. useAlphaBlending: boolean;
  63381. /**
  63382. * Defines if the alpha value should be determined via the rgb values.
  63383. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63384. */
  63385. opacityRGB: boolean;
  63386. /**
  63387. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63388. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63389. */
  63390. useRadianceOverAlpha: boolean;
  63391. /**
  63392. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63393. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63394. */
  63395. useSpecularOverAlpha: boolean;
  63396. /**
  63397. * Enables specular anti aliasing in the PBR shader.
  63398. * It will both interacts on the Geometry for analytical and IBL lighting.
  63399. * It also prefilter the roughness map based on the bump values.
  63400. */
  63401. enableSpecularAntiAliasing: boolean;
  63402. /**
  63403. * Enables realtime filtering on the texture.
  63404. */
  63405. realTimeFiltering: boolean;
  63406. /**
  63407. * Quality switch for realtime filtering
  63408. */
  63409. realTimeFilteringQuality: number;
  63410. /**
  63411. * Defines if the material uses energy conservation.
  63412. */
  63413. useEnergyConservation: boolean;
  63414. /**
  63415. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63416. * too much the area relying on ambient texture to define their ambient occlusion.
  63417. */
  63418. useRadianceOcclusion: boolean;
  63419. /**
  63420. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63421. * makes the reflect vector face the model (under horizon).
  63422. */
  63423. useHorizonOcclusion: boolean;
  63424. /**
  63425. * If set to true, no lighting calculations will be applied.
  63426. */
  63427. unlit: boolean;
  63428. /**
  63429. * Force normal to face away from face.
  63430. */
  63431. forceNormalForward: boolean;
  63432. /**
  63433. * Defines the material debug mode.
  63434. * It helps seeing only some components of the material while troubleshooting.
  63435. */
  63436. debugMode: number;
  63437. /**
  63438. * Specify from where on screen the debug mode should start.
  63439. * The value goes from -1 (full screen) to 1 (not visible)
  63440. * It helps with side by side comparison against the final render
  63441. * This defaults to 0
  63442. */
  63443. debugLimit: number;
  63444. /**
  63445. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63446. * You can use the factor to better multiply the final value.
  63447. */
  63448. debugFactor: number;
  63449. /**
  63450. * Initialize the block and prepare the context for build
  63451. * @param state defines the state that will be used for the build
  63452. */
  63453. initialize(state: NodeMaterialBuildState): void;
  63454. /**
  63455. * Gets the current class name
  63456. * @returns the class name
  63457. */
  63458. getClassName(): string;
  63459. /**
  63460. * Gets the world position input component
  63461. */
  63462. get worldPosition(): NodeMaterialConnectionPoint;
  63463. /**
  63464. * Gets the world normal input component
  63465. */
  63466. get worldNormal(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the perturbed normal input component
  63469. */
  63470. get perturbedNormal(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the camera position input component
  63473. */
  63474. get cameraPosition(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the base color input component
  63477. */
  63478. get baseColor(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the opacity texture input component
  63481. */
  63482. get opacityTexture(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the ambient color input component
  63485. */
  63486. get ambientColor(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the reflectivity object parameters
  63489. */
  63490. get reflectivity(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the ambient occlusion object parameters
  63493. */
  63494. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the reflection object parameters
  63497. */
  63498. get reflection(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the sheen object parameters
  63501. */
  63502. get sheen(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the clear coat object parameters
  63505. */
  63506. get clearcoat(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the sub surface object parameters
  63509. */
  63510. get subsurface(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the anisotropy object parameters
  63513. */
  63514. get anisotropy(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the ambient output component
  63517. */
  63518. get ambient(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the diffuse output component
  63521. */
  63522. get diffuse(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the specular output component
  63525. */
  63526. get specular(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the sheen output component
  63529. */
  63530. get sheenDir(): NodeMaterialConnectionPoint;
  63531. /**
  63532. * Gets the clear coat output component
  63533. */
  63534. get clearcoatDir(): NodeMaterialConnectionPoint;
  63535. /**
  63536. * Gets the indirect diffuse output component
  63537. */
  63538. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63539. /**
  63540. * Gets the indirect specular output component
  63541. */
  63542. get specularIndirect(): NodeMaterialConnectionPoint;
  63543. /**
  63544. * Gets the indirect sheen output component
  63545. */
  63546. get sheenIndirect(): NodeMaterialConnectionPoint;
  63547. /**
  63548. * Gets the indirect clear coat output component
  63549. */
  63550. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the refraction output component
  63553. */
  63554. get refraction(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the global lighting output component
  63557. */
  63558. get lighting(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the shadow output component
  63561. */
  63562. get shadow(): NodeMaterialConnectionPoint;
  63563. /**
  63564. * Gets the alpha output component
  63565. */
  63566. get alpha(): NodeMaterialConnectionPoint;
  63567. autoConfigure(material: NodeMaterial): void;
  63568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63569. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63570. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63571. private _injectVertexCode;
  63572. /**
  63573. * Gets the code corresponding to the albedo/opacity module
  63574. * @returns the shader code
  63575. */
  63576. getAlbedoOpacityCode(): string;
  63577. protected _buildBlock(state: NodeMaterialBuildState): this;
  63578. protected _dumpPropertiesCode(): string;
  63579. serialize(): any;
  63580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63581. }
  63582. }
  63583. declare module BABYLON {
  63584. /**
  63585. * Block used to compute value of one parameter modulo another
  63586. */
  63587. export class ModBlock extends NodeMaterialBlock {
  63588. /**
  63589. * Creates a new ModBlock
  63590. * @param name defines the block name
  63591. */
  63592. constructor(name: string);
  63593. /**
  63594. * Gets the current class name
  63595. * @returns the class name
  63596. */
  63597. getClassName(): string;
  63598. /**
  63599. * Gets the left operand input component
  63600. */
  63601. get left(): NodeMaterialConnectionPoint;
  63602. /**
  63603. * Gets the right operand input component
  63604. */
  63605. get right(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the output component
  63608. */
  63609. get output(): NodeMaterialConnectionPoint;
  63610. protected _buildBlock(state: NodeMaterialBuildState): this;
  63611. }
  63612. }
  63613. declare module BABYLON {
  63614. /**
  63615. * Helper class to push actions to a pool of workers.
  63616. */
  63617. export class WorkerPool implements IDisposable {
  63618. private _workerInfos;
  63619. private _pendingActions;
  63620. /**
  63621. * Constructor
  63622. * @param workers Array of workers to use for actions
  63623. */
  63624. constructor(workers: Array<Worker>);
  63625. /**
  63626. * Terminates all workers and clears any pending actions.
  63627. */
  63628. dispose(): void;
  63629. /**
  63630. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63631. * pended until a worker has completed its action.
  63632. * @param action The action to perform. Call onComplete when the action is complete.
  63633. */
  63634. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63635. private _execute;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Configuration for Draco compression
  63641. */
  63642. export interface IDracoCompressionConfiguration {
  63643. /**
  63644. * Configuration for the decoder.
  63645. */
  63646. decoder: {
  63647. /**
  63648. * The url to the WebAssembly module.
  63649. */
  63650. wasmUrl?: string;
  63651. /**
  63652. * The url to the WebAssembly binary.
  63653. */
  63654. wasmBinaryUrl?: string;
  63655. /**
  63656. * The url to the fallback JavaScript module.
  63657. */
  63658. fallbackUrl?: string;
  63659. };
  63660. }
  63661. /**
  63662. * Draco compression (https://google.github.io/draco/)
  63663. *
  63664. * This class wraps the Draco module.
  63665. *
  63666. * **Encoder**
  63667. *
  63668. * The encoder is not currently implemented.
  63669. *
  63670. * **Decoder**
  63671. *
  63672. * 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.
  63673. *
  63674. * To update the configuration, use the following code:
  63675. * ```javascript
  63676. * DracoCompression.Configuration = {
  63677. * decoder: {
  63678. * wasmUrl: "<url to the WebAssembly library>",
  63679. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63680. * fallbackUrl: "<url to the fallback JavaScript library>",
  63681. * }
  63682. * };
  63683. * ```
  63684. *
  63685. * 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.
  63686. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63687. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63688. *
  63689. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63690. * ```javascript
  63691. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63692. * ```
  63693. *
  63694. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63695. */
  63696. export class DracoCompression implements IDisposable {
  63697. private _workerPoolPromise?;
  63698. private _decoderModulePromise?;
  63699. /**
  63700. * The configuration. Defaults to the following urls:
  63701. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63702. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63703. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63704. */
  63705. static Configuration: IDracoCompressionConfiguration;
  63706. /**
  63707. * Returns true if the decoder configuration is available.
  63708. */
  63709. static get DecoderAvailable(): boolean;
  63710. /**
  63711. * Default number of workers to create when creating the draco compression object.
  63712. */
  63713. static DefaultNumWorkers: number;
  63714. private static GetDefaultNumWorkers;
  63715. private static _Default;
  63716. /**
  63717. * Default instance for the draco compression object.
  63718. */
  63719. static get Default(): DracoCompression;
  63720. /**
  63721. * Constructor
  63722. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63723. */
  63724. constructor(numWorkers?: number);
  63725. /**
  63726. * Stop all async operations and release resources.
  63727. */
  63728. dispose(): void;
  63729. /**
  63730. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63731. * @returns a promise that resolves when ready
  63732. */
  63733. whenReadyAsync(): Promise<void>;
  63734. /**
  63735. * Decode Draco compressed mesh data to vertex data.
  63736. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63737. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63738. * @returns A promise that resolves with the decoded vertex data
  63739. */
  63740. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63741. [kind: string]: number;
  63742. }): Promise<VertexData>;
  63743. }
  63744. }
  63745. declare module BABYLON {
  63746. /**
  63747. * Class for building Constructive Solid Geometry
  63748. */
  63749. export class CSG {
  63750. private polygons;
  63751. /**
  63752. * The world matrix
  63753. */
  63754. matrix: Matrix;
  63755. /**
  63756. * Stores the position
  63757. */
  63758. position: Vector3;
  63759. /**
  63760. * Stores the rotation
  63761. */
  63762. rotation: Vector3;
  63763. /**
  63764. * Stores the rotation quaternion
  63765. */
  63766. rotationQuaternion: Nullable<Quaternion>;
  63767. /**
  63768. * Stores the scaling vector
  63769. */
  63770. scaling: Vector3;
  63771. /**
  63772. * Convert the Mesh to CSG
  63773. * @param mesh The Mesh to convert to CSG
  63774. * @returns A new CSG from the Mesh
  63775. */
  63776. static FromMesh(mesh: Mesh): CSG;
  63777. /**
  63778. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63779. * @param polygons Polygons used to construct a CSG solid
  63780. */
  63781. private static FromPolygons;
  63782. /**
  63783. * Clones, or makes a deep copy, of the CSG
  63784. * @returns A new CSG
  63785. */
  63786. clone(): CSG;
  63787. /**
  63788. * Unions this CSG with another CSG
  63789. * @param csg The CSG to union against this CSG
  63790. * @returns The unioned CSG
  63791. */
  63792. union(csg: CSG): CSG;
  63793. /**
  63794. * Unions this CSG with another CSG in place
  63795. * @param csg The CSG to union against this CSG
  63796. */
  63797. unionInPlace(csg: CSG): void;
  63798. /**
  63799. * Subtracts this CSG with another CSG
  63800. * @param csg The CSG to subtract against this CSG
  63801. * @returns A new CSG
  63802. */
  63803. subtract(csg: CSG): CSG;
  63804. /**
  63805. * Subtracts this CSG with another CSG in place
  63806. * @param csg The CSG to subtact against this CSG
  63807. */
  63808. subtractInPlace(csg: CSG): void;
  63809. /**
  63810. * Intersect this CSG with another CSG
  63811. * @param csg The CSG to intersect against this CSG
  63812. * @returns A new CSG
  63813. */
  63814. intersect(csg: CSG): CSG;
  63815. /**
  63816. * Intersects this CSG with another CSG in place
  63817. * @param csg The CSG to intersect against this CSG
  63818. */
  63819. intersectInPlace(csg: CSG): void;
  63820. /**
  63821. * Return a new CSG solid with solid and empty space switched. This solid is
  63822. * not modified.
  63823. * @returns A new CSG solid with solid and empty space switched
  63824. */
  63825. inverse(): CSG;
  63826. /**
  63827. * Inverses the CSG in place
  63828. */
  63829. inverseInPlace(): void;
  63830. /**
  63831. * This is used to keep meshes transformations so they can be restored
  63832. * when we build back a Babylon Mesh
  63833. * NB : All CSG operations are performed in world coordinates
  63834. * @param csg The CSG to copy the transform attributes from
  63835. * @returns This CSG
  63836. */
  63837. copyTransformAttributes(csg: CSG): CSG;
  63838. /**
  63839. * Build Raw mesh from CSG
  63840. * Coordinates here are in world space
  63841. * @param name The name of the mesh geometry
  63842. * @param scene The Scene
  63843. * @param keepSubMeshes Specifies if the submeshes should be kept
  63844. * @returns A new Mesh
  63845. */
  63846. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63847. /**
  63848. * Build Mesh from CSG taking material and transforms into account
  63849. * @param name The name of the Mesh
  63850. * @param material The material of the Mesh
  63851. * @param scene The Scene
  63852. * @param keepSubMeshes Specifies if submeshes should be kept
  63853. * @returns The new Mesh
  63854. */
  63855. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63856. }
  63857. }
  63858. declare module BABYLON {
  63859. /**
  63860. * Class used to create a trail following a mesh
  63861. */
  63862. export class TrailMesh extends Mesh {
  63863. private _generator;
  63864. private _autoStart;
  63865. private _running;
  63866. private _diameter;
  63867. private _length;
  63868. private _sectionPolygonPointsCount;
  63869. private _sectionVectors;
  63870. private _sectionNormalVectors;
  63871. private _beforeRenderObserver;
  63872. /**
  63873. * @constructor
  63874. * @param name The value used by scene.getMeshByName() to do a lookup.
  63875. * @param generator The mesh or transform node to generate a trail.
  63876. * @param scene The scene to add this mesh to.
  63877. * @param diameter Diameter of trailing mesh. Default is 1.
  63878. * @param length Length of trailing mesh. Default is 60.
  63879. * @param autoStart Automatically start trailing mesh. Default true.
  63880. */
  63881. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63882. /**
  63883. * "TrailMesh"
  63884. * @returns "TrailMesh"
  63885. */
  63886. getClassName(): string;
  63887. private _createMesh;
  63888. /**
  63889. * Start trailing mesh.
  63890. */
  63891. start(): void;
  63892. /**
  63893. * Stop trailing mesh.
  63894. */
  63895. stop(): void;
  63896. /**
  63897. * Update trailing mesh geometry.
  63898. */
  63899. update(): void;
  63900. /**
  63901. * Returns a new TrailMesh object.
  63902. * @param name is a string, the name given to the new mesh
  63903. * @param newGenerator use new generator object for cloned trail mesh
  63904. * @returns a new mesh
  63905. */
  63906. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63907. /**
  63908. * Serializes this trail mesh
  63909. * @param serializationObject object to write serialization to
  63910. */
  63911. serialize(serializationObject: any): void;
  63912. /**
  63913. * Parses a serialized trail mesh
  63914. * @param parsedMesh the serialized mesh
  63915. * @param scene the scene to create the trail mesh in
  63916. * @returns the created trail mesh
  63917. */
  63918. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63919. }
  63920. }
  63921. declare module BABYLON {
  63922. /**
  63923. * Class containing static functions to help procedurally build meshes
  63924. */
  63925. export class TiledBoxBuilder {
  63926. /**
  63927. * Creates a box mesh
  63928. * 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)
  63929. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63931. * * 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
  63932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63933. * @param name defines the name of the mesh
  63934. * @param options defines the options used to create the mesh
  63935. * @param scene defines the hosting scene
  63936. * @returns the box mesh
  63937. */
  63938. static CreateTiledBox(name: string, options: {
  63939. pattern?: number;
  63940. width?: number;
  63941. height?: number;
  63942. depth?: number;
  63943. tileSize?: number;
  63944. tileWidth?: number;
  63945. tileHeight?: number;
  63946. alignHorizontal?: number;
  63947. alignVertical?: number;
  63948. faceUV?: Vector4[];
  63949. faceColors?: Color4[];
  63950. sideOrientation?: number;
  63951. updatable?: boolean;
  63952. }, scene?: Nullable<Scene>): Mesh;
  63953. }
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * Class containing static functions to help procedurally build meshes
  63958. */
  63959. export class TorusKnotBuilder {
  63960. /**
  63961. * Creates a torus knot mesh
  63962. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63963. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63964. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63965. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63967. * * 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
  63968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63969. * @param name defines the name of the mesh
  63970. * @param options defines the options used to create the mesh
  63971. * @param scene defines the hosting scene
  63972. * @returns the torus knot mesh
  63973. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63974. */
  63975. static CreateTorusKnot(name: string, options: {
  63976. radius?: number;
  63977. tube?: number;
  63978. radialSegments?: number;
  63979. tubularSegments?: number;
  63980. p?: number;
  63981. q?: number;
  63982. updatable?: boolean;
  63983. sideOrientation?: number;
  63984. frontUVs?: Vector4;
  63985. backUVs?: Vector4;
  63986. }, scene: any): Mesh;
  63987. }
  63988. }
  63989. declare module BABYLON {
  63990. /**
  63991. * Polygon
  63992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63993. */
  63994. export class Polygon {
  63995. /**
  63996. * Creates a rectangle
  63997. * @param xmin bottom X coord
  63998. * @param ymin bottom Y coord
  63999. * @param xmax top X coord
  64000. * @param ymax top Y coord
  64001. * @returns points that make the resulting rectation
  64002. */
  64003. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64004. /**
  64005. * Creates a circle
  64006. * @param radius radius of circle
  64007. * @param cx scale in x
  64008. * @param cy scale in y
  64009. * @param numberOfSides number of sides that make up the circle
  64010. * @returns points that make the resulting circle
  64011. */
  64012. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64013. /**
  64014. * Creates a polygon from input string
  64015. * @param input Input polygon data
  64016. * @returns the parsed points
  64017. */
  64018. static Parse(input: string): Vector2[];
  64019. /**
  64020. * Starts building a polygon from x and y coordinates
  64021. * @param x x coordinate
  64022. * @param y y coordinate
  64023. * @returns the started path2
  64024. */
  64025. static StartingAt(x: number, y: number): Path2;
  64026. }
  64027. /**
  64028. * Builds a polygon
  64029. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64030. */
  64031. export class PolygonMeshBuilder {
  64032. private _points;
  64033. private _outlinepoints;
  64034. private _holes;
  64035. private _name;
  64036. private _scene;
  64037. private _epoints;
  64038. private _eholes;
  64039. private _addToepoint;
  64040. /**
  64041. * Babylon reference to the earcut plugin.
  64042. */
  64043. bjsEarcut: any;
  64044. /**
  64045. * Creates a PolygonMeshBuilder
  64046. * @param name name of the builder
  64047. * @param contours Path of the polygon
  64048. * @param scene scene to add to when creating the mesh
  64049. * @param earcutInjection can be used to inject your own earcut reference
  64050. */
  64051. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64052. /**
  64053. * Adds a whole within the polygon
  64054. * @param hole Array of points defining the hole
  64055. * @returns this
  64056. */
  64057. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64058. /**
  64059. * Creates the polygon
  64060. * @param updatable If the mesh should be updatable
  64061. * @param depth The depth of the mesh created
  64062. * @returns the created mesh
  64063. */
  64064. build(updatable?: boolean, depth?: number): Mesh;
  64065. /**
  64066. * Creates the polygon
  64067. * @param depth The depth of the mesh created
  64068. * @returns the created VertexData
  64069. */
  64070. buildVertexData(depth?: number): VertexData;
  64071. /**
  64072. * Adds a side to the polygon
  64073. * @param positions points that make the polygon
  64074. * @param normals normals of the polygon
  64075. * @param uvs uvs of the polygon
  64076. * @param indices indices of the polygon
  64077. * @param bounds bounds of the polygon
  64078. * @param points points of the polygon
  64079. * @param depth depth of the polygon
  64080. * @param flip flip of the polygon
  64081. */
  64082. private addSide;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * Class containing static functions to help procedurally build meshes
  64088. */
  64089. export class PolygonBuilder {
  64090. /**
  64091. * Creates a polygon mesh
  64092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64093. * * 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
  64094. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64096. * * 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)
  64097. * * Remember you can only change the shape positions, not their number when updating a polygon
  64098. * @param name defines the name of the mesh
  64099. * @param options defines the options used to create the mesh
  64100. * @param scene defines the hosting scene
  64101. * @param earcutInjection can be used to inject your own earcut reference
  64102. * @returns the polygon mesh
  64103. */
  64104. static CreatePolygon(name: string, options: {
  64105. shape: Vector3[];
  64106. holes?: Vector3[][];
  64107. depth?: number;
  64108. faceUV?: Vector4[];
  64109. faceColors?: Color4[];
  64110. updatable?: boolean;
  64111. sideOrientation?: number;
  64112. frontUVs?: Vector4;
  64113. backUVs?: Vector4;
  64114. wrap?: boolean;
  64115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64116. /**
  64117. * Creates an extruded polygon mesh, with depth in the Y direction.
  64118. * * 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)
  64119. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64120. * @param name defines the name of the mesh
  64121. * @param options defines the options used to create the mesh
  64122. * @param scene defines the hosting scene
  64123. * @param earcutInjection can be used to inject your own earcut reference
  64124. * @returns the polygon mesh
  64125. */
  64126. static ExtrudePolygon(name: string, options: {
  64127. shape: Vector3[];
  64128. holes?: Vector3[][];
  64129. depth?: number;
  64130. faceUV?: Vector4[];
  64131. faceColors?: Color4[];
  64132. updatable?: boolean;
  64133. sideOrientation?: number;
  64134. frontUVs?: Vector4;
  64135. backUVs?: Vector4;
  64136. wrap?: boolean;
  64137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64138. }
  64139. }
  64140. declare module BABYLON {
  64141. /**
  64142. * Class containing static functions to help procedurally build meshes
  64143. */
  64144. export class LatheBuilder {
  64145. /**
  64146. * Creates lathe mesh.
  64147. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64148. * * 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
  64149. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64150. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64151. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64152. * * 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
  64153. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64154. * * 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
  64155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64156. * * 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
  64157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64159. * @param name defines the name of the mesh
  64160. * @param options defines the options used to create the mesh
  64161. * @param scene defines the hosting scene
  64162. * @returns the lathe mesh
  64163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64164. */
  64165. static CreateLathe(name: string, options: {
  64166. shape: Vector3[];
  64167. radius?: number;
  64168. tessellation?: number;
  64169. clip?: number;
  64170. arc?: number;
  64171. closed?: boolean;
  64172. updatable?: boolean;
  64173. sideOrientation?: number;
  64174. frontUVs?: Vector4;
  64175. backUVs?: Vector4;
  64176. cap?: number;
  64177. invertUV?: boolean;
  64178. }, scene?: Nullable<Scene>): Mesh;
  64179. }
  64180. }
  64181. declare module BABYLON {
  64182. /**
  64183. * Class containing static functions to help procedurally build meshes
  64184. */
  64185. export class TiledPlaneBuilder {
  64186. /**
  64187. * Creates a tiled plane mesh
  64188. * * The parameter `pattern` will, depending on value, do nothing or
  64189. * * * flip (reflect about central vertical) alternate tiles across and up
  64190. * * * flip every tile on alternate rows
  64191. * * * rotate (180 degs) alternate tiles across and up
  64192. * * * rotate every tile on alternate rows
  64193. * * * flip and rotate alternate tiles across and up
  64194. * * * flip and rotate every tile on alternate rows
  64195. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64196. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64197. * * 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
  64198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64199. * * 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)
  64200. * * 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)
  64201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64202. * @param name defines the name of the mesh
  64203. * @param options defines the options used to create the mesh
  64204. * @param scene defines the hosting scene
  64205. * @returns the box mesh
  64206. */
  64207. static CreateTiledPlane(name: string, options: {
  64208. pattern?: number;
  64209. tileSize?: number;
  64210. tileWidth?: number;
  64211. tileHeight?: number;
  64212. size?: number;
  64213. width?: number;
  64214. height?: number;
  64215. alignHorizontal?: number;
  64216. alignVertical?: number;
  64217. sideOrientation?: number;
  64218. frontUVs?: Vector4;
  64219. backUVs?: Vector4;
  64220. updatable?: boolean;
  64221. }, scene?: Nullable<Scene>): Mesh;
  64222. }
  64223. }
  64224. declare module BABYLON {
  64225. /**
  64226. * Class containing static functions to help procedurally build meshes
  64227. */
  64228. export class TubeBuilder {
  64229. /**
  64230. * Creates a tube mesh.
  64231. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64232. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64233. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64234. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64235. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64236. * * 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)
  64237. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64238. * * 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
  64239. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64244. * @param name defines the name of the mesh
  64245. * @param options defines the options used to create the mesh
  64246. * @param scene defines the hosting scene
  64247. * @returns the tube mesh
  64248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64249. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64250. */
  64251. static CreateTube(name: string, options: {
  64252. path: Vector3[];
  64253. radius?: number;
  64254. tessellation?: number;
  64255. radiusFunction?: {
  64256. (i: number, distance: number): number;
  64257. };
  64258. cap?: number;
  64259. arc?: number;
  64260. updatable?: boolean;
  64261. sideOrientation?: number;
  64262. frontUVs?: Vector4;
  64263. backUVs?: Vector4;
  64264. instance?: Mesh;
  64265. invertUV?: boolean;
  64266. }, scene?: Nullable<Scene>): Mesh;
  64267. }
  64268. }
  64269. declare module BABYLON {
  64270. /**
  64271. * Class containing static functions to help procedurally build meshes
  64272. */
  64273. export class IcoSphereBuilder {
  64274. /**
  64275. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64276. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64277. * * 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`)
  64278. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64279. * * 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
  64280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64281. * * 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
  64282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64283. * @param name defines the name of the mesh
  64284. * @param options defines the options used to create the mesh
  64285. * @param scene defines the hosting scene
  64286. * @returns the icosahedron mesh
  64287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64288. */
  64289. static CreateIcoSphere(name: string, options: {
  64290. radius?: number;
  64291. radiusX?: number;
  64292. radiusY?: number;
  64293. radiusZ?: number;
  64294. flat?: boolean;
  64295. subdivisions?: number;
  64296. sideOrientation?: number;
  64297. frontUVs?: Vector4;
  64298. backUVs?: Vector4;
  64299. updatable?: boolean;
  64300. }, scene?: Nullable<Scene>): Mesh;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Class containing static functions to help procedurally build meshes
  64306. */
  64307. export class DecalBuilder {
  64308. /**
  64309. * Creates a decal mesh.
  64310. * 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
  64311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64315. * @param name defines the name of the mesh
  64316. * @param sourceMesh defines the mesh where the decal must be applied
  64317. * @param options defines the options used to create the mesh
  64318. * @param scene defines the hosting scene
  64319. * @returns the decal mesh
  64320. * @see https://doc.babylonjs.com/how_to/decals
  64321. */
  64322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64323. position?: Vector3;
  64324. normal?: Vector3;
  64325. size?: Vector3;
  64326. angle?: number;
  64327. }): Mesh;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * Class containing static functions to help procedurally build meshes
  64333. */
  64334. export class MeshBuilder {
  64335. /**
  64336. * Creates a box mesh
  64337. * * The parameter `size` sets the size (float) of each box side (default 1)
  64338. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64339. * * 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)
  64340. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64342. * * 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
  64343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64345. * @param name defines the name of the mesh
  64346. * @param options defines the options used to create the mesh
  64347. * @param scene defines the hosting scene
  64348. * @returns the box mesh
  64349. */
  64350. static CreateBox(name: string, options: {
  64351. size?: number;
  64352. width?: number;
  64353. height?: number;
  64354. depth?: number;
  64355. faceUV?: Vector4[];
  64356. faceColors?: Color4[];
  64357. sideOrientation?: number;
  64358. frontUVs?: Vector4;
  64359. backUVs?: Vector4;
  64360. wrap?: boolean;
  64361. topBaseAt?: number;
  64362. bottomBaseAt?: number;
  64363. updatable?: boolean;
  64364. }, scene?: Nullable<Scene>): Mesh;
  64365. /**
  64366. * Creates a tiled box mesh
  64367. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64369. * @param name defines the name of the mesh
  64370. * @param options defines the options used to create the mesh
  64371. * @param scene defines the hosting scene
  64372. * @returns the tiled box mesh
  64373. */
  64374. static CreateTiledBox(name: string, options: {
  64375. pattern?: number;
  64376. size?: number;
  64377. width?: number;
  64378. height?: number;
  64379. depth: number;
  64380. tileSize?: number;
  64381. tileWidth?: number;
  64382. tileHeight?: number;
  64383. faceUV?: Vector4[];
  64384. faceColors?: Color4[];
  64385. alignHorizontal?: number;
  64386. alignVertical?: number;
  64387. sideOrientation?: number;
  64388. updatable?: boolean;
  64389. }, scene?: Nullable<Scene>): Mesh;
  64390. /**
  64391. * Creates a sphere mesh
  64392. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64393. * * 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`)
  64394. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64395. * * 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
  64396. * * 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)
  64397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64398. * * 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
  64399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64400. * @param name defines the name of the mesh
  64401. * @param options defines the options used to create the mesh
  64402. * @param scene defines the hosting scene
  64403. * @returns the sphere mesh
  64404. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64405. */
  64406. static CreateSphere(name: string, options: {
  64407. segments?: number;
  64408. diameter?: number;
  64409. diameterX?: number;
  64410. diameterY?: number;
  64411. diameterZ?: number;
  64412. arc?: number;
  64413. slice?: number;
  64414. sideOrientation?: number;
  64415. frontUVs?: Vector4;
  64416. backUVs?: Vector4;
  64417. updatable?: boolean;
  64418. }, scene?: Nullable<Scene>): Mesh;
  64419. /**
  64420. * Creates a plane polygonal mesh. By default, this is a disc
  64421. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64422. * * 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
  64423. * * 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
  64424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64425. * * 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
  64426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64427. * @param name defines the name of the mesh
  64428. * @param options defines the options used to create the mesh
  64429. * @param scene defines the hosting scene
  64430. * @returns the plane polygonal mesh
  64431. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64432. */
  64433. static CreateDisc(name: string, options: {
  64434. radius?: number;
  64435. tessellation?: number;
  64436. arc?: number;
  64437. updatable?: boolean;
  64438. sideOrientation?: number;
  64439. frontUVs?: Vector4;
  64440. backUVs?: Vector4;
  64441. }, scene?: Nullable<Scene>): Mesh;
  64442. /**
  64443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64445. * * 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`)
  64446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64447. * * 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
  64448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64449. * * 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
  64450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64451. * @param name defines the name of the mesh
  64452. * @param options defines the options used to create the mesh
  64453. * @param scene defines the hosting scene
  64454. * @returns the icosahedron mesh
  64455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64456. */
  64457. static CreateIcoSphere(name: string, options: {
  64458. radius?: number;
  64459. radiusX?: number;
  64460. radiusY?: number;
  64461. radiusZ?: number;
  64462. flat?: boolean;
  64463. subdivisions?: number;
  64464. sideOrientation?: number;
  64465. frontUVs?: Vector4;
  64466. backUVs?: Vector4;
  64467. updatable?: boolean;
  64468. }, scene?: Nullable<Scene>): Mesh;
  64469. /**
  64470. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64471. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64472. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64473. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64474. * * 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
  64475. * * 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
  64476. * * 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
  64477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64478. * * 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
  64479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64480. * * 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
  64481. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64482. * * 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
  64483. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64485. * @param name defines the name of the mesh
  64486. * @param options defines the options used to create the mesh
  64487. * @param scene defines the hosting scene
  64488. * @returns the ribbon mesh
  64489. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64491. */
  64492. static CreateRibbon(name: string, options: {
  64493. pathArray: Vector3[][];
  64494. closeArray?: boolean;
  64495. closePath?: boolean;
  64496. offset?: number;
  64497. updatable?: boolean;
  64498. sideOrientation?: number;
  64499. frontUVs?: Vector4;
  64500. backUVs?: Vector4;
  64501. instance?: Mesh;
  64502. invertUV?: boolean;
  64503. uvs?: Vector2[];
  64504. colors?: Color4[];
  64505. }, scene?: Nullable<Scene>): Mesh;
  64506. /**
  64507. * Creates a cylinder or a cone mesh
  64508. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64509. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64510. * * 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.
  64511. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64512. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64513. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64514. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64515. * * 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).
  64516. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64517. * * 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).
  64518. * * 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
  64519. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64520. * * 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
  64521. * * 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.
  64522. * * If `enclose` is false, a ring surface is one element.
  64523. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64524. * * 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
  64525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64526. * * 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
  64527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64528. * @param name defines the name of the mesh
  64529. * @param options defines the options used to create the mesh
  64530. * @param scene defines the hosting scene
  64531. * @returns the cylinder mesh
  64532. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64533. */
  64534. static CreateCylinder(name: string, options: {
  64535. height?: number;
  64536. diameterTop?: number;
  64537. diameterBottom?: number;
  64538. diameter?: number;
  64539. tessellation?: number;
  64540. subdivisions?: number;
  64541. arc?: number;
  64542. faceColors?: Color4[];
  64543. faceUV?: Vector4[];
  64544. updatable?: boolean;
  64545. hasRings?: boolean;
  64546. enclose?: boolean;
  64547. cap?: number;
  64548. sideOrientation?: number;
  64549. frontUVs?: Vector4;
  64550. backUVs?: Vector4;
  64551. }, scene?: Nullable<Scene>): Mesh;
  64552. /**
  64553. * Creates a torus mesh
  64554. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64555. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64556. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64558. * * 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
  64559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64560. * @param name defines the name of the mesh
  64561. * @param options defines the options used to create the mesh
  64562. * @param scene defines the hosting scene
  64563. * @returns the torus mesh
  64564. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64565. */
  64566. static CreateTorus(name: string, options: {
  64567. diameter?: number;
  64568. thickness?: number;
  64569. tessellation?: number;
  64570. updatable?: boolean;
  64571. sideOrientation?: number;
  64572. frontUVs?: Vector4;
  64573. backUVs?: Vector4;
  64574. }, scene?: Nullable<Scene>): Mesh;
  64575. /**
  64576. * Creates a torus knot mesh
  64577. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64578. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64579. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64580. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64582. * * 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
  64583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64584. * @param name defines the name of the mesh
  64585. * @param options defines the options used to create the mesh
  64586. * @param scene defines the hosting scene
  64587. * @returns the torus knot mesh
  64588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64589. */
  64590. static CreateTorusKnot(name: string, options: {
  64591. radius?: number;
  64592. tube?: number;
  64593. radialSegments?: number;
  64594. tubularSegments?: number;
  64595. p?: number;
  64596. q?: number;
  64597. updatable?: boolean;
  64598. sideOrientation?: number;
  64599. frontUVs?: Vector4;
  64600. backUVs?: Vector4;
  64601. }, scene?: Nullable<Scene>): Mesh;
  64602. /**
  64603. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64604. * * 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
  64605. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64606. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64607. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64608. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64609. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64610. * * 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
  64611. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64614. * @param name defines the name of the new line system
  64615. * @param options defines the options used to create the line system
  64616. * @param scene defines the hosting scene
  64617. * @returns a new line system mesh
  64618. */
  64619. static CreateLineSystem(name: string, options: {
  64620. lines: Vector3[][];
  64621. updatable?: boolean;
  64622. instance?: Nullable<LinesMesh>;
  64623. colors?: Nullable<Color4[][]>;
  64624. useVertexAlpha?: boolean;
  64625. }, scene: Nullable<Scene>): LinesMesh;
  64626. /**
  64627. * Creates a line mesh
  64628. * 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
  64629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64630. * * The parameter `points` is an array successive Vector3
  64631. * * 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
  64632. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64634. * * When updating an instance, remember that only point positions can change, not the number of points
  64635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64637. * @param name defines the name of the new line system
  64638. * @param options defines the options used to create the line system
  64639. * @param scene defines the hosting scene
  64640. * @returns a new line mesh
  64641. */
  64642. static CreateLines(name: string, options: {
  64643. points: Vector3[];
  64644. updatable?: boolean;
  64645. instance?: Nullable<LinesMesh>;
  64646. colors?: Color4[];
  64647. useVertexAlpha?: boolean;
  64648. }, scene?: Nullable<Scene>): LinesMesh;
  64649. /**
  64650. * Creates a dashed line mesh
  64651. * * 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
  64652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64653. * * The parameter `points` is an array successive Vector3
  64654. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64655. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64656. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64657. * * 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
  64658. * * When updating an instance, remember that only point positions can change, not the number of points
  64659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64660. * @param name defines the name of the mesh
  64661. * @param options defines the options used to create the mesh
  64662. * @param scene defines the hosting scene
  64663. * @returns the dashed line mesh
  64664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64665. */
  64666. static CreateDashedLines(name: string, options: {
  64667. points: Vector3[];
  64668. dashSize?: number;
  64669. gapSize?: number;
  64670. dashNb?: number;
  64671. updatable?: boolean;
  64672. instance?: LinesMesh;
  64673. }, scene?: Nullable<Scene>): LinesMesh;
  64674. /**
  64675. * 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.
  64676. * * 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.
  64677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64678. * * 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.
  64679. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64680. * * 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
  64681. * * 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
  64682. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64684. * * 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
  64685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64687. * @param name defines the name of the mesh
  64688. * @param options defines the options used to create the mesh
  64689. * @param scene defines the hosting scene
  64690. * @returns the extruded shape mesh
  64691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64693. */
  64694. static ExtrudeShape(name: string, options: {
  64695. shape: Vector3[];
  64696. path: Vector3[];
  64697. scale?: number;
  64698. rotation?: number;
  64699. cap?: number;
  64700. updatable?: boolean;
  64701. sideOrientation?: number;
  64702. frontUVs?: Vector4;
  64703. backUVs?: Vector4;
  64704. instance?: Mesh;
  64705. invertUV?: boolean;
  64706. }, scene?: Nullable<Scene>): Mesh;
  64707. /**
  64708. * Creates an custom extruded shape mesh.
  64709. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64710. * * 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.
  64711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64712. * * 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
  64713. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64714. * * 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
  64715. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64716. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64717. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64718. * * 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
  64719. * * 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
  64720. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64722. * * 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
  64723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64725. * @param name defines the name of the mesh
  64726. * @param options defines the options used to create the mesh
  64727. * @param scene defines the hosting scene
  64728. * @returns the custom extruded shape mesh
  64729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64732. */
  64733. static ExtrudeShapeCustom(name: string, options: {
  64734. shape: Vector3[];
  64735. path: Vector3[];
  64736. scaleFunction?: any;
  64737. rotationFunction?: any;
  64738. ribbonCloseArray?: boolean;
  64739. ribbonClosePath?: boolean;
  64740. cap?: number;
  64741. updatable?: boolean;
  64742. sideOrientation?: number;
  64743. frontUVs?: Vector4;
  64744. backUVs?: Vector4;
  64745. instance?: Mesh;
  64746. invertUV?: boolean;
  64747. }, scene?: Nullable<Scene>): Mesh;
  64748. /**
  64749. * Creates lathe mesh.
  64750. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64751. * * 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
  64752. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64753. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64754. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64755. * * 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
  64756. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64757. * * 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
  64758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64759. * * 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
  64760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the lathe mesh
  64766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64767. */
  64768. static CreateLathe(name: string, options: {
  64769. shape: Vector3[];
  64770. radius?: number;
  64771. tessellation?: number;
  64772. clip?: number;
  64773. arc?: number;
  64774. closed?: boolean;
  64775. updatable?: boolean;
  64776. sideOrientation?: number;
  64777. frontUVs?: Vector4;
  64778. backUVs?: Vector4;
  64779. cap?: number;
  64780. invertUV?: boolean;
  64781. }, scene?: Nullable<Scene>): Mesh;
  64782. /**
  64783. * Creates a tiled plane mesh
  64784. * * You can set a limited pattern arrangement with the tiles
  64785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64786. * * 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
  64787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64788. * @param name defines the name of the mesh
  64789. * @param options defines the options used to create the mesh
  64790. * @param scene defines the hosting scene
  64791. * @returns the plane mesh
  64792. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64793. */
  64794. static CreateTiledPlane(name: string, options: {
  64795. pattern?: number;
  64796. tileSize?: number;
  64797. tileWidth?: number;
  64798. tileHeight?: number;
  64799. size?: number;
  64800. width?: number;
  64801. height?: number;
  64802. alignHorizontal?: number;
  64803. alignVertical?: number;
  64804. sideOrientation?: number;
  64805. frontUVs?: Vector4;
  64806. backUVs?: Vector4;
  64807. updatable?: boolean;
  64808. }, scene?: Nullable<Scene>): Mesh;
  64809. /**
  64810. * Creates a plane mesh
  64811. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64812. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64813. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64815. * * 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
  64816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64817. * @param name defines the name of the mesh
  64818. * @param options defines the options used to create the mesh
  64819. * @param scene defines the hosting scene
  64820. * @returns the plane mesh
  64821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64822. */
  64823. static CreatePlane(name: string, options: {
  64824. size?: number;
  64825. width?: number;
  64826. height?: number;
  64827. sideOrientation?: number;
  64828. frontUVs?: Vector4;
  64829. backUVs?: Vector4;
  64830. updatable?: boolean;
  64831. sourcePlane?: Plane;
  64832. }, scene?: Nullable<Scene>): Mesh;
  64833. /**
  64834. * Creates a ground mesh
  64835. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64836. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64838. * @param name defines the name of the mesh
  64839. * @param options defines the options used to create the mesh
  64840. * @param scene defines the hosting scene
  64841. * @returns the ground mesh
  64842. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64843. */
  64844. static CreateGround(name: string, options: {
  64845. width?: number;
  64846. height?: number;
  64847. subdivisions?: number;
  64848. subdivisionsX?: number;
  64849. subdivisionsY?: number;
  64850. updatable?: boolean;
  64851. }, scene?: Nullable<Scene>): Mesh;
  64852. /**
  64853. * Creates a tiled ground mesh
  64854. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64855. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64856. * * 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
  64857. * * 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
  64858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64859. * @param name defines the name of the mesh
  64860. * @param options defines the options used to create the mesh
  64861. * @param scene defines the hosting scene
  64862. * @returns the tiled ground mesh
  64863. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64864. */
  64865. static CreateTiledGround(name: string, options: {
  64866. xmin: number;
  64867. zmin: number;
  64868. xmax: number;
  64869. zmax: number;
  64870. subdivisions?: {
  64871. w: number;
  64872. h: number;
  64873. };
  64874. precision?: {
  64875. w: number;
  64876. h: number;
  64877. };
  64878. updatable?: boolean;
  64879. }, scene?: Nullable<Scene>): Mesh;
  64880. /**
  64881. * Creates a ground mesh from a height map
  64882. * * The parameter `url` sets the URL of the height map image resource.
  64883. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64884. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64885. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64886. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64887. * * 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.
  64888. * * 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).
  64889. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64891. * @param name defines the name of the mesh
  64892. * @param url defines the url to the height map
  64893. * @param options defines the options used to create the mesh
  64894. * @param scene defines the hosting scene
  64895. * @returns the ground mesh
  64896. * @see https://doc.babylonjs.com/babylon101/height_map
  64897. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64898. */
  64899. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64900. width?: number;
  64901. height?: number;
  64902. subdivisions?: number;
  64903. minHeight?: number;
  64904. maxHeight?: number;
  64905. colorFilter?: Color3;
  64906. alphaFilter?: number;
  64907. updatable?: boolean;
  64908. onReady?: (mesh: GroundMesh) => void;
  64909. }, scene?: Nullable<Scene>): GroundMesh;
  64910. /**
  64911. * Creates a polygon mesh
  64912. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64913. * * 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
  64914. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64916. * * 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)
  64917. * * Remember you can only change the shape positions, not their number when updating a polygon
  64918. * @param name defines the name of the mesh
  64919. * @param options defines the options used to create the mesh
  64920. * @param scene defines the hosting scene
  64921. * @param earcutInjection can be used to inject your own earcut reference
  64922. * @returns the polygon mesh
  64923. */
  64924. static CreatePolygon(name: string, options: {
  64925. shape: Vector3[];
  64926. holes?: Vector3[][];
  64927. depth?: number;
  64928. faceUV?: Vector4[];
  64929. faceColors?: Color4[];
  64930. updatable?: boolean;
  64931. sideOrientation?: number;
  64932. frontUVs?: Vector4;
  64933. backUVs?: Vector4;
  64934. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64935. /**
  64936. * Creates an extruded polygon mesh, with depth in the Y direction.
  64937. * * 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)
  64938. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64939. * @param name defines the name of the mesh
  64940. * @param options defines the options used to create the mesh
  64941. * @param scene defines the hosting scene
  64942. * @param earcutInjection can be used to inject your own earcut reference
  64943. * @returns the polygon mesh
  64944. */
  64945. static ExtrudePolygon(name: string, options: {
  64946. shape: Vector3[];
  64947. holes?: Vector3[][];
  64948. depth?: number;
  64949. faceUV?: Vector4[];
  64950. faceColors?: Color4[];
  64951. updatable?: boolean;
  64952. sideOrientation?: number;
  64953. frontUVs?: Vector4;
  64954. backUVs?: Vector4;
  64955. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64956. /**
  64957. * Creates a tube mesh.
  64958. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64959. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64960. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64961. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64962. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64963. * * 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)
  64964. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64965. * * 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
  64966. * * 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
  64967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64968. * * 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
  64969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64971. * @param name defines the name of the mesh
  64972. * @param options defines the options used to create the mesh
  64973. * @param scene defines the hosting scene
  64974. * @returns the tube mesh
  64975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64976. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64977. */
  64978. static CreateTube(name: string, options: {
  64979. path: Vector3[];
  64980. radius?: number;
  64981. tessellation?: number;
  64982. radiusFunction?: {
  64983. (i: number, distance: number): number;
  64984. };
  64985. cap?: number;
  64986. arc?: number;
  64987. updatable?: boolean;
  64988. sideOrientation?: number;
  64989. frontUVs?: Vector4;
  64990. backUVs?: Vector4;
  64991. instance?: Mesh;
  64992. invertUV?: boolean;
  64993. }, scene?: Nullable<Scene>): Mesh;
  64994. /**
  64995. * Creates a polyhedron mesh
  64996. * * 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
  64997. * * The parameter `size` (positive float, default 1) sets the polygon size
  64998. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64999. * * 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`
  65000. * * 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
  65001. * * 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)`)
  65002. * * 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
  65003. * * 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
  65004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65005. * * 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
  65006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65007. * @param name defines the name of the mesh
  65008. * @param options defines the options used to create the mesh
  65009. * @param scene defines the hosting scene
  65010. * @returns the polyhedron mesh
  65011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65012. */
  65013. static CreatePolyhedron(name: string, options: {
  65014. type?: number;
  65015. size?: number;
  65016. sizeX?: number;
  65017. sizeY?: number;
  65018. sizeZ?: number;
  65019. custom?: any;
  65020. faceUV?: Vector4[];
  65021. faceColors?: Color4[];
  65022. flat?: boolean;
  65023. updatable?: boolean;
  65024. sideOrientation?: number;
  65025. frontUVs?: Vector4;
  65026. backUVs?: Vector4;
  65027. }, scene?: Nullable<Scene>): Mesh;
  65028. /**
  65029. * Creates a decal mesh.
  65030. * 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
  65031. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65032. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65033. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65034. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65035. * @param name defines the name of the mesh
  65036. * @param sourceMesh defines the mesh where the decal must be applied
  65037. * @param options defines the options used to create the mesh
  65038. * @param scene defines the hosting scene
  65039. * @returns the decal mesh
  65040. * @see https://doc.babylonjs.com/how_to/decals
  65041. */
  65042. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65043. position?: Vector3;
  65044. normal?: Vector3;
  65045. size?: Vector3;
  65046. angle?: number;
  65047. }): Mesh;
  65048. }
  65049. }
  65050. declare module BABYLON {
  65051. /**
  65052. * A simplifier interface for future simplification implementations
  65053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65054. */
  65055. export interface ISimplifier {
  65056. /**
  65057. * Simplification of a given mesh according to the given settings.
  65058. * Since this requires computation, it is assumed that the function runs async.
  65059. * @param settings The settings of the simplification, including quality and distance
  65060. * @param successCallback A callback that will be called after the mesh was simplified.
  65061. * @param errorCallback in case of an error, this callback will be called. optional.
  65062. */
  65063. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65064. }
  65065. /**
  65066. * Expected simplification settings.
  65067. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65069. */
  65070. export interface ISimplificationSettings {
  65071. /**
  65072. * Gets or sets the expected quality
  65073. */
  65074. quality: number;
  65075. /**
  65076. * Gets or sets the distance when this optimized version should be used
  65077. */
  65078. distance: number;
  65079. /**
  65080. * Gets an already optimized mesh
  65081. */
  65082. optimizeMesh?: boolean;
  65083. }
  65084. /**
  65085. * Class used to specify simplification options
  65086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65087. */
  65088. export class SimplificationSettings implements ISimplificationSettings {
  65089. /** expected quality */
  65090. quality: number;
  65091. /** distance when this optimized version should be used */
  65092. distance: number;
  65093. /** already optimized mesh */
  65094. optimizeMesh?: boolean | undefined;
  65095. /**
  65096. * Creates a SimplificationSettings
  65097. * @param quality expected quality
  65098. * @param distance distance when this optimized version should be used
  65099. * @param optimizeMesh already optimized mesh
  65100. */
  65101. constructor(
  65102. /** expected quality */
  65103. quality: number,
  65104. /** distance when this optimized version should be used */
  65105. distance: number,
  65106. /** already optimized mesh */
  65107. optimizeMesh?: boolean | undefined);
  65108. }
  65109. /**
  65110. * Interface used to define a simplification task
  65111. */
  65112. export interface ISimplificationTask {
  65113. /**
  65114. * Array of settings
  65115. */
  65116. settings: Array<ISimplificationSettings>;
  65117. /**
  65118. * Simplification type
  65119. */
  65120. simplificationType: SimplificationType;
  65121. /**
  65122. * Mesh to simplify
  65123. */
  65124. mesh: Mesh;
  65125. /**
  65126. * Callback called on success
  65127. */
  65128. successCallback?: () => void;
  65129. /**
  65130. * Defines if parallel processing can be used
  65131. */
  65132. parallelProcessing: boolean;
  65133. }
  65134. /**
  65135. * Queue used to order the simplification tasks
  65136. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65137. */
  65138. export class SimplificationQueue {
  65139. private _simplificationArray;
  65140. /**
  65141. * Gets a boolean indicating that the process is still running
  65142. */
  65143. running: boolean;
  65144. /**
  65145. * Creates a new queue
  65146. */
  65147. constructor();
  65148. /**
  65149. * Adds a new simplification task
  65150. * @param task defines a task to add
  65151. */
  65152. addTask(task: ISimplificationTask): void;
  65153. /**
  65154. * Execute next task
  65155. */
  65156. executeNext(): void;
  65157. /**
  65158. * Execute a simplification task
  65159. * @param task defines the task to run
  65160. */
  65161. runSimplification(task: ISimplificationTask): void;
  65162. private getSimplifier;
  65163. }
  65164. /**
  65165. * The implemented types of simplification
  65166. * At the moment only Quadratic Error Decimation is implemented
  65167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65168. */
  65169. export enum SimplificationType {
  65170. /** Quadratic error decimation */
  65171. QUADRATIC = 0
  65172. }
  65173. /**
  65174. * An implementation of the Quadratic Error simplification algorithm.
  65175. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65176. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65177. * @author RaananW
  65178. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65179. */
  65180. export class QuadraticErrorSimplification implements ISimplifier {
  65181. private _mesh;
  65182. private triangles;
  65183. private vertices;
  65184. private references;
  65185. private _reconstructedMesh;
  65186. /** Gets or sets the number pf sync interations */
  65187. syncIterations: number;
  65188. /** Gets or sets the aggressiveness of the simplifier */
  65189. aggressiveness: number;
  65190. /** Gets or sets the number of allowed iterations for decimation */
  65191. decimationIterations: number;
  65192. /** Gets or sets the espilon to use for bounding box computation */
  65193. boundingBoxEpsilon: number;
  65194. /**
  65195. * Creates a new QuadraticErrorSimplification
  65196. * @param _mesh defines the target mesh
  65197. */
  65198. constructor(_mesh: Mesh);
  65199. /**
  65200. * Simplification of a given mesh according to the given settings.
  65201. * Since this requires computation, it is assumed that the function runs async.
  65202. * @param settings The settings of the simplification, including quality and distance
  65203. * @param successCallback A callback that will be called after the mesh was simplified.
  65204. */
  65205. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65206. private runDecimation;
  65207. private initWithMesh;
  65208. private init;
  65209. private reconstructMesh;
  65210. private initDecimatedMesh;
  65211. private isFlipped;
  65212. private updateTriangles;
  65213. private identifyBorder;
  65214. private updateMesh;
  65215. private vertexError;
  65216. private calculateError;
  65217. }
  65218. }
  65219. declare module BABYLON {
  65220. interface Scene {
  65221. /** @hidden (Backing field) */
  65222. _simplificationQueue: SimplificationQueue;
  65223. /**
  65224. * Gets or sets the simplification queue attached to the scene
  65225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65226. */
  65227. simplificationQueue: SimplificationQueue;
  65228. }
  65229. interface Mesh {
  65230. /**
  65231. * Simplify the mesh according to the given array of settings.
  65232. * Function will return immediately and will simplify async
  65233. * @param settings a collection of simplification settings
  65234. * @param parallelProcessing should all levels calculate parallel or one after the other
  65235. * @param simplificationType the type of simplification to run
  65236. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65237. * @returns the current mesh
  65238. */
  65239. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65240. }
  65241. /**
  65242. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65243. * created in a scene
  65244. */
  65245. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65246. /**
  65247. * The component name helpfull to identify the component in the list of scene components.
  65248. */
  65249. readonly name: string;
  65250. /**
  65251. * The scene the component belongs to.
  65252. */
  65253. scene: Scene;
  65254. /**
  65255. * Creates a new instance of the component for the given scene
  65256. * @param scene Defines the scene to register the component in
  65257. */
  65258. constructor(scene: Scene);
  65259. /**
  65260. * Registers the component in a given scene
  65261. */
  65262. register(): void;
  65263. /**
  65264. * Rebuilds the elements related to this component in case of
  65265. * context lost for instance.
  65266. */
  65267. rebuild(): void;
  65268. /**
  65269. * Disposes the component and the associated ressources
  65270. */
  65271. dispose(): void;
  65272. private _beforeCameraUpdate;
  65273. }
  65274. }
  65275. declare module BABYLON {
  65276. interface Mesh {
  65277. /**
  65278. * Creates a new thin instance
  65279. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65280. * @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
  65281. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65282. */
  65283. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65284. /**
  65285. * Adds the transformation (matrix) of the current mesh as a thin instance
  65286. * @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
  65287. * @returns the thin instance index number
  65288. */
  65289. thinInstanceAddSelf(refresh: boolean): number;
  65290. /**
  65291. * Registers a custom attribute to be used with thin instances
  65292. * @param kind name of the attribute
  65293. * @param stride size in floats of the attribute
  65294. */
  65295. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65296. /**
  65297. * Sets the matrix of a thin instance
  65298. * @param index index of the thin instance
  65299. * @param matrix matrix to set
  65300. * @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
  65301. */
  65302. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65303. /**
  65304. * Sets the value of a custom attribute for a thin instance
  65305. * @param kind name of the attribute
  65306. * @param index index of the thin instance
  65307. * @param value value to set
  65308. * @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
  65309. */
  65310. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65311. /**
  65312. * 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.
  65313. */
  65314. thinInstanceCount: number;
  65315. /**
  65316. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65317. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65318. * @param buffer buffer to set
  65319. * @param stride size in floats of each value of the buffer
  65320. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65321. */
  65322. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65323. /**
  65324. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65325. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65326. */
  65327. thinInstanceBufferUpdated(kind: string): void;
  65328. /**
  65329. * Refreshes the bounding info, taking into account all the thin instances defined
  65330. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65331. */
  65332. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65333. /** @hidden */
  65334. _thinInstanceInitializeUserStorage(): void;
  65335. /** @hidden */
  65336. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65337. /** @hidden */
  65338. _userThinInstanceBuffersStorage: {
  65339. data: {
  65340. [key: string]: Float32Array;
  65341. };
  65342. sizes: {
  65343. [key: string]: number;
  65344. };
  65345. vertexBuffers: {
  65346. [key: string]: Nullable<VertexBuffer>;
  65347. };
  65348. strides: {
  65349. [key: string]: number;
  65350. };
  65351. };
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65357. */
  65358. export interface INavigationEnginePlugin {
  65359. /**
  65360. * plugin name
  65361. */
  65362. name: string;
  65363. /**
  65364. * Creates a navigation mesh
  65365. * @param meshes array of all the geometry used to compute the navigatio mesh
  65366. * @param parameters bunch of parameters used to filter geometry
  65367. */
  65368. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65369. /**
  65370. * Create a navigation mesh debug mesh
  65371. * @param scene is where the mesh will be added
  65372. * @returns debug display mesh
  65373. */
  65374. createDebugNavMesh(scene: Scene): Mesh;
  65375. /**
  65376. * Get a navigation mesh constrained position, closest to the parameter position
  65377. * @param position world position
  65378. * @returns the closest point to position constrained by the navigation mesh
  65379. */
  65380. getClosestPoint(position: Vector3): Vector3;
  65381. /**
  65382. * Get a navigation mesh constrained position, closest to the parameter position
  65383. * @param position world position
  65384. * @param result output the closest point to position constrained by the navigation mesh
  65385. */
  65386. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65387. /**
  65388. * Get a navigation mesh constrained position, within a particular radius
  65389. * @param position world position
  65390. * @param maxRadius the maximum distance to the constrained world position
  65391. * @returns the closest point to position constrained by the navigation mesh
  65392. */
  65393. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65394. /**
  65395. * Get a navigation mesh constrained position, within a particular radius
  65396. * @param position world position
  65397. * @param maxRadius the maximum distance to the constrained world position
  65398. * @param result output the closest point to position constrained by the navigation mesh
  65399. */
  65400. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65401. /**
  65402. * Compute the final position from a segment made of destination-position
  65403. * @param position world position
  65404. * @param destination world position
  65405. * @returns the resulting point along the navmesh
  65406. */
  65407. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65408. /**
  65409. * Compute the final position from a segment made of destination-position
  65410. * @param position world position
  65411. * @param destination world position
  65412. * @param result output the resulting point along the navmesh
  65413. */
  65414. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65415. /**
  65416. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65417. * @param start world position
  65418. * @param end world position
  65419. * @returns array containing world position composing the path
  65420. */
  65421. computePath(start: Vector3, end: Vector3): Vector3[];
  65422. /**
  65423. * If this plugin is supported
  65424. * @returns true if plugin is supported
  65425. */
  65426. isSupported(): boolean;
  65427. /**
  65428. * Create a new Crowd so you can add agents
  65429. * @param maxAgents the maximum agent count in the crowd
  65430. * @param maxAgentRadius the maximum radius an agent can have
  65431. * @param scene to attach the crowd to
  65432. * @returns the crowd you can add agents to
  65433. */
  65434. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65435. /**
  65436. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65437. * The queries will try to find a solution within those bounds
  65438. * default is (1,1,1)
  65439. * @param extent x,y,z value that define the extent around the queries point of reference
  65440. */
  65441. setDefaultQueryExtent(extent: Vector3): void;
  65442. /**
  65443. * Get the Bounding box extent specified by setDefaultQueryExtent
  65444. * @returns the box extent values
  65445. */
  65446. getDefaultQueryExtent(): Vector3;
  65447. /**
  65448. * build the navmesh from a previously saved state using getNavmeshData
  65449. * @param data the Uint8Array returned by getNavmeshData
  65450. */
  65451. buildFromNavmeshData(data: Uint8Array): void;
  65452. /**
  65453. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65454. * @returns data the Uint8Array that can be saved and reused
  65455. */
  65456. getNavmeshData(): Uint8Array;
  65457. /**
  65458. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65459. * @param result output the box extent values
  65460. */
  65461. getDefaultQueryExtentToRef(result: Vector3): void;
  65462. /**
  65463. * Release all resources
  65464. */
  65465. dispose(): void;
  65466. }
  65467. /**
  65468. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65469. */
  65470. export interface ICrowd {
  65471. /**
  65472. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65473. * You can attach anything to that node. The node position is updated in the scene update tick.
  65474. * @param pos world position that will be constrained by the navigation mesh
  65475. * @param parameters agent parameters
  65476. * @param transform hooked to the agent that will be update by the scene
  65477. * @returns agent index
  65478. */
  65479. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65480. /**
  65481. * Returns the agent position in world space
  65482. * @param index agent index returned by addAgent
  65483. * @returns world space position
  65484. */
  65485. getAgentPosition(index: number): Vector3;
  65486. /**
  65487. * Gets the agent position result in world space
  65488. * @param index agent index returned by addAgent
  65489. * @param result output world space position
  65490. */
  65491. getAgentPositionToRef(index: number, result: Vector3): void;
  65492. /**
  65493. * Gets the agent velocity in world space
  65494. * @param index agent index returned by addAgent
  65495. * @returns world space velocity
  65496. */
  65497. getAgentVelocity(index: number): Vector3;
  65498. /**
  65499. * Gets the agent velocity result in world space
  65500. * @param index agent index returned by addAgent
  65501. * @param result output world space velocity
  65502. */
  65503. getAgentVelocityToRef(index: number, result: Vector3): void;
  65504. /**
  65505. * remove a particular agent previously created
  65506. * @param index agent index returned by addAgent
  65507. */
  65508. removeAgent(index: number): void;
  65509. /**
  65510. * get the list of all agents attached to this crowd
  65511. * @returns list of agent indices
  65512. */
  65513. getAgents(): number[];
  65514. /**
  65515. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65516. * @param deltaTime in seconds
  65517. */
  65518. update(deltaTime: number): void;
  65519. /**
  65520. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65521. * @param index agent index returned by addAgent
  65522. * @param destination targeted world position
  65523. */
  65524. agentGoto(index: number, destination: Vector3): void;
  65525. /**
  65526. * Teleport the agent to a new position
  65527. * @param index agent index returned by addAgent
  65528. * @param destination targeted world position
  65529. */
  65530. agentTeleport(index: number, destination: Vector3): void;
  65531. /**
  65532. * Update agent parameters
  65533. * @param index agent index returned by addAgent
  65534. * @param parameters agent parameters
  65535. */
  65536. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65537. /**
  65538. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65539. * The queries will try to find a solution within those bounds
  65540. * default is (1,1,1)
  65541. * @param extent x,y,z value that define the extent around the queries point of reference
  65542. */
  65543. setDefaultQueryExtent(extent: Vector3): void;
  65544. /**
  65545. * Get the Bounding box extent specified by setDefaultQueryExtent
  65546. * @returns the box extent values
  65547. */
  65548. getDefaultQueryExtent(): Vector3;
  65549. /**
  65550. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65551. * @param result output the box extent values
  65552. */
  65553. getDefaultQueryExtentToRef(result: Vector3): void;
  65554. /**
  65555. * Release all resources
  65556. */
  65557. dispose(): void;
  65558. }
  65559. /**
  65560. * Configures an agent
  65561. */
  65562. export interface IAgentParameters {
  65563. /**
  65564. * Agent radius. [Limit: >= 0]
  65565. */
  65566. radius: number;
  65567. /**
  65568. * Agent height. [Limit: > 0]
  65569. */
  65570. height: number;
  65571. /**
  65572. * Maximum allowed acceleration. [Limit: >= 0]
  65573. */
  65574. maxAcceleration: number;
  65575. /**
  65576. * Maximum allowed speed. [Limit: >= 0]
  65577. */
  65578. maxSpeed: number;
  65579. /**
  65580. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65581. */
  65582. collisionQueryRange: number;
  65583. /**
  65584. * The path visibility optimization range. [Limit: > 0]
  65585. */
  65586. pathOptimizationRange: number;
  65587. /**
  65588. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65589. */
  65590. separationWeight: number;
  65591. }
  65592. /**
  65593. * Configures the navigation mesh creation
  65594. */
  65595. export interface INavMeshParameters {
  65596. /**
  65597. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65598. */
  65599. cs: number;
  65600. /**
  65601. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65602. */
  65603. ch: number;
  65604. /**
  65605. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65606. */
  65607. walkableSlopeAngle: number;
  65608. /**
  65609. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65610. * be considered walkable. [Limit: >= 3] [Units: vx]
  65611. */
  65612. walkableHeight: number;
  65613. /**
  65614. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65615. */
  65616. walkableClimb: number;
  65617. /**
  65618. * The distance to erode/shrink the walkable area of the heightfield away from
  65619. * obstructions. [Limit: >=0] [Units: vx]
  65620. */
  65621. walkableRadius: number;
  65622. /**
  65623. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65624. */
  65625. maxEdgeLen: number;
  65626. /**
  65627. * The maximum distance a simplfied contour's border edges should deviate
  65628. * the original raw contour. [Limit: >=0] [Units: vx]
  65629. */
  65630. maxSimplificationError: number;
  65631. /**
  65632. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65633. */
  65634. minRegionArea: number;
  65635. /**
  65636. * Any regions with a span count smaller than this value will, if possible,
  65637. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65638. */
  65639. mergeRegionArea: number;
  65640. /**
  65641. * The maximum number of vertices allowed for polygons generated during the
  65642. * contour to polygon conversion process. [Limit: >= 3]
  65643. */
  65644. maxVertsPerPoly: number;
  65645. /**
  65646. * Sets the sampling distance to use when generating the detail mesh.
  65647. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65648. */
  65649. detailSampleDist: number;
  65650. /**
  65651. * The maximum distance the detail mesh surface should deviate from heightfield
  65652. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65653. */
  65654. detailSampleMaxError: number;
  65655. }
  65656. }
  65657. declare module BABYLON {
  65658. /**
  65659. * RecastJS navigation plugin
  65660. */
  65661. export class RecastJSPlugin implements INavigationEnginePlugin {
  65662. /**
  65663. * Reference to the Recast library
  65664. */
  65665. bjsRECAST: any;
  65666. /**
  65667. * plugin name
  65668. */
  65669. name: string;
  65670. /**
  65671. * the first navmesh created. We might extend this to support multiple navmeshes
  65672. */
  65673. navMesh: any;
  65674. /**
  65675. * Initializes the recastJS plugin
  65676. * @param recastInjection can be used to inject your own recast reference
  65677. */
  65678. constructor(recastInjection?: any);
  65679. /**
  65680. * Creates a navigation mesh
  65681. * @param meshes array of all the geometry used to compute the navigatio mesh
  65682. * @param parameters bunch of parameters used to filter geometry
  65683. */
  65684. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65685. /**
  65686. * Create a navigation mesh debug mesh
  65687. * @param scene is where the mesh will be added
  65688. * @returns debug display mesh
  65689. */
  65690. createDebugNavMesh(scene: Scene): Mesh;
  65691. /**
  65692. * Get a navigation mesh constrained position, closest to the parameter position
  65693. * @param position world position
  65694. * @returns the closest point to position constrained by the navigation mesh
  65695. */
  65696. getClosestPoint(position: Vector3): Vector3;
  65697. /**
  65698. * Get a navigation mesh constrained position, closest to the parameter position
  65699. * @param position world position
  65700. * @param result output the closest point to position constrained by the navigation mesh
  65701. */
  65702. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65703. /**
  65704. * Get a navigation mesh constrained position, within a particular radius
  65705. * @param position world position
  65706. * @param maxRadius the maximum distance to the constrained world position
  65707. * @returns the closest point to position constrained by the navigation mesh
  65708. */
  65709. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65710. /**
  65711. * Get a navigation mesh constrained position, within a particular radius
  65712. * @param position world position
  65713. * @param maxRadius the maximum distance to the constrained world position
  65714. * @param result output the closest point to position constrained by the navigation mesh
  65715. */
  65716. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65717. /**
  65718. * Compute the final position from a segment made of destination-position
  65719. * @param position world position
  65720. * @param destination world position
  65721. * @returns the resulting point along the navmesh
  65722. */
  65723. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65724. /**
  65725. * Compute the final position from a segment made of destination-position
  65726. * @param position world position
  65727. * @param destination world position
  65728. * @param result output the resulting point along the navmesh
  65729. */
  65730. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65731. /**
  65732. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65733. * @param start world position
  65734. * @param end world position
  65735. * @returns array containing world position composing the path
  65736. */
  65737. computePath(start: Vector3, end: Vector3): Vector3[];
  65738. /**
  65739. * Create a new Crowd so you can add agents
  65740. * @param maxAgents the maximum agent count in the crowd
  65741. * @param maxAgentRadius the maximum radius an agent can have
  65742. * @param scene to attach the crowd to
  65743. * @returns the crowd you can add agents to
  65744. */
  65745. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65746. /**
  65747. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65748. * The queries will try to find a solution within those bounds
  65749. * default is (1,1,1)
  65750. * @param extent x,y,z value that define the extent around the queries point of reference
  65751. */
  65752. setDefaultQueryExtent(extent: Vector3): void;
  65753. /**
  65754. * Get the Bounding box extent specified by setDefaultQueryExtent
  65755. * @returns the box extent values
  65756. */
  65757. getDefaultQueryExtent(): Vector3;
  65758. /**
  65759. * build the navmesh from a previously saved state using getNavmeshData
  65760. * @param data the Uint8Array returned by getNavmeshData
  65761. */
  65762. buildFromNavmeshData(data: Uint8Array): void;
  65763. /**
  65764. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65765. * @returns data the Uint8Array that can be saved and reused
  65766. */
  65767. getNavmeshData(): Uint8Array;
  65768. /**
  65769. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65770. * @param result output the box extent values
  65771. */
  65772. getDefaultQueryExtentToRef(result: Vector3): void;
  65773. /**
  65774. * Disposes
  65775. */
  65776. dispose(): void;
  65777. /**
  65778. * If this plugin is supported
  65779. * @returns true if plugin is supported
  65780. */
  65781. isSupported(): boolean;
  65782. }
  65783. /**
  65784. * Recast detour crowd implementation
  65785. */
  65786. export class RecastJSCrowd implements ICrowd {
  65787. /**
  65788. * Recast/detour plugin
  65789. */
  65790. bjsRECASTPlugin: RecastJSPlugin;
  65791. /**
  65792. * Link to the detour crowd
  65793. */
  65794. recastCrowd: any;
  65795. /**
  65796. * One transform per agent
  65797. */
  65798. transforms: TransformNode[];
  65799. /**
  65800. * All agents created
  65801. */
  65802. agents: number[];
  65803. /**
  65804. * Link to the scene is kept to unregister the crowd from the scene
  65805. */
  65806. private _scene;
  65807. /**
  65808. * Observer for crowd updates
  65809. */
  65810. private _onBeforeAnimationsObserver;
  65811. /**
  65812. * Constructor
  65813. * @param plugin recastJS plugin
  65814. * @param maxAgents the maximum agent count in the crowd
  65815. * @param maxAgentRadius the maximum radius an agent can have
  65816. * @param scene to attach the crowd to
  65817. * @returns the crowd you can add agents to
  65818. */
  65819. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65820. /**
  65821. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65822. * You can attach anything to that node. The node position is updated in the scene update tick.
  65823. * @param pos world position that will be constrained by the navigation mesh
  65824. * @param parameters agent parameters
  65825. * @param transform hooked to the agent that will be update by the scene
  65826. * @returns agent index
  65827. */
  65828. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65829. /**
  65830. * Returns the agent position in world space
  65831. * @param index agent index returned by addAgent
  65832. * @returns world space position
  65833. */
  65834. getAgentPosition(index: number): Vector3;
  65835. /**
  65836. * Returns the agent position result in world space
  65837. * @param index agent index returned by addAgent
  65838. * @param result output world space position
  65839. */
  65840. getAgentPositionToRef(index: number, result: Vector3): void;
  65841. /**
  65842. * Returns the agent velocity in world space
  65843. * @param index agent index returned by addAgent
  65844. * @returns world space velocity
  65845. */
  65846. getAgentVelocity(index: number): Vector3;
  65847. /**
  65848. * Returns the agent velocity result in world space
  65849. * @param index agent index returned by addAgent
  65850. * @param result output world space velocity
  65851. */
  65852. getAgentVelocityToRef(index: number, result: Vector3): void;
  65853. /**
  65854. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65855. * @param index agent index returned by addAgent
  65856. * @param destination targeted world position
  65857. */
  65858. agentGoto(index: number, destination: Vector3): void;
  65859. /**
  65860. * Teleport the agent to a new position
  65861. * @param index agent index returned by addAgent
  65862. * @param destination targeted world position
  65863. */
  65864. agentTeleport(index: number, destination: Vector3): void;
  65865. /**
  65866. * Update agent parameters
  65867. * @param index agent index returned by addAgent
  65868. * @param parameters agent parameters
  65869. */
  65870. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65871. /**
  65872. * remove a particular agent previously created
  65873. * @param index agent index returned by addAgent
  65874. */
  65875. removeAgent(index: number): void;
  65876. /**
  65877. * get the list of all agents attached to this crowd
  65878. * @returns list of agent indices
  65879. */
  65880. getAgents(): number[];
  65881. /**
  65882. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65883. * @param deltaTime in seconds
  65884. */
  65885. update(deltaTime: number): void;
  65886. /**
  65887. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65888. * The queries will try to find a solution within those bounds
  65889. * default is (1,1,1)
  65890. * @param extent x,y,z value that define the extent around the queries point of reference
  65891. */
  65892. setDefaultQueryExtent(extent: Vector3): void;
  65893. /**
  65894. * Get the Bounding box extent specified by setDefaultQueryExtent
  65895. * @returns the box extent values
  65896. */
  65897. getDefaultQueryExtent(): Vector3;
  65898. /**
  65899. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65900. * @param result output the box extent values
  65901. */
  65902. getDefaultQueryExtentToRef(result: Vector3): void;
  65903. /**
  65904. * Release all resources
  65905. */
  65906. dispose(): void;
  65907. }
  65908. }
  65909. declare module BABYLON {
  65910. /**
  65911. * Class used to enable access to IndexedDB
  65912. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65913. */
  65914. export class Database implements IOfflineProvider {
  65915. private _callbackManifestChecked;
  65916. private _currentSceneUrl;
  65917. private _db;
  65918. private _enableSceneOffline;
  65919. private _enableTexturesOffline;
  65920. private _manifestVersionFound;
  65921. private _mustUpdateRessources;
  65922. private _hasReachedQuota;
  65923. private _isSupported;
  65924. private _idbFactory;
  65925. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65926. private static IsUASupportingBlobStorage;
  65927. /**
  65928. * Gets a boolean indicating if Database storate is enabled (off by default)
  65929. */
  65930. static IDBStorageEnabled: boolean;
  65931. /**
  65932. * Gets a boolean indicating if scene must be saved in the database
  65933. */
  65934. get enableSceneOffline(): boolean;
  65935. /**
  65936. * Gets a boolean indicating if textures must be saved in the database
  65937. */
  65938. get enableTexturesOffline(): boolean;
  65939. /**
  65940. * Creates a new Database
  65941. * @param urlToScene defines the url to load the scene
  65942. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65943. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65944. */
  65945. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65946. private static _ParseURL;
  65947. private static _ReturnFullUrlLocation;
  65948. private _checkManifestFile;
  65949. /**
  65950. * Open the database and make it available
  65951. * @param successCallback defines the callback to call on success
  65952. * @param errorCallback defines the callback to call on error
  65953. */
  65954. open(successCallback: () => void, errorCallback: () => void): void;
  65955. /**
  65956. * Loads an image from the database
  65957. * @param url defines the url to load from
  65958. * @param image defines the target DOM image
  65959. */
  65960. loadImage(url: string, image: HTMLImageElement): void;
  65961. private _loadImageFromDBAsync;
  65962. private _saveImageIntoDBAsync;
  65963. private _checkVersionFromDB;
  65964. private _loadVersionFromDBAsync;
  65965. private _saveVersionIntoDBAsync;
  65966. /**
  65967. * Loads a file from database
  65968. * @param url defines the URL to load from
  65969. * @param sceneLoaded defines a callback to call on success
  65970. * @param progressCallBack defines a callback to call when progress changed
  65971. * @param errorCallback defines a callback to call on error
  65972. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65973. */
  65974. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65975. private _loadFileAsync;
  65976. private _saveFileAsync;
  65977. /**
  65978. * Validates if xhr data is correct
  65979. * @param xhr defines the request to validate
  65980. * @param dataType defines the expected data type
  65981. * @returns true if data is correct
  65982. */
  65983. private static _ValidateXHRData;
  65984. }
  65985. }
  65986. declare module BABYLON {
  65987. /** @hidden */
  65988. export var gpuUpdateParticlesPixelShader: {
  65989. name: string;
  65990. shader: string;
  65991. };
  65992. }
  65993. declare module BABYLON {
  65994. /** @hidden */
  65995. export var gpuUpdateParticlesVertexShader: {
  65996. name: string;
  65997. shader: string;
  65998. };
  65999. }
  66000. declare module BABYLON {
  66001. /** @hidden */
  66002. export var clipPlaneFragmentDeclaration2: {
  66003. name: string;
  66004. shader: string;
  66005. };
  66006. }
  66007. declare module BABYLON {
  66008. /** @hidden */
  66009. export var gpuRenderParticlesPixelShader: {
  66010. name: string;
  66011. shader: string;
  66012. };
  66013. }
  66014. declare module BABYLON {
  66015. /** @hidden */
  66016. export var clipPlaneVertexDeclaration2: {
  66017. name: string;
  66018. shader: string;
  66019. };
  66020. }
  66021. declare module BABYLON {
  66022. /** @hidden */
  66023. export var gpuRenderParticlesVertexShader: {
  66024. name: string;
  66025. shader: string;
  66026. };
  66027. }
  66028. declare module BABYLON {
  66029. /**
  66030. * This represents a GPU particle system in Babylon
  66031. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66032. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66033. */
  66034. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66035. /**
  66036. * The layer mask we are rendering the particles through.
  66037. */
  66038. layerMask: number;
  66039. private _capacity;
  66040. private _activeCount;
  66041. private _currentActiveCount;
  66042. private _accumulatedCount;
  66043. private _renderEffect;
  66044. private _updateEffect;
  66045. private _buffer0;
  66046. private _buffer1;
  66047. private _spriteBuffer;
  66048. private _updateVAO;
  66049. private _renderVAO;
  66050. private _targetIndex;
  66051. private _sourceBuffer;
  66052. private _targetBuffer;
  66053. private _engine;
  66054. private _currentRenderId;
  66055. private _started;
  66056. private _stopped;
  66057. private _timeDelta;
  66058. private _randomTexture;
  66059. private _randomTexture2;
  66060. private _attributesStrideSize;
  66061. private _updateEffectOptions;
  66062. private _randomTextureSize;
  66063. private _actualFrame;
  66064. private _customEffect;
  66065. private readonly _rawTextureWidth;
  66066. /**
  66067. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66068. */
  66069. static get IsSupported(): boolean;
  66070. /**
  66071. * An event triggered when the system is disposed.
  66072. */
  66073. onDisposeObservable: Observable<IParticleSystem>;
  66074. /**
  66075. * Gets the maximum number of particles active at the same time.
  66076. * @returns The max number of active particles.
  66077. */
  66078. getCapacity(): number;
  66079. /**
  66080. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66081. * to override the particles.
  66082. */
  66083. forceDepthWrite: boolean;
  66084. /**
  66085. * Gets or set the number of active particles
  66086. */
  66087. get activeParticleCount(): number;
  66088. set activeParticleCount(value: number);
  66089. private _preWarmDone;
  66090. /**
  66091. * Specifies if the particles are updated in emitter local space or world space.
  66092. */
  66093. isLocal: boolean;
  66094. /**
  66095. * Is this system ready to be used/rendered
  66096. * @return true if the system is ready
  66097. */
  66098. isReady(): boolean;
  66099. /**
  66100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66101. * @returns True if it has been started, otherwise false.
  66102. */
  66103. isStarted(): boolean;
  66104. /**
  66105. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66106. * @returns True if it has been stopped, otherwise false.
  66107. */
  66108. isStopped(): boolean;
  66109. /**
  66110. * Gets a boolean indicating that the system is stopping
  66111. * @returns true if the system is currently stopping
  66112. */
  66113. isStopping(): boolean;
  66114. /**
  66115. * Gets the number of particles active at the same time.
  66116. * @returns The number of active particles.
  66117. */
  66118. getActiveCount(): number;
  66119. /**
  66120. * Starts the particle system and begins to emit
  66121. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66122. */
  66123. start(delay?: number): void;
  66124. /**
  66125. * Stops the particle system.
  66126. */
  66127. stop(): void;
  66128. /**
  66129. * Remove all active particles
  66130. */
  66131. reset(): void;
  66132. /**
  66133. * Returns the string "GPUParticleSystem"
  66134. * @returns a string containing the class name
  66135. */
  66136. getClassName(): string;
  66137. /**
  66138. * Gets the custom effect used to render the particles
  66139. * @param blendMode Blend mode for which the effect should be retrieved
  66140. * @returns The effect
  66141. */
  66142. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66143. /**
  66144. * Sets the custom effect used to render the particles
  66145. * @param effect The effect to set
  66146. * @param blendMode Blend mode for which the effect should be set
  66147. */
  66148. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66149. /** @hidden */
  66150. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66151. /**
  66152. * Observable that will be called just before the particles are drawn
  66153. */
  66154. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66155. /**
  66156. * Gets the name of the particle vertex shader
  66157. */
  66158. get vertexShaderName(): string;
  66159. private _colorGradientsTexture;
  66160. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66161. /**
  66162. * Adds a new color gradient
  66163. * @param gradient defines the gradient to use (between 0 and 1)
  66164. * @param color1 defines the color to affect to the specified gradient
  66165. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66166. * @returns the current particle system
  66167. */
  66168. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66169. private _refreshColorGradient;
  66170. /** Force the system to rebuild all gradients that need to be resync */
  66171. forceRefreshGradients(): void;
  66172. /**
  66173. * Remove a specific color gradient
  66174. * @param gradient defines the gradient to remove
  66175. * @returns the current particle system
  66176. */
  66177. removeColorGradient(gradient: number): GPUParticleSystem;
  66178. private _angularSpeedGradientsTexture;
  66179. private _sizeGradientsTexture;
  66180. private _velocityGradientsTexture;
  66181. private _limitVelocityGradientsTexture;
  66182. private _dragGradientsTexture;
  66183. private _addFactorGradient;
  66184. /**
  66185. * Adds a new size gradient
  66186. * @param gradient defines the gradient to use (between 0 and 1)
  66187. * @param factor defines the size factor to affect to the specified gradient
  66188. * @returns the current particle system
  66189. */
  66190. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66191. /**
  66192. * Remove a specific size gradient
  66193. * @param gradient defines the gradient to remove
  66194. * @returns the current particle system
  66195. */
  66196. removeSizeGradient(gradient: number): GPUParticleSystem;
  66197. private _refreshFactorGradient;
  66198. /**
  66199. * Adds a new angular speed gradient
  66200. * @param gradient defines the gradient to use (between 0 and 1)
  66201. * @param factor defines the angular speed to affect to the specified gradient
  66202. * @returns the current particle system
  66203. */
  66204. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66205. /**
  66206. * Remove a specific angular speed gradient
  66207. * @param gradient defines the gradient to remove
  66208. * @returns the current particle system
  66209. */
  66210. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66211. /**
  66212. * Adds a new velocity gradient
  66213. * @param gradient defines the gradient to use (between 0 and 1)
  66214. * @param factor defines the velocity to affect to the specified gradient
  66215. * @returns the current particle system
  66216. */
  66217. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66218. /**
  66219. * Remove a specific velocity gradient
  66220. * @param gradient defines the gradient to remove
  66221. * @returns the current particle system
  66222. */
  66223. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66224. /**
  66225. * Adds a new limit velocity gradient
  66226. * @param gradient defines the gradient to use (between 0 and 1)
  66227. * @param factor defines the limit velocity value to affect to the specified gradient
  66228. * @returns the current particle system
  66229. */
  66230. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66231. /**
  66232. * Remove a specific limit velocity gradient
  66233. * @param gradient defines the gradient to remove
  66234. * @returns the current particle system
  66235. */
  66236. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66237. /**
  66238. * Adds a new drag gradient
  66239. * @param gradient defines the gradient to use (between 0 and 1)
  66240. * @param factor defines the drag value to affect to the specified gradient
  66241. * @returns the current particle system
  66242. */
  66243. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66244. /**
  66245. * Remove a specific drag gradient
  66246. * @param gradient defines the gradient to remove
  66247. * @returns the current particle system
  66248. */
  66249. removeDragGradient(gradient: number): GPUParticleSystem;
  66250. /**
  66251. * Not supported by GPUParticleSystem
  66252. * @param gradient defines the gradient to use (between 0 and 1)
  66253. * @param factor defines the emit rate value to affect to the specified gradient
  66254. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66255. * @returns the current particle system
  66256. */
  66257. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66258. /**
  66259. * Not supported by GPUParticleSystem
  66260. * @param gradient defines the gradient to remove
  66261. * @returns the current particle system
  66262. */
  66263. removeEmitRateGradient(gradient: number): IParticleSystem;
  66264. /**
  66265. * Not supported by GPUParticleSystem
  66266. * @param gradient defines the gradient to use (between 0 and 1)
  66267. * @param factor defines the start size value to affect to the specified gradient
  66268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66269. * @returns the current particle system
  66270. */
  66271. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66272. /**
  66273. * Not supported by GPUParticleSystem
  66274. * @param gradient defines the gradient to remove
  66275. * @returns the current particle system
  66276. */
  66277. removeStartSizeGradient(gradient: number): IParticleSystem;
  66278. /**
  66279. * Not supported by GPUParticleSystem
  66280. * @param gradient defines the gradient to use (between 0 and 1)
  66281. * @param min defines the color remap minimal range
  66282. * @param max defines the color remap maximal range
  66283. * @returns the current particle system
  66284. */
  66285. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66286. /**
  66287. * Not supported by GPUParticleSystem
  66288. * @param gradient defines the gradient to remove
  66289. * @returns the current particle system
  66290. */
  66291. removeColorRemapGradient(): IParticleSystem;
  66292. /**
  66293. * Not supported by GPUParticleSystem
  66294. * @param gradient defines the gradient to use (between 0 and 1)
  66295. * @param min defines the alpha remap minimal range
  66296. * @param max defines the alpha remap maximal range
  66297. * @returns the current particle system
  66298. */
  66299. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66300. /**
  66301. * Not supported by GPUParticleSystem
  66302. * @param gradient defines the gradient to remove
  66303. * @returns the current particle system
  66304. */
  66305. removeAlphaRemapGradient(): IParticleSystem;
  66306. /**
  66307. * Not supported by GPUParticleSystem
  66308. * @param gradient defines the gradient to use (between 0 and 1)
  66309. * @param color defines the color to affect to the specified gradient
  66310. * @returns the current particle system
  66311. */
  66312. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66313. /**
  66314. * Not supported by GPUParticleSystem
  66315. * @param gradient defines the gradient to remove
  66316. * @returns the current particle system
  66317. */
  66318. removeRampGradient(): IParticleSystem;
  66319. /**
  66320. * Not supported by GPUParticleSystem
  66321. * @returns the list of ramp gradients
  66322. */
  66323. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66324. /**
  66325. * Not supported by GPUParticleSystem
  66326. * Gets or sets a boolean indicating that ramp gradients must be used
  66327. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66328. */
  66329. get useRampGradients(): boolean;
  66330. set useRampGradients(value: boolean);
  66331. /**
  66332. * Not supported by GPUParticleSystem
  66333. * @param gradient defines the gradient to use (between 0 and 1)
  66334. * @param factor defines the life time factor to affect to the specified gradient
  66335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66336. * @returns the current particle system
  66337. */
  66338. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66339. /**
  66340. * Not supported by GPUParticleSystem
  66341. * @param gradient defines the gradient to remove
  66342. * @returns the current particle system
  66343. */
  66344. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66345. /**
  66346. * Instantiates a GPU particle system.
  66347. * 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.
  66348. * @param name The name of the particle system
  66349. * @param options The options used to create the system
  66350. * @param scene The scene the particle system belongs to
  66351. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66352. * @param customEffect a custom effect used to change the way particles are rendered by default
  66353. */
  66354. constructor(name: string, options: Partial<{
  66355. capacity: number;
  66356. randomTextureSize: number;
  66357. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66358. protected _reset(): void;
  66359. private _createUpdateVAO;
  66360. private _createRenderVAO;
  66361. private _initialize;
  66362. /** @hidden */
  66363. _recreateUpdateEffect(): void;
  66364. private _getEffect;
  66365. /**
  66366. * Fill the defines array according to the current settings of the particle system
  66367. * @param defines Array to be updated
  66368. * @param blendMode blend mode to take into account when updating the array
  66369. */
  66370. fillDefines(defines: Array<string>, blendMode?: number): void;
  66371. /**
  66372. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66373. * @param uniforms Uniforms array to fill
  66374. * @param attributes Attributes array to fill
  66375. * @param samplers Samplers array to fill
  66376. */
  66377. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66378. /** @hidden */
  66379. _recreateRenderEffect(): Effect;
  66380. /**
  66381. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66382. * @param preWarm defines if we are in the pre-warmimg phase
  66383. */
  66384. animate(preWarm?: boolean): void;
  66385. private _createFactorGradientTexture;
  66386. private _createSizeGradientTexture;
  66387. private _createAngularSpeedGradientTexture;
  66388. private _createVelocityGradientTexture;
  66389. private _createLimitVelocityGradientTexture;
  66390. private _createDragGradientTexture;
  66391. private _createColorGradientTexture;
  66392. /**
  66393. * Renders the particle system in its current state
  66394. * @param preWarm defines if the system should only update the particles but not render them
  66395. * @returns the current number of particles
  66396. */
  66397. render(preWarm?: boolean): number;
  66398. /**
  66399. * Rebuilds the particle system
  66400. */
  66401. rebuild(): void;
  66402. private _releaseBuffers;
  66403. private _releaseVAOs;
  66404. /**
  66405. * Disposes the particle system and free the associated resources
  66406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66407. */
  66408. dispose(disposeTexture?: boolean): void;
  66409. /**
  66410. * Clones the particle system.
  66411. * @param name The name of the cloned object
  66412. * @param newEmitter The new emitter to use
  66413. * @returns the cloned particle system
  66414. */
  66415. clone(name: string, newEmitter: any): GPUParticleSystem;
  66416. /**
  66417. * Serializes the particle system to a JSON object
  66418. * @param serializeTexture defines if the texture must be serialized as well
  66419. * @returns the JSON object
  66420. */
  66421. serialize(serializeTexture?: boolean): any;
  66422. /**
  66423. * Parses a JSON object to create a GPU particle system.
  66424. * @param parsedParticleSystem The JSON object to parse
  66425. * @param scene The scene to create the particle system in
  66426. * @param rootUrl The root url to use to load external dependencies like texture
  66427. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66428. * @returns the parsed GPU particle system
  66429. */
  66430. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66431. }
  66432. }
  66433. declare module BABYLON {
  66434. /**
  66435. * Represents a set of particle systems working together to create a specific effect
  66436. */
  66437. export class ParticleSystemSet implements IDisposable {
  66438. /**
  66439. * Gets or sets base Assets URL
  66440. */
  66441. static BaseAssetsUrl: string;
  66442. private _emitterCreationOptions;
  66443. private _emitterNode;
  66444. /**
  66445. * Gets the particle system list
  66446. */
  66447. systems: IParticleSystem[];
  66448. /**
  66449. * Gets the emitter node used with this set
  66450. */
  66451. get emitterNode(): Nullable<TransformNode>;
  66452. /**
  66453. * Creates a new emitter mesh as a sphere
  66454. * @param options defines the options used to create the sphere
  66455. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66456. * @param scene defines the hosting scene
  66457. */
  66458. setEmitterAsSphere(options: {
  66459. diameter: number;
  66460. segments: number;
  66461. color: Color3;
  66462. }, renderingGroupId: number, scene: Scene): void;
  66463. /**
  66464. * Starts all particle systems of the set
  66465. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66466. */
  66467. start(emitter?: AbstractMesh): void;
  66468. /**
  66469. * Release all associated resources
  66470. */
  66471. dispose(): void;
  66472. /**
  66473. * Serialize the set into a JSON compatible object
  66474. * @param serializeTexture defines if the texture must be serialized as well
  66475. * @returns a JSON compatible representation of the set
  66476. */
  66477. serialize(serializeTexture?: boolean): any;
  66478. /**
  66479. * Parse a new ParticleSystemSet from a serialized source
  66480. * @param data defines a JSON compatible representation of the set
  66481. * @param scene defines the hosting scene
  66482. * @param gpu defines if we want GPU particles or CPU particles
  66483. * @returns a new ParticleSystemSet
  66484. */
  66485. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66486. }
  66487. }
  66488. declare module BABYLON {
  66489. /**
  66490. * This class is made for on one-liner static method to help creating particle system set.
  66491. */
  66492. export class ParticleHelper {
  66493. /**
  66494. * Gets or sets base Assets URL
  66495. */
  66496. static BaseAssetsUrl: string;
  66497. /** Define the Url to load snippets */
  66498. static SnippetUrl: string;
  66499. /**
  66500. * Create a default particle system that you can tweak
  66501. * @param emitter defines the emitter to use
  66502. * @param capacity defines the system capacity (default is 500 particles)
  66503. * @param scene defines the hosting scene
  66504. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66505. * @returns the new Particle system
  66506. */
  66507. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66508. /**
  66509. * This is the main static method (one-liner) of this helper to create different particle systems
  66510. * @param type This string represents the type to the particle system to create
  66511. * @param scene The scene where the particle system should live
  66512. * @param gpu If the system will use gpu
  66513. * @returns the ParticleSystemSet created
  66514. */
  66515. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66516. /**
  66517. * Static function used to export a particle system to a ParticleSystemSet variable.
  66518. * Please note that the emitter shape is not exported
  66519. * @param systems defines the particle systems to export
  66520. * @returns the created particle system set
  66521. */
  66522. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66523. /**
  66524. * Creates a particle system from a snippet saved in a remote file
  66525. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66526. * @param url defines the url to load from
  66527. * @param scene defines the hosting scene
  66528. * @param gpu If the system will use gpu
  66529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66530. * @returns a promise that will resolve to the new particle system
  66531. */
  66532. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66533. /**
  66534. * Creates a particle system from a snippet saved by the particle system editor
  66535. * @param snippetId defines the snippet to load
  66536. * @param scene defines the hosting scene
  66537. * @param gpu If the system will use gpu
  66538. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66539. * @returns a promise that will resolve to the new particle system
  66540. */
  66541. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66542. }
  66543. }
  66544. declare module BABYLON {
  66545. interface Engine {
  66546. /**
  66547. * Create an effect to use with particle systems.
  66548. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66549. * the particle system for which you want to create a custom effect in the last parameter
  66550. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66551. * @param uniformsNames defines a list of attribute names
  66552. * @param samplers defines an array of string used to represent textures
  66553. * @param defines defines the string containing the defines to use to compile the shaders
  66554. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66555. * @param onCompiled defines a function to call when the effect creation is successful
  66556. * @param onError defines a function to call when the effect creation has failed
  66557. * @param particleSystem the particle system you want to create the effect for
  66558. * @returns the new Effect
  66559. */
  66560. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66561. }
  66562. interface Mesh {
  66563. /**
  66564. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66565. * @returns an array of IParticleSystem
  66566. */
  66567. getEmittedParticleSystems(): IParticleSystem[];
  66568. /**
  66569. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66570. * @returns an array of IParticleSystem
  66571. */
  66572. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. /** Defines the 4 color options */
  66577. export enum PointColor {
  66578. /** color value */
  66579. Color = 2,
  66580. /** uv value */
  66581. UV = 1,
  66582. /** random value */
  66583. Random = 0,
  66584. /** stated value */
  66585. Stated = 3
  66586. }
  66587. /**
  66588. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66589. * 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.
  66590. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66591. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66592. *
  66593. * Full documentation here : TO BE ENTERED
  66594. */
  66595. export class PointsCloudSystem implements IDisposable {
  66596. /**
  66597. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66598. * Example : var p = SPS.particles[i];
  66599. */
  66600. particles: CloudPoint[];
  66601. /**
  66602. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66603. */
  66604. nbParticles: number;
  66605. /**
  66606. * This a counter for your own usage. It's not set by any SPS functions.
  66607. */
  66608. counter: number;
  66609. /**
  66610. * The PCS name. This name is also given to the underlying mesh.
  66611. */
  66612. name: string;
  66613. /**
  66614. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66615. */
  66616. mesh: Mesh;
  66617. /**
  66618. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66619. * Please read :
  66620. */
  66621. vars: any;
  66622. /**
  66623. * @hidden
  66624. */
  66625. _size: number;
  66626. private _scene;
  66627. private _promises;
  66628. private _positions;
  66629. private _indices;
  66630. private _normals;
  66631. private _colors;
  66632. private _uvs;
  66633. private _indices32;
  66634. private _positions32;
  66635. private _colors32;
  66636. private _uvs32;
  66637. private _updatable;
  66638. private _isVisibilityBoxLocked;
  66639. private _alwaysVisible;
  66640. private _groups;
  66641. private _groupCounter;
  66642. private _computeParticleColor;
  66643. private _computeParticleTexture;
  66644. private _computeParticleRotation;
  66645. private _computeBoundingBox;
  66646. private _isReady;
  66647. /**
  66648. * Creates a PCS (Points Cloud System) object
  66649. * @param name (String) is the PCS name, this will be the underlying mesh name
  66650. * @param pointSize (number) is the size for each point
  66651. * @param scene (Scene) is the scene in which the PCS is added
  66652. * @param options defines the options of the PCS e.g.
  66653. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66654. */
  66655. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66656. updatable?: boolean;
  66657. });
  66658. /**
  66659. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66660. * If no points were added to the PCS, the returned mesh is just a single point.
  66661. * @returns a promise for the created mesh
  66662. */
  66663. buildMeshAsync(): Promise<Mesh>;
  66664. /**
  66665. * @hidden
  66666. */
  66667. private _buildMesh;
  66668. private _addParticle;
  66669. private _randomUnitVector;
  66670. private _getColorIndicesForCoord;
  66671. private _setPointsColorOrUV;
  66672. private _colorFromTexture;
  66673. private _calculateDensity;
  66674. /**
  66675. * Adds points to the PCS in random positions within a unit sphere
  66676. * @param nb (positive integer) the number of particles to be created from this model
  66677. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66678. * @returns the number of groups in the system
  66679. */
  66680. addPoints(nb: number, pointFunction?: any): number;
  66681. /**
  66682. * Adds points to the PCS from the surface of the model shape
  66683. * @param mesh is any Mesh object that will be used as a surface model for the points
  66684. * @param nb (positive integer) the number of particles to be created from this model
  66685. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66686. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66687. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66688. * @returns the number of groups in the system
  66689. */
  66690. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66691. /**
  66692. * Adds points to the PCS inside the model shape
  66693. * @param mesh is any Mesh object that will be used as a surface model for the points
  66694. * @param nb (positive integer) the number of particles to be created from this model
  66695. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66696. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66697. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66698. * @returns the number of groups in the system
  66699. */
  66700. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66701. /**
  66702. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66703. * This method calls `updateParticle()` for each particle of the SPS.
  66704. * For an animated SPS, it is usually called within the render loop.
  66705. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66706. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66707. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66708. * @returns the PCS.
  66709. */
  66710. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66711. /**
  66712. * Disposes the PCS.
  66713. */
  66714. dispose(): void;
  66715. /**
  66716. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66717. * doc :
  66718. * @returns the PCS.
  66719. */
  66720. refreshVisibleSize(): PointsCloudSystem;
  66721. /**
  66722. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66723. * @param size the size (float) of the visibility box
  66724. * note : this doesn't lock the PCS mesh bounding box.
  66725. * doc :
  66726. */
  66727. setVisibilityBox(size: number): void;
  66728. /**
  66729. * Gets whether the PCS is always visible or not
  66730. * doc :
  66731. */
  66732. get isAlwaysVisible(): boolean;
  66733. /**
  66734. * Sets the PCS as always visible or not
  66735. * doc :
  66736. */
  66737. set isAlwaysVisible(val: boolean);
  66738. /**
  66739. * Tells to `setParticles()` to compute the particle rotations or not
  66740. * Default value : false. The PCS is faster when it's set to false
  66741. * Note : particle rotations are only applied to parent particles
  66742. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66743. */
  66744. set computeParticleRotation(val: boolean);
  66745. /**
  66746. * Tells to `setParticles()` to compute the particle colors or not.
  66747. * Default value : true. The PCS is faster when it's set to false.
  66748. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66749. */
  66750. set computeParticleColor(val: boolean);
  66751. set computeParticleTexture(val: boolean);
  66752. /**
  66753. * Gets if `setParticles()` computes the particle colors or not.
  66754. * Default value : false. The PCS is faster when it's set to false.
  66755. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66756. */
  66757. get computeParticleColor(): boolean;
  66758. /**
  66759. * Gets if `setParticles()` computes the particle textures or not.
  66760. * Default value : false. The PCS is faster when it's set to false.
  66761. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66762. */
  66763. get computeParticleTexture(): boolean;
  66764. /**
  66765. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66766. */
  66767. set computeBoundingBox(val: boolean);
  66768. /**
  66769. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66770. */
  66771. get computeBoundingBox(): boolean;
  66772. /**
  66773. * This function does nothing. It may be overwritten to set all the particle first values.
  66774. * The PCS doesn't call this function, you may have to call it by your own.
  66775. * doc :
  66776. */
  66777. initParticles(): void;
  66778. /**
  66779. * This function does nothing. It may be overwritten to recycle a particle
  66780. * The PCS doesn't call this function, you can to call it
  66781. * doc :
  66782. * @param particle The particle to recycle
  66783. * @returns the recycled particle
  66784. */
  66785. recycleParticle(particle: CloudPoint): CloudPoint;
  66786. /**
  66787. * Updates a particle : this function should be overwritten by the user.
  66788. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66789. * doc :
  66790. * @example : just set a particle position or velocity and recycle conditions
  66791. * @param particle The particle to update
  66792. * @returns the updated particle
  66793. */
  66794. updateParticle(particle: CloudPoint): CloudPoint;
  66795. /**
  66796. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66797. * This does nothing and may be overwritten by the user.
  66798. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66799. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66800. * @param update the boolean update value actually passed to setParticles()
  66801. */
  66802. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66803. /**
  66804. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66805. * This will be passed three parameters.
  66806. * This does nothing and may be overwritten by the user.
  66807. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66808. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66809. * @param update the boolean update value actually passed to setParticles()
  66810. */
  66811. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66812. }
  66813. }
  66814. declare module BABYLON {
  66815. /**
  66816. * Represents one particle of a points cloud system.
  66817. */
  66818. export class CloudPoint {
  66819. /**
  66820. * particle global index
  66821. */
  66822. idx: number;
  66823. /**
  66824. * The color of the particle
  66825. */
  66826. color: Nullable<Color4>;
  66827. /**
  66828. * The world space position of the particle.
  66829. */
  66830. position: Vector3;
  66831. /**
  66832. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66833. */
  66834. rotation: Vector3;
  66835. /**
  66836. * The world space rotation quaternion of the particle.
  66837. */
  66838. rotationQuaternion: Nullable<Quaternion>;
  66839. /**
  66840. * The uv of the particle.
  66841. */
  66842. uv: Nullable<Vector2>;
  66843. /**
  66844. * The current speed of the particle.
  66845. */
  66846. velocity: Vector3;
  66847. /**
  66848. * The pivot point in the particle local space.
  66849. */
  66850. pivot: Vector3;
  66851. /**
  66852. * Must the particle be translated from its pivot point in its local space ?
  66853. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66854. * Default : false
  66855. */
  66856. translateFromPivot: boolean;
  66857. /**
  66858. * Index of this particle in the global "positions" array (Internal use)
  66859. * @hidden
  66860. */
  66861. _pos: number;
  66862. /**
  66863. * @hidden Index of this particle in the global "indices" array (Internal use)
  66864. */
  66865. _ind: number;
  66866. /**
  66867. * Group this particle belongs to
  66868. */
  66869. _group: PointsGroup;
  66870. /**
  66871. * Group id of this particle
  66872. */
  66873. groupId: number;
  66874. /**
  66875. * Index of the particle in its group id (Internal use)
  66876. */
  66877. idxInGroup: number;
  66878. /**
  66879. * @hidden Particle BoundingInfo object (Internal use)
  66880. */
  66881. _boundingInfo: BoundingInfo;
  66882. /**
  66883. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66884. */
  66885. _pcs: PointsCloudSystem;
  66886. /**
  66887. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66888. */
  66889. _stillInvisible: boolean;
  66890. /**
  66891. * @hidden Last computed particle rotation matrix
  66892. */
  66893. _rotationMatrix: number[];
  66894. /**
  66895. * Parent particle Id, if any.
  66896. * Default null.
  66897. */
  66898. parentId: Nullable<number>;
  66899. /**
  66900. * @hidden Internal global position in the PCS.
  66901. */
  66902. _globalPosition: Vector3;
  66903. /**
  66904. * Creates a Point Cloud object.
  66905. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66906. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66907. * @param group (PointsGroup) is the group the particle belongs to
  66908. * @param groupId (integer) is the group identifier in the PCS.
  66909. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66910. * @param pcs defines the PCS it is associated to
  66911. */
  66912. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66913. /**
  66914. * get point size
  66915. */
  66916. get size(): Vector3;
  66917. /**
  66918. * Set point size
  66919. */
  66920. set size(scale: Vector3);
  66921. /**
  66922. * Legacy support, changed quaternion to rotationQuaternion
  66923. */
  66924. get quaternion(): Nullable<Quaternion>;
  66925. /**
  66926. * Legacy support, changed quaternion to rotationQuaternion
  66927. */
  66928. set quaternion(q: Nullable<Quaternion>);
  66929. /**
  66930. * Returns a boolean. True if the particle intersects a mesh, else false
  66931. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66932. * @param target is the object (point or mesh) what the intersection is computed against
  66933. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66934. * @returns true if it intersects
  66935. */
  66936. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66937. /**
  66938. * get the rotation matrix of the particle
  66939. * @hidden
  66940. */
  66941. getRotationMatrix(m: Matrix): void;
  66942. }
  66943. /**
  66944. * Represents a group of points in a points cloud system
  66945. * * PCS internal tool, don't use it manually.
  66946. */
  66947. export class PointsGroup {
  66948. /**
  66949. * The group id
  66950. * @hidden
  66951. */
  66952. groupID: number;
  66953. /**
  66954. * image data for group (internal use)
  66955. * @hidden
  66956. */
  66957. _groupImageData: Nullable<ArrayBufferView>;
  66958. /**
  66959. * Image Width (internal use)
  66960. * @hidden
  66961. */
  66962. _groupImgWidth: number;
  66963. /**
  66964. * Image Height (internal use)
  66965. * @hidden
  66966. */
  66967. _groupImgHeight: number;
  66968. /**
  66969. * Custom position function (internal use)
  66970. * @hidden
  66971. */
  66972. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66973. /**
  66974. * density per facet for surface points
  66975. * @hidden
  66976. */
  66977. _groupDensity: number[];
  66978. /**
  66979. * Only when points are colored by texture carries pointer to texture list array
  66980. * @hidden
  66981. */
  66982. _textureNb: number;
  66983. /**
  66984. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66985. * PCS internal tool, don't use it manually.
  66986. * @hidden
  66987. */
  66988. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66989. }
  66990. }
  66991. declare module BABYLON {
  66992. interface Scene {
  66993. /** @hidden (Backing field) */
  66994. _physicsEngine: Nullable<IPhysicsEngine>;
  66995. /** @hidden */
  66996. _physicsTimeAccumulator: number;
  66997. /**
  66998. * Gets the current physics engine
  66999. * @returns a IPhysicsEngine or null if none attached
  67000. */
  67001. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67002. /**
  67003. * Enables physics to the current scene
  67004. * @param gravity defines the scene's gravity for the physics engine
  67005. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67006. * @return a boolean indicating if the physics engine was initialized
  67007. */
  67008. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67009. /**
  67010. * Disables and disposes the physics engine associated with the scene
  67011. */
  67012. disablePhysicsEngine(): void;
  67013. /**
  67014. * Gets a boolean indicating if there is an active physics engine
  67015. * @returns a boolean indicating if there is an active physics engine
  67016. */
  67017. isPhysicsEnabled(): boolean;
  67018. /**
  67019. * Deletes a physics compound impostor
  67020. * @param compound defines the compound to delete
  67021. */
  67022. deleteCompoundImpostor(compound: any): void;
  67023. /**
  67024. * An event triggered when physic simulation is about to be run
  67025. */
  67026. onBeforePhysicsObservable: Observable<Scene>;
  67027. /**
  67028. * An event triggered when physic simulation has been done
  67029. */
  67030. onAfterPhysicsObservable: Observable<Scene>;
  67031. }
  67032. interface AbstractMesh {
  67033. /** @hidden */
  67034. _physicsImpostor: Nullable<PhysicsImpostor>;
  67035. /**
  67036. * Gets or sets impostor used for physic simulation
  67037. * @see http://doc.babylonjs.com/features/physics_engine
  67038. */
  67039. physicsImpostor: Nullable<PhysicsImpostor>;
  67040. /**
  67041. * Gets the current physics impostor
  67042. * @see http://doc.babylonjs.com/features/physics_engine
  67043. * @returns a physics impostor or null
  67044. */
  67045. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67046. /** Apply a physic impulse to the mesh
  67047. * @param force defines the force to apply
  67048. * @param contactPoint defines where to apply the force
  67049. * @returns the current mesh
  67050. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67051. */
  67052. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67053. /**
  67054. * Creates a physic joint between two meshes
  67055. * @param otherMesh defines the other mesh to use
  67056. * @param pivot1 defines the pivot to use on this mesh
  67057. * @param pivot2 defines the pivot to use on the other mesh
  67058. * @param options defines additional options (can be plugin dependent)
  67059. * @returns the current mesh
  67060. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67061. */
  67062. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67063. /** @hidden */
  67064. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67065. }
  67066. /**
  67067. * Defines the physics engine scene component responsible to manage a physics engine
  67068. */
  67069. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67070. /**
  67071. * The component name helpful to identify the component in the list of scene components.
  67072. */
  67073. readonly name: string;
  67074. /**
  67075. * The scene the component belongs to.
  67076. */
  67077. scene: Scene;
  67078. /**
  67079. * Creates a new instance of the component for the given scene
  67080. * @param scene Defines the scene to register the component in
  67081. */
  67082. constructor(scene: Scene);
  67083. /**
  67084. * Registers the component in a given scene
  67085. */
  67086. register(): void;
  67087. /**
  67088. * Rebuilds the elements related to this component in case of
  67089. * context lost for instance.
  67090. */
  67091. rebuild(): void;
  67092. /**
  67093. * Disposes the component and the associated ressources
  67094. */
  67095. dispose(): void;
  67096. }
  67097. }
  67098. declare module BABYLON {
  67099. /**
  67100. * A helper for physics simulations
  67101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67102. */
  67103. export class PhysicsHelper {
  67104. private _scene;
  67105. private _physicsEngine;
  67106. /**
  67107. * Initializes the Physics helper
  67108. * @param scene Babylon.js scene
  67109. */
  67110. constructor(scene: Scene);
  67111. /**
  67112. * Applies a radial explosion impulse
  67113. * @param origin the origin of the explosion
  67114. * @param radiusOrEventOptions the radius or the options of radial explosion
  67115. * @param strength the explosion strength
  67116. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67117. * @returns A physics radial explosion event, or null
  67118. */
  67119. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67120. /**
  67121. * Applies a radial explosion force
  67122. * @param origin the origin of the explosion
  67123. * @param radiusOrEventOptions the radius or the options of radial explosion
  67124. * @param strength the explosion strength
  67125. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67126. * @returns A physics radial explosion event, or null
  67127. */
  67128. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67129. /**
  67130. * Creates a gravitational field
  67131. * @param origin the origin of the explosion
  67132. * @param radiusOrEventOptions the radius or the options of radial explosion
  67133. * @param strength the explosion strength
  67134. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67135. * @returns A physics gravitational field event, or null
  67136. */
  67137. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67138. /**
  67139. * Creates a physics updraft event
  67140. * @param origin the origin of the updraft
  67141. * @param radiusOrEventOptions the radius or the options of the updraft
  67142. * @param strength the strength of the updraft
  67143. * @param height the height of the updraft
  67144. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67145. * @returns A physics updraft event, or null
  67146. */
  67147. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67148. /**
  67149. * Creates a physics vortex event
  67150. * @param origin the of the vortex
  67151. * @param radiusOrEventOptions the radius or the options of the vortex
  67152. * @param strength the strength of the vortex
  67153. * @param height the height of the vortex
  67154. * @returns a Physics vortex event, or null
  67155. * A physics vortex event or null
  67156. */
  67157. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67158. }
  67159. /**
  67160. * Represents a physics radial explosion event
  67161. */
  67162. class PhysicsRadialExplosionEvent {
  67163. private _scene;
  67164. private _options;
  67165. private _sphere;
  67166. private _dataFetched;
  67167. /**
  67168. * Initializes a radial explosioin event
  67169. * @param _scene BabylonJS scene
  67170. * @param _options The options for the vortex event
  67171. */
  67172. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67173. /**
  67174. * Returns the data related to the radial explosion event (sphere).
  67175. * @returns The radial explosion event data
  67176. */
  67177. getData(): PhysicsRadialExplosionEventData;
  67178. /**
  67179. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67180. * @param impostor A physics imposter
  67181. * @param origin the origin of the explosion
  67182. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67183. */
  67184. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67185. /**
  67186. * Triggers affecterd impostors callbacks
  67187. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67188. */
  67189. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67190. /**
  67191. * Disposes the sphere.
  67192. * @param force Specifies if the sphere should be disposed by force
  67193. */
  67194. dispose(force?: boolean): void;
  67195. /*** Helpers ***/
  67196. private _prepareSphere;
  67197. private _intersectsWithSphere;
  67198. }
  67199. /**
  67200. * Represents a gravitational field event
  67201. */
  67202. class PhysicsGravitationalFieldEvent {
  67203. private _physicsHelper;
  67204. private _scene;
  67205. private _origin;
  67206. private _options;
  67207. private _tickCallback;
  67208. private _sphere;
  67209. private _dataFetched;
  67210. /**
  67211. * Initializes the physics gravitational field event
  67212. * @param _physicsHelper A physics helper
  67213. * @param _scene BabylonJS scene
  67214. * @param _origin The origin position of the gravitational field event
  67215. * @param _options The options for the vortex event
  67216. */
  67217. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67218. /**
  67219. * Returns the data related to the gravitational field event (sphere).
  67220. * @returns A gravitational field event
  67221. */
  67222. getData(): PhysicsGravitationalFieldEventData;
  67223. /**
  67224. * Enables the gravitational field.
  67225. */
  67226. enable(): void;
  67227. /**
  67228. * Disables the gravitational field.
  67229. */
  67230. disable(): void;
  67231. /**
  67232. * Disposes the sphere.
  67233. * @param force The force to dispose from the gravitational field event
  67234. */
  67235. dispose(force?: boolean): void;
  67236. private _tick;
  67237. }
  67238. /**
  67239. * Represents a physics updraft event
  67240. */
  67241. class PhysicsUpdraftEvent {
  67242. private _scene;
  67243. private _origin;
  67244. private _options;
  67245. private _physicsEngine;
  67246. private _originTop;
  67247. private _originDirection;
  67248. private _tickCallback;
  67249. private _cylinder;
  67250. private _cylinderPosition;
  67251. private _dataFetched;
  67252. /**
  67253. * Initializes the physics updraft event
  67254. * @param _scene BabylonJS scene
  67255. * @param _origin The origin position of the updraft
  67256. * @param _options The options for the updraft event
  67257. */
  67258. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67259. /**
  67260. * Returns the data related to the updraft event (cylinder).
  67261. * @returns A physics updraft event
  67262. */
  67263. getData(): PhysicsUpdraftEventData;
  67264. /**
  67265. * Enables the updraft.
  67266. */
  67267. enable(): void;
  67268. /**
  67269. * Disables the updraft.
  67270. */
  67271. disable(): void;
  67272. /**
  67273. * Disposes the cylinder.
  67274. * @param force Specifies if the updraft should be disposed by force
  67275. */
  67276. dispose(force?: boolean): void;
  67277. private getImpostorHitData;
  67278. private _tick;
  67279. /*** Helpers ***/
  67280. private _prepareCylinder;
  67281. private _intersectsWithCylinder;
  67282. }
  67283. /**
  67284. * Represents a physics vortex event
  67285. */
  67286. class PhysicsVortexEvent {
  67287. private _scene;
  67288. private _origin;
  67289. private _options;
  67290. private _physicsEngine;
  67291. private _originTop;
  67292. private _tickCallback;
  67293. private _cylinder;
  67294. private _cylinderPosition;
  67295. private _dataFetched;
  67296. /**
  67297. * Initializes the physics vortex event
  67298. * @param _scene The BabylonJS scene
  67299. * @param _origin The origin position of the vortex
  67300. * @param _options The options for the vortex event
  67301. */
  67302. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67303. /**
  67304. * Returns the data related to the vortex event (cylinder).
  67305. * @returns The physics vortex event data
  67306. */
  67307. getData(): PhysicsVortexEventData;
  67308. /**
  67309. * Enables the vortex.
  67310. */
  67311. enable(): void;
  67312. /**
  67313. * Disables the cortex.
  67314. */
  67315. disable(): void;
  67316. /**
  67317. * Disposes the sphere.
  67318. * @param force
  67319. */
  67320. dispose(force?: boolean): void;
  67321. private getImpostorHitData;
  67322. private _tick;
  67323. /*** Helpers ***/
  67324. private _prepareCylinder;
  67325. private _intersectsWithCylinder;
  67326. }
  67327. /**
  67328. * Options fot the radial explosion event
  67329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67330. */
  67331. export class PhysicsRadialExplosionEventOptions {
  67332. /**
  67333. * The radius of the sphere for the radial explosion.
  67334. */
  67335. radius: number;
  67336. /**
  67337. * The strenth of the explosion.
  67338. */
  67339. strength: number;
  67340. /**
  67341. * The strenght of the force in correspondence to the distance of the affected object
  67342. */
  67343. falloff: PhysicsRadialImpulseFalloff;
  67344. /**
  67345. * Sphere options for the radial explosion.
  67346. */
  67347. sphere: {
  67348. segments: number;
  67349. diameter: number;
  67350. };
  67351. /**
  67352. * Sphere options for the radial explosion.
  67353. */
  67354. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67355. }
  67356. /**
  67357. * Options fot the updraft event
  67358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67359. */
  67360. export class PhysicsUpdraftEventOptions {
  67361. /**
  67362. * The radius of the cylinder for the vortex
  67363. */
  67364. radius: number;
  67365. /**
  67366. * The strenth of the updraft.
  67367. */
  67368. strength: number;
  67369. /**
  67370. * The height of the cylinder for the updraft.
  67371. */
  67372. height: number;
  67373. /**
  67374. * The mode for the the updraft.
  67375. */
  67376. updraftMode: PhysicsUpdraftMode;
  67377. }
  67378. /**
  67379. * Options fot the vortex event
  67380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67381. */
  67382. export class PhysicsVortexEventOptions {
  67383. /**
  67384. * The radius of the cylinder for the vortex
  67385. */
  67386. radius: number;
  67387. /**
  67388. * The strenth of the vortex.
  67389. */
  67390. strength: number;
  67391. /**
  67392. * The height of the cylinder for the vortex.
  67393. */
  67394. height: number;
  67395. /**
  67396. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67397. */
  67398. centripetalForceThreshold: number;
  67399. /**
  67400. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67401. */
  67402. centripetalForceMultiplier: number;
  67403. /**
  67404. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67405. */
  67406. centrifugalForceMultiplier: number;
  67407. /**
  67408. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67409. */
  67410. updraftForceMultiplier: number;
  67411. }
  67412. /**
  67413. * The strenght of the force in correspondence to the distance of the affected object
  67414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67415. */
  67416. export enum PhysicsRadialImpulseFalloff {
  67417. /** Defines that impulse is constant in strength across it's whole radius */
  67418. Constant = 0,
  67419. /** Defines that impulse gets weaker if it's further from the origin */
  67420. Linear = 1
  67421. }
  67422. /**
  67423. * The strength of the force in correspondence to the distance of the affected object
  67424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67425. */
  67426. export enum PhysicsUpdraftMode {
  67427. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67428. Center = 0,
  67429. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67430. Perpendicular = 1
  67431. }
  67432. /**
  67433. * Interface for a physics hit data
  67434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67435. */
  67436. export interface PhysicsHitData {
  67437. /**
  67438. * The force applied at the contact point
  67439. */
  67440. force: Vector3;
  67441. /**
  67442. * The contact point
  67443. */
  67444. contactPoint: Vector3;
  67445. /**
  67446. * The distance from the origin to the contact point
  67447. */
  67448. distanceFromOrigin: number;
  67449. }
  67450. /**
  67451. * Interface for radial explosion event data
  67452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67453. */
  67454. export interface PhysicsRadialExplosionEventData {
  67455. /**
  67456. * A sphere used for the radial explosion event
  67457. */
  67458. sphere: Mesh;
  67459. }
  67460. /**
  67461. * Interface for gravitational field event data
  67462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67463. */
  67464. export interface PhysicsGravitationalFieldEventData {
  67465. /**
  67466. * A sphere mesh used for the gravitational field event
  67467. */
  67468. sphere: Mesh;
  67469. }
  67470. /**
  67471. * Interface for updraft event data
  67472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67473. */
  67474. export interface PhysicsUpdraftEventData {
  67475. /**
  67476. * A cylinder used for the updraft event
  67477. */
  67478. cylinder: Mesh;
  67479. }
  67480. /**
  67481. * Interface for vortex event data
  67482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67483. */
  67484. export interface PhysicsVortexEventData {
  67485. /**
  67486. * A cylinder used for the vortex event
  67487. */
  67488. cylinder: Mesh;
  67489. }
  67490. /**
  67491. * Interface for an affected physics impostor
  67492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67493. */
  67494. export interface PhysicsAffectedImpostorWithData {
  67495. /**
  67496. * The impostor affected by the effect
  67497. */
  67498. impostor: PhysicsImpostor;
  67499. /**
  67500. * The data about the hit/horce from the explosion
  67501. */
  67502. hitData: PhysicsHitData;
  67503. }
  67504. }
  67505. declare module BABYLON {
  67506. /** @hidden */
  67507. export var blackAndWhitePixelShader: {
  67508. name: string;
  67509. shader: string;
  67510. };
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * Post process used to render in black and white
  67515. */
  67516. export class BlackAndWhitePostProcess extends PostProcess {
  67517. /**
  67518. * Linear about to convert he result to black and white (default: 1)
  67519. */
  67520. degree: number;
  67521. /**
  67522. * Creates a black and white post process
  67523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67524. * @param name The name of the effect.
  67525. * @param options The required width/height ratio to downsize to before computing the render pass.
  67526. * @param camera The camera to apply the render pass to.
  67527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67528. * @param engine The engine which the post process will be applied. (default: current engine)
  67529. * @param reusable If the post process can be reused on the same frame. (default: false)
  67530. */
  67531. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67532. }
  67533. }
  67534. declare module BABYLON {
  67535. /**
  67536. * This represents a set of one or more post processes in Babylon.
  67537. * A post process can be used to apply a shader to a texture after it is rendered.
  67538. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67539. */
  67540. export class PostProcessRenderEffect {
  67541. private _postProcesses;
  67542. private _getPostProcesses;
  67543. private _singleInstance;
  67544. private _cameras;
  67545. private _indicesForCamera;
  67546. /**
  67547. * Name of the effect
  67548. * @hidden
  67549. */
  67550. _name: string;
  67551. /**
  67552. * Instantiates a post process render effect.
  67553. * A post process can be used to apply a shader to a texture after it is rendered.
  67554. * @param engine The engine the effect is tied to
  67555. * @param name The name of the effect
  67556. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67557. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67558. */
  67559. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67560. /**
  67561. * Checks if all the post processes in the effect are supported.
  67562. */
  67563. get isSupported(): boolean;
  67564. /**
  67565. * Updates the current state of the effect
  67566. * @hidden
  67567. */
  67568. _update(): void;
  67569. /**
  67570. * Attaches the effect on cameras
  67571. * @param cameras The camera to attach to.
  67572. * @hidden
  67573. */
  67574. _attachCameras(cameras: Camera): void;
  67575. /**
  67576. * Attaches the effect on cameras
  67577. * @param cameras The camera to attach to.
  67578. * @hidden
  67579. */
  67580. _attachCameras(cameras: Camera[]): void;
  67581. /**
  67582. * Detaches the effect on cameras
  67583. * @param cameras The camera to detatch from.
  67584. * @hidden
  67585. */
  67586. _detachCameras(cameras: Camera): void;
  67587. /**
  67588. * Detatches the effect on cameras
  67589. * @param cameras The camera to detatch from.
  67590. * @hidden
  67591. */
  67592. _detachCameras(cameras: Camera[]): void;
  67593. /**
  67594. * Enables the effect on given cameras
  67595. * @param cameras The camera to enable.
  67596. * @hidden
  67597. */
  67598. _enable(cameras: Camera): void;
  67599. /**
  67600. * Enables the effect on given cameras
  67601. * @param cameras The camera to enable.
  67602. * @hidden
  67603. */
  67604. _enable(cameras: Nullable<Camera[]>): void;
  67605. /**
  67606. * Disables the effect on the given cameras
  67607. * @param cameras The camera to disable.
  67608. * @hidden
  67609. */
  67610. _disable(cameras: Camera): void;
  67611. /**
  67612. * Disables the effect on the given cameras
  67613. * @param cameras The camera to disable.
  67614. * @hidden
  67615. */
  67616. _disable(cameras: Nullable<Camera[]>): void;
  67617. /**
  67618. * Gets a list of the post processes contained in the effect.
  67619. * @param camera The camera to get the post processes on.
  67620. * @returns The list of the post processes in the effect.
  67621. */
  67622. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67623. }
  67624. }
  67625. declare module BABYLON {
  67626. /** @hidden */
  67627. export var extractHighlightsPixelShader: {
  67628. name: string;
  67629. shader: string;
  67630. };
  67631. }
  67632. declare module BABYLON {
  67633. /**
  67634. * 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.
  67635. */
  67636. export class ExtractHighlightsPostProcess extends PostProcess {
  67637. /**
  67638. * The luminance threshold, pixels below this value will be set to black.
  67639. */
  67640. threshold: number;
  67641. /** @hidden */
  67642. _exposure: number;
  67643. /**
  67644. * Post process which has the input texture to be used when performing highlight extraction
  67645. * @hidden
  67646. */
  67647. _inputPostProcess: Nullable<PostProcess>;
  67648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67649. }
  67650. }
  67651. declare module BABYLON {
  67652. /** @hidden */
  67653. export var bloomMergePixelShader: {
  67654. name: string;
  67655. shader: string;
  67656. };
  67657. }
  67658. declare module BABYLON {
  67659. /**
  67660. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67661. */
  67662. export class BloomMergePostProcess extends PostProcess {
  67663. /** Weight of the bloom to be added to the original input. */
  67664. weight: number;
  67665. /**
  67666. * Creates a new instance of @see BloomMergePostProcess
  67667. * @param name The name of the effect.
  67668. * @param originalFromInput Post process which's input will be used for the merge.
  67669. * @param blurred Blurred highlights post process which's output will be used.
  67670. * @param weight Weight of the bloom to be added to the original input.
  67671. * @param options The required width/height ratio to downsize to before computing the render pass.
  67672. * @param camera The camera to apply the render pass to.
  67673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67674. * @param engine The engine which the post process will be applied. (default: current engine)
  67675. * @param reusable If the post process can be reused on the same frame. (default: false)
  67676. * @param textureType Type of textures used when performing the post process. (default: 0)
  67677. * @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)
  67678. */
  67679. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67680. /** Weight of the bloom to be added to the original input. */
  67681. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67682. }
  67683. }
  67684. declare module BABYLON {
  67685. /**
  67686. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67687. */
  67688. export class BloomEffect extends PostProcessRenderEffect {
  67689. private bloomScale;
  67690. /**
  67691. * @hidden Internal
  67692. */
  67693. _effects: Array<PostProcess>;
  67694. /**
  67695. * @hidden Internal
  67696. */
  67697. _downscale: ExtractHighlightsPostProcess;
  67698. private _blurX;
  67699. private _blurY;
  67700. private _merge;
  67701. /**
  67702. * The luminance threshold to find bright areas of the image to bloom.
  67703. */
  67704. get threshold(): number;
  67705. set threshold(value: number);
  67706. /**
  67707. * The strength of the bloom.
  67708. */
  67709. get weight(): number;
  67710. set weight(value: number);
  67711. /**
  67712. * Specifies the size of the bloom blur kernel, relative to the final output size
  67713. */
  67714. get kernel(): number;
  67715. set kernel(value: number);
  67716. /**
  67717. * Creates a new instance of @see BloomEffect
  67718. * @param scene The scene the effect belongs to.
  67719. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67720. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67721. * @param bloomWeight The the strength of bloom.
  67722. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67723. * @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)
  67724. */
  67725. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67726. /**
  67727. * Disposes each of the internal effects for a given camera.
  67728. * @param camera The camera to dispose the effect on.
  67729. */
  67730. disposeEffects(camera: Camera): void;
  67731. /**
  67732. * @hidden Internal
  67733. */
  67734. _updateEffects(): void;
  67735. /**
  67736. * Internal
  67737. * @returns if all the contained post processes are ready.
  67738. * @hidden
  67739. */
  67740. _isReady(): boolean;
  67741. }
  67742. }
  67743. declare module BABYLON {
  67744. /** @hidden */
  67745. export var chromaticAberrationPixelShader: {
  67746. name: string;
  67747. shader: string;
  67748. };
  67749. }
  67750. declare module BABYLON {
  67751. /**
  67752. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67753. */
  67754. export class ChromaticAberrationPostProcess extends PostProcess {
  67755. /**
  67756. * The amount of seperation of rgb channels (default: 30)
  67757. */
  67758. aberrationAmount: number;
  67759. /**
  67760. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67761. */
  67762. radialIntensity: number;
  67763. /**
  67764. * 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))
  67765. */
  67766. direction: Vector2;
  67767. /**
  67768. * 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))
  67769. */
  67770. centerPosition: Vector2;
  67771. /**
  67772. * Creates a new instance ChromaticAberrationPostProcess
  67773. * @param name The name of the effect.
  67774. * @param screenWidth The width of the screen to apply the effect on.
  67775. * @param screenHeight The height of the screen to apply the effect on.
  67776. * @param options The required width/height ratio to downsize to before computing the render pass.
  67777. * @param camera The camera to apply the render pass to.
  67778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67779. * @param engine The engine which the post process will be applied. (default: current engine)
  67780. * @param reusable If the post process can be reused on the same frame. (default: false)
  67781. * @param textureType Type of textures used when performing the post process. (default: 0)
  67782. * @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)
  67783. */
  67784. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67785. }
  67786. }
  67787. declare module BABYLON {
  67788. /** @hidden */
  67789. export var circleOfConfusionPixelShader: {
  67790. name: string;
  67791. shader: string;
  67792. };
  67793. }
  67794. declare module BABYLON {
  67795. /**
  67796. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67797. */
  67798. export class CircleOfConfusionPostProcess extends PostProcess {
  67799. /**
  67800. * 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.
  67801. */
  67802. lensSize: number;
  67803. /**
  67804. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67805. */
  67806. fStop: number;
  67807. /**
  67808. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67809. */
  67810. focusDistance: number;
  67811. /**
  67812. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67813. */
  67814. focalLength: number;
  67815. private _depthTexture;
  67816. /**
  67817. * Creates a new instance CircleOfConfusionPostProcess
  67818. * @param name The name of the effect.
  67819. * @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.
  67820. * @param options The required width/height ratio to downsize to before computing the render pass.
  67821. * @param camera The camera to apply the render pass to.
  67822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67823. * @param engine The engine which the post process will be applied. (default: current engine)
  67824. * @param reusable If the post process can be reused on the same frame. (default: false)
  67825. * @param textureType Type of textures used when performing the post process. (default: 0)
  67826. * @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)
  67827. */
  67828. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67829. /**
  67830. * 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.
  67831. */
  67832. set depthTexture(value: RenderTargetTexture);
  67833. }
  67834. }
  67835. declare module BABYLON {
  67836. /** @hidden */
  67837. export var colorCorrectionPixelShader: {
  67838. name: string;
  67839. shader: string;
  67840. };
  67841. }
  67842. declare module BABYLON {
  67843. /**
  67844. *
  67845. * This post-process allows the modification of rendered colors by using
  67846. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67847. *
  67848. * The object needs to be provided an url to a texture containing the color
  67849. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67850. * Use an image editing software to tweak the LUT to match your needs.
  67851. *
  67852. * For an example of a color LUT, see here:
  67853. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67854. * For explanations on color grading, see here:
  67855. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67856. *
  67857. */
  67858. export class ColorCorrectionPostProcess extends PostProcess {
  67859. private _colorTableTexture;
  67860. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67861. }
  67862. }
  67863. declare module BABYLON {
  67864. /** @hidden */
  67865. export var convolutionPixelShader: {
  67866. name: string;
  67867. shader: string;
  67868. };
  67869. }
  67870. declare module BABYLON {
  67871. /**
  67872. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67873. * input texture to perform effects such as edge detection or sharpening
  67874. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67875. */
  67876. export class ConvolutionPostProcess extends PostProcess {
  67877. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67878. kernel: number[];
  67879. /**
  67880. * Creates a new instance ConvolutionPostProcess
  67881. * @param name The name of the effect.
  67882. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67883. * @param options The required width/height ratio to downsize to before computing the render pass.
  67884. * @param camera The camera to apply the render pass to.
  67885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67886. * @param engine The engine which the post process will be applied. (default: current engine)
  67887. * @param reusable If the post process can be reused on the same frame. (default: false)
  67888. * @param textureType Type of textures used when performing the post process. (default: 0)
  67889. */
  67890. constructor(name: string,
  67891. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67892. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67893. /**
  67894. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67895. */
  67896. static EdgeDetect0Kernel: number[];
  67897. /**
  67898. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67899. */
  67900. static EdgeDetect1Kernel: number[];
  67901. /**
  67902. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67903. */
  67904. static EdgeDetect2Kernel: number[];
  67905. /**
  67906. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67907. */
  67908. static SharpenKernel: number[];
  67909. /**
  67910. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67911. */
  67912. static EmbossKernel: number[];
  67913. /**
  67914. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67915. */
  67916. static GaussianKernel: number[];
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67922. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67923. * based on samples that have a large difference in distance than the center pixel.
  67924. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67925. */
  67926. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67927. direction: Vector2;
  67928. /**
  67929. * Creates a new instance CircleOfConfusionPostProcess
  67930. * @param name The name of the effect.
  67931. * @param scene The scene the effect belongs to.
  67932. * @param direction The direction the blur should be applied.
  67933. * @param kernel The size of the kernel used to blur.
  67934. * @param options The required width/height ratio to downsize to before computing the render pass.
  67935. * @param camera The camera to apply the render pass to.
  67936. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67937. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67939. * @param engine The engine which the post process will be applied. (default: current engine)
  67940. * @param reusable If the post process can be reused on the same frame. (default: false)
  67941. * @param textureType Type of textures used when performing the post process. (default: 0)
  67942. * @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)
  67943. */
  67944. 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);
  67945. }
  67946. }
  67947. declare module BABYLON {
  67948. /** @hidden */
  67949. export var depthOfFieldMergePixelShader: {
  67950. name: string;
  67951. shader: string;
  67952. };
  67953. }
  67954. declare module BABYLON {
  67955. /**
  67956. * Options to be set when merging outputs from the default pipeline.
  67957. */
  67958. export class DepthOfFieldMergePostProcessOptions {
  67959. /**
  67960. * The original image to merge on top of
  67961. */
  67962. originalFromInput: PostProcess;
  67963. /**
  67964. * Parameters to perform the merge of the depth of field effect
  67965. */
  67966. depthOfField?: {
  67967. circleOfConfusion: PostProcess;
  67968. blurSteps: Array<PostProcess>;
  67969. };
  67970. /**
  67971. * Parameters to perform the merge of bloom effect
  67972. */
  67973. bloom?: {
  67974. blurred: PostProcess;
  67975. weight: number;
  67976. };
  67977. }
  67978. /**
  67979. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67980. */
  67981. export class DepthOfFieldMergePostProcess extends PostProcess {
  67982. private blurSteps;
  67983. /**
  67984. * Creates a new instance of DepthOfFieldMergePostProcess
  67985. * @param name The name of the effect.
  67986. * @param originalFromInput Post process which's input will be used for the merge.
  67987. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67988. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67989. * @param options The required width/height ratio to downsize to before computing the render pass.
  67990. * @param camera The camera to apply the render pass to.
  67991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67992. * @param engine The engine which the post process will be applied. (default: current engine)
  67993. * @param reusable If the post process can be reused on the same frame. (default: false)
  67994. * @param textureType Type of textures used when performing the post process. (default: 0)
  67995. * @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)
  67996. */
  67997. 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);
  67998. /**
  67999. * Updates the effect with the current post process compile time values and recompiles the shader.
  68000. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68001. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68002. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68003. * @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
  68004. * @param onCompiled Called when the shader has been compiled.
  68005. * @param onError Called if there is an error when compiling a shader.
  68006. */
  68007. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68008. }
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. * Specifies the level of max blur that should be applied when using the depth of field effect
  68013. */
  68014. export enum DepthOfFieldEffectBlurLevel {
  68015. /**
  68016. * Subtle blur
  68017. */
  68018. Low = 0,
  68019. /**
  68020. * Medium blur
  68021. */
  68022. Medium = 1,
  68023. /**
  68024. * Large blur
  68025. */
  68026. High = 2
  68027. }
  68028. /**
  68029. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68030. */
  68031. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68032. private _circleOfConfusion;
  68033. /**
  68034. * @hidden Internal, blurs from high to low
  68035. */
  68036. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68037. private _depthOfFieldBlurY;
  68038. private _dofMerge;
  68039. /**
  68040. * @hidden Internal post processes in depth of field effect
  68041. */
  68042. _effects: Array<PostProcess>;
  68043. /**
  68044. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68045. */
  68046. set focalLength(value: number);
  68047. get focalLength(): number;
  68048. /**
  68049. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68050. */
  68051. set fStop(value: number);
  68052. get fStop(): number;
  68053. /**
  68054. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68055. */
  68056. set focusDistance(value: number);
  68057. get focusDistance(): number;
  68058. /**
  68059. * 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.
  68060. */
  68061. set lensSize(value: number);
  68062. get lensSize(): number;
  68063. /**
  68064. * Creates a new instance DepthOfFieldEffect
  68065. * @param scene The scene the effect belongs to.
  68066. * @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.
  68067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68068. * @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)
  68069. */
  68070. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68071. /**
  68072. * Get the current class name of the current effet
  68073. * @returns "DepthOfFieldEffect"
  68074. */
  68075. getClassName(): string;
  68076. /**
  68077. * 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.
  68078. */
  68079. set depthTexture(value: RenderTargetTexture);
  68080. /**
  68081. * Disposes each of the internal effects for a given camera.
  68082. * @param camera The camera to dispose the effect on.
  68083. */
  68084. disposeEffects(camera: Camera): void;
  68085. /**
  68086. * @hidden Internal
  68087. */
  68088. _updateEffects(): void;
  68089. /**
  68090. * Internal
  68091. * @returns if all the contained post processes are ready.
  68092. * @hidden
  68093. */
  68094. _isReady(): boolean;
  68095. }
  68096. }
  68097. declare module BABYLON {
  68098. /** @hidden */
  68099. export var displayPassPixelShader: {
  68100. name: string;
  68101. shader: string;
  68102. };
  68103. }
  68104. declare module BABYLON {
  68105. /**
  68106. * DisplayPassPostProcess which produces an output the same as it's input
  68107. */
  68108. export class DisplayPassPostProcess extends PostProcess {
  68109. /**
  68110. * Creates the DisplayPassPostProcess
  68111. * @param name The name of the effect.
  68112. * @param options The required width/height ratio to downsize to before computing the render pass.
  68113. * @param camera The camera to apply the render pass to.
  68114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68115. * @param engine The engine which the post process will be applied. (default: current engine)
  68116. * @param reusable If the post process can be reused on the same frame. (default: false)
  68117. */
  68118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68119. }
  68120. }
  68121. declare module BABYLON {
  68122. /** @hidden */
  68123. export var filterPixelShader: {
  68124. name: string;
  68125. shader: string;
  68126. };
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * Applies a kernel filter to the image
  68131. */
  68132. export class FilterPostProcess extends PostProcess {
  68133. /** The matrix to be applied to the image */
  68134. kernelMatrix: Matrix;
  68135. /**
  68136. *
  68137. * @param name The name of the effect.
  68138. * @param kernelMatrix The matrix to be applied to the image
  68139. * @param options The required width/height ratio to downsize to before computing the render pass.
  68140. * @param camera The camera to apply the render pass to.
  68141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68142. * @param engine The engine which the post process will be applied. (default: current engine)
  68143. * @param reusable If the post process can be reused on the same frame. (default: false)
  68144. */
  68145. constructor(name: string,
  68146. /** The matrix to be applied to the image */
  68147. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68148. }
  68149. }
  68150. declare module BABYLON {
  68151. /** @hidden */
  68152. export var fxaaPixelShader: {
  68153. name: string;
  68154. shader: string;
  68155. };
  68156. }
  68157. declare module BABYLON {
  68158. /** @hidden */
  68159. export var fxaaVertexShader: {
  68160. name: string;
  68161. shader: string;
  68162. };
  68163. }
  68164. declare module BABYLON {
  68165. /**
  68166. * Fxaa post process
  68167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68168. */
  68169. export class FxaaPostProcess extends PostProcess {
  68170. /** @hidden */
  68171. texelWidth: number;
  68172. /** @hidden */
  68173. texelHeight: number;
  68174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68175. private _getDefines;
  68176. }
  68177. }
  68178. declare module BABYLON {
  68179. /** @hidden */
  68180. export var grainPixelShader: {
  68181. name: string;
  68182. shader: string;
  68183. };
  68184. }
  68185. declare module BABYLON {
  68186. /**
  68187. * The GrainPostProcess adds noise to the image at mid luminance levels
  68188. */
  68189. export class GrainPostProcess extends PostProcess {
  68190. /**
  68191. * The intensity of the grain added (default: 30)
  68192. */
  68193. intensity: number;
  68194. /**
  68195. * If the grain should be randomized on every frame
  68196. */
  68197. animated: boolean;
  68198. /**
  68199. * Creates a new instance of @see GrainPostProcess
  68200. * @param name The name of the effect.
  68201. * @param options The required width/height ratio to downsize to before computing the render pass.
  68202. * @param camera The camera to apply the render pass to.
  68203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68204. * @param engine The engine which the post process will be applied. (default: current engine)
  68205. * @param reusable If the post process can be reused on the same frame. (default: false)
  68206. * @param textureType Type of textures used when performing the post process. (default: 0)
  68207. * @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)
  68208. */
  68209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /** @hidden */
  68214. export var highlightsPixelShader: {
  68215. name: string;
  68216. shader: string;
  68217. };
  68218. }
  68219. declare module BABYLON {
  68220. /**
  68221. * Extracts highlights from the image
  68222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68223. */
  68224. export class HighlightsPostProcess extends PostProcess {
  68225. /**
  68226. * Extracts highlights from the image
  68227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68228. * @param name The name of the effect.
  68229. * @param options The required width/height ratio to downsize to before computing the render pass.
  68230. * @param camera The camera to apply the render pass to.
  68231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68232. * @param engine The engine which the post process will be applied. (default: current engine)
  68233. * @param reusable If the post process can be reused on the same frame. (default: false)
  68234. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68235. */
  68236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68237. }
  68238. }
  68239. declare module BABYLON {
  68240. /** @hidden */
  68241. export var mrtFragmentDeclaration: {
  68242. name: string;
  68243. shader: string;
  68244. };
  68245. }
  68246. declare module BABYLON {
  68247. /** @hidden */
  68248. export var geometryPixelShader: {
  68249. name: string;
  68250. shader: string;
  68251. };
  68252. }
  68253. declare module BABYLON {
  68254. /** @hidden */
  68255. export var geometryVertexShader: {
  68256. name: string;
  68257. shader: string;
  68258. };
  68259. }
  68260. declare module BABYLON {
  68261. /** @hidden */
  68262. interface ISavedTransformationMatrix {
  68263. world: Matrix;
  68264. viewProjection: Matrix;
  68265. }
  68266. /**
  68267. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68268. */
  68269. export class GeometryBufferRenderer {
  68270. /**
  68271. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68272. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68273. */
  68274. static readonly POSITION_TEXTURE_TYPE: number;
  68275. /**
  68276. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68277. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68278. */
  68279. static readonly VELOCITY_TEXTURE_TYPE: number;
  68280. /**
  68281. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68282. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68283. */
  68284. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68285. /**
  68286. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68287. * in order to compute objects velocities when enableVelocity is set to "true"
  68288. * @hidden
  68289. */
  68290. _previousTransformationMatrices: {
  68291. [index: number]: ISavedTransformationMatrix;
  68292. };
  68293. /**
  68294. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68295. * in order to compute objects velocities when enableVelocity is set to "true"
  68296. * @hidden
  68297. */
  68298. _previousBonesTransformationMatrices: {
  68299. [index: number]: Float32Array;
  68300. };
  68301. /**
  68302. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68303. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68304. */
  68305. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68306. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68307. renderTransparentMeshes: boolean;
  68308. private _scene;
  68309. private _multiRenderTarget;
  68310. private _ratio;
  68311. private _enablePosition;
  68312. private _enableVelocity;
  68313. private _enableReflectivity;
  68314. private _positionIndex;
  68315. private _velocityIndex;
  68316. private _reflectivityIndex;
  68317. protected _effect: Effect;
  68318. protected _cachedDefines: string;
  68319. /**
  68320. * Set the render list (meshes to be rendered) used in the G buffer.
  68321. */
  68322. set renderList(meshes: Mesh[]);
  68323. /**
  68324. * Gets wether or not G buffer are supported by the running hardware.
  68325. * This requires draw buffer supports
  68326. */
  68327. get isSupported(): boolean;
  68328. /**
  68329. * Returns the index of the given texture type in the G-Buffer textures array
  68330. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68331. * @returns the index of the given texture type in the G-Buffer textures array
  68332. */
  68333. getTextureIndex(textureType: number): number;
  68334. /**
  68335. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68336. */
  68337. get enablePosition(): boolean;
  68338. /**
  68339. * Sets whether or not objects positions are enabled for the G buffer.
  68340. */
  68341. set enablePosition(enable: boolean);
  68342. /**
  68343. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68344. */
  68345. get enableVelocity(): boolean;
  68346. /**
  68347. * Sets wether or not objects velocities are enabled for the G buffer.
  68348. */
  68349. set enableVelocity(enable: boolean);
  68350. /**
  68351. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68352. */
  68353. get enableReflectivity(): boolean;
  68354. /**
  68355. * Sets wether or not objects roughness are enabled for the G buffer.
  68356. */
  68357. set enableReflectivity(enable: boolean);
  68358. /**
  68359. * Gets the scene associated with the buffer.
  68360. */
  68361. get scene(): Scene;
  68362. /**
  68363. * Gets the ratio used by the buffer during its creation.
  68364. * How big is the buffer related to the main canvas.
  68365. */
  68366. get ratio(): number;
  68367. /** @hidden */
  68368. static _SceneComponentInitialization: (scene: Scene) => void;
  68369. /**
  68370. * Creates a new G Buffer for the scene
  68371. * @param scene The scene the buffer belongs to
  68372. * @param ratio How big is the buffer related to the main canvas.
  68373. */
  68374. constructor(scene: Scene, ratio?: number);
  68375. /**
  68376. * Checks wether everything is ready to render a submesh to the G buffer.
  68377. * @param subMesh the submesh to check readiness for
  68378. * @param useInstances is the mesh drawn using instance or not
  68379. * @returns true if ready otherwise false
  68380. */
  68381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68382. /**
  68383. * Gets the current underlying G Buffer.
  68384. * @returns the buffer
  68385. */
  68386. getGBuffer(): MultiRenderTarget;
  68387. /**
  68388. * Gets the number of samples used to render the buffer (anti aliasing).
  68389. */
  68390. get samples(): number;
  68391. /**
  68392. * Sets the number of samples used to render the buffer (anti aliasing).
  68393. */
  68394. set samples(value: number);
  68395. /**
  68396. * Disposes the renderer and frees up associated resources.
  68397. */
  68398. dispose(): void;
  68399. protected _createRenderTargets(): void;
  68400. private _copyBonesTransformationMatrices;
  68401. }
  68402. }
  68403. declare module BABYLON {
  68404. interface Scene {
  68405. /** @hidden (Backing field) */
  68406. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68407. /**
  68408. * Gets or Sets the current geometry buffer associated to the scene.
  68409. */
  68410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68411. /**
  68412. * Enables a GeometryBufferRender and associates it with the scene
  68413. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68414. * @returns the GeometryBufferRenderer
  68415. */
  68416. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68417. /**
  68418. * Disables the GeometryBufferRender associated with the scene
  68419. */
  68420. disableGeometryBufferRenderer(): void;
  68421. }
  68422. /**
  68423. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68424. * in several rendering techniques.
  68425. */
  68426. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68427. /**
  68428. * The component name helpful to identify the component in the list of scene components.
  68429. */
  68430. readonly name: string;
  68431. /**
  68432. * The scene the component belongs to.
  68433. */
  68434. scene: Scene;
  68435. /**
  68436. * Creates a new instance of the component for the given scene
  68437. * @param scene Defines the scene to register the component in
  68438. */
  68439. constructor(scene: Scene);
  68440. /**
  68441. * Registers the component in a given scene
  68442. */
  68443. register(): void;
  68444. /**
  68445. * Rebuilds the elements related to this component in case of
  68446. * context lost for instance.
  68447. */
  68448. rebuild(): void;
  68449. /**
  68450. * Disposes the component and the associated ressources
  68451. */
  68452. dispose(): void;
  68453. private _gatherRenderTargets;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /** @hidden */
  68458. export var motionBlurPixelShader: {
  68459. name: string;
  68460. shader: string;
  68461. };
  68462. }
  68463. declare module BABYLON {
  68464. /**
  68465. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68466. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68467. * As an example, all you have to do is to create the post-process:
  68468. * var mb = new BABYLON.MotionBlurPostProcess(
  68469. * 'mb', // The name of the effect.
  68470. * scene, // The scene containing the objects to blur according to their velocity.
  68471. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68472. * camera // The camera to apply the render pass to.
  68473. * );
  68474. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68475. */
  68476. export class MotionBlurPostProcess extends PostProcess {
  68477. /**
  68478. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68479. */
  68480. motionStrength: number;
  68481. /**
  68482. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68483. */
  68484. get motionBlurSamples(): number;
  68485. /**
  68486. * Sets the number of iterations to be used for motion blur quality
  68487. */
  68488. set motionBlurSamples(samples: number);
  68489. private _motionBlurSamples;
  68490. private _geometryBufferRenderer;
  68491. /**
  68492. * Creates a new instance MotionBlurPostProcess
  68493. * @param name The name of the effect.
  68494. * @param scene The scene containing the objects to blur according to their velocity.
  68495. * @param options The required width/height ratio to downsize to before computing the render pass.
  68496. * @param camera The camera to apply the render pass to.
  68497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68498. * @param engine The engine which the post process will be applied. (default: current engine)
  68499. * @param reusable If the post process can be reused on the same frame. (default: false)
  68500. * @param textureType Type of textures used when performing the post process. (default: 0)
  68501. * @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)
  68502. */
  68503. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68504. /**
  68505. * Excludes the given skinned mesh from computing bones velocities.
  68506. * 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.
  68507. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68508. */
  68509. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68510. /**
  68511. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68512. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68513. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68514. */
  68515. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68516. /**
  68517. * Disposes the post process.
  68518. * @param camera The camera to dispose the post process on.
  68519. */
  68520. dispose(camera?: Camera): void;
  68521. }
  68522. }
  68523. declare module BABYLON {
  68524. /** @hidden */
  68525. export var refractionPixelShader: {
  68526. name: string;
  68527. shader: string;
  68528. };
  68529. }
  68530. declare module BABYLON {
  68531. /**
  68532. * Post process which applies a refractin texture
  68533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68534. */
  68535. export class RefractionPostProcess extends PostProcess {
  68536. /** the base color of the refraction (used to taint the rendering) */
  68537. color: Color3;
  68538. /** simulated refraction depth */
  68539. depth: number;
  68540. /** the coefficient of the base color (0 to remove base color tainting) */
  68541. colorLevel: number;
  68542. private _refTexture;
  68543. private _ownRefractionTexture;
  68544. /**
  68545. * Gets or sets the refraction texture
  68546. * Please note that you are responsible for disposing the texture if you set it manually
  68547. */
  68548. get refractionTexture(): Texture;
  68549. set refractionTexture(value: Texture);
  68550. /**
  68551. * Initializes the RefractionPostProcess
  68552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68553. * @param name The name of the effect.
  68554. * @param refractionTextureUrl Url of the refraction texture to use
  68555. * @param color the base color of the refraction (used to taint the rendering)
  68556. * @param depth simulated refraction depth
  68557. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68558. * @param camera The camera to apply the render pass to.
  68559. * @param options The required width/height ratio to downsize to before computing the render pass.
  68560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68561. * @param engine The engine which the post process will be applied. (default: current engine)
  68562. * @param reusable If the post process can be reused on the same frame. (default: false)
  68563. */
  68564. constructor(name: string, refractionTextureUrl: string,
  68565. /** the base color of the refraction (used to taint the rendering) */
  68566. color: Color3,
  68567. /** simulated refraction depth */
  68568. depth: number,
  68569. /** the coefficient of the base color (0 to remove base color tainting) */
  68570. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68571. /**
  68572. * Disposes of the post process
  68573. * @param camera Camera to dispose post process on
  68574. */
  68575. dispose(camera: Camera): void;
  68576. }
  68577. }
  68578. declare module BABYLON {
  68579. /** @hidden */
  68580. export var sharpenPixelShader: {
  68581. name: string;
  68582. shader: string;
  68583. };
  68584. }
  68585. declare module BABYLON {
  68586. /**
  68587. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68588. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68589. */
  68590. export class SharpenPostProcess extends PostProcess {
  68591. /**
  68592. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68593. */
  68594. colorAmount: number;
  68595. /**
  68596. * How much sharpness should be applied (default: 0.3)
  68597. */
  68598. edgeAmount: number;
  68599. /**
  68600. * Creates a new instance ConvolutionPostProcess
  68601. * @param name The name of the effect.
  68602. * @param options The required width/height ratio to downsize to before computing the render pass.
  68603. * @param camera The camera to apply the render pass to.
  68604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68605. * @param engine The engine which the post process will be applied. (default: current engine)
  68606. * @param reusable If the post process can be reused on the same frame. (default: false)
  68607. * @param textureType Type of textures used when performing the post process. (default: 0)
  68608. * @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)
  68609. */
  68610. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68611. }
  68612. }
  68613. declare module BABYLON {
  68614. /**
  68615. * PostProcessRenderPipeline
  68616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68617. */
  68618. export class PostProcessRenderPipeline {
  68619. private engine;
  68620. private _renderEffects;
  68621. private _renderEffectsForIsolatedPass;
  68622. /**
  68623. * List of inspectable custom properties (used by the Inspector)
  68624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68625. */
  68626. inspectableCustomProperties: IInspectable[];
  68627. /**
  68628. * @hidden
  68629. */
  68630. protected _cameras: Camera[];
  68631. /** @hidden */
  68632. _name: string;
  68633. /**
  68634. * Gets pipeline name
  68635. */
  68636. get name(): string;
  68637. /** Gets the list of attached cameras */
  68638. get cameras(): Camera[];
  68639. /**
  68640. * Initializes a PostProcessRenderPipeline
  68641. * @param engine engine to add the pipeline to
  68642. * @param name name of the pipeline
  68643. */
  68644. constructor(engine: Engine, name: string);
  68645. /**
  68646. * Gets the class name
  68647. * @returns "PostProcessRenderPipeline"
  68648. */
  68649. getClassName(): string;
  68650. /**
  68651. * If all the render effects in the pipeline are supported
  68652. */
  68653. get isSupported(): boolean;
  68654. /**
  68655. * Adds an effect to the pipeline
  68656. * @param renderEffect the effect to add
  68657. */
  68658. addEffect(renderEffect: PostProcessRenderEffect): void;
  68659. /** @hidden */
  68660. _rebuild(): void;
  68661. /** @hidden */
  68662. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68663. /** @hidden */
  68664. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68665. /** @hidden */
  68666. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68667. /** @hidden */
  68668. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68669. /** @hidden */
  68670. _attachCameras(cameras: Camera, unique: boolean): void;
  68671. /** @hidden */
  68672. _attachCameras(cameras: Camera[], unique: boolean): void;
  68673. /** @hidden */
  68674. _detachCameras(cameras: Camera): void;
  68675. /** @hidden */
  68676. _detachCameras(cameras: Nullable<Camera[]>): void;
  68677. /** @hidden */
  68678. _update(): void;
  68679. /** @hidden */
  68680. _reset(): void;
  68681. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68682. /**
  68683. * Disposes of the pipeline
  68684. */
  68685. dispose(): void;
  68686. }
  68687. }
  68688. declare module BABYLON {
  68689. /**
  68690. * PostProcessRenderPipelineManager class
  68691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68692. */
  68693. export class PostProcessRenderPipelineManager {
  68694. private _renderPipelines;
  68695. /**
  68696. * Initializes a PostProcessRenderPipelineManager
  68697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68698. */
  68699. constructor();
  68700. /**
  68701. * Gets the list of supported render pipelines
  68702. */
  68703. get supportedPipelines(): PostProcessRenderPipeline[];
  68704. /**
  68705. * Adds a pipeline to the manager
  68706. * @param renderPipeline The pipeline to add
  68707. */
  68708. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68709. /**
  68710. * Attaches a camera to the pipeline
  68711. * @param renderPipelineName The name of the pipeline to attach to
  68712. * @param cameras the camera to attach
  68713. * @param unique if the camera can be attached multiple times to the pipeline
  68714. */
  68715. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68716. /**
  68717. * Detaches a camera from the pipeline
  68718. * @param renderPipelineName The name of the pipeline to detach from
  68719. * @param cameras the camera to detach
  68720. */
  68721. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68722. /**
  68723. * Enables an effect by name on a pipeline
  68724. * @param renderPipelineName the name of the pipeline to enable the effect in
  68725. * @param renderEffectName the name of the effect to enable
  68726. * @param cameras the cameras that the effect should be enabled on
  68727. */
  68728. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68729. /**
  68730. * Disables an effect by name on a pipeline
  68731. * @param renderPipelineName the name of the pipeline to disable the effect in
  68732. * @param renderEffectName the name of the effect to disable
  68733. * @param cameras the cameras that the effect should be disabled on
  68734. */
  68735. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68736. /**
  68737. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68738. */
  68739. update(): void;
  68740. /** @hidden */
  68741. _rebuild(): void;
  68742. /**
  68743. * Disposes of the manager and pipelines
  68744. */
  68745. dispose(): void;
  68746. }
  68747. }
  68748. declare module BABYLON {
  68749. interface Scene {
  68750. /** @hidden (Backing field) */
  68751. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68752. /**
  68753. * Gets the postprocess render pipeline manager
  68754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68755. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68756. */
  68757. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68758. }
  68759. /**
  68760. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68761. */
  68762. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68763. /**
  68764. * The component name helpfull to identify the component in the list of scene components.
  68765. */
  68766. readonly name: string;
  68767. /**
  68768. * The scene the component belongs to.
  68769. */
  68770. scene: Scene;
  68771. /**
  68772. * Creates a new instance of the component for the given scene
  68773. * @param scene Defines the scene to register the component in
  68774. */
  68775. constructor(scene: Scene);
  68776. /**
  68777. * Registers the component in a given scene
  68778. */
  68779. register(): void;
  68780. /**
  68781. * Rebuilds the elements related to this component in case of
  68782. * context lost for instance.
  68783. */
  68784. rebuild(): void;
  68785. /**
  68786. * Disposes the component and the associated ressources
  68787. */
  68788. dispose(): void;
  68789. private _gatherRenderTargets;
  68790. }
  68791. }
  68792. declare module BABYLON {
  68793. /**
  68794. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68795. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68796. */
  68797. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68798. private _scene;
  68799. private _camerasToBeAttached;
  68800. /**
  68801. * ID of the sharpen post process,
  68802. */
  68803. private readonly SharpenPostProcessId;
  68804. /**
  68805. * @ignore
  68806. * ID of the image processing post process;
  68807. */
  68808. readonly ImageProcessingPostProcessId: string;
  68809. /**
  68810. * @ignore
  68811. * ID of the Fast Approximate Anti-Aliasing post process;
  68812. */
  68813. readonly FxaaPostProcessId: string;
  68814. /**
  68815. * ID of the chromatic aberration post process,
  68816. */
  68817. private readonly ChromaticAberrationPostProcessId;
  68818. /**
  68819. * ID of the grain post process
  68820. */
  68821. private readonly GrainPostProcessId;
  68822. /**
  68823. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68824. */
  68825. sharpen: SharpenPostProcess;
  68826. private _sharpenEffect;
  68827. private bloom;
  68828. /**
  68829. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68830. */
  68831. depthOfField: DepthOfFieldEffect;
  68832. /**
  68833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68834. */
  68835. fxaa: FxaaPostProcess;
  68836. /**
  68837. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68838. */
  68839. imageProcessing: ImageProcessingPostProcess;
  68840. /**
  68841. * Chromatic aberration post process which will shift rgb colors in the image
  68842. */
  68843. chromaticAberration: ChromaticAberrationPostProcess;
  68844. private _chromaticAberrationEffect;
  68845. /**
  68846. * Grain post process which add noise to the image
  68847. */
  68848. grain: GrainPostProcess;
  68849. private _grainEffect;
  68850. /**
  68851. * Glow post process which adds a glow to emissive areas of the image
  68852. */
  68853. private _glowLayer;
  68854. /**
  68855. * Animations which can be used to tweak settings over a period of time
  68856. */
  68857. animations: Animation[];
  68858. private _imageProcessingConfigurationObserver;
  68859. private _sharpenEnabled;
  68860. private _bloomEnabled;
  68861. private _depthOfFieldEnabled;
  68862. private _depthOfFieldBlurLevel;
  68863. private _fxaaEnabled;
  68864. private _imageProcessingEnabled;
  68865. private _defaultPipelineTextureType;
  68866. private _bloomScale;
  68867. private _chromaticAberrationEnabled;
  68868. private _grainEnabled;
  68869. private _buildAllowed;
  68870. /**
  68871. * Gets active scene
  68872. */
  68873. get scene(): Scene;
  68874. /**
  68875. * Enable or disable the sharpen process from the pipeline
  68876. */
  68877. set sharpenEnabled(enabled: boolean);
  68878. get sharpenEnabled(): boolean;
  68879. private _resizeObserver;
  68880. private _hardwareScaleLevel;
  68881. private _bloomKernel;
  68882. /**
  68883. * Specifies the size of the bloom blur kernel, relative to the final output size
  68884. */
  68885. get bloomKernel(): number;
  68886. set bloomKernel(value: number);
  68887. /**
  68888. * Specifies the weight of the bloom in the final rendering
  68889. */
  68890. private _bloomWeight;
  68891. /**
  68892. * Specifies the luma threshold for the area that will be blurred by the bloom
  68893. */
  68894. private _bloomThreshold;
  68895. private _hdr;
  68896. /**
  68897. * The strength of the bloom.
  68898. */
  68899. set bloomWeight(value: number);
  68900. get bloomWeight(): number;
  68901. /**
  68902. * The strength of the bloom.
  68903. */
  68904. set bloomThreshold(value: number);
  68905. get bloomThreshold(): number;
  68906. /**
  68907. * The scale of the bloom, lower value will provide better performance.
  68908. */
  68909. set bloomScale(value: number);
  68910. get bloomScale(): number;
  68911. /**
  68912. * Enable or disable the bloom from the pipeline
  68913. */
  68914. set bloomEnabled(enabled: boolean);
  68915. get bloomEnabled(): boolean;
  68916. private _rebuildBloom;
  68917. /**
  68918. * If the depth of field is enabled.
  68919. */
  68920. get depthOfFieldEnabled(): boolean;
  68921. set depthOfFieldEnabled(enabled: boolean);
  68922. /**
  68923. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68924. */
  68925. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68926. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68927. /**
  68928. * If the anti aliasing is enabled.
  68929. */
  68930. set fxaaEnabled(enabled: boolean);
  68931. get fxaaEnabled(): boolean;
  68932. private _samples;
  68933. /**
  68934. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68935. */
  68936. set samples(sampleCount: number);
  68937. get samples(): number;
  68938. /**
  68939. * If image processing is enabled.
  68940. */
  68941. set imageProcessingEnabled(enabled: boolean);
  68942. get imageProcessingEnabled(): boolean;
  68943. /**
  68944. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68945. */
  68946. set glowLayerEnabled(enabled: boolean);
  68947. get glowLayerEnabled(): boolean;
  68948. /**
  68949. * Gets the glow layer (or null if not defined)
  68950. */
  68951. get glowLayer(): Nullable<GlowLayer>;
  68952. /**
  68953. * Enable or disable the chromaticAberration process from the pipeline
  68954. */
  68955. set chromaticAberrationEnabled(enabled: boolean);
  68956. get chromaticAberrationEnabled(): boolean;
  68957. /**
  68958. * Enable or disable the grain process from the pipeline
  68959. */
  68960. set grainEnabled(enabled: boolean);
  68961. get grainEnabled(): boolean;
  68962. /**
  68963. * @constructor
  68964. * @param name - The rendering pipeline name (default: "")
  68965. * @param hdr - If high dynamic range textures should be used (default: true)
  68966. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68967. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68968. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68969. */
  68970. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68971. /**
  68972. * Get the class name
  68973. * @returns "DefaultRenderingPipeline"
  68974. */
  68975. getClassName(): string;
  68976. /**
  68977. * Force the compilation of the entire pipeline.
  68978. */
  68979. prepare(): void;
  68980. private _hasCleared;
  68981. private _prevPostProcess;
  68982. private _prevPrevPostProcess;
  68983. private _setAutoClearAndTextureSharing;
  68984. private _depthOfFieldSceneObserver;
  68985. private _buildPipeline;
  68986. private _disposePostProcesses;
  68987. /**
  68988. * Adds a camera to the pipeline
  68989. * @param camera the camera to be added
  68990. */
  68991. addCamera(camera: Camera): void;
  68992. /**
  68993. * Removes a camera from the pipeline
  68994. * @param camera the camera to remove
  68995. */
  68996. removeCamera(camera: Camera): void;
  68997. /**
  68998. * Dispose of the pipeline and stop all post processes
  68999. */
  69000. dispose(): void;
  69001. /**
  69002. * Serialize the rendering pipeline (Used when exporting)
  69003. * @returns the serialized object
  69004. */
  69005. serialize(): any;
  69006. /**
  69007. * Parse the serialized pipeline
  69008. * @param source Source pipeline.
  69009. * @param scene The scene to load the pipeline to.
  69010. * @param rootUrl The URL of the serialized pipeline.
  69011. * @returns An instantiated pipeline from the serialized object.
  69012. */
  69013. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69014. }
  69015. }
  69016. declare module BABYLON {
  69017. /** @hidden */
  69018. export var lensHighlightsPixelShader: {
  69019. name: string;
  69020. shader: string;
  69021. };
  69022. }
  69023. declare module BABYLON {
  69024. /** @hidden */
  69025. export var depthOfFieldPixelShader: {
  69026. name: string;
  69027. shader: string;
  69028. };
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * BABYLON.JS Chromatic Aberration GLSL Shader
  69033. * Author: Olivier Guyot
  69034. * Separates very slightly R, G and B colors on the edges of the screen
  69035. * Inspired by Francois Tarlier & Martins Upitis
  69036. */
  69037. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69038. /**
  69039. * @ignore
  69040. * The chromatic aberration PostProcess id in the pipeline
  69041. */
  69042. LensChromaticAberrationEffect: string;
  69043. /**
  69044. * @ignore
  69045. * The highlights enhancing PostProcess id in the pipeline
  69046. */
  69047. HighlightsEnhancingEffect: string;
  69048. /**
  69049. * @ignore
  69050. * The depth-of-field PostProcess id in the pipeline
  69051. */
  69052. LensDepthOfFieldEffect: string;
  69053. private _scene;
  69054. private _depthTexture;
  69055. private _grainTexture;
  69056. private _chromaticAberrationPostProcess;
  69057. private _highlightsPostProcess;
  69058. private _depthOfFieldPostProcess;
  69059. private _edgeBlur;
  69060. private _grainAmount;
  69061. private _chromaticAberration;
  69062. private _distortion;
  69063. private _highlightsGain;
  69064. private _highlightsThreshold;
  69065. private _dofDistance;
  69066. private _dofAperture;
  69067. private _dofDarken;
  69068. private _dofPentagon;
  69069. private _blurNoise;
  69070. /**
  69071. * @constructor
  69072. *
  69073. * Effect parameters are as follow:
  69074. * {
  69075. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69076. * edge_blur: number; // from 0 to x (1 for realism)
  69077. * distortion: number; // from 0 to x (1 for realism)
  69078. * grain_amount: number; // from 0 to 1
  69079. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69080. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69081. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69082. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69083. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69084. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69085. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69086. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69087. * }
  69088. * Note: if an effect parameter is unset, effect is disabled
  69089. *
  69090. * @param name The rendering pipeline name
  69091. * @param parameters - An object containing all parameters (see above)
  69092. * @param scene The scene linked to this pipeline
  69093. * @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)
  69094. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69095. */
  69096. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69097. /**
  69098. * Get the class name
  69099. * @returns "LensRenderingPipeline"
  69100. */
  69101. getClassName(): string;
  69102. /**
  69103. * Gets associated scene
  69104. */
  69105. get scene(): Scene;
  69106. /**
  69107. * Gets or sets the edge blur
  69108. */
  69109. get edgeBlur(): number;
  69110. set edgeBlur(value: number);
  69111. /**
  69112. * Gets or sets the grain amount
  69113. */
  69114. get grainAmount(): number;
  69115. set grainAmount(value: number);
  69116. /**
  69117. * Gets or sets the chromatic aberration amount
  69118. */
  69119. get chromaticAberration(): number;
  69120. set chromaticAberration(value: number);
  69121. /**
  69122. * Gets or sets the depth of field aperture
  69123. */
  69124. get dofAperture(): number;
  69125. set dofAperture(value: number);
  69126. /**
  69127. * Gets or sets the edge distortion
  69128. */
  69129. get edgeDistortion(): number;
  69130. set edgeDistortion(value: number);
  69131. /**
  69132. * Gets or sets the depth of field distortion
  69133. */
  69134. get dofDistortion(): number;
  69135. set dofDistortion(value: number);
  69136. /**
  69137. * Gets or sets the darken out of focus amount
  69138. */
  69139. get darkenOutOfFocus(): number;
  69140. set darkenOutOfFocus(value: number);
  69141. /**
  69142. * Gets or sets a boolean indicating if blur noise is enabled
  69143. */
  69144. get blurNoise(): boolean;
  69145. set blurNoise(value: boolean);
  69146. /**
  69147. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69148. */
  69149. get pentagonBokeh(): boolean;
  69150. set pentagonBokeh(value: boolean);
  69151. /**
  69152. * Gets or sets the highlight grain amount
  69153. */
  69154. get highlightsGain(): number;
  69155. set highlightsGain(value: number);
  69156. /**
  69157. * Gets or sets the highlight threshold
  69158. */
  69159. get highlightsThreshold(): number;
  69160. set highlightsThreshold(value: number);
  69161. /**
  69162. * Sets the amount of blur at the edges
  69163. * @param amount blur amount
  69164. */
  69165. setEdgeBlur(amount: number): void;
  69166. /**
  69167. * Sets edge blur to 0
  69168. */
  69169. disableEdgeBlur(): void;
  69170. /**
  69171. * Sets the amout of grain
  69172. * @param amount Amount of grain
  69173. */
  69174. setGrainAmount(amount: number): void;
  69175. /**
  69176. * Set grain amount to 0
  69177. */
  69178. disableGrain(): void;
  69179. /**
  69180. * Sets the chromatic aberration amount
  69181. * @param amount amount of chromatic aberration
  69182. */
  69183. setChromaticAberration(amount: number): void;
  69184. /**
  69185. * Sets chromatic aberration amount to 0
  69186. */
  69187. disableChromaticAberration(): void;
  69188. /**
  69189. * Sets the EdgeDistortion amount
  69190. * @param amount amount of EdgeDistortion
  69191. */
  69192. setEdgeDistortion(amount: number): void;
  69193. /**
  69194. * Sets edge distortion to 0
  69195. */
  69196. disableEdgeDistortion(): void;
  69197. /**
  69198. * Sets the FocusDistance amount
  69199. * @param amount amount of FocusDistance
  69200. */
  69201. setFocusDistance(amount: number): void;
  69202. /**
  69203. * Disables depth of field
  69204. */
  69205. disableDepthOfField(): void;
  69206. /**
  69207. * Sets the Aperture amount
  69208. * @param amount amount of Aperture
  69209. */
  69210. setAperture(amount: number): void;
  69211. /**
  69212. * Sets the DarkenOutOfFocus amount
  69213. * @param amount amount of DarkenOutOfFocus
  69214. */
  69215. setDarkenOutOfFocus(amount: number): void;
  69216. private _pentagonBokehIsEnabled;
  69217. /**
  69218. * Creates a pentagon bokeh effect
  69219. */
  69220. enablePentagonBokeh(): void;
  69221. /**
  69222. * Disables the pentagon bokeh effect
  69223. */
  69224. disablePentagonBokeh(): void;
  69225. /**
  69226. * Enables noise blur
  69227. */
  69228. enableNoiseBlur(): void;
  69229. /**
  69230. * Disables noise blur
  69231. */
  69232. disableNoiseBlur(): void;
  69233. /**
  69234. * Sets the HighlightsGain amount
  69235. * @param amount amount of HighlightsGain
  69236. */
  69237. setHighlightsGain(amount: number): void;
  69238. /**
  69239. * Sets the HighlightsThreshold amount
  69240. * @param amount amount of HighlightsThreshold
  69241. */
  69242. setHighlightsThreshold(amount: number): void;
  69243. /**
  69244. * Disables highlights
  69245. */
  69246. disableHighlights(): void;
  69247. /**
  69248. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69249. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69250. */
  69251. dispose(disableDepthRender?: boolean): void;
  69252. private _createChromaticAberrationPostProcess;
  69253. private _createHighlightsPostProcess;
  69254. private _createDepthOfFieldPostProcess;
  69255. private _createGrainTexture;
  69256. }
  69257. }
  69258. declare module BABYLON {
  69259. /** @hidden */
  69260. export var ssao2PixelShader: {
  69261. name: string;
  69262. shader: string;
  69263. };
  69264. }
  69265. declare module BABYLON {
  69266. /** @hidden */
  69267. export var ssaoCombinePixelShader: {
  69268. name: string;
  69269. shader: string;
  69270. };
  69271. }
  69272. declare module BABYLON {
  69273. /**
  69274. * Render pipeline to produce ssao effect
  69275. */
  69276. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69277. /**
  69278. * @ignore
  69279. * The PassPostProcess id in the pipeline that contains the original scene color
  69280. */
  69281. SSAOOriginalSceneColorEffect: string;
  69282. /**
  69283. * @ignore
  69284. * The SSAO PostProcess id in the pipeline
  69285. */
  69286. SSAORenderEffect: string;
  69287. /**
  69288. * @ignore
  69289. * The horizontal blur PostProcess id in the pipeline
  69290. */
  69291. SSAOBlurHRenderEffect: string;
  69292. /**
  69293. * @ignore
  69294. * The vertical blur PostProcess id in the pipeline
  69295. */
  69296. SSAOBlurVRenderEffect: string;
  69297. /**
  69298. * @ignore
  69299. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69300. */
  69301. SSAOCombineRenderEffect: string;
  69302. /**
  69303. * The output strength of the SSAO post-process. Default value is 1.0.
  69304. */
  69305. totalStrength: number;
  69306. /**
  69307. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69308. */
  69309. maxZ: number;
  69310. /**
  69311. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69312. */
  69313. minZAspect: number;
  69314. private _samples;
  69315. /**
  69316. * Number of samples used for the SSAO calculations. Default value is 8
  69317. */
  69318. set samples(n: number);
  69319. get samples(): number;
  69320. private _textureSamples;
  69321. /**
  69322. * Number of samples to use for antialiasing
  69323. */
  69324. set textureSamples(n: number);
  69325. get textureSamples(): number;
  69326. /**
  69327. * Ratio object used for SSAO ratio and blur ratio
  69328. */
  69329. private _ratio;
  69330. /**
  69331. * Dynamically generated sphere sampler.
  69332. */
  69333. private _sampleSphere;
  69334. /**
  69335. * Blur filter offsets
  69336. */
  69337. private _samplerOffsets;
  69338. private _expensiveBlur;
  69339. /**
  69340. * If bilateral blur should be used
  69341. */
  69342. set expensiveBlur(b: boolean);
  69343. get expensiveBlur(): boolean;
  69344. /**
  69345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69346. */
  69347. radius: number;
  69348. /**
  69349. * The base color of the SSAO post-process
  69350. * The final result is "base + ssao" between [0, 1]
  69351. */
  69352. base: number;
  69353. /**
  69354. * Support test.
  69355. */
  69356. static get IsSupported(): boolean;
  69357. private _scene;
  69358. private _depthTexture;
  69359. private _normalTexture;
  69360. private _randomTexture;
  69361. private _originalColorPostProcess;
  69362. private _ssaoPostProcess;
  69363. private _blurHPostProcess;
  69364. private _blurVPostProcess;
  69365. private _ssaoCombinePostProcess;
  69366. /**
  69367. * Gets active scene
  69368. */
  69369. get scene(): Scene;
  69370. /**
  69371. * @constructor
  69372. * @param name The rendering pipeline name
  69373. * @param scene The scene linked to this pipeline
  69374. * @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 }
  69375. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69376. */
  69377. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69378. /**
  69379. * Get the class name
  69380. * @returns "SSAO2RenderingPipeline"
  69381. */
  69382. getClassName(): string;
  69383. /**
  69384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69385. */
  69386. dispose(disableGeometryBufferRenderer?: boolean): void;
  69387. private _createBlurPostProcess;
  69388. /** @hidden */
  69389. _rebuild(): void;
  69390. private _bits;
  69391. private _radicalInverse_VdC;
  69392. private _hammersley;
  69393. private _hemisphereSample_uniform;
  69394. private _generateHemisphere;
  69395. private _createSSAOPostProcess;
  69396. private _createSSAOCombinePostProcess;
  69397. private _createRandomTexture;
  69398. /**
  69399. * Serialize the rendering pipeline (Used when exporting)
  69400. * @returns the serialized object
  69401. */
  69402. serialize(): any;
  69403. /**
  69404. * Parse the serialized pipeline
  69405. * @param source Source pipeline.
  69406. * @param scene The scene to load the pipeline to.
  69407. * @param rootUrl The URL of the serialized pipeline.
  69408. * @returns An instantiated pipeline from the serialized object.
  69409. */
  69410. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69411. }
  69412. }
  69413. declare module BABYLON {
  69414. /** @hidden */
  69415. export var ssaoPixelShader: {
  69416. name: string;
  69417. shader: string;
  69418. };
  69419. }
  69420. declare module BABYLON {
  69421. /**
  69422. * Render pipeline to produce ssao effect
  69423. */
  69424. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69425. /**
  69426. * @ignore
  69427. * The PassPostProcess id in the pipeline that contains the original scene color
  69428. */
  69429. SSAOOriginalSceneColorEffect: string;
  69430. /**
  69431. * @ignore
  69432. * The SSAO PostProcess id in the pipeline
  69433. */
  69434. SSAORenderEffect: string;
  69435. /**
  69436. * @ignore
  69437. * The horizontal blur PostProcess id in the pipeline
  69438. */
  69439. SSAOBlurHRenderEffect: string;
  69440. /**
  69441. * @ignore
  69442. * The vertical blur PostProcess id in the pipeline
  69443. */
  69444. SSAOBlurVRenderEffect: string;
  69445. /**
  69446. * @ignore
  69447. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69448. */
  69449. SSAOCombineRenderEffect: string;
  69450. /**
  69451. * The output strength of the SSAO post-process. Default value is 1.0.
  69452. */
  69453. totalStrength: number;
  69454. /**
  69455. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69456. */
  69457. radius: number;
  69458. /**
  69459. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69460. * Must not be equal to fallOff and superior to fallOff.
  69461. * Default value is 0.0075
  69462. */
  69463. area: number;
  69464. /**
  69465. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69466. * Must not be equal to area and inferior to area.
  69467. * Default value is 0.000001
  69468. */
  69469. fallOff: number;
  69470. /**
  69471. * The base color of the SSAO post-process
  69472. * The final result is "base + ssao" between [0, 1]
  69473. */
  69474. base: number;
  69475. private _scene;
  69476. private _depthTexture;
  69477. private _randomTexture;
  69478. private _originalColorPostProcess;
  69479. private _ssaoPostProcess;
  69480. private _blurHPostProcess;
  69481. private _blurVPostProcess;
  69482. private _ssaoCombinePostProcess;
  69483. private _firstUpdate;
  69484. /**
  69485. * Gets active scene
  69486. */
  69487. get scene(): Scene;
  69488. /**
  69489. * @constructor
  69490. * @param name - The rendering pipeline name
  69491. * @param scene - The scene linked to this pipeline
  69492. * @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 }
  69493. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69494. */
  69495. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69496. /**
  69497. * Get the class name
  69498. * @returns "SSAORenderingPipeline"
  69499. */
  69500. getClassName(): string;
  69501. /**
  69502. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69503. */
  69504. dispose(disableDepthRender?: boolean): void;
  69505. private _createBlurPostProcess;
  69506. /** @hidden */
  69507. _rebuild(): void;
  69508. private _createSSAOPostProcess;
  69509. private _createSSAOCombinePostProcess;
  69510. private _createRandomTexture;
  69511. }
  69512. }
  69513. declare module BABYLON {
  69514. /** @hidden */
  69515. export var screenSpaceReflectionPixelShader: {
  69516. name: string;
  69517. shader: string;
  69518. };
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69523. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69524. */
  69525. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69526. /**
  69527. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69528. */
  69529. threshold: number;
  69530. /**
  69531. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69532. */
  69533. strength: number;
  69534. /**
  69535. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69536. */
  69537. reflectionSpecularFalloffExponent: number;
  69538. /**
  69539. * 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]
  69540. */
  69541. step: number;
  69542. /**
  69543. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69544. */
  69545. roughnessFactor: number;
  69546. private _geometryBufferRenderer;
  69547. private _enableSmoothReflections;
  69548. private _reflectionSamples;
  69549. private _smoothSteps;
  69550. /**
  69551. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69552. * @param name The name of the effect.
  69553. * @param scene The scene containing the objects to calculate reflections.
  69554. * @param options The required width/height ratio to downsize to before computing the render pass.
  69555. * @param camera The camera to apply the render pass to.
  69556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69557. * @param engine The engine which the post process will be applied. (default: current engine)
  69558. * @param reusable If the post process can be reused on the same frame. (default: false)
  69559. * @param textureType Type of textures used when performing the post process. (default: 0)
  69560. * @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)
  69561. */
  69562. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69563. /**
  69564. * Gets wether or not smoothing reflections is enabled.
  69565. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69566. */
  69567. get enableSmoothReflections(): boolean;
  69568. /**
  69569. * Sets wether or not smoothing reflections is enabled.
  69570. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69571. */
  69572. set enableSmoothReflections(enabled: boolean);
  69573. /**
  69574. * Gets the number of samples taken while computing reflections. More samples count is high,
  69575. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69576. */
  69577. get reflectionSamples(): number;
  69578. /**
  69579. * Sets the number of samples taken while computing reflections. More samples count is high,
  69580. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69581. */
  69582. set reflectionSamples(samples: number);
  69583. /**
  69584. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69585. * more the post-process will require GPU power and can generate a drop in FPS.
  69586. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69587. */
  69588. get smoothSteps(): number;
  69589. set smoothSteps(steps: number);
  69590. private _updateEffectDefines;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export var standardPixelShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module BABYLON {
  69601. /**
  69602. * Standard rendering pipeline
  69603. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69604. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69605. */
  69606. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69607. /**
  69608. * Public members
  69609. */
  69610. /**
  69611. * Post-process which contains the original scene color before the pipeline applies all the effects
  69612. */
  69613. originalPostProcess: Nullable<PostProcess>;
  69614. /**
  69615. * Post-process used to down scale an image x4
  69616. */
  69617. downSampleX4PostProcess: Nullable<PostProcess>;
  69618. /**
  69619. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69620. */
  69621. brightPassPostProcess: Nullable<PostProcess>;
  69622. /**
  69623. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69624. */
  69625. blurHPostProcesses: PostProcess[];
  69626. /**
  69627. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69628. */
  69629. blurVPostProcesses: PostProcess[];
  69630. /**
  69631. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69632. */
  69633. textureAdderPostProcess: Nullable<PostProcess>;
  69634. /**
  69635. * Post-process used to create volumetric lighting effect
  69636. */
  69637. volumetricLightPostProcess: Nullable<PostProcess>;
  69638. /**
  69639. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69640. */
  69641. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69642. /**
  69643. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69644. */
  69645. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69646. /**
  69647. * Post-process used to merge the volumetric light effect and the real scene color
  69648. */
  69649. volumetricLightMergePostProces: Nullable<PostProcess>;
  69650. /**
  69651. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69652. */
  69653. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69654. /**
  69655. * Base post-process used to calculate the average luminance of the final image for HDR
  69656. */
  69657. luminancePostProcess: Nullable<PostProcess>;
  69658. /**
  69659. * Post-processes used to create down sample post-processes in order to get
  69660. * the average luminance of the final image for HDR
  69661. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69662. */
  69663. luminanceDownSamplePostProcesses: PostProcess[];
  69664. /**
  69665. * Post-process used to create a HDR effect (light adaptation)
  69666. */
  69667. hdrPostProcess: Nullable<PostProcess>;
  69668. /**
  69669. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69670. */
  69671. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69672. /**
  69673. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69674. */
  69675. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69676. /**
  69677. * Post-process used to merge the final HDR post-process and the real scene color
  69678. */
  69679. hdrFinalPostProcess: Nullable<PostProcess>;
  69680. /**
  69681. * Post-process used to create a lens flare effect
  69682. */
  69683. lensFlarePostProcess: Nullable<PostProcess>;
  69684. /**
  69685. * Post-process that merges the result of the lens flare post-process and the real scene color
  69686. */
  69687. lensFlareComposePostProcess: Nullable<PostProcess>;
  69688. /**
  69689. * Post-process used to create a motion blur effect
  69690. */
  69691. motionBlurPostProcess: Nullable<PostProcess>;
  69692. /**
  69693. * Post-process used to create a depth of field effect
  69694. */
  69695. depthOfFieldPostProcess: Nullable<PostProcess>;
  69696. /**
  69697. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69698. */
  69699. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69700. /**
  69701. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69702. */
  69703. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69704. /**
  69705. * Represents the brightness threshold in order to configure the illuminated surfaces
  69706. */
  69707. brightThreshold: number;
  69708. /**
  69709. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69710. */
  69711. blurWidth: number;
  69712. /**
  69713. * Sets if the blur for highlighted surfaces must be only horizontal
  69714. */
  69715. horizontalBlur: boolean;
  69716. /**
  69717. * Gets the overall exposure used by the pipeline
  69718. */
  69719. get exposure(): number;
  69720. /**
  69721. * Sets the overall exposure used by the pipeline
  69722. */
  69723. set exposure(value: number);
  69724. /**
  69725. * Texture used typically to simulate "dirty" on camera lens
  69726. */
  69727. lensTexture: Nullable<Texture>;
  69728. /**
  69729. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69730. */
  69731. volumetricLightCoefficient: number;
  69732. /**
  69733. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69734. */
  69735. volumetricLightPower: number;
  69736. /**
  69737. * Used the set the blur intensity to smooth the volumetric lights
  69738. */
  69739. volumetricLightBlurScale: number;
  69740. /**
  69741. * Light (spot or directional) used to generate the volumetric lights rays
  69742. * The source light must have a shadow generate so the pipeline can get its
  69743. * depth map
  69744. */
  69745. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69746. /**
  69747. * For eye adaptation, represents the minimum luminance the eye can see
  69748. */
  69749. hdrMinimumLuminance: number;
  69750. /**
  69751. * For eye adaptation, represents the decrease luminance speed
  69752. */
  69753. hdrDecreaseRate: number;
  69754. /**
  69755. * For eye adaptation, represents the increase luminance speed
  69756. */
  69757. hdrIncreaseRate: number;
  69758. /**
  69759. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69760. */
  69761. get hdrAutoExposure(): boolean;
  69762. /**
  69763. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69764. */
  69765. set hdrAutoExposure(value: boolean);
  69766. /**
  69767. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69768. */
  69769. lensColorTexture: Nullable<Texture>;
  69770. /**
  69771. * The overall strengh for the lens flare effect
  69772. */
  69773. lensFlareStrength: number;
  69774. /**
  69775. * Dispersion coefficient for lens flare ghosts
  69776. */
  69777. lensFlareGhostDispersal: number;
  69778. /**
  69779. * Main lens flare halo width
  69780. */
  69781. lensFlareHaloWidth: number;
  69782. /**
  69783. * Based on the lens distortion effect, defines how much the lens flare result
  69784. * is distorted
  69785. */
  69786. lensFlareDistortionStrength: number;
  69787. /**
  69788. * Configures the blur intensity used for for lens flare (halo)
  69789. */
  69790. lensFlareBlurWidth: number;
  69791. /**
  69792. * Lens star texture must be used to simulate rays on the flares and is available
  69793. * in the documentation
  69794. */
  69795. lensStarTexture: Nullable<Texture>;
  69796. /**
  69797. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69798. * flare effect by taking account of the dirt texture
  69799. */
  69800. lensFlareDirtTexture: Nullable<Texture>;
  69801. /**
  69802. * Represents the focal length for the depth of field effect
  69803. */
  69804. depthOfFieldDistance: number;
  69805. /**
  69806. * Represents the blur intensity for the blurred part of the depth of field effect
  69807. */
  69808. depthOfFieldBlurWidth: number;
  69809. /**
  69810. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69811. */
  69812. get motionStrength(): number;
  69813. /**
  69814. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69815. */
  69816. set motionStrength(strength: number);
  69817. /**
  69818. * Gets wether or not the motion blur post-process is object based or screen based.
  69819. */
  69820. get objectBasedMotionBlur(): boolean;
  69821. /**
  69822. * Sets wether or not the motion blur post-process should be object based or screen based
  69823. */
  69824. set objectBasedMotionBlur(value: boolean);
  69825. /**
  69826. * List of animations for the pipeline (IAnimatable implementation)
  69827. */
  69828. animations: Animation[];
  69829. /**
  69830. * Private members
  69831. */
  69832. private _scene;
  69833. private _currentDepthOfFieldSource;
  69834. private _basePostProcess;
  69835. private _fixedExposure;
  69836. private _currentExposure;
  69837. private _hdrAutoExposure;
  69838. private _hdrCurrentLuminance;
  69839. private _motionStrength;
  69840. private _isObjectBasedMotionBlur;
  69841. private _floatTextureType;
  69842. private _camerasToBeAttached;
  69843. private _ratio;
  69844. private _bloomEnabled;
  69845. private _depthOfFieldEnabled;
  69846. private _vlsEnabled;
  69847. private _lensFlareEnabled;
  69848. private _hdrEnabled;
  69849. private _motionBlurEnabled;
  69850. private _fxaaEnabled;
  69851. private _screenSpaceReflectionsEnabled;
  69852. private _motionBlurSamples;
  69853. private _volumetricLightStepsCount;
  69854. private _samples;
  69855. /**
  69856. * @ignore
  69857. * Specifies if the bloom pipeline is enabled
  69858. */
  69859. get BloomEnabled(): boolean;
  69860. set BloomEnabled(enabled: boolean);
  69861. /**
  69862. * @ignore
  69863. * Specifies if the depth of field pipeline is enabed
  69864. */
  69865. get DepthOfFieldEnabled(): boolean;
  69866. set DepthOfFieldEnabled(enabled: boolean);
  69867. /**
  69868. * @ignore
  69869. * Specifies if the lens flare pipeline is enabed
  69870. */
  69871. get LensFlareEnabled(): boolean;
  69872. set LensFlareEnabled(enabled: boolean);
  69873. /**
  69874. * @ignore
  69875. * Specifies if the HDR pipeline is enabled
  69876. */
  69877. get HDREnabled(): boolean;
  69878. set HDREnabled(enabled: boolean);
  69879. /**
  69880. * @ignore
  69881. * Specifies if the volumetric lights scattering effect is enabled
  69882. */
  69883. get VLSEnabled(): boolean;
  69884. set VLSEnabled(enabled: boolean);
  69885. /**
  69886. * @ignore
  69887. * Specifies if the motion blur effect is enabled
  69888. */
  69889. get MotionBlurEnabled(): boolean;
  69890. set MotionBlurEnabled(enabled: boolean);
  69891. /**
  69892. * Specifies if anti-aliasing is enabled
  69893. */
  69894. get fxaaEnabled(): boolean;
  69895. set fxaaEnabled(enabled: boolean);
  69896. /**
  69897. * Specifies if screen space reflections are enabled.
  69898. */
  69899. get screenSpaceReflectionsEnabled(): boolean;
  69900. set screenSpaceReflectionsEnabled(enabled: boolean);
  69901. /**
  69902. * Specifies the number of steps used to calculate the volumetric lights
  69903. * Typically in interval [50, 200]
  69904. */
  69905. get volumetricLightStepsCount(): number;
  69906. set volumetricLightStepsCount(count: number);
  69907. /**
  69908. * Specifies the number of samples used for the motion blur effect
  69909. * Typically in interval [16, 64]
  69910. */
  69911. get motionBlurSamples(): number;
  69912. set motionBlurSamples(samples: number);
  69913. /**
  69914. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69915. */
  69916. get samples(): number;
  69917. set samples(sampleCount: number);
  69918. /**
  69919. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69920. * @constructor
  69921. * @param name The rendering pipeline name
  69922. * @param scene The scene linked to this pipeline
  69923. * @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)
  69924. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69925. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69926. */
  69927. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69928. private _buildPipeline;
  69929. private _createDownSampleX4PostProcess;
  69930. private _createBrightPassPostProcess;
  69931. private _createBlurPostProcesses;
  69932. private _createTextureAdderPostProcess;
  69933. private _createVolumetricLightPostProcess;
  69934. private _createLuminancePostProcesses;
  69935. private _createHdrPostProcess;
  69936. private _createLensFlarePostProcess;
  69937. private _createDepthOfFieldPostProcess;
  69938. private _createMotionBlurPostProcess;
  69939. private _getDepthTexture;
  69940. private _disposePostProcesses;
  69941. /**
  69942. * Dispose of the pipeline and stop all post processes
  69943. */
  69944. dispose(): void;
  69945. /**
  69946. * Serialize the rendering pipeline (Used when exporting)
  69947. * @returns the serialized object
  69948. */
  69949. serialize(): any;
  69950. /**
  69951. * Parse the serialized pipeline
  69952. * @param source Source pipeline.
  69953. * @param scene The scene to load the pipeline to.
  69954. * @param rootUrl The URL of the serialized pipeline.
  69955. * @returns An instantiated pipeline from the serialized object.
  69956. */
  69957. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69958. /**
  69959. * Luminance steps
  69960. */
  69961. static LuminanceSteps: number;
  69962. }
  69963. }
  69964. declare module BABYLON {
  69965. /** @hidden */
  69966. export var stereoscopicInterlacePixelShader: {
  69967. name: string;
  69968. shader: string;
  69969. };
  69970. }
  69971. declare module BABYLON {
  69972. /**
  69973. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69974. */
  69975. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69976. private _stepSize;
  69977. private _passedProcess;
  69978. /**
  69979. * Initializes a StereoscopicInterlacePostProcessI
  69980. * @param name The name of the effect.
  69981. * @param rigCameras The rig cameras to be appled to the post process
  69982. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69983. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69985. * @param engine The engine which the post process will be applied. (default: current engine)
  69986. * @param reusable If the post process can be reused on the same frame. (default: false)
  69987. */
  69988. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69989. }
  69990. /**
  69991. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69992. */
  69993. export class StereoscopicInterlacePostProcess extends PostProcess {
  69994. private _stepSize;
  69995. private _passedProcess;
  69996. /**
  69997. * Initializes a StereoscopicInterlacePostProcess
  69998. * @param name The name of the effect.
  69999. * @param rigCameras The rig cameras to be appled to the post process
  70000. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70002. * @param engine The engine which the post process will be applied. (default: current engine)
  70003. * @param reusable If the post process can be reused on the same frame. (default: false)
  70004. */
  70005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70006. }
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var tonemapPixelShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. /** Defines operator used for tonemapping */
  70017. export enum TonemappingOperator {
  70018. /** Hable */
  70019. Hable = 0,
  70020. /** Reinhard */
  70021. Reinhard = 1,
  70022. /** HejiDawson */
  70023. HejiDawson = 2,
  70024. /** Photographic */
  70025. Photographic = 3
  70026. }
  70027. /**
  70028. * Defines a post process to apply tone mapping
  70029. */
  70030. export class TonemapPostProcess extends PostProcess {
  70031. private _operator;
  70032. /** Defines the required exposure adjustement */
  70033. exposureAdjustment: number;
  70034. /**
  70035. * Creates a new TonemapPostProcess
  70036. * @param name defines the name of the postprocess
  70037. * @param _operator defines the operator to use
  70038. * @param exposureAdjustment defines the required exposure adjustement
  70039. * @param camera defines the camera to use (can be null)
  70040. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70041. * @param engine defines the hosting engine (can be ignore if camera is set)
  70042. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70043. */
  70044. constructor(name: string, _operator: TonemappingOperator,
  70045. /** Defines the required exposure adjustement */
  70046. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70047. }
  70048. }
  70049. declare module BABYLON {
  70050. /** @hidden */
  70051. export var volumetricLightScatteringPixelShader: {
  70052. name: string;
  70053. shader: string;
  70054. };
  70055. }
  70056. declare module BABYLON {
  70057. /** @hidden */
  70058. export var volumetricLightScatteringPassVertexShader: {
  70059. name: string;
  70060. shader: string;
  70061. };
  70062. }
  70063. declare module BABYLON {
  70064. /** @hidden */
  70065. export var volumetricLightScatteringPassPixelShader: {
  70066. name: string;
  70067. shader: string;
  70068. };
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70073. */
  70074. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70075. private _volumetricLightScatteringPass;
  70076. private _volumetricLightScatteringRTT;
  70077. private _viewPort;
  70078. private _screenCoordinates;
  70079. private _cachedDefines;
  70080. /**
  70081. * If not undefined, the mesh position is computed from the attached node position
  70082. */
  70083. attachedNode: {
  70084. position: Vector3;
  70085. };
  70086. /**
  70087. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70088. */
  70089. customMeshPosition: Vector3;
  70090. /**
  70091. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70092. */
  70093. useCustomMeshPosition: boolean;
  70094. /**
  70095. * If the post-process should inverse the light scattering direction
  70096. */
  70097. invert: boolean;
  70098. /**
  70099. * The internal mesh used by the post-process
  70100. */
  70101. mesh: Mesh;
  70102. /**
  70103. * @hidden
  70104. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70105. */
  70106. get useDiffuseColor(): boolean;
  70107. set useDiffuseColor(useDiffuseColor: boolean);
  70108. /**
  70109. * Array containing the excluded meshes not rendered in the internal pass
  70110. */
  70111. excludedMeshes: AbstractMesh[];
  70112. /**
  70113. * Controls the overall intensity of the post-process
  70114. */
  70115. exposure: number;
  70116. /**
  70117. * Dissipates each sample's contribution in range [0, 1]
  70118. */
  70119. decay: number;
  70120. /**
  70121. * Controls the overall intensity of each sample
  70122. */
  70123. weight: number;
  70124. /**
  70125. * Controls the density of each sample
  70126. */
  70127. density: number;
  70128. /**
  70129. * @constructor
  70130. * @param name The post-process name
  70131. * @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)
  70132. * @param camera The camera that the post-process will be attached to
  70133. * @param mesh The mesh used to create the light scattering
  70134. * @param samples The post-process quality, default 100
  70135. * @param samplingModeThe post-process filtering mode
  70136. * @param engine The babylon engine
  70137. * @param reusable If the post-process is reusable
  70138. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70139. */
  70140. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70141. /**
  70142. * Returns the string "VolumetricLightScatteringPostProcess"
  70143. * @returns "VolumetricLightScatteringPostProcess"
  70144. */
  70145. getClassName(): string;
  70146. private _isReady;
  70147. /**
  70148. * Sets the new light position for light scattering effect
  70149. * @param position The new custom light position
  70150. */
  70151. setCustomMeshPosition(position: Vector3): void;
  70152. /**
  70153. * Returns the light position for light scattering effect
  70154. * @return Vector3 The custom light position
  70155. */
  70156. getCustomMeshPosition(): Vector3;
  70157. /**
  70158. * Disposes the internal assets and detaches the post-process from the camera
  70159. */
  70160. dispose(camera: Camera): void;
  70161. /**
  70162. * Returns the render target texture used by the post-process
  70163. * @return the render target texture used by the post-process
  70164. */
  70165. getPass(): RenderTargetTexture;
  70166. private _meshExcluded;
  70167. private _createPass;
  70168. private _updateMeshScreenCoordinates;
  70169. /**
  70170. * Creates a default mesh for the Volumeric Light Scattering post-process
  70171. * @param name The mesh name
  70172. * @param scene The scene where to create the mesh
  70173. * @return the default mesh
  70174. */
  70175. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70176. }
  70177. }
  70178. declare module BABYLON {
  70179. interface Scene {
  70180. /** @hidden (Backing field) */
  70181. _boundingBoxRenderer: BoundingBoxRenderer;
  70182. /** @hidden (Backing field) */
  70183. _forceShowBoundingBoxes: boolean;
  70184. /**
  70185. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70186. */
  70187. forceShowBoundingBoxes: boolean;
  70188. /**
  70189. * Gets the bounding box renderer associated with the scene
  70190. * @returns a BoundingBoxRenderer
  70191. */
  70192. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70193. }
  70194. interface AbstractMesh {
  70195. /** @hidden (Backing field) */
  70196. _showBoundingBox: boolean;
  70197. /**
  70198. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70199. */
  70200. showBoundingBox: boolean;
  70201. }
  70202. /**
  70203. * Component responsible of rendering the bounding box of the meshes in a scene.
  70204. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70205. */
  70206. export class BoundingBoxRenderer implements ISceneComponent {
  70207. /**
  70208. * The component name helpfull to identify the component in the list of scene components.
  70209. */
  70210. readonly name: string;
  70211. /**
  70212. * The scene the component belongs to.
  70213. */
  70214. scene: Scene;
  70215. /**
  70216. * Color of the bounding box lines placed in front of an object
  70217. */
  70218. frontColor: Color3;
  70219. /**
  70220. * Color of the bounding box lines placed behind an object
  70221. */
  70222. backColor: Color3;
  70223. /**
  70224. * Defines if the renderer should show the back lines or not
  70225. */
  70226. showBackLines: boolean;
  70227. /**
  70228. * Observable raised before rendering a bounding box
  70229. */
  70230. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70231. /**
  70232. * Observable raised after rendering a bounding box
  70233. */
  70234. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70235. /**
  70236. * @hidden
  70237. */
  70238. renderList: SmartArray<BoundingBox>;
  70239. private _colorShader;
  70240. private _vertexBuffers;
  70241. private _indexBuffer;
  70242. private _fillIndexBuffer;
  70243. private _fillIndexData;
  70244. /**
  70245. * Instantiates a new bounding box renderer in a scene.
  70246. * @param scene the scene the renderer renders in
  70247. */
  70248. constructor(scene: Scene);
  70249. /**
  70250. * Registers the component in a given scene
  70251. */
  70252. register(): void;
  70253. private _evaluateSubMesh;
  70254. private _activeMesh;
  70255. private _prepareRessources;
  70256. private _createIndexBuffer;
  70257. /**
  70258. * Rebuilds the elements related to this component in case of
  70259. * context lost for instance.
  70260. */
  70261. rebuild(): void;
  70262. /**
  70263. * @hidden
  70264. */
  70265. reset(): void;
  70266. /**
  70267. * Render the bounding boxes of a specific rendering group
  70268. * @param renderingGroupId defines the rendering group to render
  70269. */
  70270. render(renderingGroupId: number): void;
  70271. /**
  70272. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70273. * @param mesh Define the mesh to render the occlusion bounding box for
  70274. */
  70275. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70276. /**
  70277. * Dispose and release the resources attached to this renderer.
  70278. */
  70279. dispose(): void;
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. interface Scene {
  70284. /** @hidden (Backing field) */
  70285. _depthRenderer: {
  70286. [id: string]: DepthRenderer;
  70287. };
  70288. /**
  70289. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70290. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70291. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70292. * @returns the created depth renderer
  70293. */
  70294. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70295. /**
  70296. * Disables a depth renderer for a given camera
  70297. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70298. */
  70299. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70300. }
  70301. /**
  70302. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70303. * in several rendering techniques.
  70304. */
  70305. export class DepthRendererSceneComponent implements ISceneComponent {
  70306. /**
  70307. * The component name helpfull to identify the component in the list of scene components.
  70308. */
  70309. readonly name: string;
  70310. /**
  70311. * The scene the component belongs to.
  70312. */
  70313. scene: Scene;
  70314. /**
  70315. * Creates a new instance of the component for the given scene
  70316. * @param scene Defines the scene to register the component in
  70317. */
  70318. constructor(scene: Scene);
  70319. /**
  70320. * Registers the component in a given scene
  70321. */
  70322. register(): void;
  70323. /**
  70324. * Rebuilds the elements related to this component in case of
  70325. * context lost for instance.
  70326. */
  70327. rebuild(): void;
  70328. /**
  70329. * Disposes the component and the associated ressources
  70330. */
  70331. dispose(): void;
  70332. private _gatherRenderTargets;
  70333. private _gatherActiveCameraRenderTargets;
  70334. }
  70335. }
  70336. declare module BABYLON {
  70337. /** @hidden */
  70338. export var outlinePixelShader: {
  70339. name: string;
  70340. shader: string;
  70341. };
  70342. }
  70343. declare module BABYLON {
  70344. /** @hidden */
  70345. export var outlineVertexShader: {
  70346. name: string;
  70347. shader: string;
  70348. };
  70349. }
  70350. declare module BABYLON {
  70351. interface Scene {
  70352. /** @hidden */
  70353. _outlineRenderer: OutlineRenderer;
  70354. /**
  70355. * Gets the outline renderer associated with the scene
  70356. * @returns a OutlineRenderer
  70357. */
  70358. getOutlineRenderer(): OutlineRenderer;
  70359. }
  70360. interface AbstractMesh {
  70361. /** @hidden (Backing field) */
  70362. _renderOutline: boolean;
  70363. /**
  70364. * Gets or sets a boolean indicating if the outline must be rendered as well
  70365. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70366. */
  70367. renderOutline: boolean;
  70368. /** @hidden (Backing field) */
  70369. _renderOverlay: boolean;
  70370. /**
  70371. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70372. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70373. */
  70374. renderOverlay: boolean;
  70375. }
  70376. /**
  70377. * This class is responsible to draw bothe outline/overlay of meshes.
  70378. * It should not be used directly but through the available method on mesh.
  70379. */
  70380. export class OutlineRenderer implements ISceneComponent {
  70381. /**
  70382. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70383. */
  70384. private static _StencilReference;
  70385. /**
  70386. * The name of the component. Each component must have a unique name.
  70387. */
  70388. name: string;
  70389. /**
  70390. * The scene the component belongs to.
  70391. */
  70392. scene: Scene;
  70393. /**
  70394. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70395. */
  70396. zOffset: number;
  70397. private _engine;
  70398. private _effect;
  70399. private _cachedDefines;
  70400. private _savedDepthWrite;
  70401. /**
  70402. * Instantiates a new outline renderer. (There could be only one per scene).
  70403. * @param scene Defines the scene it belongs to
  70404. */
  70405. constructor(scene: Scene);
  70406. /**
  70407. * Register the component to one instance of a scene.
  70408. */
  70409. register(): void;
  70410. /**
  70411. * Rebuilds the elements related to this component in case of
  70412. * context lost for instance.
  70413. */
  70414. rebuild(): void;
  70415. /**
  70416. * Disposes the component and the associated ressources.
  70417. */
  70418. dispose(): void;
  70419. /**
  70420. * Renders the outline in the canvas.
  70421. * @param subMesh Defines the sumesh to render
  70422. * @param batch Defines the batch of meshes in case of instances
  70423. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70424. */
  70425. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70426. /**
  70427. * Returns whether or not the outline renderer is ready for a given submesh.
  70428. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70429. * @param subMesh Defines the submesh to check readyness for
  70430. * @param useInstances Defines wheter wee are trying to render instances or not
  70431. * @returns true if ready otherwise false
  70432. */
  70433. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70434. private _beforeRenderingMesh;
  70435. private _afterRenderingMesh;
  70436. }
  70437. }
  70438. declare module BABYLON {
  70439. /**
  70440. * Defines the basic options interface of a Sprite Frame Source Size.
  70441. */
  70442. export interface ISpriteJSONSpriteSourceSize {
  70443. /**
  70444. * number of the original width of the Frame
  70445. */
  70446. w: number;
  70447. /**
  70448. * number of the original height of the Frame
  70449. */
  70450. h: number;
  70451. }
  70452. /**
  70453. * Defines the basic options interface of a Sprite Frame Data.
  70454. */
  70455. export interface ISpriteJSONSpriteFrameData {
  70456. /**
  70457. * number of the x offset of the Frame
  70458. */
  70459. x: number;
  70460. /**
  70461. * number of the y offset of the Frame
  70462. */
  70463. y: number;
  70464. /**
  70465. * number of the width of the Frame
  70466. */
  70467. w: number;
  70468. /**
  70469. * number of the height of the Frame
  70470. */
  70471. h: number;
  70472. }
  70473. /**
  70474. * Defines the basic options interface of a JSON Sprite.
  70475. */
  70476. export interface ISpriteJSONSprite {
  70477. /**
  70478. * string name of the Frame
  70479. */
  70480. filename: string;
  70481. /**
  70482. * ISpriteJSONSpriteFrame basic object of the frame data
  70483. */
  70484. frame: ISpriteJSONSpriteFrameData;
  70485. /**
  70486. * boolean to flag is the frame was rotated.
  70487. */
  70488. rotated: boolean;
  70489. /**
  70490. * boolean to flag is the frame was trimmed.
  70491. */
  70492. trimmed: boolean;
  70493. /**
  70494. * ISpriteJSONSpriteFrame basic object of the source data
  70495. */
  70496. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70497. /**
  70498. * ISpriteJSONSpriteFrame basic object of the source data
  70499. */
  70500. sourceSize: ISpriteJSONSpriteSourceSize;
  70501. }
  70502. /**
  70503. * Defines the basic options interface of a JSON atlas.
  70504. */
  70505. export interface ISpriteJSONAtlas {
  70506. /**
  70507. * Array of objects that contain the frame data.
  70508. */
  70509. frames: Array<ISpriteJSONSprite>;
  70510. /**
  70511. * object basic object containing the sprite meta data.
  70512. */
  70513. meta?: object;
  70514. }
  70515. }
  70516. declare module BABYLON {
  70517. /** @hidden */
  70518. export var spriteMapPixelShader: {
  70519. name: string;
  70520. shader: string;
  70521. };
  70522. }
  70523. declare module BABYLON {
  70524. /** @hidden */
  70525. export var spriteMapVertexShader: {
  70526. name: string;
  70527. shader: string;
  70528. };
  70529. }
  70530. declare module BABYLON {
  70531. /**
  70532. * Defines the basic options interface of a SpriteMap
  70533. */
  70534. export interface ISpriteMapOptions {
  70535. /**
  70536. * Vector2 of the number of cells in the grid.
  70537. */
  70538. stageSize?: Vector2;
  70539. /**
  70540. * Vector2 of the size of the output plane in World Units.
  70541. */
  70542. outputSize?: Vector2;
  70543. /**
  70544. * Vector3 of the position of the output plane in World Units.
  70545. */
  70546. outputPosition?: Vector3;
  70547. /**
  70548. * Vector3 of the rotation of the output plane.
  70549. */
  70550. outputRotation?: Vector3;
  70551. /**
  70552. * number of layers that the system will reserve in resources.
  70553. */
  70554. layerCount?: number;
  70555. /**
  70556. * number of max animation frames a single cell will reserve in resources.
  70557. */
  70558. maxAnimationFrames?: number;
  70559. /**
  70560. * number cell index of the base tile when the system compiles.
  70561. */
  70562. baseTile?: number;
  70563. /**
  70564. * boolean flip the sprite after its been repositioned by the framing data.
  70565. */
  70566. flipU?: boolean;
  70567. /**
  70568. * Vector3 scalar of the global RGB values of the SpriteMap.
  70569. */
  70570. colorMultiply?: Vector3;
  70571. }
  70572. /**
  70573. * Defines the IDisposable interface in order to be cleanable from resources.
  70574. */
  70575. export interface ISpriteMap extends IDisposable {
  70576. /**
  70577. * String name of the SpriteMap.
  70578. */
  70579. name: string;
  70580. /**
  70581. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70582. */
  70583. atlasJSON: ISpriteJSONAtlas;
  70584. /**
  70585. * Texture of the SpriteMap.
  70586. */
  70587. spriteSheet: Texture;
  70588. /**
  70589. * The parameters to initialize the SpriteMap with.
  70590. */
  70591. options: ISpriteMapOptions;
  70592. }
  70593. /**
  70594. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70595. */
  70596. export class SpriteMap implements ISpriteMap {
  70597. /** The Name of the spriteMap */
  70598. name: string;
  70599. /** The JSON file with the frame and meta data */
  70600. atlasJSON: ISpriteJSONAtlas;
  70601. /** The systems Sprite Sheet Texture */
  70602. spriteSheet: Texture;
  70603. /** Arguments passed with the Constructor */
  70604. options: ISpriteMapOptions;
  70605. /** Public Sprite Storage array, parsed from atlasJSON */
  70606. sprites: Array<ISpriteJSONSprite>;
  70607. /** Returns the Number of Sprites in the System */
  70608. get spriteCount(): number;
  70609. /** Returns the Position of Output Plane*/
  70610. get position(): Vector3;
  70611. /** Returns the Position of Output Plane*/
  70612. set position(v: Vector3);
  70613. /** Returns the Rotation of Output Plane*/
  70614. get rotation(): Vector3;
  70615. /** Returns the Rotation of Output Plane*/
  70616. set rotation(v: Vector3);
  70617. /** Sets the AnimationMap*/
  70618. get animationMap(): RawTexture;
  70619. /** Sets the AnimationMap*/
  70620. set animationMap(v: RawTexture);
  70621. /** Scene that the SpriteMap was created in */
  70622. private _scene;
  70623. /** Texture Buffer of Float32 that holds tile frame data*/
  70624. private _frameMap;
  70625. /** Texture Buffers of Float32 that holds tileMap data*/
  70626. private _tileMaps;
  70627. /** Texture Buffer of Float32 that holds Animation Data*/
  70628. private _animationMap;
  70629. /** Custom ShaderMaterial Central to the System*/
  70630. private _material;
  70631. /** Custom ShaderMaterial Central to the System*/
  70632. private _output;
  70633. /** Systems Time Ticker*/
  70634. private _time;
  70635. /**
  70636. * Creates a new SpriteMap
  70637. * @param name defines the SpriteMaps Name
  70638. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70639. * @param spriteSheet is the Texture that the Sprites are on.
  70640. * @param options a basic deployment configuration
  70641. * @param scene The Scene that the map is deployed on
  70642. */
  70643. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70644. /**
  70645. * Returns tileID location
  70646. * @returns Vector2 the cell position ID
  70647. */
  70648. getTileID(): Vector2;
  70649. /**
  70650. * Gets the UV location of the mouse over the SpriteMap.
  70651. * @returns Vector2 the UV position of the mouse interaction
  70652. */
  70653. getMousePosition(): Vector2;
  70654. /**
  70655. * Creates the "frame" texture Buffer
  70656. * -------------------------------------
  70657. * Structure of frames
  70658. * "filename": "Falling-Water-2.png",
  70659. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70660. * "rotated": true,
  70661. * "trimmed": true,
  70662. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70663. * "sourceSize": {"w":32,"h":32}
  70664. * @returns RawTexture of the frameMap
  70665. */
  70666. private _createFrameBuffer;
  70667. /**
  70668. * Creates the tileMap texture Buffer
  70669. * @param buffer normally and array of numbers, or a false to generate from scratch
  70670. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70671. * @returns RawTexture of the tileMap
  70672. */
  70673. private _createTileBuffer;
  70674. /**
  70675. * Modifies the data of the tileMaps
  70676. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70677. * @param pos is the iVector2 Coordinates of the Tile
  70678. * @param tile The SpriteIndex of the new Tile
  70679. */
  70680. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70681. /**
  70682. * Creates the animationMap texture Buffer
  70683. * @param buffer normally and array of numbers, or a false to generate from scratch
  70684. * @returns RawTexture of the animationMap
  70685. */
  70686. private _createTileAnimationBuffer;
  70687. /**
  70688. * Modifies the data of the animationMap
  70689. * @param cellID is the Index of the Sprite
  70690. * @param _frame is the target Animation frame
  70691. * @param toCell is the Target Index of the next frame of the animation
  70692. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70693. * @param speed is a global scalar of the time variable on the map.
  70694. */
  70695. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70696. /**
  70697. * Exports the .tilemaps file
  70698. */
  70699. saveTileMaps(): void;
  70700. /**
  70701. * Imports the .tilemaps file
  70702. * @param url of the .tilemaps file
  70703. */
  70704. loadTileMaps(url: string): void;
  70705. /**
  70706. * Release associated resources
  70707. */
  70708. dispose(): void;
  70709. }
  70710. }
  70711. declare module BABYLON {
  70712. /**
  70713. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70714. * @see http://doc.babylonjs.com/babylon101/sprites
  70715. */
  70716. export class SpritePackedManager extends SpriteManager {
  70717. /** defines the packed manager's name */
  70718. name: string;
  70719. /**
  70720. * Creates a new sprite manager from a packed sprite sheet
  70721. * @param name defines the manager's name
  70722. * @param imgUrl defines the sprite sheet url
  70723. * @param capacity defines the maximum allowed number of sprites
  70724. * @param scene defines the hosting scene
  70725. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70726. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70727. * @param samplingMode defines the smapling mode to use with spritesheet
  70728. * @param fromPacked set to true; do not alter
  70729. */
  70730. constructor(
  70731. /** defines the packed manager's name */
  70732. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70733. }
  70734. }
  70735. declare module BABYLON {
  70736. /**
  70737. * Defines the list of states available for a task inside a AssetsManager
  70738. */
  70739. export enum AssetTaskState {
  70740. /**
  70741. * Initialization
  70742. */
  70743. INIT = 0,
  70744. /**
  70745. * Running
  70746. */
  70747. RUNNING = 1,
  70748. /**
  70749. * Done
  70750. */
  70751. DONE = 2,
  70752. /**
  70753. * Error
  70754. */
  70755. ERROR = 3
  70756. }
  70757. /**
  70758. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70759. */
  70760. export abstract class AbstractAssetTask {
  70761. /**
  70762. * Task name
  70763. */ name: string;
  70764. /**
  70765. * Callback called when the task is successful
  70766. */
  70767. onSuccess: (task: any) => void;
  70768. /**
  70769. * Callback called when the task is not successful
  70770. */
  70771. onError: (task: any, message?: string, exception?: any) => void;
  70772. /**
  70773. * Creates a new AssetsManager
  70774. * @param name defines the name of the task
  70775. */
  70776. constructor(
  70777. /**
  70778. * Task name
  70779. */ name: string);
  70780. private _isCompleted;
  70781. private _taskState;
  70782. private _errorObject;
  70783. /**
  70784. * Get if the task is completed
  70785. */
  70786. get isCompleted(): boolean;
  70787. /**
  70788. * Gets the current state of the task
  70789. */
  70790. get taskState(): AssetTaskState;
  70791. /**
  70792. * Gets the current error object (if task is in error)
  70793. */
  70794. get errorObject(): {
  70795. message?: string;
  70796. exception?: any;
  70797. };
  70798. /**
  70799. * Internal only
  70800. * @hidden
  70801. */
  70802. _setErrorObject(message?: string, exception?: any): void;
  70803. /**
  70804. * Execute the current task
  70805. * @param scene defines the scene where you want your assets to be loaded
  70806. * @param onSuccess is a callback called when the task is successfully executed
  70807. * @param onError is a callback called if an error occurs
  70808. */
  70809. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70810. /**
  70811. * Execute the current task
  70812. * @param scene defines the scene where you want your assets to be loaded
  70813. * @param onSuccess is a callback called when the task is successfully executed
  70814. * @param onError is a callback called if an error occurs
  70815. */
  70816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70817. /**
  70818. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70819. * This can be used with failed tasks that have the reason for failure fixed.
  70820. */
  70821. reset(): void;
  70822. private onErrorCallback;
  70823. private onDoneCallback;
  70824. }
  70825. /**
  70826. * Define the interface used by progress events raised during assets loading
  70827. */
  70828. export interface IAssetsProgressEvent {
  70829. /**
  70830. * Defines the number of remaining tasks to process
  70831. */
  70832. remainingCount: number;
  70833. /**
  70834. * Defines the total number of tasks
  70835. */
  70836. totalCount: number;
  70837. /**
  70838. * Defines the task that was just processed
  70839. */
  70840. task: AbstractAssetTask;
  70841. }
  70842. /**
  70843. * Class used to share progress information about assets loading
  70844. */
  70845. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70846. /**
  70847. * Defines the number of remaining tasks to process
  70848. */
  70849. remainingCount: number;
  70850. /**
  70851. * Defines the total number of tasks
  70852. */
  70853. totalCount: number;
  70854. /**
  70855. * Defines the task that was just processed
  70856. */
  70857. task: AbstractAssetTask;
  70858. /**
  70859. * Creates a AssetsProgressEvent
  70860. * @param remainingCount defines the number of remaining tasks to process
  70861. * @param totalCount defines the total number of tasks
  70862. * @param task defines the task that was just processed
  70863. */
  70864. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70865. }
  70866. /**
  70867. * Define a task used by AssetsManager to load meshes
  70868. */
  70869. export class MeshAssetTask extends AbstractAssetTask {
  70870. /**
  70871. * Defines the name of the task
  70872. */
  70873. name: string;
  70874. /**
  70875. * Defines the list of mesh's names you want to load
  70876. */
  70877. meshesNames: any;
  70878. /**
  70879. * Defines the root url to use as a base to load your meshes and associated resources
  70880. */
  70881. rootUrl: string;
  70882. /**
  70883. * Defines the filename or File of the scene to load from
  70884. */
  70885. sceneFilename: string | File;
  70886. /**
  70887. * Gets the list of loaded meshes
  70888. */
  70889. loadedMeshes: Array<AbstractMesh>;
  70890. /**
  70891. * Gets the list of loaded particle systems
  70892. */
  70893. loadedParticleSystems: Array<IParticleSystem>;
  70894. /**
  70895. * Gets the list of loaded skeletons
  70896. */
  70897. loadedSkeletons: Array<Skeleton>;
  70898. /**
  70899. * Gets the list of loaded animation groups
  70900. */
  70901. loadedAnimationGroups: Array<AnimationGroup>;
  70902. /**
  70903. * Callback called when the task is successful
  70904. */
  70905. onSuccess: (task: MeshAssetTask) => void;
  70906. /**
  70907. * Callback called when the task is successful
  70908. */
  70909. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70910. /**
  70911. * Creates a new MeshAssetTask
  70912. * @param name defines the name of the task
  70913. * @param meshesNames defines the list of mesh's names you want to load
  70914. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70915. * @param sceneFilename defines the filename or File of the scene to load from
  70916. */
  70917. constructor(
  70918. /**
  70919. * Defines the name of the task
  70920. */
  70921. name: string,
  70922. /**
  70923. * Defines the list of mesh's names you want to load
  70924. */
  70925. meshesNames: any,
  70926. /**
  70927. * Defines the root url to use as a base to load your meshes and associated resources
  70928. */
  70929. rootUrl: string,
  70930. /**
  70931. * Defines the filename or File of the scene to load from
  70932. */
  70933. sceneFilename: string | File);
  70934. /**
  70935. * Execute the current task
  70936. * @param scene defines the scene where you want your assets to be loaded
  70937. * @param onSuccess is a callback called when the task is successfully executed
  70938. * @param onError is a callback called if an error occurs
  70939. */
  70940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70941. }
  70942. /**
  70943. * Define a task used by AssetsManager to load text content
  70944. */
  70945. export class TextFileAssetTask extends AbstractAssetTask {
  70946. /**
  70947. * Defines the name of the task
  70948. */
  70949. name: string;
  70950. /**
  70951. * Defines the location of the file to load
  70952. */
  70953. url: string;
  70954. /**
  70955. * Gets the loaded text string
  70956. */
  70957. text: string;
  70958. /**
  70959. * Callback called when the task is successful
  70960. */
  70961. onSuccess: (task: TextFileAssetTask) => void;
  70962. /**
  70963. * Callback called when the task is successful
  70964. */
  70965. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70966. /**
  70967. * Creates a new TextFileAssetTask object
  70968. * @param name defines the name of the task
  70969. * @param url defines the location of the file to load
  70970. */
  70971. constructor(
  70972. /**
  70973. * Defines the name of the task
  70974. */
  70975. name: string,
  70976. /**
  70977. * Defines the location of the file to load
  70978. */
  70979. url: string);
  70980. /**
  70981. * Execute the current task
  70982. * @param scene defines the scene where you want your assets to be loaded
  70983. * @param onSuccess is a callback called when the task is successfully executed
  70984. * @param onError is a callback called if an error occurs
  70985. */
  70986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70987. }
  70988. /**
  70989. * Define a task used by AssetsManager to load binary data
  70990. */
  70991. export class BinaryFileAssetTask extends AbstractAssetTask {
  70992. /**
  70993. * Defines the name of the task
  70994. */
  70995. name: string;
  70996. /**
  70997. * Defines the location of the file to load
  70998. */
  70999. url: string;
  71000. /**
  71001. * Gets the lodaded data (as an array buffer)
  71002. */
  71003. data: ArrayBuffer;
  71004. /**
  71005. * Callback called when the task is successful
  71006. */
  71007. onSuccess: (task: BinaryFileAssetTask) => void;
  71008. /**
  71009. * Callback called when the task is successful
  71010. */
  71011. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71012. /**
  71013. * Creates a new BinaryFileAssetTask object
  71014. * @param name defines the name of the new task
  71015. * @param url defines the location of the file to load
  71016. */
  71017. constructor(
  71018. /**
  71019. * Defines the name of the task
  71020. */
  71021. name: string,
  71022. /**
  71023. * Defines the location of the file to load
  71024. */
  71025. url: string);
  71026. /**
  71027. * Execute the current task
  71028. * @param scene defines the scene where you want your assets to be loaded
  71029. * @param onSuccess is a callback called when the task is successfully executed
  71030. * @param onError is a callback called if an error occurs
  71031. */
  71032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71033. }
  71034. /**
  71035. * Define a task used by AssetsManager to load images
  71036. */
  71037. export class ImageAssetTask extends AbstractAssetTask {
  71038. /**
  71039. * Defines the name of the task
  71040. */
  71041. name: string;
  71042. /**
  71043. * Defines the location of the image to load
  71044. */
  71045. url: string;
  71046. /**
  71047. * Gets the loaded images
  71048. */
  71049. image: HTMLImageElement;
  71050. /**
  71051. * Callback called when the task is successful
  71052. */
  71053. onSuccess: (task: ImageAssetTask) => void;
  71054. /**
  71055. * Callback called when the task is successful
  71056. */
  71057. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71058. /**
  71059. * Creates a new ImageAssetTask
  71060. * @param name defines the name of the task
  71061. * @param url defines the location of the image to load
  71062. */
  71063. constructor(
  71064. /**
  71065. * Defines the name of the task
  71066. */
  71067. name: string,
  71068. /**
  71069. * Defines the location of the image to load
  71070. */
  71071. url: string);
  71072. /**
  71073. * Execute the current task
  71074. * @param scene defines the scene where you want your assets to be loaded
  71075. * @param onSuccess is a callback called when the task is successfully executed
  71076. * @param onError is a callback called if an error occurs
  71077. */
  71078. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71079. }
  71080. /**
  71081. * Defines the interface used by texture loading tasks
  71082. */
  71083. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71084. /**
  71085. * Gets the loaded texture
  71086. */
  71087. texture: TEX;
  71088. }
  71089. /**
  71090. * Define a task used by AssetsManager to load 2D textures
  71091. */
  71092. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71093. /**
  71094. * Defines the name of the task
  71095. */
  71096. name: string;
  71097. /**
  71098. * Defines the location of the file to load
  71099. */
  71100. url: string;
  71101. /**
  71102. * Defines if mipmap should not be generated (default is false)
  71103. */
  71104. noMipmap?: boolean | undefined;
  71105. /**
  71106. * Defines if texture must be inverted on Y axis (default is true)
  71107. */
  71108. invertY: boolean;
  71109. /**
  71110. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71111. */
  71112. samplingMode: number;
  71113. /**
  71114. * Gets the loaded texture
  71115. */
  71116. texture: Texture;
  71117. /**
  71118. * Callback called when the task is successful
  71119. */
  71120. onSuccess: (task: TextureAssetTask) => void;
  71121. /**
  71122. * Callback called when the task is successful
  71123. */
  71124. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71125. /**
  71126. * Creates a new TextureAssetTask object
  71127. * @param name defines the name of the task
  71128. * @param url defines the location of the file to load
  71129. * @param noMipmap defines if mipmap should not be generated (default is false)
  71130. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71131. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71132. */
  71133. constructor(
  71134. /**
  71135. * Defines the name of the task
  71136. */
  71137. name: string,
  71138. /**
  71139. * Defines the location of the file to load
  71140. */
  71141. url: string,
  71142. /**
  71143. * Defines if mipmap should not be generated (default is false)
  71144. */
  71145. noMipmap?: boolean | undefined,
  71146. /**
  71147. * Defines if texture must be inverted on Y axis (default is true)
  71148. */
  71149. invertY?: boolean,
  71150. /**
  71151. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71152. */
  71153. samplingMode?: number);
  71154. /**
  71155. * Execute the current task
  71156. * @param scene defines the scene where you want your assets to be loaded
  71157. * @param onSuccess is a callback called when the task is successfully executed
  71158. * @param onError is a callback called if an error occurs
  71159. */
  71160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71161. }
  71162. /**
  71163. * Define a task used by AssetsManager to load cube textures
  71164. */
  71165. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71166. /**
  71167. * Defines the name of the task
  71168. */
  71169. name: string;
  71170. /**
  71171. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71172. */
  71173. url: string;
  71174. /**
  71175. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71176. */
  71177. extensions?: string[] | undefined;
  71178. /**
  71179. * Defines if mipmaps should not be generated (default is false)
  71180. */
  71181. noMipmap?: boolean | undefined;
  71182. /**
  71183. * Defines the explicit list of files (undefined by default)
  71184. */
  71185. files?: string[] | undefined;
  71186. /**
  71187. * Gets the loaded texture
  71188. */
  71189. texture: CubeTexture;
  71190. /**
  71191. * Callback called when the task is successful
  71192. */
  71193. onSuccess: (task: CubeTextureAssetTask) => void;
  71194. /**
  71195. * Callback called when the task is successful
  71196. */
  71197. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71198. /**
  71199. * Creates a new CubeTextureAssetTask
  71200. * @param name defines the name of the task
  71201. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71202. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71203. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71204. * @param files defines the explicit list of files (undefined by default)
  71205. */
  71206. constructor(
  71207. /**
  71208. * Defines the name of the task
  71209. */
  71210. name: string,
  71211. /**
  71212. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71213. */
  71214. url: string,
  71215. /**
  71216. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71217. */
  71218. extensions?: string[] | undefined,
  71219. /**
  71220. * Defines if mipmaps should not be generated (default is false)
  71221. */
  71222. noMipmap?: boolean | undefined,
  71223. /**
  71224. * Defines the explicit list of files (undefined by default)
  71225. */
  71226. files?: string[] | undefined);
  71227. /**
  71228. * Execute the current task
  71229. * @param scene defines the scene where you want your assets to be loaded
  71230. * @param onSuccess is a callback called when the task is successfully executed
  71231. * @param onError is a callback called if an error occurs
  71232. */
  71233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71234. }
  71235. /**
  71236. * Define a task used by AssetsManager to load HDR cube textures
  71237. */
  71238. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71239. /**
  71240. * Defines the name of the task
  71241. */
  71242. name: string;
  71243. /**
  71244. * Defines the location of the file to load
  71245. */
  71246. url: string;
  71247. /**
  71248. * Defines the desired size (the more it increases the longer the generation will be)
  71249. */
  71250. size: number;
  71251. /**
  71252. * Defines if mipmaps should not be generated (default is false)
  71253. */
  71254. noMipmap: boolean;
  71255. /**
  71256. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71257. */
  71258. generateHarmonics: boolean;
  71259. /**
  71260. * 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)
  71261. */
  71262. gammaSpace: boolean;
  71263. /**
  71264. * Internal Use Only
  71265. */
  71266. reserved: boolean;
  71267. /**
  71268. * Gets the loaded texture
  71269. */
  71270. texture: HDRCubeTexture;
  71271. /**
  71272. * Callback called when the task is successful
  71273. */
  71274. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71275. /**
  71276. * Callback called when the task is successful
  71277. */
  71278. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71279. /**
  71280. * Creates a new HDRCubeTextureAssetTask object
  71281. * @param name defines the name of the task
  71282. * @param url defines the location of the file to load
  71283. * @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.
  71284. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71285. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71286. * @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)
  71287. * @param reserved Internal use only
  71288. */
  71289. constructor(
  71290. /**
  71291. * Defines the name of the task
  71292. */
  71293. name: string,
  71294. /**
  71295. * Defines the location of the file to load
  71296. */
  71297. url: string,
  71298. /**
  71299. * Defines the desired size (the more it increases the longer the generation will be)
  71300. */
  71301. size: number,
  71302. /**
  71303. * Defines if mipmaps should not be generated (default is false)
  71304. */
  71305. noMipmap?: boolean,
  71306. /**
  71307. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71308. */
  71309. generateHarmonics?: boolean,
  71310. /**
  71311. * 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)
  71312. */
  71313. gammaSpace?: boolean,
  71314. /**
  71315. * Internal Use Only
  71316. */
  71317. reserved?: boolean);
  71318. /**
  71319. * Execute the current task
  71320. * @param scene defines the scene where you want your assets to be loaded
  71321. * @param onSuccess is a callback called when the task is successfully executed
  71322. * @param onError is a callback called if an error occurs
  71323. */
  71324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71325. }
  71326. /**
  71327. * Define a task used by AssetsManager to load Equirectangular cube textures
  71328. */
  71329. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71330. /**
  71331. * Defines the name of the task
  71332. */
  71333. name: string;
  71334. /**
  71335. * Defines the location of the file to load
  71336. */
  71337. url: string;
  71338. /**
  71339. * Defines the desired size (the more it increases the longer the generation will be)
  71340. */
  71341. size: number;
  71342. /**
  71343. * Defines if mipmaps should not be generated (default is false)
  71344. */
  71345. noMipmap: boolean;
  71346. /**
  71347. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71348. * but the standard material would require them in Gamma space) (default is true)
  71349. */
  71350. gammaSpace: boolean;
  71351. /**
  71352. * Gets the loaded texture
  71353. */
  71354. texture: EquiRectangularCubeTexture;
  71355. /**
  71356. * Callback called when the task is successful
  71357. */
  71358. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71359. /**
  71360. * Callback called when the task is successful
  71361. */
  71362. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71363. /**
  71364. * Creates a new EquiRectangularCubeTextureAssetTask object
  71365. * @param name defines the name of the task
  71366. * @param url defines the location of the file to load
  71367. * @param size defines the desired size (the more it increases the longer the generation will be)
  71368. * If the size is omitted this implies you are using a preprocessed cubemap.
  71369. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71370. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71371. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71372. * (default is true)
  71373. */
  71374. constructor(
  71375. /**
  71376. * Defines the name of the task
  71377. */
  71378. name: string,
  71379. /**
  71380. * Defines the location of the file to load
  71381. */
  71382. url: string,
  71383. /**
  71384. * Defines the desired size (the more it increases the longer the generation will be)
  71385. */
  71386. size: number,
  71387. /**
  71388. * Defines if mipmaps should not be generated (default is false)
  71389. */
  71390. noMipmap?: boolean,
  71391. /**
  71392. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71393. * but the standard material would require them in Gamma space) (default is true)
  71394. */
  71395. gammaSpace?: boolean);
  71396. /**
  71397. * Execute the current task
  71398. * @param scene defines the scene where you want your assets to be loaded
  71399. * @param onSuccess is a callback called when the task is successfully executed
  71400. * @param onError is a callback called if an error occurs
  71401. */
  71402. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71403. }
  71404. /**
  71405. * This class can be used to easily import assets into a scene
  71406. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71407. */
  71408. export class AssetsManager {
  71409. private _scene;
  71410. private _isLoading;
  71411. protected _tasks: AbstractAssetTask[];
  71412. protected _waitingTasksCount: number;
  71413. protected _totalTasksCount: number;
  71414. /**
  71415. * Callback called when all tasks are processed
  71416. */
  71417. onFinish: (tasks: AbstractAssetTask[]) => void;
  71418. /**
  71419. * Callback called when a task is successful
  71420. */
  71421. onTaskSuccess: (task: AbstractAssetTask) => void;
  71422. /**
  71423. * Callback called when a task had an error
  71424. */
  71425. onTaskError: (task: AbstractAssetTask) => void;
  71426. /**
  71427. * Callback called when a task is done (whatever the result is)
  71428. */
  71429. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71430. /**
  71431. * Observable called when all tasks are processed
  71432. */
  71433. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71434. /**
  71435. * Observable called when a task had an error
  71436. */
  71437. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71438. /**
  71439. * Observable called when all tasks were executed
  71440. */
  71441. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71442. /**
  71443. * Observable called when a task is done (whatever the result is)
  71444. */
  71445. onProgressObservable: Observable<IAssetsProgressEvent>;
  71446. /**
  71447. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71448. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71449. */
  71450. useDefaultLoadingScreen: boolean;
  71451. /**
  71452. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71453. * when all assets have been downloaded.
  71454. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71455. */
  71456. autoHideLoadingUI: boolean;
  71457. /**
  71458. * Creates a new AssetsManager
  71459. * @param scene defines the scene to work on
  71460. */
  71461. constructor(scene: Scene);
  71462. /**
  71463. * Add a MeshAssetTask to the list of active tasks
  71464. * @param taskName defines the name of the new task
  71465. * @param meshesNames defines the name of meshes to load
  71466. * @param rootUrl defines the root url to use to locate files
  71467. * @param sceneFilename defines the filename of the scene file
  71468. * @returns a new MeshAssetTask object
  71469. */
  71470. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71471. /**
  71472. * Add a TextFileAssetTask to the list of active tasks
  71473. * @param taskName defines the name of the new task
  71474. * @param url defines the url of the file to load
  71475. * @returns a new TextFileAssetTask object
  71476. */
  71477. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71478. /**
  71479. * Add a BinaryFileAssetTask to the list of active tasks
  71480. * @param taskName defines the name of the new task
  71481. * @param url defines the url of the file to load
  71482. * @returns a new BinaryFileAssetTask object
  71483. */
  71484. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71485. /**
  71486. * Add a ImageAssetTask to the list of active tasks
  71487. * @param taskName defines the name of the new task
  71488. * @param url defines the url of the file to load
  71489. * @returns a new ImageAssetTask object
  71490. */
  71491. addImageTask(taskName: string, url: string): ImageAssetTask;
  71492. /**
  71493. * Add a TextureAssetTask to the list of active tasks
  71494. * @param taskName defines the name of the new task
  71495. * @param url defines the url of the file to load
  71496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71497. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71498. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71499. * @returns a new TextureAssetTask object
  71500. */
  71501. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71502. /**
  71503. * Add a CubeTextureAssetTask to the list of active tasks
  71504. * @param taskName defines the name of the new task
  71505. * @param url defines the url of the file to load
  71506. * @param extensions defines the extension to use to load the cube map (can be null)
  71507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71508. * @param files defines the list of files to load (can be null)
  71509. * @returns a new CubeTextureAssetTask object
  71510. */
  71511. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71512. /**
  71513. *
  71514. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71515. * @param taskName defines the name of the new task
  71516. * @param url defines the url of the file to load
  71517. * @param size defines the size you want for the cubemap (can be null)
  71518. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71519. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71520. * @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)
  71521. * @param reserved Internal use only
  71522. * @returns a new HDRCubeTextureAssetTask object
  71523. */
  71524. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71525. /**
  71526. *
  71527. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71528. * @param taskName defines the name of the new task
  71529. * @param url defines the url of the file to load
  71530. * @param size defines the size you want for the cubemap (can be null)
  71531. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71532. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71533. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71534. * @returns a new EquiRectangularCubeTextureAssetTask object
  71535. */
  71536. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71537. /**
  71538. * Remove a task from the assets manager.
  71539. * @param task the task to remove
  71540. */
  71541. removeTask(task: AbstractAssetTask): void;
  71542. private _decreaseWaitingTasksCount;
  71543. private _runTask;
  71544. /**
  71545. * Reset the AssetsManager and remove all tasks
  71546. * @return the current instance of the AssetsManager
  71547. */
  71548. reset(): AssetsManager;
  71549. /**
  71550. * Start the loading process
  71551. * @return the current instance of the AssetsManager
  71552. */
  71553. load(): AssetsManager;
  71554. /**
  71555. * Start the loading process as an async operation
  71556. * @return a promise returning the list of failed tasks
  71557. */
  71558. loadAsync(): Promise<void>;
  71559. }
  71560. }
  71561. declare module BABYLON {
  71562. /**
  71563. * Wrapper class for promise with external resolve and reject.
  71564. */
  71565. export class Deferred<T> {
  71566. /**
  71567. * The promise associated with this deferred object.
  71568. */
  71569. readonly promise: Promise<T>;
  71570. private _resolve;
  71571. private _reject;
  71572. /**
  71573. * The resolve method of the promise associated with this deferred object.
  71574. */
  71575. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71576. /**
  71577. * The reject method of the promise associated with this deferred object.
  71578. */
  71579. get reject(): (reason?: any) => void;
  71580. /**
  71581. * Constructor for this deferred object.
  71582. */
  71583. constructor();
  71584. }
  71585. }
  71586. declare module BABYLON {
  71587. /**
  71588. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71589. */
  71590. export class MeshExploder {
  71591. private _centerMesh;
  71592. private _meshes;
  71593. private _meshesOrigins;
  71594. private _toCenterVectors;
  71595. private _scaledDirection;
  71596. private _newPosition;
  71597. private _centerPosition;
  71598. /**
  71599. * Explodes meshes from a center mesh.
  71600. * @param meshes The meshes to explode.
  71601. * @param centerMesh The mesh to be center of explosion.
  71602. */
  71603. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71604. private _setCenterMesh;
  71605. /**
  71606. * Get class name
  71607. * @returns "MeshExploder"
  71608. */
  71609. getClassName(): string;
  71610. /**
  71611. * "Exploded meshes"
  71612. * @returns Array of meshes with the centerMesh at index 0.
  71613. */
  71614. getMeshes(): Array<Mesh>;
  71615. /**
  71616. * Explodes meshes giving a specific direction
  71617. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71618. */
  71619. explode(direction?: number): void;
  71620. }
  71621. }
  71622. declare module BABYLON {
  71623. /**
  71624. * Class used to help managing file picking and drag'n'drop
  71625. */
  71626. export class FilesInput {
  71627. /**
  71628. * List of files ready to be loaded
  71629. */
  71630. static get FilesToLoad(): {
  71631. [key: string]: File;
  71632. };
  71633. /**
  71634. * Callback called when a file is processed
  71635. */
  71636. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71637. private _engine;
  71638. private _currentScene;
  71639. private _sceneLoadedCallback;
  71640. private _progressCallback;
  71641. private _additionalRenderLoopLogicCallback;
  71642. private _textureLoadingCallback;
  71643. private _startingProcessingFilesCallback;
  71644. private _onReloadCallback;
  71645. private _errorCallback;
  71646. private _elementToMonitor;
  71647. private _sceneFileToLoad;
  71648. private _filesToLoad;
  71649. /**
  71650. * Creates a new FilesInput
  71651. * @param engine defines the rendering engine
  71652. * @param scene defines the hosting scene
  71653. * @param sceneLoadedCallback callback called when scene is loaded
  71654. * @param progressCallback callback called to track progress
  71655. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71656. * @param textureLoadingCallback callback called when a texture is loading
  71657. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71658. * @param onReloadCallback callback called when a reload is requested
  71659. * @param errorCallback callback call if an error occurs
  71660. */
  71661. 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);
  71662. private _dragEnterHandler;
  71663. private _dragOverHandler;
  71664. private _dropHandler;
  71665. /**
  71666. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71667. * @param elementToMonitor defines the DOM element to track
  71668. */
  71669. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71670. /**
  71671. * Release all associated resources
  71672. */
  71673. dispose(): void;
  71674. private renderFunction;
  71675. private drag;
  71676. private drop;
  71677. private _traverseFolder;
  71678. private _processFiles;
  71679. /**
  71680. * Load files from a drop event
  71681. * @param event defines the drop event to use as source
  71682. */
  71683. loadFiles(event: any): void;
  71684. private _processReload;
  71685. /**
  71686. * Reload the current scene from the loaded files
  71687. */
  71688. reload(): void;
  71689. }
  71690. }
  71691. declare module BABYLON {
  71692. /**
  71693. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71695. */
  71696. export class SceneOptimization {
  71697. /**
  71698. * Defines the priority of this optimization (0 by default which means first in the list)
  71699. */
  71700. priority: number;
  71701. /**
  71702. * Gets a string describing the action executed by the current optimization
  71703. * @returns description string
  71704. */
  71705. getDescription(): string;
  71706. /**
  71707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71708. * @param scene defines the current scene where to apply this optimization
  71709. * @param optimizer defines the current optimizer
  71710. * @returns true if everything that can be done was applied
  71711. */
  71712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71713. /**
  71714. * Creates the SceneOptimization object
  71715. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71716. * @param desc defines the description associated with the optimization
  71717. */
  71718. constructor(
  71719. /**
  71720. * Defines the priority of this optimization (0 by default which means first in the list)
  71721. */
  71722. priority?: number);
  71723. }
  71724. /**
  71725. * Defines an optimization used to reduce the size of render target textures
  71726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71727. */
  71728. export class TextureOptimization extends SceneOptimization {
  71729. /**
  71730. * Defines the priority of this optimization (0 by default which means first in the list)
  71731. */
  71732. priority: number;
  71733. /**
  71734. * 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
  71735. */
  71736. maximumSize: number;
  71737. /**
  71738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71739. */
  71740. step: number;
  71741. /**
  71742. * Gets a string describing the action executed by the current optimization
  71743. * @returns description string
  71744. */
  71745. getDescription(): string;
  71746. /**
  71747. * Creates the TextureOptimization object
  71748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71749. * @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
  71750. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71751. */
  71752. constructor(
  71753. /**
  71754. * Defines the priority of this optimization (0 by default which means first in the list)
  71755. */
  71756. priority?: number,
  71757. /**
  71758. * 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
  71759. */
  71760. maximumSize?: number,
  71761. /**
  71762. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71763. */
  71764. step?: number);
  71765. /**
  71766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71767. * @param scene defines the current scene where to apply this optimization
  71768. * @param optimizer defines the current optimizer
  71769. * @returns true if everything that can be done was applied
  71770. */
  71771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71772. }
  71773. /**
  71774. * Defines an optimization used to increase or decrease the rendering resolution
  71775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71776. */
  71777. export class HardwareScalingOptimization extends SceneOptimization {
  71778. /**
  71779. * Defines the priority of this optimization (0 by default which means first in the list)
  71780. */
  71781. priority: number;
  71782. /**
  71783. * Defines the maximum scale to use (2 by default)
  71784. */
  71785. maximumScale: number;
  71786. /**
  71787. * Defines the step to use between two passes (0.5 by default)
  71788. */
  71789. step: number;
  71790. private _currentScale;
  71791. private _directionOffset;
  71792. /**
  71793. * Gets a string describing the action executed by the current optimization
  71794. * @return description string
  71795. */
  71796. getDescription(): string;
  71797. /**
  71798. * Creates the HardwareScalingOptimization object
  71799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71800. * @param maximumScale defines the maximum scale to use (2 by default)
  71801. * @param step defines the step to use between two passes (0.5 by default)
  71802. */
  71803. constructor(
  71804. /**
  71805. * Defines the priority of this optimization (0 by default which means first in the list)
  71806. */
  71807. priority?: number,
  71808. /**
  71809. * Defines the maximum scale to use (2 by default)
  71810. */
  71811. maximumScale?: number,
  71812. /**
  71813. * Defines the step to use between two passes (0.5 by default)
  71814. */
  71815. step?: number);
  71816. /**
  71817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71818. * @param scene defines the current scene where to apply this optimization
  71819. * @param optimizer defines the current optimizer
  71820. * @returns true if everything that can be done was applied
  71821. */
  71822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71823. }
  71824. /**
  71825. * Defines an optimization used to remove shadows
  71826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71827. */
  71828. export class ShadowsOptimization extends SceneOptimization {
  71829. /**
  71830. * Gets a string describing the action executed by the current optimization
  71831. * @return description string
  71832. */
  71833. getDescription(): string;
  71834. /**
  71835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71836. * @param scene defines the current scene where to apply this optimization
  71837. * @param optimizer defines the current optimizer
  71838. * @returns true if everything that can be done was applied
  71839. */
  71840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71841. }
  71842. /**
  71843. * Defines an optimization used to turn post-processes off
  71844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71845. */
  71846. export class PostProcessesOptimization extends SceneOptimization {
  71847. /**
  71848. * Gets a string describing the action executed by the current optimization
  71849. * @return description string
  71850. */
  71851. getDescription(): string;
  71852. /**
  71853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71854. * @param scene defines the current scene where to apply this optimization
  71855. * @param optimizer defines the current optimizer
  71856. * @returns true if everything that can be done was applied
  71857. */
  71858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71859. }
  71860. /**
  71861. * Defines an optimization used to turn lens flares off
  71862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71863. */
  71864. export class LensFlaresOptimization extends SceneOptimization {
  71865. /**
  71866. * Gets a string describing the action executed by the current optimization
  71867. * @return description string
  71868. */
  71869. getDescription(): string;
  71870. /**
  71871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71872. * @param scene defines the current scene where to apply this optimization
  71873. * @param optimizer defines the current optimizer
  71874. * @returns true if everything that can be done was applied
  71875. */
  71876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71877. }
  71878. /**
  71879. * Defines an optimization based on user defined callback.
  71880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71881. */
  71882. export class CustomOptimization extends SceneOptimization {
  71883. /**
  71884. * Callback called to apply the custom optimization.
  71885. */
  71886. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71887. /**
  71888. * Callback called to get custom description
  71889. */
  71890. onGetDescription: () => string;
  71891. /**
  71892. * Gets a string describing the action executed by the current optimization
  71893. * @returns description string
  71894. */
  71895. getDescription(): string;
  71896. /**
  71897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71898. * @param scene defines the current scene where to apply this optimization
  71899. * @param optimizer defines the current optimizer
  71900. * @returns true if everything that can be done was applied
  71901. */
  71902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71903. }
  71904. /**
  71905. * Defines an optimization used to turn particles off
  71906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71907. */
  71908. export class ParticlesOptimization extends SceneOptimization {
  71909. /**
  71910. * Gets a string describing the action executed by the current optimization
  71911. * @return description string
  71912. */
  71913. getDescription(): string;
  71914. /**
  71915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71916. * @param scene defines the current scene where to apply this optimization
  71917. * @param optimizer defines the current optimizer
  71918. * @returns true if everything that can be done was applied
  71919. */
  71920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71921. }
  71922. /**
  71923. * Defines an optimization used to turn render targets off
  71924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71925. */
  71926. export class RenderTargetsOptimization extends SceneOptimization {
  71927. /**
  71928. * Gets a string describing the action executed by the current optimization
  71929. * @return description string
  71930. */
  71931. getDescription(): string;
  71932. /**
  71933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71934. * @param scene defines the current scene where to apply this optimization
  71935. * @param optimizer defines the current optimizer
  71936. * @returns true if everything that can be done was applied
  71937. */
  71938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71939. }
  71940. /**
  71941. * Defines an optimization used to merge meshes with compatible materials
  71942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71943. */
  71944. export class MergeMeshesOptimization extends SceneOptimization {
  71945. private static _UpdateSelectionTree;
  71946. /**
  71947. * Gets or sets a boolean which defines if optimization octree has to be updated
  71948. */
  71949. static get UpdateSelectionTree(): boolean;
  71950. /**
  71951. * Gets or sets a boolean which defines if optimization octree has to be updated
  71952. */
  71953. static set UpdateSelectionTree(value: boolean);
  71954. /**
  71955. * Gets a string describing the action executed by the current optimization
  71956. * @return description string
  71957. */
  71958. getDescription(): string;
  71959. private _canBeMerged;
  71960. /**
  71961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71962. * @param scene defines the current scene where to apply this optimization
  71963. * @param optimizer defines the current optimizer
  71964. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71965. * @returns true if everything that can be done was applied
  71966. */
  71967. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71968. }
  71969. /**
  71970. * Defines a list of options used by SceneOptimizer
  71971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71972. */
  71973. export class SceneOptimizerOptions {
  71974. /**
  71975. * Defines the target frame rate to reach (60 by default)
  71976. */
  71977. targetFrameRate: number;
  71978. /**
  71979. * Defines the interval between two checkes (2000ms by default)
  71980. */
  71981. trackerDuration: number;
  71982. /**
  71983. * Gets the list of optimizations to apply
  71984. */
  71985. optimizations: SceneOptimization[];
  71986. /**
  71987. * Creates a new list of options used by SceneOptimizer
  71988. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71989. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71990. */
  71991. constructor(
  71992. /**
  71993. * Defines the target frame rate to reach (60 by default)
  71994. */
  71995. targetFrameRate?: number,
  71996. /**
  71997. * Defines the interval between two checkes (2000ms by default)
  71998. */
  71999. trackerDuration?: number);
  72000. /**
  72001. * Add a new optimization
  72002. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72003. * @returns the current SceneOptimizerOptions
  72004. */
  72005. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72006. /**
  72007. * Add a new custom optimization
  72008. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72009. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72010. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72011. * @returns the current SceneOptimizerOptions
  72012. */
  72013. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72014. /**
  72015. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72016. * @param targetFrameRate defines the target frame rate (60 by default)
  72017. * @returns a SceneOptimizerOptions object
  72018. */
  72019. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72020. /**
  72021. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72022. * @param targetFrameRate defines the target frame rate (60 by default)
  72023. * @returns a SceneOptimizerOptions object
  72024. */
  72025. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72026. /**
  72027. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72028. * @param targetFrameRate defines the target frame rate (60 by default)
  72029. * @returns a SceneOptimizerOptions object
  72030. */
  72031. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72032. }
  72033. /**
  72034. * Class used to run optimizations in order to reach a target frame rate
  72035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72036. */
  72037. export class SceneOptimizer implements IDisposable {
  72038. private _isRunning;
  72039. private _options;
  72040. private _scene;
  72041. private _currentPriorityLevel;
  72042. private _targetFrameRate;
  72043. private _trackerDuration;
  72044. private _currentFrameRate;
  72045. private _sceneDisposeObserver;
  72046. private _improvementMode;
  72047. /**
  72048. * Defines an observable called when the optimizer reaches the target frame rate
  72049. */
  72050. onSuccessObservable: Observable<SceneOptimizer>;
  72051. /**
  72052. * Defines an observable called when the optimizer enables an optimization
  72053. */
  72054. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72055. /**
  72056. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72057. */
  72058. onFailureObservable: Observable<SceneOptimizer>;
  72059. /**
  72060. * Gets a boolean indicating if the optimizer is in improvement mode
  72061. */
  72062. get isInImprovementMode(): boolean;
  72063. /**
  72064. * Gets the current priority level (0 at start)
  72065. */
  72066. get currentPriorityLevel(): number;
  72067. /**
  72068. * Gets the current frame rate checked by the SceneOptimizer
  72069. */
  72070. get currentFrameRate(): number;
  72071. /**
  72072. * Gets or sets the current target frame rate (60 by default)
  72073. */
  72074. get targetFrameRate(): number;
  72075. /**
  72076. * Gets or sets the current target frame rate (60 by default)
  72077. */
  72078. set targetFrameRate(value: number);
  72079. /**
  72080. * Gets or sets the current interval between two checks (every 2000ms by default)
  72081. */
  72082. get trackerDuration(): number;
  72083. /**
  72084. * Gets or sets the current interval between two checks (every 2000ms by default)
  72085. */
  72086. set trackerDuration(value: number);
  72087. /**
  72088. * Gets the list of active optimizations
  72089. */
  72090. get optimizations(): SceneOptimization[];
  72091. /**
  72092. * Creates a new SceneOptimizer
  72093. * @param scene defines the scene to work on
  72094. * @param options defines the options to use with the SceneOptimizer
  72095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72096. * @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)
  72097. */
  72098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72099. /**
  72100. * Stops the current optimizer
  72101. */
  72102. stop(): void;
  72103. /**
  72104. * Reset the optimizer to initial step (current priority level = 0)
  72105. */
  72106. reset(): void;
  72107. /**
  72108. * Start the optimizer. By default it will try to reach a specific framerate
  72109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72110. */
  72111. start(): void;
  72112. private _checkCurrentState;
  72113. /**
  72114. * Release all resources
  72115. */
  72116. dispose(): void;
  72117. /**
  72118. * Helper function to create a SceneOptimizer with one single line of code
  72119. * @param scene defines the scene to work on
  72120. * @param options defines the options to use with the SceneOptimizer
  72121. * @param onSuccess defines a callback to call on success
  72122. * @param onFailure defines a callback to call on failure
  72123. * @returns the new SceneOptimizer object
  72124. */
  72125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72126. }
  72127. }
  72128. declare module BABYLON {
  72129. /**
  72130. * Class used to serialize a scene into a string
  72131. */
  72132. export class SceneSerializer {
  72133. /**
  72134. * Clear cache used by a previous serialization
  72135. */
  72136. static ClearCache(): void;
  72137. /**
  72138. * Serialize a scene into a JSON compatible object
  72139. * @param scene defines the scene to serialize
  72140. * @returns a JSON compatible object
  72141. */
  72142. static Serialize(scene: Scene): any;
  72143. /**
  72144. * Serialize a mesh into a JSON compatible object
  72145. * @param toSerialize defines the mesh to serialize
  72146. * @param withParents defines if parents must be serialized as well
  72147. * @param withChildren defines if children must be serialized as well
  72148. * @returns a JSON compatible object
  72149. */
  72150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72151. }
  72152. }
  72153. declare module BABYLON {
  72154. /**
  72155. * Class used to host texture specific utilities
  72156. */
  72157. export class TextureTools {
  72158. /**
  72159. * Uses the GPU to create a copy texture rescaled at a given size
  72160. * @param texture Texture to copy from
  72161. * @param width defines the desired width
  72162. * @param height defines the desired height
  72163. * @param useBilinearMode defines if bilinear mode has to be used
  72164. * @return the generated texture
  72165. */
  72166. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72167. }
  72168. }
  72169. declare module BABYLON {
  72170. /**
  72171. * This represents the different options available for the video capture.
  72172. */
  72173. export interface VideoRecorderOptions {
  72174. /** Defines the mime type of the video. */
  72175. mimeType: string;
  72176. /** Defines the FPS the video should be recorded at. */
  72177. fps: number;
  72178. /** Defines the chunk size for the recording data. */
  72179. recordChunckSize: number;
  72180. /** The audio tracks to attach to the recording. */
  72181. audioTracks?: MediaStreamTrack[];
  72182. }
  72183. /**
  72184. * This can help with recording videos from BabylonJS.
  72185. * This is based on the available WebRTC functionalities of the browser.
  72186. *
  72187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72188. */
  72189. export class VideoRecorder {
  72190. private static readonly _defaultOptions;
  72191. /**
  72192. * Returns whether or not the VideoRecorder is available in your browser.
  72193. * @param engine Defines the Babylon Engine.
  72194. * @returns true if supported otherwise false.
  72195. */
  72196. static IsSupported(engine: Engine): boolean;
  72197. private readonly _options;
  72198. private _canvas;
  72199. private _mediaRecorder;
  72200. private _recordedChunks;
  72201. private _fileName;
  72202. private _resolve;
  72203. private _reject;
  72204. /**
  72205. * True when a recording is already in progress.
  72206. */
  72207. get isRecording(): boolean;
  72208. /**
  72209. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72210. * @param engine Defines the BabylonJS Engine you wish to record.
  72211. * @param options Defines options that can be used to customize the capture.
  72212. */
  72213. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72214. /**
  72215. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72216. */
  72217. stopRecording(): void;
  72218. /**
  72219. * Starts recording the canvas for a max duration specified in parameters.
  72220. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72221. * If null no automatic download will start and you can rely on the promise to get the data back.
  72222. * @param maxDuration Defines the maximum recording time in seconds.
  72223. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72224. * @return A promise callback at the end of the recording with the video data in Blob.
  72225. */
  72226. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72227. /**
  72228. * Releases internal resources used during the recording.
  72229. */
  72230. dispose(): void;
  72231. private _handleDataAvailable;
  72232. private _handleError;
  72233. private _handleStop;
  72234. }
  72235. }
  72236. declare module BABYLON {
  72237. /**
  72238. * Class containing a set of static utilities functions for screenshots
  72239. */
  72240. export class ScreenshotTools {
  72241. /**
  72242. * Captures a screenshot of the current rendering
  72243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72244. * @param engine defines the rendering engine
  72245. * @param camera defines the source camera
  72246. * @param size This parameter can be set to a single number or to an object with the
  72247. * following (optional) properties: precision, width, height. If a single number is passed,
  72248. * it will be used for both width and height. If an object is passed, the screenshot size
  72249. * will be derived from the parameters. The precision property is a multiplier allowing
  72250. * rendering at a higher or lower resolution
  72251. * @param successCallback defines the callback receives a single parameter which contains the
  72252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72253. * src parameter of an <img> to display it
  72254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72255. * Check your browser for supported MIME types
  72256. */
  72257. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72258. /**
  72259. * Captures a screenshot of the current rendering
  72260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72261. * @param engine defines the rendering engine
  72262. * @param camera defines the source camera
  72263. * @param size This parameter can be set to a single number or to an object with the
  72264. * following (optional) properties: precision, width, height. If a single number is passed,
  72265. * it will be used for both width and height. If an object is passed, the screenshot size
  72266. * will be derived from the parameters. The precision property is a multiplier allowing
  72267. * rendering at a higher or lower resolution
  72268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72269. * Check your browser for supported MIME types
  72270. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72271. * to the src parameter of an <img> to display it
  72272. */
  72273. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72274. /**
  72275. * Generates an image screenshot from the specified camera.
  72276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72277. * @param engine The engine to use for rendering
  72278. * @param camera The camera to use for rendering
  72279. * @param size This parameter can be set to a single number or to an object with the
  72280. * following (optional) properties: precision, width, height. If a single number is passed,
  72281. * it will be used for both width and height. If an object is passed, the screenshot size
  72282. * will be derived from the parameters. The precision property is a multiplier allowing
  72283. * rendering at a higher or lower resolution
  72284. * @param successCallback The callback receives a single parameter which contains the
  72285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72286. * src parameter of an <img> to display it
  72287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72288. * Check your browser for supported MIME types
  72289. * @param samples Texture samples (default: 1)
  72290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72291. * @param fileName A name for for the downloaded file.
  72292. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72293. */
  72294. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72295. /**
  72296. * Generates an image screenshot from the specified camera.
  72297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72298. * @param engine The engine to use for rendering
  72299. * @param camera The camera to use for rendering
  72300. * @param size This parameter can be set to a single number or to an object with the
  72301. * following (optional) properties: precision, width, height. If a single number is passed,
  72302. * it will be used for both width and height. If an object is passed, the screenshot size
  72303. * will be derived from the parameters. The precision property is a multiplier allowing
  72304. * rendering at a higher or lower resolution
  72305. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72306. * Check your browser for supported MIME types
  72307. * @param samples Texture samples (default: 1)
  72308. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72309. * @param fileName A name for for the downloaded file.
  72310. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72312. * to the src parameter of an <img> to display it
  72313. */
  72314. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72315. /**
  72316. * Gets height and width for screenshot size
  72317. * @private
  72318. */
  72319. private static _getScreenshotSize;
  72320. }
  72321. }
  72322. declare module BABYLON {
  72323. /**
  72324. * Interface for a data buffer
  72325. */
  72326. export interface IDataBuffer {
  72327. /**
  72328. * Reads bytes from the data buffer.
  72329. * @param byteOffset The byte offset to read
  72330. * @param byteLength The byte length to read
  72331. * @returns A promise that resolves when the bytes are read
  72332. */
  72333. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72334. /**
  72335. * The byte length of the buffer.
  72336. */
  72337. readonly byteLength: number;
  72338. }
  72339. /**
  72340. * Utility class for reading from a data buffer
  72341. */
  72342. export class DataReader {
  72343. /**
  72344. * The data buffer associated with this data reader.
  72345. */
  72346. readonly buffer: IDataBuffer;
  72347. /**
  72348. * The current byte offset from the beginning of the data buffer.
  72349. */
  72350. byteOffset: number;
  72351. private _dataView;
  72352. private _dataByteOffset;
  72353. /**
  72354. * Constructor
  72355. * @param buffer The buffer to read
  72356. */
  72357. constructor(buffer: IDataBuffer);
  72358. /**
  72359. * Loads the given byte length.
  72360. * @param byteLength The byte length to load
  72361. * @returns A promise that resolves when the load is complete
  72362. */
  72363. loadAsync(byteLength: number): Promise<void>;
  72364. /**
  72365. * Read a unsigned 32-bit integer from the currently loaded data range.
  72366. * @returns The 32-bit integer read
  72367. */
  72368. readUint32(): number;
  72369. /**
  72370. * Read a byte array from the currently loaded data range.
  72371. * @param byteLength The byte length to read
  72372. * @returns The byte array read
  72373. */
  72374. readUint8Array(byteLength: number): Uint8Array;
  72375. /**
  72376. * Read a string from the currently loaded data range.
  72377. * @param byteLength The byte length to read
  72378. * @returns The string read
  72379. */
  72380. readString(byteLength: number): string;
  72381. /**
  72382. * Skips the given byte length the currently loaded data range.
  72383. * @param byteLength The byte length to skip
  72384. */
  72385. skipBytes(byteLength: number): void;
  72386. }
  72387. }
  72388. declare module BABYLON {
  72389. /**
  72390. * Class for storing data to local storage if available or in-memory storage otherwise
  72391. */
  72392. export class DataStorage {
  72393. private static _Storage;
  72394. private static _GetStorage;
  72395. /**
  72396. * Reads a string from the data storage
  72397. * @param key The key to read
  72398. * @param defaultValue The value if the key doesn't exist
  72399. * @returns The string value
  72400. */
  72401. static ReadString(key: string, defaultValue: string): string;
  72402. /**
  72403. * Writes a string to the data storage
  72404. * @param key The key to write
  72405. * @param value The value to write
  72406. */
  72407. static WriteString(key: string, value: string): void;
  72408. /**
  72409. * Reads a boolean from the data storage
  72410. * @param key The key to read
  72411. * @param defaultValue The value if the key doesn't exist
  72412. * @returns The boolean value
  72413. */
  72414. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72415. /**
  72416. * Writes a boolean to the data storage
  72417. * @param key The key to write
  72418. * @param value The value to write
  72419. */
  72420. static WriteBoolean(key: string, value: boolean): void;
  72421. /**
  72422. * Reads a number from the data storage
  72423. * @param key The key to read
  72424. * @param defaultValue The value if the key doesn't exist
  72425. * @returns The number value
  72426. */
  72427. static ReadNumber(key: string, defaultValue: number): number;
  72428. /**
  72429. * Writes a number to the data storage
  72430. * @param key The key to write
  72431. * @param value The value to write
  72432. */
  72433. static WriteNumber(key: string, value: number): void;
  72434. }
  72435. }
  72436. declare module BABYLON {
  72437. /**
  72438. * An interface for all Hit test features
  72439. */
  72440. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72441. /**
  72442. * Triggered when new babylon (transformed) hit test results are available
  72443. */
  72444. onHitTestResultObservable: Observable<T[]>;
  72445. }
  72446. /**
  72447. * Options used for hit testing
  72448. */
  72449. export interface IWebXRLegacyHitTestOptions {
  72450. /**
  72451. * Only test when user interacted with the scene. Default - hit test every frame
  72452. */
  72453. testOnPointerDownOnly?: boolean;
  72454. /**
  72455. * The node to use to transform the local results to world coordinates
  72456. */
  72457. worldParentNode?: TransformNode;
  72458. }
  72459. /**
  72460. * Interface defining the babylon result of raycasting/hit-test
  72461. */
  72462. export interface IWebXRLegacyHitResult {
  72463. /**
  72464. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72465. */
  72466. transformationMatrix: Matrix;
  72467. /**
  72468. * The native hit test result
  72469. */
  72470. xrHitResult: XRHitResult | XRHitTestResult;
  72471. }
  72472. /**
  72473. * The currently-working hit-test module.
  72474. * Hit test (or Ray-casting) is used to interact with the real world.
  72475. * For further information read here - https://github.com/immersive-web/hit-test
  72476. */
  72477. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72478. /**
  72479. * options to use when constructing this feature
  72480. */
  72481. readonly options: IWebXRLegacyHitTestOptions;
  72482. private _direction;
  72483. private _mat;
  72484. private _onSelectEnabled;
  72485. private _origin;
  72486. /**
  72487. * The module's name
  72488. */
  72489. static readonly Name: string;
  72490. /**
  72491. * The (Babylon) version of this module.
  72492. * This is an integer representing the implementation version.
  72493. * This number does not correspond to the WebXR specs version
  72494. */
  72495. static readonly Version: number;
  72496. /**
  72497. * Populated with the last native XR Hit Results
  72498. */
  72499. lastNativeXRHitResults: XRHitResult[];
  72500. /**
  72501. * Triggered when new babylon (transformed) hit test results are available
  72502. */
  72503. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72504. /**
  72505. * Creates a new instance of the (legacy version) hit test feature
  72506. * @param _xrSessionManager an instance of WebXRSessionManager
  72507. * @param options options to use when constructing this feature
  72508. */
  72509. constructor(_xrSessionManager: WebXRSessionManager,
  72510. /**
  72511. * options to use when constructing this feature
  72512. */
  72513. options?: IWebXRLegacyHitTestOptions);
  72514. /**
  72515. * execute a hit test with an XR Ray
  72516. *
  72517. * @param xrSession a native xrSession that will execute this hit test
  72518. * @param xrRay the ray (position and direction) to use for ray-casting
  72519. * @param referenceSpace native XR reference space to use for the hit-test
  72520. * @param filter filter function that will filter the results
  72521. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72522. */
  72523. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72524. /**
  72525. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72526. * @param event the (select) event to use to select with
  72527. * @param referenceSpace the reference space to use for this hit test
  72528. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72529. */
  72530. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72531. /**
  72532. * attach this feature
  72533. * Will usually be called by the features manager
  72534. *
  72535. * @returns true if successful.
  72536. */
  72537. attach(): boolean;
  72538. /**
  72539. * detach this feature.
  72540. * Will usually be called by the features manager
  72541. *
  72542. * @returns true if successful.
  72543. */
  72544. detach(): boolean;
  72545. /**
  72546. * Dispose this feature and all of the resources attached
  72547. */
  72548. dispose(): void;
  72549. protected _onXRFrame(frame: XRFrame): void;
  72550. private _onHitTestResults;
  72551. private _onSelect;
  72552. }
  72553. }
  72554. declare module BABYLON {
  72555. /**
  72556. * Options used for hit testing (version 2)
  72557. */
  72558. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72559. /**
  72560. * Do not create a permanent hit test. Will usually be used when only
  72561. * transient inputs are needed.
  72562. */
  72563. disablePermanentHitTest?: boolean;
  72564. /**
  72565. * Enable transient (for example touch-based) hit test inspections
  72566. */
  72567. enableTransientHitTest?: boolean;
  72568. /**
  72569. * Offset ray for the permanent hit test
  72570. */
  72571. offsetRay?: Vector3;
  72572. /**
  72573. * Offset ray for the transient hit test
  72574. */
  72575. transientOffsetRay?: Vector3;
  72576. /**
  72577. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72578. */
  72579. useReferenceSpace?: boolean;
  72580. }
  72581. /**
  72582. * Interface defining the babylon result of hit-test
  72583. */
  72584. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72585. /**
  72586. * The input source that generated this hit test (if transient)
  72587. */
  72588. inputSource?: XRInputSource;
  72589. /**
  72590. * Is this a transient hit test
  72591. */
  72592. isTransient?: boolean;
  72593. /**
  72594. * Position of the hit test result
  72595. */
  72596. position: Vector3;
  72597. /**
  72598. * Rotation of the hit test result
  72599. */
  72600. rotationQuaternion: Quaternion;
  72601. /**
  72602. * The native hit test result
  72603. */
  72604. xrHitResult: XRHitTestResult;
  72605. }
  72606. /**
  72607. * The currently-working hit-test module.
  72608. * Hit test (or Ray-casting) is used to interact with the real world.
  72609. * For further information read here - https://github.com/immersive-web/hit-test
  72610. *
  72611. * Tested on chrome (mobile) 80.
  72612. */
  72613. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72614. /**
  72615. * options to use when constructing this feature
  72616. */
  72617. readonly options: IWebXRHitTestOptions;
  72618. private _tmpMat;
  72619. private _tmpPos;
  72620. private _tmpQuat;
  72621. private _transientXrHitTestSource;
  72622. private _xrHitTestSource;
  72623. private initHitTestSource;
  72624. /**
  72625. * The module's name
  72626. */
  72627. static readonly Name: string;
  72628. /**
  72629. * The (Babylon) version of this module.
  72630. * This is an integer representing the implementation version.
  72631. * This number does not correspond to the WebXR specs version
  72632. */
  72633. static readonly Version: number;
  72634. /**
  72635. * When set to true, each hit test will have its own position/rotation objects
  72636. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72637. * the developers will clone them or copy them as they see fit.
  72638. */
  72639. autoCloneTransformation: boolean;
  72640. /**
  72641. * Triggered when new babylon (transformed) hit test results are available
  72642. */
  72643. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72644. /**
  72645. * Use this to temporarily pause hit test checks.
  72646. */
  72647. paused: boolean;
  72648. /**
  72649. * Creates a new instance of the hit test feature
  72650. * @param _xrSessionManager an instance of WebXRSessionManager
  72651. * @param options options to use when constructing this feature
  72652. */
  72653. constructor(_xrSessionManager: WebXRSessionManager,
  72654. /**
  72655. * options to use when constructing this feature
  72656. */
  72657. options?: IWebXRHitTestOptions);
  72658. /**
  72659. * attach this feature
  72660. * Will usually be called by the features manager
  72661. *
  72662. * @returns true if successful.
  72663. */
  72664. attach(): boolean;
  72665. /**
  72666. * detach this feature.
  72667. * Will usually be called by the features manager
  72668. *
  72669. * @returns true if successful.
  72670. */
  72671. detach(): boolean;
  72672. /**
  72673. * Dispose this feature and all of the resources attached
  72674. */
  72675. dispose(): void;
  72676. protected _onXRFrame(frame: XRFrame): void;
  72677. private _processWebXRHitTestResult;
  72678. }
  72679. }
  72680. declare module BABYLON {
  72681. /**
  72682. * Configuration options of the anchor system
  72683. */
  72684. export interface IWebXRAnchorSystemOptions {
  72685. /**
  72686. * a node that will be used to convert local to world coordinates
  72687. */
  72688. worldParentNode?: TransformNode;
  72689. /**
  72690. * If set to true a reference of the created anchors will be kept until the next session starts
  72691. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72692. */
  72693. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72694. }
  72695. /**
  72696. * A babylon container for an XR Anchor
  72697. */
  72698. export interface IWebXRAnchor {
  72699. /**
  72700. * A babylon-assigned ID for this anchor
  72701. */
  72702. id: number;
  72703. /**
  72704. * Transformation matrix to apply to an object attached to this anchor
  72705. */
  72706. transformationMatrix: Matrix;
  72707. /**
  72708. * The native anchor object
  72709. */
  72710. xrAnchor: XRAnchor;
  72711. /**
  72712. * if defined, this object will be constantly updated by the anchor's position and rotation
  72713. */
  72714. attachedNode?: TransformNode;
  72715. }
  72716. /**
  72717. * An implementation of the anchor system for WebXR.
  72718. * For further information see https://github.com/immersive-web/anchors/
  72719. */
  72720. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72721. private _options;
  72722. private _lastFrameDetected;
  72723. private _trackedAnchors;
  72724. private _referenceSpaceForFrameAnchors;
  72725. private _futureAnchors;
  72726. /**
  72727. * The module's name
  72728. */
  72729. static readonly Name: string;
  72730. /**
  72731. * The (Babylon) version of this module.
  72732. * This is an integer representing the implementation version.
  72733. * This number does not correspond to the WebXR specs version
  72734. */
  72735. static readonly Version: number;
  72736. /**
  72737. * Observers registered here will be executed when a new anchor was added to the session
  72738. */
  72739. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72740. /**
  72741. * Observers registered here will be executed when an anchor was removed from the session
  72742. */
  72743. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72744. /**
  72745. * Observers registered here will be executed when an existing anchor updates
  72746. * This can execute N times every frame
  72747. */
  72748. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72749. /**
  72750. * Set the reference space to use for anchor creation, when not using a hit test.
  72751. * Will default to the session's reference space if not defined
  72752. */
  72753. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72754. /**
  72755. * constructs a new anchor system
  72756. * @param _xrSessionManager an instance of WebXRSessionManager
  72757. * @param _options configuration object for this feature
  72758. */
  72759. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72760. private _tmpVector;
  72761. private _tmpQuaternion;
  72762. private _populateTmpTransformation;
  72763. /**
  72764. * Create a new anchor point using a hit test result at a specific point in the scene
  72765. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72766. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72767. *
  72768. * @param hitTestResult The hit test result to use for this anchor creation
  72769. * @param position an optional position offset for this anchor
  72770. * @param rotationQuaternion an optional rotation offset for this anchor
  72771. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72772. */
  72773. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72774. /**
  72775. * Add a new anchor at a specific position and rotation
  72776. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72777. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72778. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72779. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72780. *
  72781. * @param position the position in which to add an anchor
  72782. * @param rotationQuaternion an optional rotation for the anchor transformation
  72783. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72784. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72785. */
  72786. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72787. /**
  72788. * detach this feature.
  72789. * Will usually be called by the features manager
  72790. *
  72791. * @returns true if successful.
  72792. */
  72793. detach(): boolean;
  72794. /**
  72795. * Dispose this feature and all of the resources attached
  72796. */
  72797. dispose(): void;
  72798. protected _onXRFrame(frame: XRFrame): void;
  72799. /**
  72800. * avoiding using Array.find for global support.
  72801. * @param xrAnchor the plane to find in the array
  72802. */
  72803. private _findIndexInAnchorArray;
  72804. private _updateAnchorWithXRFrame;
  72805. private _createAnchorAtTransformation;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /**
  72810. * Options used in the plane detector module
  72811. */
  72812. export interface IWebXRPlaneDetectorOptions {
  72813. /**
  72814. * The node to use to transform the local results to world coordinates
  72815. */
  72816. worldParentNode?: TransformNode;
  72817. /**
  72818. * If set to true a reference of the created planes will be kept until the next session starts
  72819. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72820. */
  72821. doNotRemovePlanesOnSessionEnded?: boolean;
  72822. }
  72823. /**
  72824. * A babylon interface for a WebXR plane.
  72825. * A Plane is actually a polygon, built from N points in space
  72826. *
  72827. * Supported in chrome 79, not supported in canary 81 ATM
  72828. */
  72829. export interface IWebXRPlane {
  72830. /**
  72831. * a babylon-assigned ID for this polygon
  72832. */
  72833. id: number;
  72834. /**
  72835. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72836. */
  72837. polygonDefinition: Array<Vector3>;
  72838. /**
  72839. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72840. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72841. */
  72842. transformationMatrix: Matrix;
  72843. /**
  72844. * the native xr-plane object
  72845. */
  72846. xrPlane: XRPlane;
  72847. }
  72848. /**
  72849. * The plane detector is used to detect planes in the real world when in AR
  72850. * For more information see https://github.com/immersive-web/real-world-geometry/
  72851. */
  72852. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72853. private _options;
  72854. private _detectedPlanes;
  72855. private _enabled;
  72856. private _lastFrameDetected;
  72857. /**
  72858. * The module's name
  72859. */
  72860. static readonly Name: string;
  72861. /**
  72862. * The (Babylon) version of this module.
  72863. * This is an integer representing the implementation version.
  72864. * This number does not correspond to the WebXR specs version
  72865. */
  72866. static readonly Version: number;
  72867. /**
  72868. * Observers registered here will be executed when a new plane was added to the session
  72869. */
  72870. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72871. /**
  72872. * Observers registered here will be executed when a plane is no longer detected in the session
  72873. */
  72874. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72875. /**
  72876. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72877. * This can execute N times every frame
  72878. */
  72879. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72880. /**
  72881. * construct a new Plane Detector
  72882. * @param _xrSessionManager an instance of xr Session manager
  72883. * @param _options configuration to use when constructing this feature
  72884. */
  72885. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72886. /**
  72887. * detach this feature.
  72888. * Will usually be called by the features manager
  72889. *
  72890. * @returns true if successful.
  72891. */
  72892. detach(): boolean;
  72893. /**
  72894. * Dispose this feature and all of the resources attached
  72895. */
  72896. dispose(): void;
  72897. protected _onXRFrame(frame: XRFrame): void;
  72898. private _init;
  72899. private _updatePlaneWithXRPlane;
  72900. /**
  72901. * avoiding using Array.find for global support.
  72902. * @param xrPlane the plane to find in the array
  72903. */
  72904. private findIndexInPlaneArray;
  72905. }
  72906. }
  72907. declare module BABYLON {
  72908. /**
  72909. * Options interface for the background remover plugin
  72910. */
  72911. export interface IWebXRBackgroundRemoverOptions {
  72912. /**
  72913. * Further background meshes to disable when entering AR
  72914. */
  72915. backgroundMeshes?: AbstractMesh[];
  72916. /**
  72917. * flags to configure the removal of the environment helper.
  72918. * If not set, the entire background will be removed. If set, flags should be set as well.
  72919. */
  72920. environmentHelperRemovalFlags?: {
  72921. /**
  72922. * Should the skybox be removed (default false)
  72923. */
  72924. skyBox?: boolean;
  72925. /**
  72926. * Should the ground be removed (default false)
  72927. */
  72928. ground?: boolean;
  72929. };
  72930. /**
  72931. * don't disable the environment helper
  72932. */
  72933. ignoreEnvironmentHelper?: boolean;
  72934. }
  72935. /**
  72936. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72937. */
  72938. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72939. /**
  72940. * read-only options to be used in this module
  72941. */
  72942. readonly options: IWebXRBackgroundRemoverOptions;
  72943. /**
  72944. * The module's name
  72945. */
  72946. static readonly Name: string;
  72947. /**
  72948. * The (Babylon) version of this module.
  72949. * This is an integer representing the implementation version.
  72950. * This number does not correspond to the WebXR specs version
  72951. */
  72952. static readonly Version: number;
  72953. /**
  72954. * registered observers will be triggered when the background state changes
  72955. */
  72956. onBackgroundStateChangedObservable: Observable<boolean>;
  72957. /**
  72958. * constructs a new background remover module
  72959. * @param _xrSessionManager the session manager for this module
  72960. * @param options read-only options to be used in this module
  72961. */
  72962. constructor(_xrSessionManager: WebXRSessionManager,
  72963. /**
  72964. * read-only options to be used in this module
  72965. */
  72966. options?: IWebXRBackgroundRemoverOptions);
  72967. /**
  72968. * attach this feature
  72969. * Will usually be called by the features manager
  72970. *
  72971. * @returns true if successful.
  72972. */
  72973. attach(): boolean;
  72974. /**
  72975. * detach this feature.
  72976. * Will usually be called by the features manager
  72977. *
  72978. * @returns true if successful.
  72979. */
  72980. detach(): boolean;
  72981. /**
  72982. * Dispose this feature and all of the resources attached
  72983. */
  72984. dispose(): void;
  72985. protected _onXRFrame(_xrFrame: XRFrame): void;
  72986. private _setBackgroundState;
  72987. }
  72988. }
  72989. declare module BABYLON {
  72990. /**
  72991. * Options for the controller physics feature
  72992. */
  72993. export class IWebXRControllerPhysicsOptions {
  72994. /**
  72995. * Should the headset get its own impostor
  72996. */
  72997. enableHeadsetImpostor?: boolean;
  72998. /**
  72999. * Optional parameters for the headset impostor
  73000. */
  73001. headsetImpostorParams?: {
  73002. /**
  73003. * The type of impostor to create. Default is sphere
  73004. */
  73005. impostorType: number;
  73006. /**
  73007. * the size of the impostor. Defaults to 10cm
  73008. */
  73009. impostorSize?: number | {
  73010. width: number;
  73011. height: number;
  73012. depth: number;
  73013. };
  73014. /**
  73015. * Friction definitions
  73016. */
  73017. friction?: number;
  73018. /**
  73019. * Restitution
  73020. */
  73021. restitution?: number;
  73022. };
  73023. /**
  73024. * The physics properties of the future impostors
  73025. */
  73026. physicsProperties?: {
  73027. /**
  73028. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73029. * Note that this requires a physics engine that supports mesh impostors!
  73030. */
  73031. useControllerMesh?: boolean;
  73032. /**
  73033. * The type of impostor to create. Default is sphere
  73034. */
  73035. impostorType?: number;
  73036. /**
  73037. * the size of the impostor. Defaults to 10cm
  73038. */
  73039. impostorSize?: number | {
  73040. width: number;
  73041. height: number;
  73042. depth: number;
  73043. };
  73044. /**
  73045. * Friction definitions
  73046. */
  73047. friction?: number;
  73048. /**
  73049. * Restitution
  73050. */
  73051. restitution?: number;
  73052. };
  73053. /**
  73054. * the xr input to use with this pointer selection
  73055. */
  73056. xrInput: WebXRInput;
  73057. }
  73058. /**
  73059. * Add physics impostor to your webxr controllers,
  73060. * including naive calculation of their linear and angular velocity
  73061. */
  73062. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73063. private readonly _options;
  73064. private _attachController;
  73065. private _controllers;
  73066. private _debugMode;
  73067. private _delta;
  73068. private _headsetImpostor?;
  73069. private _headsetMesh?;
  73070. private _lastTimestamp;
  73071. private _tmpQuaternion;
  73072. private _tmpVector;
  73073. /**
  73074. * The module's name
  73075. */
  73076. static readonly Name: string;
  73077. /**
  73078. * The (Babylon) version of this module.
  73079. * This is an integer representing the implementation version.
  73080. * This number does not correspond to the webxr specs version
  73081. */
  73082. static readonly Version: number;
  73083. /**
  73084. * Construct a new Controller Physics Feature
  73085. * @param _xrSessionManager the corresponding xr session manager
  73086. * @param _options options to create this feature with
  73087. */
  73088. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73089. /**
  73090. * @hidden
  73091. * enable debugging - will show console outputs and the impostor mesh
  73092. */
  73093. _enablePhysicsDebug(): void;
  73094. /**
  73095. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73096. * @param xrController the controller to add
  73097. */
  73098. addController(xrController: WebXRInputSource): void;
  73099. /**
  73100. * attach this feature
  73101. * Will usually be called by the features manager
  73102. *
  73103. * @returns true if successful.
  73104. */
  73105. attach(): boolean;
  73106. /**
  73107. * detach this feature.
  73108. * Will usually be called by the features manager
  73109. *
  73110. * @returns true if successful.
  73111. */
  73112. detach(): boolean;
  73113. /**
  73114. * Get the headset impostor, if enabled
  73115. * @returns the impostor
  73116. */
  73117. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73118. /**
  73119. * Get the physics impostor of a specific controller.
  73120. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73121. * @param controller the controller or the controller id of which to get the impostor
  73122. * @returns the impostor or null
  73123. */
  73124. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73125. /**
  73126. * Update the physics properties provided in the constructor
  73127. * @param newProperties the new properties object
  73128. */
  73129. setPhysicsProperties(newProperties: {
  73130. impostorType?: number;
  73131. impostorSize?: number | {
  73132. width: number;
  73133. height: number;
  73134. depth: number;
  73135. };
  73136. friction?: number;
  73137. restitution?: number;
  73138. }): void;
  73139. protected _onXRFrame(_xrFrame: any): void;
  73140. private _detachController;
  73141. }
  73142. }
  73143. declare module BABYLON {
  73144. /**
  73145. * The motion controller class for all microsoft mixed reality controllers
  73146. */
  73147. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73148. protected readonly _mapping: {
  73149. defaultButton: {
  73150. valueNodeName: string;
  73151. unpressedNodeName: string;
  73152. pressedNodeName: string;
  73153. };
  73154. defaultAxis: {
  73155. valueNodeName: string;
  73156. minNodeName: string;
  73157. maxNodeName: string;
  73158. };
  73159. buttons: {
  73160. "xr-standard-trigger": {
  73161. rootNodeName: string;
  73162. componentProperty: string;
  73163. states: string[];
  73164. };
  73165. "xr-standard-squeeze": {
  73166. rootNodeName: string;
  73167. componentProperty: string;
  73168. states: string[];
  73169. };
  73170. "xr-standard-touchpad": {
  73171. rootNodeName: string;
  73172. labelAnchorNodeName: string;
  73173. touchPointNodeName: string;
  73174. };
  73175. "xr-standard-thumbstick": {
  73176. rootNodeName: string;
  73177. componentProperty: string;
  73178. states: string[];
  73179. };
  73180. };
  73181. axes: {
  73182. "xr-standard-touchpad": {
  73183. "x-axis": {
  73184. rootNodeName: string;
  73185. };
  73186. "y-axis": {
  73187. rootNodeName: string;
  73188. };
  73189. };
  73190. "xr-standard-thumbstick": {
  73191. "x-axis": {
  73192. rootNodeName: string;
  73193. };
  73194. "y-axis": {
  73195. rootNodeName: string;
  73196. };
  73197. };
  73198. };
  73199. };
  73200. /**
  73201. * The base url used to load the left and right controller models
  73202. */
  73203. static MODEL_BASE_URL: string;
  73204. /**
  73205. * The name of the left controller model file
  73206. */
  73207. static MODEL_LEFT_FILENAME: string;
  73208. /**
  73209. * The name of the right controller model file
  73210. */
  73211. static MODEL_RIGHT_FILENAME: string;
  73212. profileId: string;
  73213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73214. protected _getFilenameAndPath(): {
  73215. filename: string;
  73216. path: string;
  73217. };
  73218. protected _getModelLoadingConstraints(): boolean;
  73219. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73221. protected _updateModel(): void;
  73222. }
  73223. }
  73224. declare module BABYLON {
  73225. /**
  73226. * The motion controller class for oculus touch (quest, rift).
  73227. * This class supports legacy mapping as well the standard xr mapping
  73228. */
  73229. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73230. private _forceLegacyControllers;
  73231. private _modelRootNode;
  73232. /**
  73233. * The base url used to load the left and right controller models
  73234. */
  73235. static MODEL_BASE_URL: string;
  73236. /**
  73237. * The name of the left controller model file
  73238. */
  73239. static MODEL_LEFT_FILENAME: string;
  73240. /**
  73241. * The name of the right controller model file
  73242. */
  73243. static MODEL_RIGHT_FILENAME: string;
  73244. /**
  73245. * Base Url for the Quest controller model.
  73246. */
  73247. static QUEST_MODEL_BASE_URL: string;
  73248. profileId: string;
  73249. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73250. protected _getFilenameAndPath(): {
  73251. filename: string;
  73252. path: string;
  73253. };
  73254. protected _getModelLoadingConstraints(): boolean;
  73255. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73256. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73257. protected _updateModel(): void;
  73258. /**
  73259. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73260. * between the touch and touch 2.
  73261. */
  73262. private _isQuest;
  73263. }
  73264. }
  73265. declare module BABYLON {
  73266. /**
  73267. * The motion controller class for the standard HTC-Vive controllers
  73268. */
  73269. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73270. private _modelRootNode;
  73271. /**
  73272. * The base url used to load the left and right controller models
  73273. */
  73274. static MODEL_BASE_URL: string;
  73275. /**
  73276. * File name for the controller model.
  73277. */
  73278. static MODEL_FILENAME: string;
  73279. profileId: string;
  73280. /**
  73281. * Create a new Vive motion controller object
  73282. * @param scene the scene to use to create this controller
  73283. * @param gamepadObject the corresponding gamepad object
  73284. * @param handedness the handedness of the controller
  73285. */
  73286. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73287. protected _getFilenameAndPath(): {
  73288. filename: string;
  73289. path: string;
  73290. };
  73291. protected _getModelLoadingConstraints(): boolean;
  73292. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73293. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73294. protected _updateModel(): void;
  73295. }
  73296. }
  73297. declare module BABYLON {
  73298. /**
  73299. * A cursor which tracks a point on a path
  73300. */
  73301. export class PathCursor {
  73302. private path;
  73303. /**
  73304. * Stores path cursor callbacks for when an onchange event is triggered
  73305. */
  73306. private _onchange;
  73307. /**
  73308. * The value of the path cursor
  73309. */
  73310. value: number;
  73311. /**
  73312. * The animation array of the path cursor
  73313. */
  73314. animations: Animation[];
  73315. /**
  73316. * Initializes the path cursor
  73317. * @param path The path to track
  73318. */
  73319. constructor(path: Path2);
  73320. /**
  73321. * Gets the cursor point on the path
  73322. * @returns A point on the path cursor at the cursor location
  73323. */
  73324. getPoint(): Vector3;
  73325. /**
  73326. * Moves the cursor ahead by the step amount
  73327. * @param step The amount to move the cursor forward
  73328. * @returns This path cursor
  73329. */
  73330. moveAhead(step?: number): PathCursor;
  73331. /**
  73332. * Moves the cursor behind by the step amount
  73333. * @param step The amount to move the cursor back
  73334. * @returns This path cursor
  73335. */
  73336. moveBack(step?: number): PathCursor;
  73337. /**
  73338. * Moves the cursor by the step amount
  73339. * If the step amount is greater than one, an exception is thrown
  73340. * @param step The amount to move the cursor
  73341. * @returns This path cursor
  73342. */
  73343. move(step: number): PathCursor;
  73344. /**
  73345. * Ensures that the value is limited between zero and one
  73346. * @returns This path cursor
  73347. */
  73348. private ensureLimits;
  73349. /**
  73350. * Runs onchange callbacks on change (used by the animation engine)
  73351. * @returns This path cursor
  73352. */
  73353. private raiseOnChange;
  73354. /**
  73355. * Executes a function on change
  73356. * @param f A path cursor onchange callback
  73357. * @returns This path cursor
  73358. */
  73359. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73360. }
  73361. }
  73362. declare module BABYLON {
  73363. /** @hidden */
  73364. export var blurPixelShader: {
  73365. name: string;
  73366. shader: string;
  73367. };
  73368. }
  73369. declare module BABYLON {
  73370. /** @hidden */
  73371. export var pointCloudVertexDeclaration: {
  73372. name: string;
  73373. shader: string;
  73374. };
  73375. }
  73376. // Mixins
  73377. interface Window {
  73378. mozIndexedDB: IDBFactory;
  73379. webkitIndexedDB: IDBFactory;
  73380. msIndexedDB: IDBFactory;
  73381. webkitURL: typeof URL;
  73382. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73383. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73384. WebGLRenderingContext: WebGLRenderingContext;
  73385. MSGesture: MSGesture;
  73386. CANNON: any;
  73387. AudioContext: AudioContext;
  73388. webkitAudioContext: AudioContext;
  73389. PointerEvent: any;
  73390. Math: Math;
  73391. Uint8Array: Uint8ArrayConstructor;
  73392. Float32Array: Float32ArrayConstructor;
  73393. mozURL: typeof URL;
  73394. msURL: typeof URL;
  73395. VRFrameData: any; // WebVR, from specs 1.1
  73396. DracoDecoderModule: any;
  73397. setImmediate(handler: (...args: any[]) => void): number;
  73398. }
  73399. interface HTMLCanvasElement {
  73400. requestPointerLock(): void;
  73401. msRequestPointerLock?(): void;
  73402. mozRequestPointerLock?(): void;
  73403. webkitRequestPointerLock?(): void;
  73404. /** Track wether a record is in progress */
  73405. isRecording: boolean;
  73406. /** Capture Stream method defined by some browsers */
  73407. captureStream(fps?: number): MediaStream;
  73408. }
  73409. interface CanvasRenderingContext2D {
  73410. msImageSmoothingEnabled: boolean;
  73411. }
  73412. interface MouseEvent {
  73413. mozMovementX: number;
  73414. mozMovementY: number;
  73415. webkitMovementX: number;
  73416. webkitMovementY: number;
  73417. msMovementX: number;
  73418. msMovementY: number;
  73419. }
  73420. interface Navigator {
  73421. mozGetVRDevices: (any: any) => any;
  73422. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73423. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73424. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73425. webkitGetGamepads(): Gamepad[];
  73426. msGetGamepads(): Gamepad[];
  73427. webkitGamepads(): Gamepad[];
  73428. }
  73429. interface HTMLVideoElement {
  73430. mozSrcObject: any;
  73431. }
  73432. interface Math {
  73433. fround(x: number): number;
  73434. imul(a: number, b: number): number;
  73435. }
  73436. interface WebGLRenderingContext {
  73437. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73438. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73439. vertexAttribDivisor(index: number, divisor: number): void;
  73440. createVertexArray(): any;
  73441. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73442. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73443. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73444. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73445. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73446. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73447. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73448. // Queries
  73449. createQuery(): WebGLQuery;
  73450. deleteQuery(query: WebGLQuery): void;
  73451. beginQuery(target: number, query: WebGLQuery): void;
  73452. endQuery(target: number): void;
  73453. getQueryParameter(query: WebGLQuery, pname: number): any;
  73454. getQuery(target: number, pname: number): any;
  73455. MAX_SAMPLES: number;
  73456. RGBA8: number;
  73457. READ_FRAMEBUFFER: number;
  73458. DRAW_FRAMEBUFFER: number;
  73459. UNIFORM_BUFFER: number;
  73460. HALF_FLOAT_OES: number;
  73461. RGBA16F: number;
  73462. RGBA32F: number;
  73463. R32F: number;
  73464. RG32F: number;
  73465. RGB32F: number;
  73466. R16F: number;
  73467. RG16F: number;
  73468. RGB16F: number;
  73469. RED: number;
  73470. RG: number;
  73471. R8: number;
  73472. RG8: number;
  73473. UNSIGNED_INT_24_8: number;
  73474. DEPTH24_STENCIL8: number;
  73475. MIN: number;
  73476. MAX: number;
  73477. /* Multiple Render Targets */
  73478. drawBuffers(buffers: number[]): void;
  73479. readBuffer(src: number): void;
  73480. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73481. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73482. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73483. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73484. // Occlusion Query
  73485. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73486. ANY_SAMPLES_PASSED: number;
  73487. QUERY_RESULT_AVAILABLE: number;
  73488. QUERY_RESULT: number;
  73489. }
  73490. interface WebGLProgram {
  73491. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73492. }
  73493. interface EXT_disjoint_timer_query {
  73494. QUERY_COUNTER_BITS_EXT: number;
  73495. TIME_ELAPSED_EXT: number;
  73496. TIMESTAMP_EXT: number;
  73497. GPU_DISJOINT_EXT: number;
  73498. QUERY_RESULT_EXT: number;
  73499. QUERY_RESULT_AVAILABLE_EXT: number;
  73500. queryCounterEXT(query: WebGLQuery, target: number): void;
  73501. createQueryEXT(): WebGLQuery;
  73502. beginQueryEXT(target: number, query: WebGLQuery): void;
  73503. endQueryEXT(target: number): void;
  73504. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73505. deleteQueryEXT(query: WebGLQuery): void;
  73506. }
  73507. interface WebGLUniformLocation {
  73508. _currentState: any;
  73509. }
  73510. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73511. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73512. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73513. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73514. interface WebGLRenderingContext {
  73515. readonly RASTERIZER_DISCARD: number;
  73516. readonly DEPTH_COMPONENT24: number;
  73517. readonly TEXTURE_3D: number;
  73518. readonly TEXTURE_2D_ARRAY: number;
  73519. readonly TEXTURE_COMPARE_FUNC: number;
  73520. readonly TEXTURE_COMPARE_MODE: number;
  73521. readonly COMPARE_REF_TO_TEXTURE: number;
  73522. readonly TEXTURE_WRAP_R: number;
  73523. readonly HALF_FLOAT: number;
  73524. readonly RGB8: number;
  73525. readonly RED_INTEGER: number;
  73526. readonly RG_INTEGER: number;
  73527. readonly RGB_INTEGER: number;
  73528. readonly RGBA_INTEGER: number;
  73529. readonly R8_SNORM: number;
  73530. readonly RG8_SNORM: number;
  73531. readonly RGB8_SNORM: number;
  73532. readonly RGBA8_SNORM: number;
  73533. readonly R8I: number;
  73534. readonly RG8I: number;
  73535. readonly RGB8I: number;
  73536. readonly RGBA8I: number;
  73537. readonly R8UI: number;
  73538. readonly RG8UI: number;
  73539. readonly RGB8UI: number;
  73540. readonly RGBA8UI: number;
  73541. readonly R16I: number;
  73542. readonly RG16I: number;
  73543. readonly RGB16I: number;
  73544. readonly RGBA16I: number;
  73545. readonly R16UI: number;
  73546. readonly RG16UI: number;
  73547. readonly RGB16UI: number;
  73548. readonly RGBA16UI: number;
  73549. readonly R32I: number;
  73550. readonly RG32I: number;
  73551. readonly RGB32I: number;
  73552. readonly RGBA32I: number;
  73553. readonly R32UI: number;
  73554. readonly RG32UI: number;
  73555. readonly RGB32UI: number;
  73556. readonly RGBA32UI: number;
  73557. readonly RGB10_A2UI: number;
  73558. readonly R11F_G11F_B10F: number;
  73559. readonly RGB9_E5: number;
  73560. readonly RGB10_A2: number;
  73561. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73562. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73563. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73564. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73565. readonly DEPTH_COMPONENT32F: number;
  73566. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73567. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73568. 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;
  73569. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73570. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73571. readonly TRANSFORM_FEEDBACK: number;
  73572. readonly INTERLEAVED_ATTRIBS: number;
  73573. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73574. createTransformFeedback(): WebGLTransformFeedback;
  73575. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73576. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73577. beginTransformFeedback(primitiveMode: number): void;
  73578. endTransformFeedback(): void;
  73579. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73580. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73581. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73582. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73583. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73584. }
  73585. interface ImageBitmap {
  73586. readonly width: number;
  73587. readonly height: number;
  73588. close(): void;
  73589. }
  73590. interface WebGLQuery extends WebGLObject {
  73591. }
  73592. declare var WebGLQuery: {
  73593. prototype: WebGLQuery;
  73594. new(): WebGLQuery;
  73595. };
  73596. interface WebGLSampler extends WebGLObject {
  73597. }
  73598. declare var WebGLSampler: {
  73599. prototype: WebGLSampler;
  73600. new(): WebGLSampler;
  73601. };
  73602. interface WebGLSync extends WebGLObject {
  73603. }
  73604. declare var WebGLSync: {
  73605. prototype: WebGLSync;
  73606. new(): WebGLSync;
  73607. };
  73608. interface WebGLTransformFeedback extends WebGLObject {
  73609. }
  73610. declare var WebGLTransformFeedback: {
  73611. prototype: WebGLTransformFeedback;
  73612. new(): WebGLTransformFeedback;
  73613. };
  73614. interface WebGLVertexArrayObject extends WebGLObject {
  73615. }
  73616. declare var WebGLVertexArrayObject: {
  73617. prototype: WebGLVertexArrayObject;
  73618. new(): WebGLVertexArrayObject;
  73619. };
  73620. // Type definitions for WebVR API
  73621. // Project: https://w3c.github.io/webvr/
  73622. // Definitions by: six a <https://github.com/lostfictions>
  73623. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73624. interface VRDisplay extends EventTarget {
  73625. /**
  73626. * Dictionary of capabilities describing the VRDisplay.
  73627. */
  73628. readonly capabilities: VRDisplayCapabilities;
  73629. /**
  73630. * z-depth defining the far plane of the eye view frustum
  73631. * enables mapping of values in the render target depth
  73632. * attachment to scene coordinates. Initially set to 10000.0.
  73633. */
  73634. depthFar: number;
  73635. /**
  73636. * z-depth defining the near plane of the eye view frustum
  73637. * enables mapping of values in the render target depth
  73638. * attachment to scene coordinates. Initially set to 0.01.
  73639. */
  73640. depthNear: number;
  73641. /**
  73642. * An identifier for this distinct VRDisplay. Used as an
  73643. * association point in the Gamepad API.
  73644. */
  73645. readonly displayId: number;
  73646. /**
  73647. * A display name, a user-readable name identifying it.
  73648. */
  73649. readonly displayName: string;
  73650. readonly isConnected: boolean;
  73651. readonly isPresenting: boolean;
  73652. /**
  73653. * If this VRDisplay supports room-scale experiences, the optional
  73654. * stage attribute contains details on the room-scale parameters.
  73655. */
  73656. readonly stageParameters: VRStageParameters | null;
  73657. /**
  73658. * Passing the value returned by `requestAnimationFrame` to
  73659. * `cancelAnimationFrame` will unregister the callback.
  73660. * @param handle Define the hanle of the request to cancel
  73661. */
  73662. cancelAnimationFrame(handle: number): void;
  73663. /**
  73664. * Stops presenting to the VRDisplay.
  73665. * @returns a promise to know when it stopped
  73666. */
  73667. exitPresent(): Promise<void>;
  73668. /**
  73669. * Return the current VREyeParameters for the given eye.
  73670. * @param whichEye Define the eye we want the parameter for
  73671. * @returns the eye parameters
  73672. */
  73673. getEyeParameters(whichEye: string): VREyeParameters;
  73674. /**
  73675. * Populates the passed VRFrameData with the information required to render
  73676. * the current frame.
  73677. * @param frameData Define the data structure to populate
  73678. * @returns true if ok otherwise false
  73679. */
  73680. getFrameData(frameData: VRFrameData): boolean;
  73681. /**
  73682. * Get the layers currently being presented.
  73683. * @returns the list of VR layers
  73684. */
  73685. getLayers(): VRLayer[];
  73686. /**
  73687. * Return a VRPose containing the future predicted pose of the VRDisplay
  73688. * when the current frame will be presented. The value returned will not
  73689. * change until JavaScript has returned control to the browser.
  73690. *
  73691. * The VRPose will contain the position, orientation, velocity,
  73692. * and acceleration of each of these properties.
  73693. * @returns the pose object
  73694. */
  73695. getPose(): VRPose;
  73696. /**
  73697. * Return the current instantaneous pose of the VRDisplay, with no
  73698. * prediction applied.
  73699. * @returns the current instantaneous pose
  73700. */
  73701. getImmediatePose(): VRPose;
  73702. /**
  73703. * The callback passed to `requestAnimationFrame` will be called
  73704. * any time a new frame should be rendered. When the VRDisplay is
  73705. * presenting the callback will be called at the native refresh
  73706. * rate of the HMD. When not presenting this function acts
  73707. * identically to how window.requestAnimationFrame acts. Content should
  73708. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73709. * asynchronously from other displays and at differing refresh rates.
  73710. * @param callback Define the eaction to run next frame
  73711. * @returns the request handle it
  73712. */
  73713. requestAnimationFrame(callback: FrameRequestCallback): number;
  73714. /**
  73715. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73716. * Repeat calls while already presenting will update the VRLayers being displayed.
  73717. * @param layers Define the list of layer to present
  73718. * @returns a promise to know when the request has been fulfilled
  73719. */
  73720. requestPresent(layers: VRLayer[]): Promise<void>;
  73721. /**
  73722. * Reset the pose for this display, treating its current position and
  73723. * orientation as the "origin/zero" values. VRPose.position,
  73724. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73725. * updated when calling resetPose(). This should be called in only
  73726. * sitting-space experiences.
  73727. */
  73728. resetPose(): void;
  73729. /**
  73730. * The VRLayer provided to the VRDisplay will be captured and presented
  73731. * in the HMD. Calling this function has the same effect on the source
  73732. * canvas as any other operation that uses its source image, and canvases
  73733. * created without preserveDrawingBuffer set to true will be cleared.
  73734. * @param pose Define the pose to submit
  73735. */
  73736. submitFrame(pose?: VRPose): void;
  73737. }
  73738. declare var VRDisplay: {
  73739. prototype: VRDisplay;
  73740. new(): VRDisplay;
  73741. };
  73742. interface VRLayer {
  73743. leftBounds?: number[] | Float32Array | null;
  73744. rightBounds?: number[] | Float32Array | null;
  73745. source?: HTMLCanvasElement | null;
  73746. }
  73747. interface VRDisplayCapabilities {
  73748. readonly canPresent: boolean;
  73749. readonly hasExternalDisplay: boolean;
  73750. readonly hasOrientation: boolean;
  73751. readonly hasPosition: boolean;
  73752. readonly maxLayers: number;
  73753. }
  73754. interface VREyeParameters {
  73755. /** @deprecated */
  73756. readonly fieldOfView: VRFieldOfView;
  73757. readonly offset: Float32Array;
  73758. readonly renderHeight: number;
  73759. readonly renderWidth: number;
  73760. }
  73761. interface VRFieldOfView {
  73762. readonly downDegrees: number;
  73763. readonly leftDegrees: number;
  73764. readonly rightDegrees: number;
  73765. readonly upDegrees: number;
  73766. }
  73767. interface VRFrameData {
  73768. readonly leftProjectionMatrix: Float32Array;
  73769. readonly leftViewMatrix: Float32Array;
  73770. readonly pose: VRPose;
  73771. readonly rightProjectionMatrix: Float32Array;
  73772. readonly rightViewMatrix: Float32Array;
  73773. readonly timestamp: number;
  73774. }
  73775. interface VRPose {
  73776. readonly angularAcceleration: Float32Array | null;
  73777. readonly angularVelocity: Float32Array | null;
  73778. readonly linearAcceleration: Float32Array | null;
  73779. readonly linearVelocity: Float32Array | null;
  73780. readonly orientation: Float32Array | null;
  73781. readonly position: Float32Array | null;
  73782. readonly timestamp: number;
  73783. }
  73784. interface VRStageParameters {
  73785. sittingToStandingTransform?: Float32Array;
  73786. sizeX?: number;
  73787. sizeY?: number;
  73788. }
  73789. interface Navigator {
  73790. getVRDisplays(): Promise<VRDisplay[]>;
  73791. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73792. }
  73793. interface Window {
  73794. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73795. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73796. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73797. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73798. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73799. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73800. }
  73801. interface Gamepad {
  73802. readonly displayId: number;
  73803. }
  73804. type XRSessionMode =
  73805. | "inline"
  73806. | "immersive-vr"
  73807. | "immersive-ar";
  73808. type XRReferenceSpaceType =
  73809. | "viewer"
  73810. | "local"
  73811. | "local-floor"
  73812. | "bounded-floor"
  73813. | "unbounded";
  73814. type XREnvironmentBlendMode =
  73815. | "opaque"
  73816. | "additive"
  73817. | "alpha-blend";
  73818. type XRVisibilityState =
  73819. | "visible"
  73820. | "visible-blurred"
  73821. | "hidden";
  73822. type XRHandedness =
  73823. | "none"
  73824. | "left"
  73825. | "right";
  73826. type XRTargetRayMode =
  73827. | "gaze"
  73828. | "tracked-pointer"
  73829. | "screen";
  73830. type XREye =
  73831. | "none"
  73832. | "left"
  73833. | "right";
  73834. type XREventType =
  73835. | "devicechange"
  73836. | "visibilitychange"
  73837. | "end"
  73838. | "inputsourceschange"
  73839. | "select"
  73840. | "selectstart"
  73841. | "selectend"
  73842. | "squeeze"
  73843. | "squeezestart"
  73844. | "squeezeend"
  73845. | "reset";
  73846. interface XRSpace extends EventTarget {
  73847. }
  73848. interface XRRenderState {
  73849. depthNear?: number;
  73850. depthFar?: number;
  73851. inlineVerticalFieldOfView?: number;
  73852. baseLayer?: XRWebGLLayer;
  73853. }
  73854. interface XRInputSource {
  73855. handedness: XRHandedness;
  73856. targetRayMode: XRTargetRayMode;
  73857. targetRaySpace: XRSpace;
  73858. gripSpace: XRSpace | undefined;
  73859. gamepad: Gamepad | undefined;
  73860. profiles: Array<string>;
  73861. }
  73862. interface XRSessionInit {
  73863. optionalFeatures?: string[];
  73864. requiredFeatures?: string[];
  73865. }
  73866. interface XRSession {
  73867. addEventListener: Function;
  73868. removeEventListener: Function;
  73869. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73870. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73871. requestAnimationFrame: Function;
  73872. end(): Promise<void>;
  73873. renderState: XRRenderState;
  73874. inputSources: Array<XRInputSource>;
  73875. // hit test
  73876. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73877. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73878. // legacy AR hit test
  73879. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73880. // legacy plane detection
  73881. updateWorldTrackingState(options: {
  73882. planeDetectionState?: { enabled: boolean; }
  73883. }): void;
  73884. }
  73885. interface XRReferenceSpace extends XRSpace {
  73886. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73887. onreset: any;
  73888. }
  73889. type XRPlaneSet = Set<XRPlane>;
  73890. type XRAnchorSet = Set<XRAnchor>;
  73891. interface XRFrame {
  73892. session: XRSession;
  73893. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73894. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73895. // AR
  73896. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73897. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73898. // Anchors
  73899. trackedAnchors?: XRAnchorSet;
  73900. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73901. // Planes
  73902. worldInformation: {
  73903. detectedPlanes?: XRPlaneSet;
  73904. };
  73905. }
  73906. interface XRViewerPose extends XRPose {
  73907. views: Array<XRView>;
  73908. }
  73909. interface XRPose {
  73910. transform: XRRigidTransform;
  73911. emulatedPosition: boolean;
  73912. }
  73913. interface XRWebGLLayerOptions {
  73914. antialias?: boolean;
  73915. depth?: boolean;
  73916. stencil?: boolean;
  73917. alpha?: boolean;
  73918. multiview?: boolean;
  73919. framebufferScaleFactor?: number;
  73920. }
  73921. declare var XRWebGLLayer: {
  73922. prototype: XRWebGLLayer;
  73923. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73924. };
  73925. interface XRWebGLLayer {
  73926. framebuffer: WebGLFramebuffer;
  73927. framebufferWidth: number;
  73928. framebufferHeight: number;
  73929. getViewport: Function;
  73930. }
  73931. declare class XRRigidTransform {
  73932. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73933. position: DOMPointReadOnly;
  73934. orientation: DOMPointReadOnly;
  73935. matrix: Float32Array;
  73936. inverse: XRRigidTransform;
  73937. }
  73938. interface XRView {
  73939. eye: XREye;
  73940. projectionMatrix: Float32Array;
  73941. transform: XRRigidTransform;
  73942. }
  73943. interface XRInputSourceChangeEvent {
  73944. session: XRSession;
  73945. removed: Array<XRInputSource>;
  73946. added: Array<XRInputSource>;
  73947. }
  73948. interface XRInputSourceEvent extends Event {
  73949. readonly frame: XRFrame;
  73950. readonly inputSource: XRInputSource;
  73951. }
  73952. // Experimental(er) features
  73953. declare class XRRay {
  73954. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73955. origin: DOMPointReadOnly;
  73956. direction: DOMPointReadOnly;
  73957. matrix: Float32Array;
  73958. }
  73959. declare enum XRHitTestTrackableType {
  73960. "point",
  73961. "plane"
  73962. }
  73963. interface XRHitResult {
  73964. hitMatrix: Float32Array;
  73965. }
  73966. interface XRTransientInputHitTestResult {
  73967. readonly inputSource: XRInputSource;
  73968. readonly results: Array<XRHitTestResult>;
  73969. }
  73970. interface XRHitTestResult {
  73971. getPose(baseSpace: XRSpace): XRPose | undefined;
  73972. // When anchor system is enabled
  73973. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73974. }
  73975. interface XRHitTestSource {
  73976. cancel(): void;
  73977. }
  73978. interface XRTransientInputHitTestSource {
  73979. cancel(): void;
  73980. }
  73981. interface XRHitTestOptionsInit {
  73982. space: XRSpace;
  73983. entityTypes?: Array<XRHitTestTrackableType>;
  73984. offsetRay?: XRRay;
  73985. }
  73986. interface XRTransientInputHitTestOptionsInit {
  73987. profile: string;
  73988. entityTypes?: Array<XRHitTestTrackableType>;
  73989. offsetRay?: XRRay;
  73990. }
  73991. interface XRAnchor {
  73992. anchorSpace: XRSpace;
  73993. delete(): void;
  73994. }
  73995. interface XRPlane {
  73996. orientation: "Horizontal" | "Vertical";
  73997. planeSpace: XRSpace;
  73998. polygon: Array<DOMPointReadOnly>;
  73999. lastChangedTime: number;
  74000. }
  74001. /**
  74002. * @ignore
  74003. */
  74004. declare module BABYLON.GLTF2.Exporter {
  74005. }
  74006. /**
  74007. * @ignore
  74008. */
  74009. declare module BABYLON.GLTF1 {
  74010. }
  74011. declare module BABYLON.GUI {
  74012. /**
  74013. * Class used to specific a value and its associated unit
  74014. */
  74015. export class ValueAndUnit {
  74016. /** defines the unit to store */
  74017. unit: number;
  74018. /** defines a boolean indicating if the value can be negative */
  74019. negativeValueAllowed: boolean;
  74020. private _value;
  74021. private _originalUnit;
  74022. /**
  74023. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74024. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74025. */
  74026. ignoreAdaptiveScaling: boolean;
  74027. /**
  74028. * Creates a new ValueAndUnit
  74029. * @param value defines the value to store
  74030. * @param unit defines the unit to store
  74031. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74032. */
  74033. constructor(value: number,
  74034. /** defines the unit to store */
  74035. unit?: number,
  74036. /** defines a boolean indicating if the value can be negative */
  74037. negativeValueAllowed?: boolean);
  74038. /** Gets a boolean indicating if the value is a percentage */
  74039. get isPercentage(): boolean;
  74040. /** Gets a boolean indicating if the value is store as pixel */
  74041. get isPixel(): boolean;
  74042. /** Gets direct internal value */
  74043. get internalValue(): number;
  74044. /**
  74045. * Gets value as pixel
  74046. * @param host defines the root host
  74047. * @param refValue defines the reference value for percentages
  74048. * @returns the value as pixel
  74049. */
  74050. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74051. /**
  74052. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74053. * @param value defines the value to store
  74054. * @param unit defines the unit to store
  74055. * @returns the current ValueAndUnit
  74056. */
  74057. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74058. /**
  74059. * Gets the value accordingly to its unit
  74060. * @param host defines the root host
  74061. * @returns the value
  74062. */
  74063. getValue(host: AdvancedDynamicTexture): number;
  74064. /**
  74065. * Gets a string representation of the value
  74066. * @param host defines the root host
  74067. * @param decimals defines an optional number of decimals to display
  74068. * @returns a string
  74069. */
  74070. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74071. /**
  74072. * Store a value parsed from a string
  74073. * @param source defines the source string
  74074. * @returns true if the value was successfully parsed
  74075. */
  74076. fromString(source: string | number): boolean;
  74077. private static _Regex;
  74078. private static _UNITMODE_PERCENTAGE;
  74079. private static _UNITMODE_PIXEL;
  74080. /** UNITMODE_PERCENTAGE */
  74081. static get UNITMODE_PERCENTAGE(): number;
  74082. /** UNITMODE_PIXEL */
  74083. static get UNITMODE_PIXEL(): number;
  74084. }
  74085. }
  74086. declare module BABYLON.GUI {
  74087. /**
  74088. * Define a style used by control to automatically setup properties based on a template.
  74089. * Only support font related properties so far
  74090. */
  74091. export class Style implements BABYLON.IDisposable {
  74092. private _fontFamily;
  74093. private _fontStyle;
  74094. private _fontWeight;
  74095. /** @hidden */
  74096. _host: AdvancedDynamicTexture;
  74097. /** @hidden */
  74098. _fontSize: ValueAndUnit;
  74099. /**
  74100. * BABYLON.Observable raised when the style values are changed
  74101. */
  74102. onChangedObservable: BABYLON.Observable<Style>;
  74103. /**
  74104. * Creates a new style object
  74105. * @param host defines the AdvancedDynamicTexture which hosts this style
  74106. */
  74107. constructor(host: AdvancedDynamicTexture);
  74108. /**
  74109. * Gets or sets the font size
  74110. */
  74111. get fontSize(): string | number;
  74112. set fontSize(value: string | number);
  74113. /**
  74114. * Gets or sets the font family
  74115. */
  74116. get fontFamily(): string;
  74117. set fontFamily(value: string);
  74118. /**
  74119. * Gets or sets the font style
  74120. */
  74121. get fontStyle(): string;
  74122. set fontStyle(value: string);
  74123. /** Gets or sets font weight */
  74124. get fontWeight(): string;
  74125. set fontWeight(value: string);
  74126. /** Dispose all associated resources */
  74127. dispose(): void;
  74128. }
  74129. }
  74130. declare module BABYLON.GUI {
  74131. /**
  74132. * Class used to transport BABYLON.Vector2 information for pointer events
  74133. */
  74134. export class Vector2WithInfo extends BABYLON.Vector2 {
  74135. /** defines the current mouse button index */
  74136. buttonIndex: number;
  74137. /**
  74138. * Creates a new Vector2WithInfo
  74139. * @param source defines the vector2 data to transport
  74140. * @param buttonIndex defines the current mouse button index
  74141. */
  74142. constructor(source: BABYLON.Vector2,
  74143. /** defines the current mouse button index */
  74144. buttonIndex?: number);
  74145. }
  74146. /** Class used to provide 2D matrix features */
  74147. export class Matrix2D {
  74148. /** Gets the internal array of 6 floats used to store matrix data */
  74149. m: Float32Array;
  74150. /**
  74151. * Creates a new matrix
  74152. * @param m00 defines value for (0, 0)
  74153. * @param m01 defines value for (0, 1)
  74154. * @param m10 defines value for (1, 0)
  74155. * @param m11 defines value for (1, 1)
  74156. * @param m20 defines value for (2, 0)
  74157. * @param m21 defines value for (2, 1)
  74158. */
  74159. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74160. /**
  74161. * Fills the matrix from direct values
  74162. * @param m00 defines value for (0, 0)
  74163. * @param m01 defines value for (0, 1)
  74164. * @param m10 defines value for (1, 0)
  74165. * @param m11 defines value for (1, 1)
  74166. * @param m20 defines value for (2, 0)
  74167. * @param m21 defines value for (2, 1)
  74168. * @returns the current modified matrix
  74169. */
  74170. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74171. /**
  74172. * Gets matrix determinant
  74173. * @returns the determinant
  74174. */
  74175. determinant(): number;
  74176. /**
  74177. * Inverses the matrix and stores it in a target matrix
  74178. * @param result defines the target matrix
  74179. * @returns the current matrix
  74180. */
  74181. invertToRef(result: Matrix2D): Matrix2D;
  74182. /**
  74183. * Multiplies the current matrix with another one
  74184. * @param other defines the second operand
  74185. * @param result defines the target matrix
  74186. * @returns the current matrix
  74187. */
  74188. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74189. /**
  74190. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74191. * @param x defines the x coordinate to transform
  74192. * @param y defines the x coordinate to transform
  74193. * @param result defines the target vector2
  74194. * @returns the current matrix
  74195. */
  74196. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74197. /**
  74198. * Creates an identity matrix
  74199. * @returns a new matrix
  74200. */
  74201. static Identity(): Matrix2D;
  74202. /**
  74203. * Creates a translation matrix and stores it in a target matrix
  74204. * @param x defines the x coordinate of the translation
  74205. * @param y defines the y coordinate of the translation
  74206. * @param result defines the target matrix
  74207. */
  74208. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74209. /**
  74210. * Creates a scaling matrix and stores it in a target matrix
  74211. * @param x defines the x coordinate of the scaling
  74212. * @param y defines the y coordinate of the scaling
  74213. * @param result defines the target matrix
  74214. */
  74215. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74216. /**
  74217. * Creates a rotation matrix and stores it in a target matrix
  74218. * @param angle defines the rotation angle
  74219. * @param result defines the target matrix
  74220. */
  74221. static RotationToRef(angle: number, result: Matrix2D): void;
  74222. private static _TempPreTranslationMatrix;
  74223. private static _TempPostTranslationMatrix;
  74224. private static _TempRotationMatrix;
  74225. private static _TempScalingMatrix;
  74226. private static _TempCompose0;
  74227. private static _TempCompose1;
  74228. private static _TempCompose2;
  74229. /**
  74230. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74231. * @param tx defines the x coordinate of the translation
  74232. * @param ty defines the y coordinate of the translation
  74233. * @param angle defines the rotation angle
  74234. * @param scaleX defines the x coordinate of the scaling
  74235. * @param scaleY defines the y coordinate of the scaling
  74236. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74237. * @param result defines the target matrix
  74238. */
  74239. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74240. }
  74241. }
  74242. declare module BABYLON.GUI {
  74243. /**
  74244. * Class used to store 2D control sizes
  74245. */
  74246. export class Measure {
  74247. /** defines left coordinate */
  74248. left: number;
  74249. /** defines top coordinate */
  74250. top: number;
  74251. /** defines width dimension */
  74252. width: number;
  74253. /** defines height dimension */
  74254. height: number;
  74255. /**
  74256. * Creates a new measure
  74257. * @param left defines left coordinate
  74258. * @param top defines top coordinate
  74259. * @param width defines width dimension
  74260. * @param height defines height dimension
  74261. */
  74262. constructor(
  74263. /** defines left coordinate */
  74264. left: number,
  74265. /** defines top coordinate */
  74266. top: number,
  74267. /** defines width dimension */
  74268. width: number,
  74269. /** defines height dimension */
  74270. height: number);
  74271. /**
  74272. * Copy from another measure
  74273. * @param other defines the other measure to copy from
  74274. */
  74275. copyFrom(other: Measure): void;
  74276. /**
  74277. * Copy from a group of 4 floats
  74278. * @param left defines left coordinate
  74279. * @param top defines top coordinate
  74280. * @param width defines width dimension
  74281. * @param height defines height dimension
  74282. */
  74283. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74284. /**
  74285. * Computes the axis aligned bounding box measure for two given measures
  74286. * @param a Input measure
  74287. * @param b Input measure
  74288. * @param result the resulting bounding measure
  74289. */
  74290. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74291. /**
  74292. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74293. * @param transform the matrix to transform the measure before computing the AABB
  74294. * @param result the resulting AABB
  74295. */
  74296. transformToRef(transform: Matrix2D, result: Measure): void;
  74297. /**
  74298. * Check equality between this measure and another one
  74299. * @param other defines the other measures
  74300. * @returns true if both measures are equals
  74301. */
  74302. isEqualsTo(other: Measure): boolean;
  74303. /**
  74304. * Creates an empty measure
  74305. * @returns a new measure
  74306. */
  74307. static Empty(): Measure;
  74308. }
  74309. }
  74310. declare module BABYLON.GUI {
  74311. /**
  74312. * Interface used to define a control that can receive focus
  74313. */
  74314. export interface IFocusableControl {
  74315. /**
  74316. * Function called when the control receives the focus
  74317. */
  74318. onFocus(): void;
  74319. /**
  74320. * Function called when the control loses the focus
  74321. */
  74322. onBlur(): void;
  74323. /**
  74324. * Function called to let the control handle keyboard events
  74325. * @param evt defines the current keyboard event
  74326. */
  74327. processKeyboard(evt: KeyboardEvent): void;
  74328. /**
  74329. * Function called to get the list of controls that should not steal the focus from this control
  74330. * @returns an array of controls
  74331. */
  74332. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74333. }
  74334. /**
  74335. * Class used to create texture to support 2D GUI elements
  74336. * @see http://doc.babylonjs.com/how_to/gui
  74337. */
  74338. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74339. private _isDirty;
  74340. private _renderObserver;
  74341. private _resizeObserver;
  74342. private _preKeyboardObserver;
  74343. private _pointerMoveObserver;
  74344. private _pointerObserver;
  74345. private _canvasPointerOutObserver;
  74346. private _background;
  74347. /** @hidden */
  74348. _rootContainer: Container;
  74349. /** @hidden */
  74350. _lastPickedControl: Control;
  74351. /** @hidden */
  74352. _lastControlOver: {
  74353. [pointerId: number]: Control;
  74354. };
  74355. /** @hidden */
  74356. _lastControlDown: {
  74357. [pointerId: number]: Control;
  74358. };
  74359. /** @hidden */
  74360. _capturingControl: {
  74361. [pointerId: number]: Control;
  74362. };
  74363. /** @hidden */
  74364. _shouldBlockPointer: boolean;
  74365. /** @hidden */
  74366. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74367. /** @hidden */
  74368. _linkedControls: Control[];
  74369. private _isFullscreen;
  74370. private _fullscreenViewport;
  74371. private _idealWidth;
  74372. private _idealHeight;
  74373. private _useSmallestIdeal;
  74374. private _renderAtIdealSize;
  74375. private _focusedControl;
  74376. private _blockNextFocusCheck;
  74377. private _renderScale;
  74378. private _rootElement;
  74379. private _cursorChanged;
  74380. private _defaultMousePointerId;
  74381. /** @hidden */
  74382. _numLayoutCalls: number;
  74383. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74384. get numLayoutCalls(): number;
  74385. /** @hidden */
  74386. _numRenderCalls: number;
  74387. /** Gets the number of render calls made the last time the ADT has been rendered */
  74388. get numRenderCalls(): number;
  74389. /**
  74390. * Define type to string to ensure compatibility across browsers
  74391. * Safari doesn't support DataTransfer constructor
  74392. */
  74393. private _clipboardData;
  74394. /**
  74395. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74396. */
  74397. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74398. /**
  74399. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74400. */
  74401. onControlPickedObservable: BABYLON.Observable<Control>;
  74402. /**
  74403. * BABYLON.Observable event triggered before layout is evaluated
  74404. */
  74405. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74406. /**
  74407. * BABYLON.Observable event triggered after the layout was evaluated
  74408. */
  74409. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74410. /**
  74411. * BABYLON.Observable event triggered before the texture is rendered
  74412. */
  74413. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74414. /**
  74415. * BABYLON.Observable event triggered after the texture was rendered
  74416. */
  74417. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74418. /**
  74419. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74420. */
  74421. premulAlpha: boolean;
  74422. /**
  74423. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74424. * Useful when you want more antialiasing
  74425. */
  74426. get renderScale(): number;
  74427. set renderScale(value: number);
  74428. /** Gets or sets the background color */
  74429. get background(): string;
  74430. set background(value: string);
  74431. /**
  74432. * Gets or sets the ideal width used to design controls.
  74433. * The GUI will then rescale everything accordingly
  74434. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74435. */
  74436. get idealWidth(): number;
  74437. set idealWidth(value: number);
  74438. /**
  74439. * Gets or sets the ideal height used to design controls.
  74440. * The GUI will then rescale everything accordingly
  74441. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74442. */
  74443. get idealHeight(): number;
  74444. set idealHeight(value: number);
  74445. /**
  74446. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74447. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74448. */
  74449. get useSmallestIdeal(): boolean;
  74450. set useSmallestIdeal(value: boolean);
  74451. /**
  74452. * Gets or sets a boolean indicating if adaptive scaling must be used
  74453. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74454. */
  74455. get renderAtIdealSize(): boolean;
  74456. set renderAtIdealSize(value: boolean);
  74457. /**
  74458. * Gets the ratio used when in "ideal mode"
  74459. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74460. * */
  74461. get idealRatio(): number;
  74462. /**
  74463. * Gets the underlying layer used to render the texture when in fullscreen mode
  74464. */
  74465. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74466. /**
  74467. * Gets the root container control
  74468. */
  74469. get rootContainer(): Container;
  74470. /**
  74471. * Returns an array containing the root container.
  74472. * This is mostly used to let the Inspector introspects the ADT
  74473. * @returns an array containing the rootContainer
  74474. */
  74475. getChildren(): Array<Container>;
  74476. /**
  74477. * Will return all controls that are inside this texture
  74478. * @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
  74479. * @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
  74480. * @return all child controls
  74481. */
  74482. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74483. /**
  74484. * Gets or sets the current focused control
  74485. */
  74486. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74487. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74488. /**
  74489. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74490. */
  74491. get isForeground(): boolean;
  74492. set isForeground(value: boolean);
  74493. /**
  74494. * Gets or set information about clipboardData
  74495. */
  74496. get clipboardData(): string;
  74497. set clipboardData(value: string);
  74498. /**
  74499. * Creates a new AdvancedDynamicTexture
  74500. * @param name defines the name of the texture
  74501. * @param width defines the width of the texture
  74502. * @param height defines the height of the texture
  74503. * @param scene defines the hosting scene
  74504. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74505. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74506. */
  74507. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74508. /**
  74509. * Get the current class name of the texture useful for serialization or dynamic coding.
  74510. * @returns "AdvancedDynamicTexture"
  74511. */
  74512. getClassName(): string;
  74513. /**
  74514. * Function used to execute a function on all controls
  74515. * @param func defines the function to execute
  74516. * @param container defines the container where controls belong. If null the root container will be used
  74517. */
  74518. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74519. private _useInvalidateRectOptimization;
  74520. /**
  74521. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74522. */
  74523. get useInvalidateRectOptimization(): boolean;
  74524. set useInvalidateRectOptimization(value: boolean);
  74525. private _invalidatedRectangle;
  74526. /**
  74527. * Invalidates a rectangle area on the gui texture
  74528. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74529. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74530. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74531. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74532. */
  74533. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74534. /**
  74535. * Marks the texture as dirty forcing a complete update
  74536. */
  74537. markAsDirty(): void;
  74538. /**
  74539. * Helper function used to create a new style
  74540. * @returns a new style
  74541. * @see http://doc.babylonjs.com/how_to/gui#styles
  74542. */
  74543. createStyle(): Style;
  74544. /**
  74545. * Adds a new control to the root container
  74546. * @param control defines the control to add
  74547. * @returns the current texture
  74548. */
  74549. addControl(control: Control): AdvancedDynamicTexture;
  74550. /**
  74551. * Removes a control from the root container
  74552. * @param control defines the control to remove
  74553. * @returns the current texture
  74554. */
  74555. removeControl(control: Control): AdvancedDynamicTexture;
  74556. /**
  74557. * Release all resources
  74558. */
  74559. dispose(): void;
  74560. private _onResize;
  74561. /** @hidden */
  74562. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74563. /**
  74564. * Get screen coordinates for a vector3
  74565. * @param position defines the position to project
  74566. * @param worldMatrix defines the world matrix to use
  74567. * @returns the projected position
  74568. */
  74569. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74570. private _checkUpdate;
  74571. private _clearMeasure;
  74572. private _render;
  74573. /** @hidden */
  74574. _changeCursor(cursor: string): void;
  74575. /** @hidden */
  74576. _registerLastControlDown(control: Control, pointerId: number): void;
  74577. private _doPicking;
  74578. /** @hidden */
  74579. _cleanControlAfterRemovalFromList(list: {
  74580. [pointerId: number]: Control;
  74581. }, control: Control): void;
  74582. /** @hidden */
  74583. _cleanControlAfterRemoval(control: Control): void;
  74584. /** Attach to all scene events required to support pointer events */
  74585. attach(): void;
  74586. /** @hidden */
  74587. private onClipboardCopy;
  74588. /** @hidden */
  74589. private onClipboardCut;
  74590. /** @hidden */
  74591. private onClipboardPaste;
  74592. /**
  74593. * Register the clipboard Events onto the canvas
  74594. */
  74595. registerClipboardEvents(): void;
  74596. /**
  74597. * Unregister the clipboard Events from the canvas
  74598. */
  74599. unRegisterClipboardEvents(): void;
  74600. /**
  74601. * Connect the texture to a hosting mesh to enable interactions
  74602. * @param mesh defines the mesh to attach to
  74603. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74604. */
  74605. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74606. /**
  74607. * Move the focus to a specific control
  74608. * @param control defines the control which will receive the focus
  74609. */
  74610. moveFocusToControl(control: IFocusableControl): void;
  74611. private _manageFocus;
  74612. private _attachToOnPointerOut;
  74613. /**
  74614. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74615. * @param mesh defines the mesh which will receive the texture
  74616. * @param width defines the texture width (1024 by default)
  74617. * @param height defines the texture height (1024 by default)
  74618. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74619. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74620. * @returns a new AdvancedDynamicTexture
  74621. */
  74622. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74623. /**
  74624. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74625. * In this mode the texture will rely on a layer for its rendering.
  74626. * This allows it to be treated like any other layer.
  74627. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74628. * LayerMask is set through advancedTexture.layer.layerMask
  74629. * @param name defines name for the texture
  74630. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74631. * @param scene defines the hsoting scene
  74632. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74633. * @returns a new AdvancedDynamicTexture
  74634. */
  74635. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74636. }
  74637. }
  74638. declare module BABYLON.GUI {
  74639. /**
  74640. * Root class used for all 2D controls
  74641. * @see http://doc.babylonjs.com/how_to/gui#controls
  74642. */
  74643. export class Control {
  74644. /** defines the name of the control */
  74645. name?: string | undefined;
  74646. /**
  74647. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74648. */
  74649. static AllowAlphaInheritance: boolean;
  74650. private _alpha;
  74651. private _alphaSet;
  74652. private _zIndex;
  74653. /** @hidden */
  74654. _host: AdvancedDynamicTexture;
  74655. /** Gets or sets the control parent */
  74656. parent: BABYLON.Nullable<Container>;
  74657. /** @hidden */
  74658. _currentMeasure: Measure;
  74659. private _fontFamily;
  74660. private _fontStyle;
  74661. private _fontWeight;
  74662. private _fontSize;
  74663. private _font;
  74664. /** @hidden */
  74665. _width: ValueAndUnit;
  74666. /** @hidden */
  74667. _height: ValueAndUnit;
  74668. /** @hidden */
  74669. protected _fontOffset: {
  74670. ascent: number;
  74671. height: number;
  74672. descent: number;
  74673. };
  74674. private _color;
  74675. private _style;
  74676. private _styleObserver;
  74677. /** @hidden */
  74678. protected _horizontalAlignment: number;
  74679. /** @hidden */
  74680. protected _verticalAlignment: number;
  74681. /** @hidden */
  74682. protected _isDirty: boolean;
  74683. /** @hidden */
  74684. protected _wasDirty: boolean;
  74685. /** @hidden */
  74686. _tempParentMeasure: Measure;
  74687. /** @hidden */
  74688. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74689. /** @hidden */
  74690. protected _cachedParentMeasure: Measure;
  74691. private _paddingLeft;
  74692. private _paddingRight;
  74693. private _paddingTop;
  74694. private _paddingBottom;
  74695. /** @hidden */
  74696. _left: ValueAndUnit;
  74697. /** @hidden */
  74698. _top: ValueAndUnit;
  74699. private _scaleX;
  74700. private _scaleY;
  74701. private _rotation;
  74702. private _transformCenterX;
  74703. private _transformCenterY;
  74704. /** @hidden */
  74705. _transformMatrix: Matrix2D;
  74706. /** @hidden */
  74707. protected _invertTransformMatrix: Matrix2D;
  74708. /** @hidden */
  74709. protected _transformedPosition: BABYLON.Vector2;
  74710. private _isMatrixDirty;
  74711. private _cachedOffsetX;
  74712. private _cachedOffsetY;
  74713. private _isVisible;
  74714. private _isHighlighted;
  74715. /** @hidden */
  74716. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74717. private _fontSet;
  74718. private _dummyVector2;
  74719. private _downCount;
  74720. private _enterCount;
  74721. private _doNotRender;
  74722. private _downPointerIds;
  74723. protected _isEnabled: boolean;
  74724. protected _disabledColor: string;
  74725. protected _disabledColorItem: string;
  74726. /** @hidden */
  74727. protected _rebuildLayout: boolean;
  74728. /** @hidden */
  74729. _customData: any;
  74730. /** @hidden */
  74731. _isClipped: boolean;
  74732. /** @hidden */
  74733. _automaticSize: boolean;
  74734. /** @hidden */
  74735. _tag: any;
  74736. /**
  74737. * 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
  74738. */
  74739. uniqueId: number;
  74740. /**
  74741. * Gets or sets an object used to store user defined information for the node
  74742. */
  74743. metadata: any;
  74744. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74745. isHitTestVisible: boolean;
  74746. /** Gets or sets a boolean indicating if the control can block pointer events */
  74747. isPointerBlocker: boolean;
  74748. /** Gets or sets a boolean indicating if the control can be focusable */
  74749. isFocusInvisible: boolean;
  74750. /**
  74751. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74752. * 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
  74753. */
  74754. clipChildren: boolean;
  74755. /**
  74756. * Gets or sets a boolean indicating that control content must be clipped
  74757. * 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
  74758. */
  74759. clipContent: boolean;
  74760. /**
  74761. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74762. */
  74763. useBitmapCache: boolean;
  74764. private _cacheData;
  74765. private _shadowOffsetX;
  74766. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74767. get shadowOffsetX(): number;
  74768. set shadowOffsetX(value: number);
  74769. private _shadowOffsetY;
  74770. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74771. get shadowOffsetY(): number;
  74772. set shadowOffsetY(value: number);
  74773. private _shadowBlur;
  74774. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74775. get shadowBlur(): number;
  74776. set shadowBlur(value: number);
  74777. private _shadowColor;
  74778. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74779. get shadowColor(): string;
  74780. set shadowColor(value: string);
  74781. /** Gets or sets the cursor to use when the control is hovered */
  74782. hoverCursor: string;
  74783. /** @hidden */
  74784. protected _linkOffsetX: ValueAndUnit;
  74785. /** @hidden */
  74786. protected _linkOffsetY: ValueAndUnit;
  74787. /** Gets the control type name */
  74788. get typeName(): string;
  74789. /**
  74790. * Get the current class name of the control.
  74791. * @returns current class name
  74792. */
  74793. getClassName(): string;
  74794. /**
  74795. * An event triggered when pointer wheel is scrolled
  74796. */
  74797. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74798. /**
  74799. * An event triggered when the pointer move over the control.
  74800. */
  74801. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74802. /**
  74803. * An event triggered when the pointer move out of the control.
  74804. */
  74805. onPointerOutObservable: BABYLON.Observable<Control>;
  74806. /**
  74807. * An event triggered when the pointer taps the control
  74808. */
  74809. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74810. /**
  74811. * An event triggered when pointer up
  74812. */
  74813. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74814. /**
  74815. * An event triggered when a control is clicked on
  74816. */
  74817. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74818. /**
  74819. * An event triggered when pointer enters the control
  74820. */
  74821. onPointerEnterObservable: BABYLON.Observable<Control>;
  74822. /**
  74823. * An event triggered when the control is marked as dirty
  74824. */
  74825. onDirtyObservable: BABYLON.Observable<Control>;
  74826. /**
  74827. * An event triggered before drawing the control
  74828. */
  74829. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74830. /**
  74831. * An event triggered after the control was drawn
  74832. */
  74833. onAfterDrawObservable: BABYLON.Observable<Control>;
  74834. /**
  74835. * An event triggered when the control has been disposed
  74836. */
  74837. onDisposeObservable: BABYLON.Observable<Control>;
  74838. /**
  74839. * Get the hosting AdvancedDynamicTexture
  74840. */
  74841. get host(): AdvancedDynamicTexture;
  74842. /** Gets or set information about font offsets (used to render and align text) */
  74843. get fontOffset(): {
  74844. ascent: number;
  74845. height: number;
  74846. descent: number;
  74847. };
  74848. set fontOffset(offset: {
  74849. ascent: number;
  74850. height: number;
  74851. descent: number;
  74852. });
  74853. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74854. get alpha(): number;
  74855. set alpha(value: number);
  74856. /**
  74857. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74858. */
  74859. get isHighlighted(): boolean;
  74860. set isHighlighted(value: boolean);
  74861. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74862. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74863. */
  74864. get scaleX(): number;
  74865. set scaleX(value: number);
  74866. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74867. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74868. */
  74869. get scaleY(): number;
  74870. set scaleY(value: number);
  74871. /** Gets or sets the rotation angle (0 by default)
  74872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74873. */
  74874. get rotation(): number;
  74875. set rotation(value: number);
  74876. /** Gets or sets the transformation center on Y axis (0 by default)
  74877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74878. */
  74879. get transformCenterY(): number;
  74880. set transformCenterY(value: number);
  74881. /** Gets or sets the transformation center on X axis (0 by default)
  74882. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74883. */
  74884. get transformCenterX(): number;
  74885. set transformCenterX(value: number);
  74886. /**
  74887. * Gets or sets the horizontal alignment
  74888. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74889. */
  74890. get horizontalAlignment(): number;
  74891. set horizontalAlignment(value: number);
  74892. /**
  74893. * Gets or sets the vertical alignment
  74894. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74895. */
  74896. get verticalAlignment(): number;
  74897. set verticalAlignment(value: number);
  74898. /**
  74899. * Gets or sets control width
  74900. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74901. */
  74902. get width(): string | number;
  74903. set width(value: string | number);
  74904. /**
  74905. * Gets or sets the control width in pixel
  74906. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74907. */
  74908. get widthInPixels(): number;
  74909. set widthInPixels(value: number);
  74910. /**
  74911. * Gets or sets control height
  74912. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74913. */
  74914. get height(): string | number;
  74915. set height(value: string | number);
  74916. /**
  74917. * Gets or sets control height in pixel
  74918. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74919. */
  74920. get heightInPixels(): number;
  74921. set heightInPixels(value: number);
  74922. /** Gets or set font family */
  74923. get fontFamily(): string;
  74924. set fontFamily(value: string);
  74925. /** Gets or sets font style */
  74926. get fontStyle(): string;
  74927. set fontStyle(value: string);
  74928. /** Gets or sets font weight */
  74929. get fontWeight(): string;
  74930. set fontWeight(value: string);
  74931. /**
  74932. * Gets or sets style
  74933. * @see http://doc.babylonjs.com/how_to/gui#styles
  74934. */
  74935. get style(): BABYLON.Nullable<Style>;
  74936. set style(value: BABYLON.Nullable<Style>);
  74937. /** @hidden */
  74938. get _isFontSizeInPercentage(): boolean;
  74939. /** Gets or sets font size in pixels */
  74940. get fontSizeInPixels(): number;
  74941. set fontSizeInPixels(value: number);
  74942. /** Gets or sets font size */
  74943. get fontSize(): string | number;
  74944. set fontSize(value: string | number);
  74945. /** Gets or sets foreground color */
  74946. get color(): string;
  74947. set color(value: string);
  74948. /** Gets or sets z index which is used to reorder controls on the z axis */
  74949. get zIndex(): number;
  74950. set zIndex(value: number);
  74951. /** Gets or sets a boolean indicating if the control can be rendered */
  74952. get notRenderable(): boolean;
  74953. set notRenderable(value: boolean);
  74954. /** Gets or sets a boolean indicating if the control is visible */
  74955. get isVisible(): boolean;
  74956. set isVisible(value: boolean);
  74957. /** Gets a boolean indicating that the control needs to update its rendering */
  74958. get isDirty(): boolean;
  74959. /**
  74960. * Gets the current linked mesh (or null if none)
  74961. */
  74962. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74963. /**
  74964. * Gets or sets a value indicating the padding to use on the left of the control
  74965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74966. */
  74967. get paddingLeft(): string | number;
  74968. set paddingLeft(value: string | number);
  74969. /**
  74970. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74972. */
  74973. get paddingLeftInPixels(): number;
  74974. set paddingLeftInPixels(value: number);
  74975. /**
  74976. * Gets or sets a value indicating the padding to use on the right of the control
  74977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74978. */
  74979. get paddingRight(): string | number;
  74980. set paddingRight(value: string | number);
  74981. /**
  74982. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74984. */
  74985. get paddingRightInPixels(): number;
  74986. set paddingRightInPixels(value: number);
  74987. /**
  74988. * Gets or sets a value indicating the padding to use on the top of the control
  74989. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74990. */
  74991. get paddingTop(): string | number;
  74992. set paddingTop(value: string | number);
  74993. /**
  74994. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74995. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74996. */
  74997. get paddingTopInPixels(): number;
  74998. set paddingTopInPixels(value: number);
  74999. /**
  75000. * Gets or sets a value indicating the padding to use on the bottom of the control
  75001. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75002. */
  75003. get paddingBottom(): string | number;
  75004. set paddingBottom(value: string | number);
  75005. /**
  75006. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75007. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75008. */
  75009. get paddingBottomInPixels(): number;
  75010. set paddingBottomInPixels(value: number);
  75011. /**
  75012. * Gets or sets a value indicating the left coordinate of the control
  75013. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75014. */
  75015. get left(): string | number;
  75016. set left(value: string | number);
  75017. /**
  75018. * Gets or sets a value indicating the left coordinate in pixels of the control
  75019. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75020. */
  75021. get leftInPixels(): number;
  75022. set leftInPixels(value: number);
  75023. /**
  75024. * Gets or sets a value indicating the top coordinate of the control
  75025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75026. */
  75027. get top(): string | number;
  75028. set top(value: string | number);
  75029. /**
  75030. * Gets or sets a value indicating the top coordinate in pixels of the control
  75031. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75032. */
  75033. get topInPixels(): number;
  75034. set topInPixels(value: number);
  75035. /**
  75036. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75037. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75038. */
  75039. get linkOffsetX(): string | number;
  75040. set linkOffsetX(value: string | number);
  75041. /**
  75042. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75043. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75044. */
  75045. get linkOffsetXInPixels(): number;
  75046. set linkOffsetXInPixels(value: number);
  75047. /**
  75048. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75049. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75050. */
  75051. get linkOffsetY(): string | number;
  75052. set linkOffsetY(value: string | number);
  75053. /**
  75054. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75055. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75056. */
  75057. get linkOffsetYInPixels(): number;
  75058. set linkOffsetYInPixels(value: number);
  75059. /** Gets the center coordinate on X axis */
  75060. get centerX(): number;
  75061. /** Gets the center coordinate on Y axis */
  75062. get centerY(): number;
  75063. /** Gets or sets if control is Enabled*/
  75064. get isEnabled(): boolean;
  75065. set isEnabled(value: boolean);
  75066. /** Gets or sets background color of control if it's disabled*/
  75067. get disabledColor(): string;
  75068. set disabledColor(value: string);
  75069. /** Gets or sets front color of control if it's disabled*/
  75070. get disabledColorItem(): string;
  75071. set disabledColorItem(value: string);
  75072. /**
  75073. * Creates a new control
  75074. * @param name defines the name of the control
  75075. */
  75076. constructor(
  75077. /** defines the name of the control */
  75078. name?: string | undefined);
  75079. /** @hidden */
  75080. protected _getTypeName(): string;
  75081. /**
  75082. * Gets the first ascendant in the hierarchy of the given type
  75083. * @param className defines the required type
  75084. * @returns the ascendant or null if not found
  75085. */
  75086. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75087. /** @hidden */
  75088. _resetFontCache(): void;
  75089. /**
  75090. * Determines if a container is an ascendant of the current control
  75091. * @param container defines the container to look for
  75092. * @returns true if the container is one of the ascendant of the control
  75093. */
  75094. isAscendant(container: Control): boolean;
  75095. /**
  75096. * Gets coordinates in local control space
  75097. * @param globalCoordinates defines the coordinates to transform
  75098. * @returns the new coordinates in local space
  75099. */
  75100. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75101. /**
  75102. * Gets coordinates in local control space
  75103. * @param globalCoordinates defines the coordinates to transform
  75104. * @param result defines the target vector2 where to store the result
  75105. * @returns the current control
  75106. */
  75107. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75108. /**
  75109. * Gets coordinates in parent local control space
  75110. * @param globalCoordinates defines the coordinates to transform
  75111. * @returns the new coordinates in parent local space
  75112. */
  75113. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75114. /**
  75115. * Move the current control to a vector3 position projected onto the screen.
  75116. * @param position defines the target position
  75117. * @param scene defines the hosting scene
  75118. */
  75119. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75120. /**
  75121. * Will store all controls that have this control as ascendant in a given array
  75122. * @param results defines the array where to store the descendants
  75123. * @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
  75124. * @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
  75125. */
  75126. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75127. /**
  75128. * Will return all controls that have this control as ascendant
  75129. * @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
  75130. * @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
  75131. * @return all child controls
  75132. */
  75133. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75134. /**
  75135. * Link current control with a target mesh
  75136. * @param mesh defines the mesh to link with
  75137. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75138. */
  75139. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75140. /** @hidden */
  75141. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75142. /** @hidden */
  75143. _offsetLeft(offset: number): void;
  75144. /** @hidden */
  75145. _offsetTop(offset: number): void;
  75146. /** @hidden */
  75147. _markMatrixAsDirty(): void;
  75148. /** @hidden */
  75149. _flagDescendantsAsMatrixDirty(): void;
  75150. /** @hidden */
  75151. _intersectsRect(rect: Measure): boolean;
  75152. /** @hidden */
  75153. protected invalidateRect(): void;
  75154. /** @hidden */
  75155. _markAsDirty(force?: boolean): void;
  75156. /** @hidden */
  75157. _markAllAsDirty(): void;
  75158. /** @hidden */
  75159. _link(host: AdvancedDynamicTexture): void;
  75160. /** @hidden */
  75161. protected _transform(context?: CanvasRenderingContext2D): void;
  75162. /** @hidden */
  75163. _renderHighlight(context: CanvasRenderingContext2D): void;
  75164. /** @hidden */
  75165. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75166. /** @hidden */
  75167. protected _applyStates(context: CanvasRenderingContext2D): void;
  75168. /** @hidden */
  75169. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75170. /** @hidden */
  75171. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75172. protected _evaluateClippingState(parentMeasure: Measure): void;
  75173. /** @hidden */
  75174. _measure(): void;
  75175. /** @hidden */
  75176. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75177. /** @hidden */
  75178. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75179. /** @hidden */
  75180. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75181. /** @hidden */
  75182. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75183. private static _ClipMeasure;
  75184. private _tmpMeasureA;
  75185. private _clip;
  75186. /** @hidden */
  75187. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75188. /** @hidden */
  75189. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75190. /**
  75191. * Tests if a given coordinates belong to the current control
  75192. * @param x defines x coordinate to test
  75193. * @param y defines y coordinate to test
  75194. * @returns true if the coordinates are inside the control
  75195. */
  75196. contains(x: number, y: number): boolean;
  75197. /** @hidden */
  75198. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75199. /** @hidden */
  75200. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75201. /** @hidden */
  75202. _onPointerEnter(target: Control): boolean;
  75203. /** @hidden */
  75204. _onPointerOut(target: Control, force?: boolean): void;
  75205. /** @hidden */
  75206. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75207. /** @hidden */
  75208. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75209. /** @hidden */
  75210. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75211. /** @hidden */
  75212. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75213. /** @hidden */
  75214. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75215. private _prepareFont;
  75216. /** Releases associated resources */
  75217. dispose(): void;
  75218. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75219. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75220. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75221. private static _VERTICAL_ALIGNMENT_TOP;
  75222. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75223. private static _VERTICAL_ALIGNMENT_CENTER;
  75224. /** HORIZONTAL_ALIGNMENT_LEFT */
  75225. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75226. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75227. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75228. /** HORIZONTAL_ALIGNMENT_CENTER */
  75229. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75230. /** VERTICAL_ALIGNMENT_TOP */
  75231. static get VERTICAL_ALIGNMENT_TOP(): number;
  75232. /** VERTICAL_ALIGNMENT_BOTTOM */
  75233. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75234. /** VERTICAL_ALIGNMENT_CENTER */
  75235. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75236. private static _FontHeightSizes;
  75237. /** @hidden */
  75238. static _GetFontOffset(font: string): {
  75239. ascent: number;
  75240. height: number;
  75241. descent: number;
  75242. };
  75243. /**
  75244. * Creates a stack panel that can be used to render headers
  75245. * @param control defines the control to associate with the header
  75246. * @param text defines the text of the header
  75247. * @param size defines the size of the header
  75248. * @param options defines options used to configure the header
  75249. * @returns a new StackPanel
  75250. * @ignore
  75251. * @hidden
  75252. */
  75253. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75254. isHorizontal: boolean;
  75255. controlFirst: boolean;
  75256. }) => any;
  75257. /** @hidden */
  75258. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75259. }
  75260. }
  75261. declare module BABYLON.GUI {
  75262. /**
  75263. * Root class for 2D containers
  75264. * @see http://doc.babylonjs.com/how_to/gui#containers
  75265. */
  75266. export class Container extends Control {
  75267. name?: string | undefined;
  75268. /** @hidden */
  75269. _children: Control[];
  75270. /** @hidden */
  75271. protected _measureForChildren: Measure;
  75272. /** @hidden */
  75273. protected _background: string;
  75274. /** @hidden */
  75275. protected _adaptWidthToChildren: boolean;
  75276. /** @hidden */
  75277. protected _adaptHeightToChildren: boolean;
  75278. /**
  75279. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75280. */
  75281. logLayoutCycleErrors: boolean;
  75282. /**
  75283. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75284. */
  75285. maxLayoutCycle: number;
  75286. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75287. get adaptHeightToChildren(): boolean;
  75288. set adaptHeightToChildren(value: boolean);
  75289. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75290. get adaptWidthToChildren(): boolean;
  75291. set adaptWidthToChildren(value: boolean);
  75292. /** Gets or sets background color */
  75293. get background(): string;
  75294. set background(value: string);
  75295. /** Gets the list of children */
  75296. get children(): Control[];
  75297. /**
  75298. * Creates a new Container
  75299. * @param name defines the name of the container
  75300. */
  75301. constructor(name?: string | undefined);
  75302. protected _getTypeName(): string;
  75303. _flagDescendantsAsMatrixDirty(): void;
  75304. /**
  75305. * Gets a child using its name
  75306. * @param name defines the child name to look for
  75307. * @returns the child control if found
  75308. */
  75309. getChildByName(name: string): BABYLON.Nullable<Control>;
  75310. /**
  75311. * Gets a child using its type and its name
  75312. * @param name defines the child name to look for
  75313. * @param type defines the child type to look for
  75314. * @returns the child control if found
  75315. */
  75316. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75317. /**
  75318. * Search for a specific control in children
  75319. * @param control defines the control to look for
  75320. * @returns true if the control is in child list
  75321. */
  75322. containsControl(control: Control): boolean;
  75323. /**
  75324. * Adds a new control to the current container
  75325. * @param control defines the control to add
  75326. * @returns the current container
  75327. */
  75328. addControl(control: BABYLON.Nullable<Control>): Container;
  75329. /**
  75330. * Removes all controls from the current container
  75331. * @returns the current container
  75332. */
  75333. clearControls(): Container;
  75334. /**
  75335. * Removes a control from the current container
  75336. * @param control defines the control to remove
  75337. * @returns the current container
  75338. */
  75339. removeControl(control: Control): Container;
  75340. /** @hidden */
  75341. _reOrderControl(control: Control): void;
  75342. /** @hidden */
  75343. _offsetLeft(offset: number): void;
  75344. /** @hidden */
  75345. _offsetTop(offset: number): void;
  75346. /** @hidden */
  75347. _markAllAsDirty(): void;
  75348. /** @hidden */
  75349. protected _localDraw(context: CanvasRenderingContext2D): void;
  75350. /** @hidden */
  75351. _link(host: AdvancedDynamicTexture): void;
  75352. /** @hidden */
  75353. protected _beforeLayout(): void;
  75354. /** @hidden */
  75355. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75356. /** @hidden */
  75357. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75358. protected _postMeasure(): void;
  75359. /** @hidden */
  75360. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75361. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75362. /** @hidden */
  75363. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75364. /** @hidden */
  75365. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75366. /** Releases associated resources */
  75367. dispose(): void;
  75368. }
  75369. }
  75370. declare module BABYLON.GUI {
  75371. /** Class used to create rectangle container */
  75372. export class Rectangle extends Container {
  75373. name?: string | undefined;
  75374. private _thickness;
  75375. private _cornerRadius;
  75376. /** Gets or sets border thickness */
  75377. get thickness(): number;
  75378. set thickness(value: number);
  75379. /** Gets or sets the corner radius angle */
  75380. get cornerRadius(): number;
  75381. set cornerRadius(value: number);
  75382. /**
  75383. * Creates a new Rectangle
  75384. * @param name defines the control name
  75385. */
  75386. constructor(name?: string | undefined);
  75387. protected _getTypeName(): string;
  75388. protected _localDraw(context: CanvasRenderingContext2D): void;
  75389. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75390. private _drawRoundedRect;
  75391. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75392. }
  75393. }
  75394. declare module BABYLON.GUI {
  75395. /**
  75396. * Enum that determines the text-wrapping mode to use.
  75397. */
  75398. export enum TextWrapping {
  75399. /**
  75400. * Clip the text when it's larger than Control.width; this is the default mode.
  75401. */
  75402. Clip = 0,
  75403. /**
  75404. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75405. */
  75406. WordWrap = 1,
  75407. /**
  75408. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75409. */
  75410. Ellipsis = 2
  75411. }
  75412. /**
  75413. * Class used to create text block control
  75414. */
  75415. export class TextBlock extends Control {
  75416. /**
  75417. * Defines the name of the control
  75418. */
  75419. name?: string | undefined;
  75420. private _text;
  75421. private _textWrapping;
  75422. private _textHorizontalAlignment;
  75423. private _textVerticalAlignment;
  75424. private _lines;
  75425. private _resizeToFit;
  75426. private _lineSpacing;
  75427. private _outlineWidth;
  75428. private _outlineColor;
  75429. /**
  75430. * An event triggered after the text is changed
  75431. */
  75432. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75433. /**
  75434. * An event triggered after the text was broken up into lines
  75435. */
  75436. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75437. /**
  75438. * Function used to split a string into words. By default, a string is split at each space character found
  75439. */
  75440. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75441. /**
  75442. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75443. */
  75444. get lines(): any[];
  75445. /**
  75446. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75447. */
  75448. get resizeToFit(): boolean;
  75449. /**
  75450. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75451. */
  75452. set resizeToFit(value: boolean);
  75453. /**
  75454. * Gets or sets a boolean indicating if text must be wrapped
  75455. */
  75456. get textWrapping(): TextWrapping | boolean;
  75457. /**
  75458. * Gets or sets a boolean indicating if text must be wrapped
  75459. */
  75460. set textWrapping(value: TextWrapping | boolean);
  75461. /**
  75462. * Gets or sets text to display
  75463. */
  75464. get text(): string;
  75465. /**
  75466. * Gets or sets text to display
  75467. */
  75468. set text(value: string);
  75469. /**
  75470. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75471. */
  75472. get textHorizontalAlignment(): number;
  75473. /**
  75474. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75475. */
  75476. set textHorizontalAlignment(value: number);
  75477. /**
  75478. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75479. */
  75480. get textVerticalAlignment(): number;
  75481. /**
  75482. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75483. */
  75484. set textVerticalAlignment(value: number);
  75485. /**
  75486. * Gets or sets line spacing value
  75487. */
  75488. set lineSpacing(value: string | number);
  75489. /**
  75490. * Gets or sets line spacing value
  75491. */
  75492. get lineSpacing(): string | number;
  75493. /**
  75494. * Gets or sets outlineWidth of the text to display
  75495. */
  75496. get outlineWidth(): number;
  75497. /**
  75498. * Gets or sets outlineWidth of the text to display
  75499. */
  75500. set outlineWidth(value: number);
  75501. /**
  75502. * Gets or sets outlineColor of the text to display
  75503. */
  75504. get outlineColor(): string;
  75505. /**
  75506. * Gets or sets outlineColor of the text to display
  75507. */
  75508. set outlineColor(value: string);
  75509. /**
  75510. * Creates a new TextBlock object
  75511. * @param name defines the name of the control
  75512. * @param text defines the text to display (emptry string by default)
  75513. */
  75514. constructor(
  75515. /**
  75516. * Defines the name of the control
  75517. */
  75518. name?: string | undefined, text?: string);
  75519. protected _getTypeName(): string;
  75520. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75521. private _drawText;
  75522. /** @hidden */
  75523. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75524. protected _applyStates(context: CanvasRenderingContext2D): void;
  75525. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75526. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75527. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75528. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75529. protected _renderLines(context: CanvasRenderingContext2D): void;
  75530. /**
  75531. * Given a width constraint applied on the text block, find the expected height
  75532. * @returns expected height
  75533. */
  75534. computeExpectedHeight(): number;
  75535. dispose(): void;
  75536. }
  75537. }
  75538. declare module BABYLON.GUI {
  75539. /**
  75540. * Class used to create 2D images
  75541. */
  75542. export class Image extends Control {
  75543. name?: string | undefined;
  75544. private _workingCanvas;
  75545. private _domImage;
  75546. private _imageWidth;
  75547. private _imageHeight;
  75548. private _loaded;
  75549. private _stretch;
  75550. private _source;
  75551. private _autoScale;
  75552. private _sourceLeft;
  75553. private _sourceTop;
  75554. private _sourceWidth;
  75555. private _sourceHeight;
  75556. private _svgAttributesComputationCompleted;
  75557. private _isSVG;
  75558. private _cellWidth;
  75559. private _cellHeight;
  75560. private _cellId;
  75561. private _populateNinePatchSlicesFromImage;
  75562. private _sliceLeft;
  75563. private _sliceRight;
  75564. private _sliceTop;
  75565. private _sliceBottom;
  75566. private _detectPointerOnOpaqueOnly;
  75567. /**
  75568. * BABYLON.Observable notified when the content is loaded
  75569. */
  75570. onImageLoadedObservable: BABYLON.Observable<Image>;
  75571. /**
  75572. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75573. */
  75574. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75575. /**
  75576. * Gets a boolean indicating that the content is loaded
  75577. */
  75578. get isLoaded(): boolean;
  75579. /**
  75580. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75581. */
  75582. get populateNinePatchSlicesFromImage(): boolean;
  75583. set populateNinePatchSlicesFromImage(value: boolean);
  75584. /**
  75585. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75586. * Beware using this as this will comsume more memory as the image has to be stored twice
  75587. */
  75588. get detectPointerOnOpaqueOnly(): boolean;
  75589. set detectPointerOnOpaqueOnly(value: boolean);
  75590. /**
  75591. * Gets or sets the left value for slicing (9-patch)
  75592. */
  75593. get sliceLeft(): number;
  75594. set sliceLeft(value: number);
  75595. /**
  75596. * Gets or sets the right value for slicing (9-patch)
  75597. */
  75598. get sliceRight(): number;
  75599. set sliceRight(value: number);
  75600. /**
  75601. * Gets or sets the top value for slicing (9-patch)
  75602. */
  75603. get sliceTop(): number;
  75604. set sliceTop(value: number);
  75605. /**
  75606. * Gets or sets the bottom value for slicing (9-patch)
  75607. */
  75608. get sliceBottom(): number;
  75609. set sliceBottom(value: number);
  75610. /**
  75611. * Gets or sets the left coordinate in the source image
  75612. */
  75613. get sourceLeft(): number;
  75614. set sourceLeft(value: number);
  75615. /**
  75616. * Gets or sets the top coordinate in the source image
  75617. */
  75618. get sourceTop(): number;
  75619. set sourceTop(value: number);
  75620. /**
  75621. * Gets or sets the width to capture in the source image
  75622. */
  75623. get sourceWidth(): number;
  75624. set sourceWidth(value: number);
  75625. /**
  75626. * Gets or sets the height to capture in the source image
  75627. */
  75628. get sourceHeight(): number;
  75629. set sourceHeight(value: number);
  75630. /** Indicates if the format of the image is SVG */
  75631. get isSVG(): boolean;
  75632. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75633. get svgAttributesComputationCompleted(): boolean;
  75634. /**
  75635. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75636. * @see http://doc.babylonjs.com/how_to/gui#image
  75637. */
  75638. get autoScale(): boolean;
  75639. set autoScale(value: boolean);
  75640. /** Gets or sets the streching mode used by the image */
  75641. get stretch(): number;
  75642. set stretch(value: number);
  75643. /** @hidden */
  75644. _rotate90(n: number, preserveProperties?: boolean): Image;
  75645. private _handleRotationForSVGImage;
  75646. private _rotate90SourceProperties;
  75647. /**
  75648. * Gets or sets the internal DOM image used to render the control
  75649. */
  75650. set domImage(value: HTMLImageElement);
  75651. get domImage(): HTMLImageElement;
  75652. private _onImageLoaded;
  75653. private _extractNinePatchSliceDataFromImage;
  75654. /**
  75655. * Gets or sets image source url
  75656. */
  75657. set source(value: BABYLON.Nullable<string>);
  75658. /**
  75659. * Checks for svg document with icon id present
  75660. */
  75661. private _svgCheck;
  75662. /**
  75663. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75664. * given external svg file and icon id
  75665. */
  75666. private _getSVGAttribs;
  75667. /**
  75668. * Gets or sets the cell width to use when animation sheet is enabled
  75669. * @see http://doc.babylonjs.com/how_to/gui#image
  75670. */
  75671. get cellWidth(): number;
  75672. set cellWidth(value: number);
  75673. /**
  75674. * Gets or sets the cell height to use when animation sheet is enabled
  75675. * @see http://doc.babylonjs.com/how_to/gui#image
  75676. */
  75677. get cellHeight(): number;
  75678. set cellHeight(value: number);
  75679. /**
  75680. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75681. * @see http://doc.babylonjs.com/how_to/gui#image
  75682. */
  75683. get cellId(): number;
  75684. set cellId(value: number);
  75685. /**
  75686. * Creates a new Image
  75687. * @param name defines the control name
  75688. * @param url defines the image url
  75689. */
  75690. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75691. /**
  75692. * Tests if a given coordinates belong to the current control
  75693. * @param x defines x coordinate to test
  75694. * @param y defines y coordinate to test
  75695. * @returns true if the coordinates are inside the control
  75696. */
  75697. contains(x: number, y: number): boolean;
  75698. protected _getTypeName(): string;
  75699. /** Force the control to synchronize with its content */
  75700. synchronizeSizeWithContent(): void;
  75701. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75702. private _prepareWorkingCanvasForOpaqueDetection;
  75703. private _drawImage;
  75704. _draw(context: CanvasRenderingContext2D): void;
  75705. private _renderCornerPatch;
  75706. private _renderNinePatch;
  75707. dispose(): void;
  75708. /** STRETCH_NONE */
  75709. static readonly STRETCH_NONE: number;
  75710. /** STRETCH_FILL */
  75711. static readonly STRETCH_FILL: number;
  75712. /** STRETCH_UNIFORM */
  75713. static readonly STRETCH_UNIFORM: number;
  75714. /** STRETCH_EXTEND */
  75715. static readonly STRETCH_EXTEND: number;
  75716. /** NINE_PATCH */
  75717. static readonly STRETCH_NINE_PATCH: number;
  75718. }
  75719. }
  75720. declare module BABYLON.GUI {
  75721. /**
  75722. * Class used to create 2D buttons
  75723. */
  75724. export class Button extends Rectangle {
  75725. name?: string | undefined;
  75726. /**
  75727. * Function called to generate a pointer enter animation
  75728. */
  75729. pointerEnterAnimation: () => void;
  75730. /**
  75731. * Function called to generate a pointer out animation
  75732. */
  75733. pointerOutAnimation: () => void;
  75734. /**
  75735. * Function called to generate a pointer down animation
  75736. */
  75737. pointerDownAnimation: () => void;
  75738. /**
  75739. * Function called to generate a pointer up animation
  75740. */
  75741. pointerUpAnimation: () => void;
  75742. /**
  75743. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75744. */
  75745. delegatePickingToChildren: boolean;
  75746. private _image;
  75747. /**
  75748. * Returns the image part of the button (if any)
  75749. */
  75750. get image(): BABYLON.Nullable<Image>;
  75751. private _textBlock;
  75752. /**
  75753. * Returns the image part of the button (if any)
  75754. */
  75755. get textBlock(): BABYLON.Nullable<TextBlock>;
  75756. /**
  75757. * Creates a new Button
  75758. * @param name defines the name of the button
  75759. */
  75760. constructor(name?: string | undefined);
  75761. protected _getTypeName(): string;
  75762. /** @hidden */
  75763. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75764. /** @hidden */
  75765. _onPointerEnter(target: Control): boolean;
  75766. /** @hidden */
  75767. _onPointerOut(target: Control, force?: boolean): void;
  75768. /** @hidden */
  75769. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75770. /** @hidden */
  75771. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75772. /**
  75773. * Creates a new button made with an image and a text
  75774. * @param name defines the name of the button
  75775. * @param text defines the text of the button
  75776. * @param imageUrl defines the url of the image
  75777. * @returns a new Button
  75778. */
  75779. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75780. /**
  75781. * Creates a new button made with an image
  75782. * @param name defines the name of the button
  75783. * @param imageUrl defines the url of the image
  75784. * @returns a new Button
  75785. */
  75786. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75787. /**
  75788. * Creates a new button made with a text
  75789. * @param name defines the name of the button
  75790. * @param text defines the text of the button
  75791. * @returns a new Button
  75792. */
  75793. static CreateSimpleButton(name: string, text: string): Button;
  75794. /**
  75795. * Creates a new button made with an image and a centered text
  75796. * @param name defines the name of the button
  75797. * @param text defines the text of the button
  75798. * @param imageUrl defines the url of the image
  75799. * @returns a new Button
  75800. */
  75801. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75802. }
  75803. }
  75804. declare module BABYLON.GUI {
  75805. /**
  75806. * Class used to create a 2D stack panel container
  75807. */
  75808. export class StackPanel extends Container {
  75809. name?: string | undefined;
  75810. private _isVertical;
  75811. private _manualWidth;
  75812. private _manualHeight;
  75813. private _doNotTrackManualChanges;
  75814. /**
  75815. * Gets or sets a boolean indicating that layou warnings should be ignored
  75816. */
  75817. ignoreLayoutWarnings: boolean;
  75818. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75819. get isVertical(): boolean;
  75820. set isVertical(value: boolean);
  75821. /**
  75822. * Gets or sets panel width.
  75823. * This value should not be set when in horizontal mode as it will be computed automatically
  75824. */
  75825. set width(value: string | number);
  75826. get width(): string | number;
  75827. /**
  75828. * Gets or sets panel height.
  75829. * This value should not be set when in vertical mode as it will be computed automatically
  75830. */
  75831. set height(value: string | number);
  75832. get height(): string | number;
  75833. /**
  75834. * Creates a new StackPanel
  75835. * @param name defines control name
  75836. */
  75837. constructor(name?: string | undefined);
  75838. protected _getTypeName(): string;
  75839. /** @hidden */
  75840. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75841. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75842. protected _postMeasure(): void;
  75843. }
  75844. }
  75845. declare module BABYLON.GUI {
  75846. /**
  75847. * Class used to represent a 2D checkbox
  75848. */
  75849. export class Checkbox extends Control {
  75850. name?: string | undefined;
  75851. private _isChecked;
  75852. private _background;
  75853. private _checkSizeRatio;
  75854. private _thickness;
  75855. /** Gets or sets border thickness */
  75856. get thickness(): number;
  75857. set thickness(value: number);
  75858. /**
  75859. * BABYLON.Observable raised when isChecked property changes
  75860. */
  75861. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75862. /** Gets or sets a value indicating the ratio between overall size and check size */
  75863. get checkSizeRatio(): number;
  75864. set checkSizeRatio(value: number);
  75865. /** Gets or sets background color */
  75866. get background(): string;
  75867. set background(value: string);
  75868. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75869. get isChecked(): boolean;
  75870. set isChecked(value: boolean);
  75871. /**
  75872. * Creates a new CheckBox
  75873. * @param name defines the control name
  75874. */
  75875. constructor(name?: string | undefined);
  75876. protected _getTypeName(): string;
  75877. /** @hidden */
  75878. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75879. /** @hidden */
  75880. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75881. /**
  75882. * Utility function to easily create a checkbox with a header
  75883. * @param title defines the label to use for the header
  75884. * @param onValueChanged defines the callback to call when value changes
  75885. * @returns a StackPanel containing the checkbox and a textBlock
  75886. */
  75887. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75888. }
  75889. }
  75890. declare module BABYLON.GUI {
  75891. /**
  75892. * Class used to store key control properties
  75893. */
  75894. export class KeyPropertySet {
  75895. /** Width */
  75896. width?: string;
  75897. /** Height */
  75898. height?: string;
  75899. /** Left padding */
  75900. paddingLeft?: string;
  75901. /** Right padding */
  75902. paddingRight?: string;
  75903. /** Top padding */
  75904. paddingTop?: string;
  75905. /** Bottom padding */
  75906. paddingBottom?: string;
  75907. /** Foreground color */
  75908. color?: string;
  75909. /** Background color */
  75910. background?: string;
  75911. }
  75912. /**
  75913. * Class used to create virtual keyboard
  75914. */
  75915. export class VirtualKeyboard extends StackPanel {
  75916. /** BABYLON.Observable raised when a key is pressed */
  75917. onKeyPressObservable: BABYLON.Observable<string>;
  75918. /** Gets or sets default key button width */
  75919. defaultButtonWidth: string;
  75920. /** Gets or sets default key button height */
  75921. defaultButtonHeight: string;
  75922. /** Gets or sets default key button left padding */
  75923. defaultButtonPaddingLeft: string;
  75924. /** Gets or sets default key button right padding */
  75925. defaultButtonPaddingRight: string;
  75926. /** Gets or sets default key button top padding */
  75927. defaultButtonPaddingTop: string;
  75928. /** Gets or sets default key button bottom padding */
  75929. defaultButtonPaddingBottom: string;
  75930. /** Gets or sets default key button foreground color */
  75931. defaultButtonColor: string;
  75932. /** Gets or sets default key button background color */
  75933. defaultButtonBackground: string;
  75934. /** Gets or sets shift button foreground color */
  75935. shiftButtonColor: string;
  75936. /** Gets or sets shift button thickness*/
  75937. selectedShiftThickness: number;
  75938. /** Gets shift key state */
  75939. shiftState: number;
  75940. protected _getTypeName(): string;
  75941. private _createKey;
  75942. /**
  75943. * Adds a new row of keys
  75944. * @param keys defines the list of keys to add
  75945. * @param propertySets defines the associated property sets
  75946. */
  75947. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75948. /**
  75949. * Set the shift key to a specific state
  75950. * @param shiftState defines the new shift state
  75951. */
  75952. applyShiftState(shiftState: number): void;
  75953. private _currentlyConnectedInputText;
  75954. private _connectedInputTexts;
  75955. private _onKeyPressObserver;
  75956. /** Gets the input text control currently attached to the keyboard */
  75957. get connectedInputText(): BABYLON.Nullable<InputText>;
  75958. /**
  75959. * Connects the keyboard with an input text control
  75960. *
  75961. * @param input defines the target control
  75962. */
  75963. connect(input: InputText): void;
  75964. /**
  75965. * Disconnects the keyboard from connected InputText controls
  75966. *
  75967. * @param input optionally defines a target control, otherwise all are disconnected
  75968. */
  75969. disconnect(input?: InputText): void;
  75970. private _removeConnectedInputObservables;
  75971. /**
  75972. * Release all resources
  75973. */
  75974. dispose(): void;
  75975. /**
  75976. * Creates a new keyboard using a default layout
  75977. *
  75978. * @param name defines control name
  75979. * @returns a new VirtualKeyboard
  75980. */
  75981. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75982. }
  75983. }
  75984. declare module BABYLON.GUI {
  75985. /**
  75986. * Class used to create input text control
  75987. */
  75988. export class InputText extends Control implements IFocusableControl {
  75989. name?: string | undefined;
  75990. private _text;
  75991. private _placeholderText;
  75992. private _background;
  75993. private _focusedBackground;
  75994. private _focusedColor;
  75995. private _placeholderColor;
  75996. private _thickness;
  75997. private _margin;
  75998. private _autoStretchWidth;
  75999. private _maxWidth;
  76000. private _isFocused;
  76001. private _blinkTimeout;
  76002. private _blinkIsEven;
  76003. private _cursorOffset;
  76004. private _scrollLeft;
  76005. private _textWidth;
  76006. private _clickedCoordinate;
  76007. private _deadKey;
  76008. private _addKey;
  76009. private _currentKey;
  76010. private _isTextHighlightOn;
  76011. private _textHighlightColor;
  76012. private _highligherOpacity;
  76013. private _highlightedText;
  76014. private _startHighlightIndex;
  76015. private _endHighlightIndex;
  76016. private _cursorIndex;
  76017. private _onFocusSelectAll;
  76018. private _isPointerDown;
  76019. private _onClipboardObserver;
  76020. private _onPointerDblTapObserver;
  76021. /** @hidden */
  76022. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76023. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76024. promptMessage: string;
  76025. /** Force disable prompt on mobile device */
  76026. disableMobilePrompt: boolean;
  76027. /** BABYLON.Observable raised when the text changes */
  76028. onTextChangedObservable: BABYLON.Observable<InputText>;
  76029. /** BABYLON.Observable raised just before an entered character is to be added */
  76030. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76031. /** BABYLON.Observable raised when the control gets the focus */
  76032. onFocusObservable: BABYLON.Observable<InputText>;
  76033. /** BABYLON.Observable raised when the control loses the focus */
  76034. onBlurObservable: BABYLON.Observable<InputText>;
  76035. /**Observable raised when the text is highlighted */
  76036. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76037. /**Observable raised when copy event is triggered */
  76038. onTextCopyObservable: BABYLON.Observable<InputText>;
  76039. /** BABYLON.Observable raised when cut event is triggered */
  76040. onTextCutObservable: BABYLON.Observable<InputText>;
  76041. /** BABYLON.Observable raised when paste event is triggered */
  76042. onTextPasteObservable: BABYLON.Observable<InputText>;
  76043. /** BABYLON.Observable raised when a key event was processed */
  76044. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76045. /** Gets or sets the maximum width allowed by the control */
  76046. get maxWidth(): string | number;
  76047. /** Gets the maximum width allowed by the control in pixels */
  76048. get maxWidthInPixels(): number;
  76049. set maxWidth(value: string | number);
  76050. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76051. get highligherOpacity(): number;
  76052. set highligherOpacity(value: number);
  76053. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76054. get onFocusSelectAll(): boolean;
  76055. set onFocusSelectAll(value: boolean);
  76056. /** Gets or sets the text hightlight color */
  76057. get textHighlightColor(): string;
  76058. set textHighlightColor(value: string);
  76059. /** Gets or sets control margin */
  76060. get margin(): string;
  76061. /** Gets control margin in pixels */
  76062. get marginInPixels(): number;
  76063. set margin(value: string);
  76064. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76065. get autoStretchWidth(): boolean;
  76066. set autoStretchWidth(value: boolean);
  76067. /** Gets or sets border thickness */
  76068. get thickness(): number;
  76069. set thickness(value: number);
  76070. /** Gets or sets the background color when focused */
  76071. get focusedBackground(): string;
  76072. set focusedBackground(value: string);
  76073. /** Gets or sets the background color when focused */
  76074. get focusedColor(): string;
  76075. set focusedColor(value: string);
  76076. /** Gets or sets the background color */
  76077. get background(): string;
  76078. set background(value: string);
  76079. /** Gets or sets the placeholder color */
  76080. get placeholderColor(): string;
  76081. set placeholderColor(value: string);
  76082. /** Gets or sets the text displayed when the control is empty */
  76083. get placeholderText(): string;
  76084. set placeholderText(value: string);
  76085. /** Gets or sets the dead key flag */
  76086. get deadKey(): boolean;
  76087. set deadKey(flag: boolean);
  76088. /** Gets or sets the highlight text */
  76089. get highlightedText(): string;
  76090. set highlightedText(text: string);
  76091. /** Gets or sets if the current key should be added */
  76092. get addKey(): boolean;
  76093. set addKey(flag: boolean);
  76094. /** Gets or sets the value of the current key being entered */
  76095. get currentKey(): string;
  76096. set currentKey(key: string);
  76097. /** Gets or sets the text displayed in the control */
  76098. get text(): string;
  76099. set text(value: string);
  76100. /** Gets or sets control width */
  76101. get width(): string | number;
  76102. set width(value: string | number);
  76103. /**
  76104. * Creates a new InputText
  76105. * @param name defines the control name
  76106. * @param text defines the text of the control
  76107. */
  76108. constructor(name?: string | undefined, text?: string);
  76109. /** @hidden */
  76110. onBlur(): void;
  76111. /** @hidden */
  76112. onFocus(): void;
  76113. protected _getTypeName(): string;
  76114. /**
  76115. * Function called to get the list of controls that should not steal the focus from this control
  76116. * @returns an array of controls
  76117. */
  76118. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76119. /** @hidden */
  76120. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76121. /** @hidden */
  76122. private _updateValueFromCursorIndex;
  76123. /** @hidden */
  76124. private _processDblClick;
  76125. /** @hidden */
  76126. private _selectAllText;
  76127. /**
  76128. * Handles the keyboard event
  76129. * @param evt Defines the KeyboardEvent
  76130. */
  76131. processKeyboard(evt: KeyboardEvent): void;
  76132. /** @hidden */
  76133. private _onCopyText;
  76134. /** @hidden */
  76135. private _onCutText;
  76136. /** @hidden */
  76137. private _onPasteText;
  76138. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76139. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76140. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76141. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76142. protected _beforeRenderText(text: string): string;
  76143. dispose(): void;
  76144. }
  76145. }
  76146. declare module BABYLON.GUI {
  76147. /**
  76148. * Class used to create a 2D grid container
  76149. */
  76150. export class Grid extends Container {
  76151. name?: string | undefined;
  76152. private _rowDefinitions;
  76153. private _columnDefinitions;
  76154. private _cells;
  76155. private _childControls;
  76156. /**
  76157. * Gets the number of columns
  76158. */
  76159. get columnCount(): number;
  76160. /**
  76161. * Gets the number of rows
  76162. */
  76163. get rowCount(): number;
  76164. /** Gets the list of children */
  76165. get children(): Control[];
  76166. /** Gets the list of cells (e.g. the containers) */
  76167. get cells(): {
  76168. [key: string]: Container;
  76169. };
  76170. /**
  76171. * Gets the definition of a specific row
  76172. * @param index defines the index of the row
  76173. * @returns the row definition
  76174. */
  76175. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76176. /**
  76177. * Gets the definition of a specific column
  76178. * @param index defines the index of the column
  76179. * @returns the column definition
  76180. */
  76181. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76182. /**
  76183. * Adds a new row to the grid
  76184. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76185. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76186. * @returns the current grid
  76187. */
  76188. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76189. /**
  76190. * Adds a new column to the grid
  76191. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76192. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76193. * @returns the current grid
  76194. */
  76195. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76196. /**
  76197. * Update a row definition
  76198. * @param index defines the index of the row to update
  76199. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76200. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76201. * @returns the current grid
  76202. */
  76203. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76204. /**
  76205. * Update a column definition
  76206. * @param index defines the index of the column to update
  76207. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76208. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76209. * @returns the current grid
  76210. */
  76211. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76212. /**
  76213. * Gets the list of children stored in a specific cell
  76214. * @param row defines the row to check
  76215. * @param column defines the column to check
  76216. * @returns the list of controls
  76217. */
  76218. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76219. /**
  76220. * Gets a string representing the child cell info (row x column)
  76221. * @param child defines the control to get info from
  76222. * @returns a string containing the child cell info (row x column)
  76223. */
  76224. getChildCellInfo(child: Control): string;
  76225. private _removeCell;
  76226. private _offsetCell;
  76227. /**
  76228. * Remove a column definition at specified index
  76229. * @param index defines the index of the column to remove
  76230. * @returns the current grid
  76231. */
  76232. removeColumnDefinition(index: number): Grid;
  76233. /**
  76234. * Remove a row definition at specified index
  76235. * @param index defines the index of the row to remove
  76236. * @returns the current grid
  76237. */
  76238. removeRowDefinition(index: number): Grid;
  76239. /**
  76240. * Adds a new control to the current grid
  76241. * @param control defines the control to add
  76242. * @param row defines the row where to add the control (0 by default)
  76243. * @param column defines the column where to add the control (0 by default)
  76244. * @returns the current grid
  76245. */
  76246. addControl(control: Control, row?: number, column?: number): Grid;
  76247. /**
  76248. * Removes a control from the current container
  76249. * @param control defines the control to remove
  76250. * @returns the current container
  76251. */
  76252. removeControl(control: Control): Container;
  76253. /**
  76254. * Creates a new Grid
  76255. * @param name defines control name
  76256. */
  76257. constructor(name?: string | undefined);
  76258. protected _getTypeName(): string;
  76259. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76260. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76261. _flagDescendantsAsMatrixDirty(): void;
  76262. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76263. /** Releases associated resources */
  76264. dispose(): void;
  76265. }
  76266. }
  76267. declare module BABYLON.GUI {
  76268. /** Class used to create color pickers */
  76269. export class ColorPicker extends Control {
  76270. name?: string | undefined;
  76271. private static _Epsilon;
  76272. private _colorWheelCanvas;
  76273. private _value;
  76274. private _tmpColor;
  76275. private _pointerStartedOnSquare;
  76276. private _pointerStartedOnWheel;
  76277. private _squareLeft;
  76278. private _squareTop;
  76279. private _squareSize;
  76280. private _h;
  76281. private _s;
  76282. private _v;
  76283. private _lastPointerDownID;
  76284. /**
  76285. * BABYLON.Observable raised when the value changes
  76286. */
  76287. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76288. /** Gets or sets the color of the color picker */
  76289. get value(): BABYLON.Color3;
  76290. set value(value: BABYLON.Color3);
  76291. /**
  76292. * Gets or sets control width
  76293. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76294. */
  76295. get width(): string | number;
  76296. set width(value: string | number);
  76297. /**
  76298. * Gets or sets control height
  76299. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76300. */
  76301. get height(): string | number;
  76302. /** Gets or sets control height */
  76303. set height(value: string | number);
  76304. /** Gets or sets control size */
  76305. get size(): string | number;
  76306. set size(value: string | number);
  76307. /**
  76308. * Creates a new ColorPicker
  76309. * @param name defines the control name
  76310. */
  76311. constructor(name?: string | undefined);
  76312. protected _getTypeName(): string;
  76313. /** @hidden */
  76314. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76315. private _updateSquareProps;
  76316. private _drawGradientSquare;
  76317. private _drawCircle;
  76318. private _createColorWheelCanvas;
  76319. /** @hidden */
  76320. _draw(context: CanvasRenderingContext2D): void;
  76321. private _pointerIsDown;
  76322. private _updateValueFromPointer;
  76323. private _isPointOnSquare;
  76324. private _isPointOnWheel;
  76325. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76326. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76327. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76328. /**
  76329. * This function expands the color picker by creating a color picker dialog with manual
  76330. * color value input and the ability to save colors into an array to be used later in
  76331. * subsequent launches of the dialogue.
  76332. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76333. * @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.
  76334. * @returns picked color as a hex string and the saved colors array as hex strings.
  76335. */
  76336. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76337. pickerWidth?: string;
  76338. pickerHeight?: string;
  76339. headerHeight?: string;
  76340. lastColor?: string;
  76341. swatchLimit?: number;
  76342. numSwatchesPerLine?: number;
  76343. savedColors?: Array<string>;
  76344. }): Promise<{
  76345. savedColors?: string[];
  76346. pickedColor: string;
  76347. }>;
  76348. }
  76349. }
  76350. declare module BABYLON.GUI {
  76351. /** Class used to create 2D ellipse containers */
  76352. export class Ellipse extends Container {
  76353. name?: string | undefined;
  76354. private _thickness;
  76355. /** Gets or sets border thickness */
  76356. get thickness(): number;
  76357. set thickness(value: number);
  76358. /**
  76359. * Creates a new Ellipse
  76360. * @param name defines the control name
  76361. */
  76362. constructor(name?: string | undefined);
  76363. protected _getTypeName(): string;
  76364. protected _localDraw(context: CanvasRenderingContext2D): void;
  76365. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76366. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76367. }
  76368. }
  76369. declare module BABYLON.GUI {
  76370. /**
  76371. * Class used to create a password control
  76372. */
  76373. export class InputPassword extends InputText {
  76374. protected _beforeRenderText(text: string): string;
  76375. }
  76376. }
  76377. declare module BABYLON.GUI {
  76378. /** Class used to render 2D lines */
  76379. export class Line extends Control {
  76380. name?: string | undefined;
  76381. private _lineWidth;
  76382. private _x1;
  76383. private _y1;
  76384. private _x2;
  76385. private _y2;
  76386. private _dash;
  76387. private _connectedControl;
  76388. private _connectedControlDirtyObserver;
  76389. /** Gets or sets the dash pattern */
  76390. get dash(): Array<number>;
  76391. set dash(value: Array<number>);
  76392. /** Gets or sets the control connected with the line end */
  76393. get connectedControl(): Control;
  76394. set connectedControl(value: Control);
  76395. /** Gets or sets start coordinates on X axis */
  76396. get x1(): string | number;
  76397. set x1(value: string | number);
  76398. /** Gets or sets start coordinates on Y axis */
  76399. get y1(): string | number;
  76400. set y1(value: string | number);
  76401. /** Gets or sets end coordinates on X axis */
  76402. get x2(): string | number;
  76403. set x2(value: string | number);
  76404. /** Gets or sets end coordinates on Y axis */
  76405. get y2(): string | number;
  76406. set y2(value: string | number);
  76407. /** Gets or sets line width */
  76408. get lineWidth(): number;
  76409. set lineWidth(value: number);
  76410. /** Gets or sets horizontal alignment */
  76411. set horizontalAlignment(value: number);
  76412. /** Gets or sets vertical alignment */
  76413. set verticalAlignment(value: number);
  76414. private get _effectiveX2();
  76415. private get _effectiveY2();
  76416. /**
  76417. * Creates a new Line
  76418. * @param name defines the control name
  76419. */
  76420. constructor(name?: string | undefined);
  76421. protected _getTypeName(): string;
  76422. _draw(context: CanvasRenderingContext2D): void;
  76423. _measure(): void;
  76424. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76425. /**
  76426. * Move one end of the line given 3D cartesian coordinates.
  76427. * @param position Targeted world position
  76428. * @param scene BABYLON.Scene
  76429. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76430. */
  76431. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76432. /**
  76433. * Move one end of the line to a position in screen absolute space.
  76434. * @param projectedPosition Position in screen absolute space (X, Y)
  76435. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76436. */
  76437. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76438. }
  76439. }
  76440. declare module BABYLON.GUI {
  76441. /**
  76442. * Class used to store a point for a MultiLine object.
  76443. * The point can be pure 2D coordinates, a mesh or a control
  76444. */
  76445. export class MultiLinePoint {
  76446. private _multiLine;
  76447. private _x;
  76448. private _y;
  76449. private _control;
  76450. private _mesh;
  76451. private _controlObserver;
  76452. private _meshObserver;
  76453. /** @hidden */
  76454. _point: BABYLON.Vector2;
  76455. /**
  76456. * Creates a new MultiLinePoint
  76457. * @param multiLine defines the source MultiLine object
  76458. */
  76459. constructor(multiLine: MultiLine);
  76460. /** Gets or sets x coordinate */
  76461. get x(): string | number;
  76462. set x(value: string | number);
  76463. /** Gets or sets y coordinate */
  76464. get y(): string | number;
  76465. set y(value: string | number);
  76466. /** Gets or sets the control associated with this point */
  76467. get control(): BABYLON.Nullable<Control>;
  76468. set control(value: BABYLON.Nullable<Control>);
  76469. /** Gets or sets the mesh associated with this point */
  76470. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76471. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76472. /** Resets links */
  76473. resetLinks(): void;
  76474. /**
  76475. * Gets a translation vector
  76476. * @returns the translation vector
  76477. */
  76478. translate(): BABYLON.Vector2;
  76479. private _translatePoint;
  76480. /** Release associated resources */
  76481. dispose(): void;
  76482. }
  76483. }
  76484. declare module BABYLON.GUI {
  76485. /**
  76486. * Class used to create multi line control
  76487. */
  76488. export class MultiLine extends Control {
  76489. name?: string | undefined;
  76490. private _lineWidth;
  76491. private _dash;
  76492. private _points;
  76493. private _minX;
  76494. private _minY;
  76495. private _maxX;
  76496. private _maxY;
  76497. /**
  76498. * Creates a new MultiLine
  76499. * @param name defines the control name
  76500. */
  76501. constructor(name?: string | undefined);
  76502. /** Gets or sets dash pattern */
  76503. get dash(): Array<number>;
  76504. set dash(value: Array<number>);
  76505. /**
  76506. * Gets point stored at specified index
  76507. * @param index defines the index to look for
  76508. * @returns the requested point if found
  76509. */
  76510. getAt(index: number): MultiLinePoint;
  76511. /** Function called when a point is updated */
  76512. onPointUpdate: () => void;
  76513. /**
  76514. * Adds new points to the point collection
  76515. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76516. * @returns the list of created MultiLinePoint
  76517. */
  76518. add(...items: (AbstractMesh | Control | {
  76519. x: string | number;
  76520. y: string | number;
  76521. })[]): MultiLinePoint[];
  76522. /**
  76523. * Adds a new point to the point collection
  76524. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76525. * @returns the created MultiLinePoint
  76526. */
  76527. push(item?: (AbstractMesh | Control | {
  76528. x: string | number;
  76529. y: string | number;
  76530. })): MultiLinePoint;
  76531. /**
  76532. * Remove a specific value or point from the active point collection
  76533. * @param value defines the value or point to remove
  76534. */
  76535. remove(value: number | MultiLinePoint): void;
  76536. /**
  76537. * Resets this object to initial state (no point)
  76538. */
  76539. reset(): void;
  76540. /**
  76541. * Resets all links
  76542. */
  76543. resetLinks(): void;
  76544. /** Gets or sets line width */
  76545. get lineWidth(): number;
  76546. set lineWidth(value: number);
  76547. set horizontalAlignment(value: number);
  76548. set verticalAlignment(value: number);
  76549. protected _getTypeName(): string;
  76550. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76551. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76552. _measure(): void;
  76553. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76554. dispose(): void;
  76555. }
  76556. }
  76557. declare module BABYLON.GUI {
  76558. /**
  76559. * Class used to create radio button controls
  76560. */
  76561. export class RadioButton extends Control {
  76562. name?: string | undefined;
  76563. private _isChecked;
  76564. private _background;
  76565. private _checkSizeRatio;
  76566. private _thickness;
  76567. /** Gets or sets border thickness */
  76568. get thickness(): number;
  76569. set thickness(value: number);
  76570. /** Gets or sets group name */
  76571. group: string;
  76572. /** BABYLON.Observable raised when isChecked is changed */
  76573. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76574. /** Gets or sets a value indicating the ratio between overall size and check size */
  76575. get checkSizeRatio(): number;
  76576. set checkSizeRatio(value: number);
  76577. /** Gets or sets background color */
  76578. get background(): string;
  76579. set background(value: string);
  76580. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76581. get isChecked(): boolean;
  76582. set isChecked(value: boolean);
  76583. /**
  76584. * Creates a new RadioButton
  76585. * @param name defines the control name
  76586. */
  76587. constructor(name?: string | undefined);
  76588. protected _getTypeName(): string;
  76589. _draw(context: CanvasRenderingContext2D): void;
  76590. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76591. /**
  76592. * Utility function to easily create a radio button with a header
  76593. * @param title defines the label to use for the header
  76594. * @param group defines the group to use for the radio button
  76595. * @param isChecked defines the initial state of the radio button
  76596. * @param onValueChanged defines the callback to call when value changes
  76597. * @returns a StackPanel containing the radio button and a textBlock
  76598. */
  76599. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76600. }
  76601. }
  76602. declare module BABYLON.GUI {
  76603. /**
  76604. * Class used to create slider controls
  76605. */
  76606. export class BaseSlider extends Control {
  76607. name?: string | undefined;
  76608. protected _thumbWidth: ValueAndUnit;
  76609. private _minimum;
  76610. private _maximum;
  76611. private _value;
  76612. private _isVertical;
  76613. protected _barOffset: ValueAndUnit;
  76614. private _isThumbClamped;
  76615. protected _displayThumb: boolean;
  76616. private _step;
  76617. private _lastPointerDownID;
  76618. protected _effectiveBarOffset: number;
  76619. protected _renderLeft: number;
  76620. protected _renderTop: number;
  76621. protected _renderWidth: number;
  76622. protected _renderHeight: number;
  76623. protected _backgroundBoxLength: number;
  76624. protected _backgroundBoxThickness: number;
  76625. protected _effectiveThumbThickness: number;
  76626. /** BABYLON.Observable raised when the sldier value changes */
  76627. onValueChangedObservable: BABYLON.Observable<number>;
  76628. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76629. get displayThumb(): boolean;
  76630. set displayThumb(value: boolean);
  76631. /** Gets or sets a step to apply to values (0 by default) */
  76632. get step(): number;
  76633. set step(value: number);
  76634. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76635. get barOffset(): string | number;
  76636. /** Gets main bar offset in pixels*/
  76637. get barOffsetInPixels(): number;
  76638. set barOffset(value: string | number);
  76639. /** Gets or sets thumb width */
  76640. get thumbWidth(): string | number;
  76641. /** Gets thumb width in pixels */
  76642. get thumbWidthInPixels(): number;
  76643. set thumbWidth(value: string | number);
  76644. /** Gets or sets minimum value */
  76645. get minimum(): number;
  76646. set minimum(value: number);
  76647. /** Gets or sets maximum value */
  76648. get maximum(): number;
  76649. set maximum(value: number);
  76650. /** Gets or sets current value */
  76651. get value(): number;
  76652. set value(value: number);
  76653. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76654. get isVertical(): boolean;
  76655. set isVertical(value: boolean);
  76656. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76657. get isThumbClamped(): boolean;
  76658. set isThumbClamped(value: boolean);
  76659. /**
  76660. * Creates a new BaseSlider
  76661. * @param name defines the control name
  76662. */
  76663. constructor(name?: string | undefined);
  76664. protected _getTypeName(): string;
  76665. protected _getThumbPosition(): number;
  76666. protected _getThumbThickness(type: string): number;
  76667. protected _prepareRenderingData(type: string): void;
  76668. private _pointerIsDown;
  76669. /** @hidden */
  76670. protected _updateValueFromPointer(x: number, y: number): void;
  76671. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76672. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76673. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76674. }
  76675. }
  76676. declare module BABYLON.GUI {
  76677. /**
  76678. * Class used to create slider controls
  76679. */
  76680. export class Slider extends BaseSlider {
  76681. name?: string | undefined;
  76682. private _background;
  76683. private _borderColor;
  76684. private _isThumbCircle;
  76685. protected _displayValueBar: boolean;
  76686. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76687. get displayValueBar(): boolean;
  76688. set displayValueBar(value: boolean);
  76689. /** Gets or sets border color */
  76690. get borderColor(): string;
  76691. set borderColor(value: string);
  76692. /** Gets or sets background color */
  76693. get background(): string;
  76694. set background(value: string);
  76695. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76696. get isThumbCircle(): boolean;
  76697. set isThumbCircle(value: boolean);
  76698. /**
  76699. * Creates a new Slider
  76700. * @param name defines the control name
  76701. */
  76702. constructor(name?: string | undefined);
  76703. protected _getTypeName(): string;
  76704. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76705. }
  76706. }
  76707. declare module BABYLON.GUI {
  76708. /** Class used to create a RadioGroup
  76709. * which contains groups of radio buttons
  76710. */
  76711. export class SelectorGroup {
  76712. /** name of SelectorGroup */
  76713. name: string;
  76714. private _groupPanel;
  76715. private _selectors;
  76716. private _groupHeader;
  76717. /**
  76718. * Creates a new SelectorGroup
  76719. * @param name of group, used as a group heading
  76720. */
  76721. constructor(
  76722. /** name of SelectorGroup */
  76723. name: string);
  76724. /** Gets the groupPanel of the SelectorGroup */
  76725. get groupPanel(): StackPanel;
  76726. /** Gets the selectors array */
  76727. get selectors(): StackPanel[];
  76728. /** Gets and sets the group header */
  76729. get header(): string;
  76730. set header(label: string);
  76731. /** @hidden */
  76732. private _addGroupHeader;
  76733. /** @hidden*/
  76734. _getSelector(selectorNb: number): StackPanel | undefined;
  76735. /** Removes the selector at the given position
  76736. * @param selectorNb the position of the selector within the group
  76737. */
  76738. removeSelector(selectorNb: number): void;
  76739. }
  76740. /** Class used to create a CheckboxGroup
  76741. * which contains groups of checkbox buttons
  76742. */
  76743. export class CheckboxGroup extends SelectorGroup {
  76744. /** Adds a checkbox as a control
  76745. * @param text is the label for the selector
  76746. * @param func is the function called when the Selector is checked
  76747. * @param checked is true when Selector is checked
  76748. */
  76749. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76750. /** @hidden */
  76751. _setSelectorLabel(selectorNb: number, label: string): void;
  76752. /** @hidden */
  76753. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76754. /** @hidden */
  76755. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76756. /** @hidden */
  76757. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76758. }
  76759. /** Class used to create a RadioGroup
  76760. * which contains groups of radio buttons
  76761. */
  76762. export class RadioGroup extends SelectorGroup {
  76763. private _selectNb;
  76764. /** Adds a radio button as a control
  76765. * @param label is the label for the selector
  76766. * @param func is the function called when the Selector is checked
  76767. * @param checked is true when Selector is checked
  76768. */
  76769. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76770. /** @hidden */
  76771. _setSelectorLabel(selectorNb: number, label: string): void;
  76772. /** @hidden */
  76773. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76774. /** @hidden */
  76775. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76776. /** @hidden */
  76777. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76778. }
  76779. /** Class used to create a SliderGroup
  76780. * which contains groups of slider buttons
  76781. */
  76782. export class SliderGroup extends SelectorGroup {
  76783. /**
  76784. * Adds a slider to the SelectorGroup
  76785. * @param label is the label for the SliderBar
  76786. * @param func is the function called when the Slider moves
  76787. * @param unit is a string describing the units used, eg degrees or metres
  76788. * @param min is the minimum value for the Slider
  76789. * @param max is the maximum value for the Slider
  76790. * @param value is the start value for the Slider between min and max
  76791. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76792. */
  76793. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76794. /** @hidden */
  76795. _setSelectorLabel(selectorNb: number, label: string): void;
  76796. /** @hidden */
  76797. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76798. /** @hidden */
  76799. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76800. /** @hidden */
  76801. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76802. }
  76803. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76804. * @see http://doc.babylonjs.com/how_to/selector
  76805. */
  76806. export class SelectionPanel extends Rectangle {
  76807. /** name of SelectionPanel */
  76808. name: string;
  76809. /** an array of SelectionGroups */
  76810. groups: SelectorGroup[];
  76811. private _panel;
  76812. private _buttonColor;
  76813. private _buttonBackground;
  76814. private _headerColor;
  76815. private _barColor;
  76816. private _barHeight;
  76817. private _spacerHeight;
  76818. private _labelColor;
  76819. private _groups;
  76820. private _bars;
  76821. /**
  76822. * Creates a new SelectionPanel
  76823. * @param name of SelectionPanel
  76824. * @param groups is an array of SelectionGroups
  76825. */
  76826. constructor(
  76827. /** name of SelectionPanel */
  76828. name: string,
  76829. /** an array of SelectionGroups */
  76830. groups?: SelectorGroup[]);
  76831. protected _getTypeName(): string;
  76832. /** Gets or sets the headerColor */
  76833. get headerColor(): string;
  76834. set headerColor(color: string);
  76835. private _setHeaderColor;
  76836. /** Gets or sets the button color */
  76837. get buttonColor(): string;
  76838. set buttonColor(color: string);
  76839. private _setbuttonColor;
  76840. /** Gets or sets the label color */
  76841. get labelColor(): string;
  76842. set labelColor(color: string);
  76843. private _setLabelColor;
  76844. /** Gets or sets the button background */
  76845. get buttonBackground(): string;
  76846. set buttonBackground(color: string);
  76847. private _setButtonBackground;
  76848. /** Gets or sets the color of separator bar */
  76849. get barColor(): string;
  76850. set barColor(color: string);
  76851. private _setBarColor;
  76852. /** Gets or sets the height of separator bar */
  76853. get barHeight(): string;
  76854. set barHeight(value: string);
  76855. private _setBarHeight;
  76856. /** Gets or sets the height of spacers*/
  76857. get spacerHeight(): string;
  76858. set spacerHeight(value: string);
  76859. private _setSpacerHeight;
  76860. /** Adds a bar between groups */
  76861. private _addSpacer;
  76862. /** Add a group to the selection panel
  76863. * @param group is the selector group to add
  76864. */
  76865. addGroup(group: SelectorGroup): void;
  76866. /** Remove the group from the given position
  76867. * @param groupNb is the position of the group in the list
  76868. */
  76869. removeGroup(groupNb: number): void;
  76870. /** Change a group header label
  76871. * @param label is the new group header label
  76872. * @param groupNb is the number of the group to relabel
  76873. * */
  76874. setHeaderName(label: string, groupNb: number): void;
  76875. /** Change selector label to the one given
  76876. * @param label is the new selector label
  76877. * @param groupNb is the number of the groupcontaining the selector
  76878. * @param selectorNb is the number of the selector within a group to relabel
  76879. * */
  76880. relabel(label: string, groupNb: number, selectorNb: number): void;
  76881. /** For a given group position remove the selector at the given position
  76882. * @param groupNb is the number of the group to remove the selector from
  76883. * @param selectorNb is the number of the selector within the group
  76884. */
  76885. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76886. /** For a given group position of correct type add a checkbox button
  76887. * @param groupNb is the number of the group to remove the selector from
  76888. * @param label is the label for the selector
  76889. * @param func is the function called when the Selector is checked
  76890. * @param checked is true when Selector is checked
  76891. */
  76892. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76893. /** For a given group position of correct type add a radio button
  76894. * @param groupNb is the number of the group to remove the selector from
  76895. * @param label is the label for the selector
  76896. * @param func is the function called when the Selector is checked
  76897. * @param checked is true when Selector is checked
  76898. */
  76899. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76900. /**
  76901. * For a given slider group add a slider
  76902. * @param groupNb is the number of the group to add the slider to
  76903. * @param label is the label for the Slider
  76904. * @param func is the function called when the Slider moves
  76905. * @param unit is a string describing the units used, eg degrees or metres
  76906. * @param min is the minimum value for the Slider
  76907. * @param max is the maximum value for the Slider
  76908. * @param value is the start value for the Slider between min and max
  76909. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76910. */
  76911. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76912. }
  76913. }
  76914. declare module BABYLON.GUI {
  76915. /**
  76916. * Class used to hold a the container for ScrollViewer
  76917. * @hidden
  76918. */
  76919. export class _ScrollViewerWindow extends Container {
  76920. parentClientWidth: number;
  76921. parentClientHeight: number;
  76922. private _freezeControls;
  76923. private _parentMeasure;
  76924. private _oldLeft;
  76925. private _oldTop;
  76926. get freezeControls(): boolean;
  76927. set freezeControls(value: boolean);
  76928. private _bucketWidth;
  76929. private _bucketHeight;
  76930. private _buckets;
  76931. private _bucketLen;
  76932. get bucketWidth(): number;
  76933. get bucketHeight(): number;
  76934. setBucketSizes(width: number, height: number): void;
  76935. private _useBuckets;
  76936. private _makeBuckets;
  76937. private _dispatchInBuckets;
  76938. private _updateMeasures;
  76939. private _updateChildrenMeasures;
  76940. private _restoreMeasures;
  76941. /**
  76942. * Creates a new ScrollViewerWindow
  76943. * @param name of ScrollViewerWindow
  76944. */
  76945. constructor(name?: string);
  76946. protected _getTypeName(): string;
  76947. /** @hidden */
  76948. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76949. /** @hidden */
  76950. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76951. private _scrollChildren;
  76952. private _scrollChildrenWithBuckets;
  76953. /** @hidden */
  76954. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76955. protected _postMeasure(): void;
  76956. }
  76957. }
  76958. declare module BABYLON.GUI {
  76959. /**
  76960. * Class used to create slider controls
  76961. */
  76962. export class ScrollBar extends BaseSlider {
  76963. name?: string | undefined;
  76964. private _background;
  76965. private _borderColor;
  76966. private _tempMeasure;
  76967. /** Gets or sets border color */
  76968. get borderColor(): string;
  76969. set borderColor(value: string);
  76970. /** Gets or sets background color */
  76971. get background(): string;
  76972. set background(value: string);
  76973. /**
  76974. * Creates a new Slider
  76975. * @param name defines the control name
  76976. */
  76977. constructor(name?: string | undefined);
  76978. protected _getTypeName(): string;
  76979. protected _getThumbThickness(): number;
  76980. _draw(context: CanvasRenderingContext2D): void;
  76981. private _first;
  76982. private _originX;
  76983. private _originY;
  76984. /** @hidden */
  76985. protected _updateValueFromPointer(x: number, y: number): void;
  76986. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76987. }
  76988. }
  76989. declare module BABYLON.GUI {
  76990. /**
  76991. * Class used to create slider controls
  76992. */
  76993. export class ImageScrollBar extends BaseSlider {
  76994. name?: string | undefined;
  76995. private _backgroundBaseImage;
  76996. private _backgroundImage;
  76997. private _thumbImage;
  76998. private _thumbBaseImage;
  76999. private _thumbLength;
  77000. private _thumbHeight;
  77001. private _barImageHeight;
  77002. private _tempMeasure;
  77003. /** Number of 90° rotation to apply on the images when in vertical mode */
  77004. num90RotationInVerticalMode: number;
  77005. /**
  77006. * Gets or sets the image used to render the background for horizontal bar
  77007. */
  77008. get backgroundImage(): Image;
  77009. set backgroundImage(value: Image);
  77010. /**
  77011. * Gets or sets the image used to render the thumb
  77012. */
  77013. get thumbImage(): Image;
  77014. set thumbImage(value: Image);
  77015. /**
  77016. * Gets or sets the length of the thumb
  77017. */
  77018. get thumbLength(): number;
  77019. set thumbLength(value: number);
  77020. /**
  77021. * Gets or sets the height of the thumb
  77022. */
  77023. get thumbHeight(): number;
  77024. set thumbHeight(value: number);
  77025. /**
  77026. * Gets or sets the height of the bar image
  77027. */
  77028. get barImageHeight(): number;
  77029. set barImageHeight(value: number);
  77030. /**
  77031. * Creates a new ImageScrollBar
  77032. * @param name defines the control name
  77033. */
  77034. constructor(name?: string | undefined);
  77035. protected _getTypeName(): string;
  77036. protected _getThumbThickness(): number;
  77037. _draw(context: CanvasRenderingContext2D): void;
  77038. private _first;
  77039. private _originX;
  77040. private _originY;
  77041. /** @hidden */
  77042. protected _updateValueFromPointer(x: number, y: number): void;
  77043. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77044. }
  77045. }
  77046. declare module BABYLON.GUI {
  77047. /**
  77048. * Class used to hold a viewer window and sliders in a grid
  77049. */
  77050. export class ScrollViewer extends Rectangle {
  77051. private _grid;
  77052. private _horizontalBarSpace;
  77053. private _verticalBarSpace;
  77054. private _dragSpace;
  77055. private _horizontalBar;
  77056. private _verticalBar;
  77057. private _barColor;
  77058. private _barBackground;
  77059. private _barImage;
  77060. private _horizontalBarImage;
  77061. private _verticalBarImage;
  77062. private _barBackgroundImage;
  77063. private _horizontalBarBackgroundImage;
  77064. private _verticalBarBackgroundImage;
  77065. private _barSize;
  77066. private _window;
  77067. private _pointerIsOver;
  77068. private _wheelPrecision;
  77069. private _onWheelObserver;
  77070. private _clientWidth;
  77071. private _clientHeight;
  77072. private _useImageBar;
  77073. private _thumbLength;
  77074. private _thumbHeight;
  77075. private _barImageHeight;
  77076. private _horizontalBarImageHeight;
  77077. private _verticalBarImageHeight;
  77078. private _oldWindowContentsWidth;
  77079. private _oldWindowContentsHeight;
  77080. /**
  77081. * Gets the horizontal scrollbar
  77082. */
  77083. get horizontalBar(): ScrollBar | ImageScrollBar;
  77084. /**
  77085. * Gets the vertical scrollbar
  77086. */
  77087. get verticalBar(): ScrollBar | ImageScrollBar;
  77088. /**
  77089. * Adds a new control to the current container
  77090. * @param control defines the control to add
  77091. * @returns the current container
  77092. */
  77093. addControl(control: BABYLON.Nullable<Control>): Container;
  77094. /**
  77095. * Removes a control from the current container
  77096. * @param control defines the control to remove
  77097. * @returns the current container
  77098. */
  77099. removeControl(control: Control): Container;
  77100. /** Gets the list of children */
  77101. get children(): Control[];
  77102. _flagDescendantsAsMatrixDirty(): void;
  77103. /**
  77104. * Freezes or unfreezes the controls in the window.
  77105. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77106. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77107. */
  77108. get freezeControls(): boolean;
  77109. set freezeControls(value: boolean);
  77110. /** Gets the bucket width */
  77111. get bucketWidth(): number;
  77112. /** Gets the bucket height */
  77113. get bucketHeight(): number;
  77114. /**
  77115. * Sets the bucket sizes.
  77116. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77117. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77118. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77119. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77120. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77121. * used), that's why it is not enabled by default.
  77122. * @param width width of the bucket
  77123. * @param height height of the bucket
  77124. */
  77125. setBucketSizes(width: number, height: number): void;
  77126. private _forceHorizontalBar;
  77127. private _forceVerticalBar;
  77128. /**
  77129. * Forces the horizontal scroll bar to be displayed
  77130. */
  77131. get forceHorizontalBar(): boolean;
  77132. set forceHorizontalBar(value: boolean);
  77133. /**
  77134. * Forces the vertical scroll bar to be displayed
  77135. */
  77136. get forceVerticalBar(): boolean;
  77137. set forceVerticalBar(value: boolean);
  77138. /**
  77139. * Creates a new ScrollViewer
  77140. * @param name of ScrollViewer
  77141. */
  77142. constructor(name?: string, isImageBased?: boolean);
  77143. /** Reset the scroll viewer window to initial size */
  77144. resetWindow(): void;
  77145. protected _getTypeName(): string;
  77146. private _buildClientSizes;
  77147. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77148. protected _postMeasure(): void;
  77149. /**
  77150. * Gets or sets the mouse wheel precision
  77151. * from 0 to 1 with a default value of 0.05
  77152. * */
  77153. get wheelPrecision(): number;
  77154. set wheelPrecision(value: number);
  77155. /** Gets or sets the scroll bar container background color */
  77156. get scrollBackground(): string;
  77157. set scrollBackground(color: string);
  77158. /** Gets or sets the bar color */
  77159. get barColor(): string;
  77160. set barColor(color: string);
  77161. /** Gets or sets the bar image */
  77162. get thumbImage(): Image;
  77163. set thumbImage(value: Image);
  77164. /** Gets or sets the horizontal bar image */
  77165. get horizontalThumbImage(): Image;
  77166. set horizontalThumbImage(value: Image);
  77167. /** Gets or sets the vertical bar image */
  77168. get verticalThumbImage(): Image;
  77169. set verticalThumbImage(value: Image);
  77170. /** Gets or sets the size of the bar */
  77171. get barSize(): number;
  77172. set barSize(value: number);
  77173. /** Gets or sets the length of the thumb */
  77174. get thumbLength(): number;
  77175. set thumbLength(value: number);
  77176. /** Gets or sets the height of the thumb */
  77177. get thumbHeight(): number;
  77178. set thumbHeight(value: number);
  77179. /** Gets or sets the height of the bar image */
  77180. get barImageHeight(): number;
  77181. set barImageHeight(value: number);
  77182. /** Gets or sets the height of the horizontal bar image */
  77183. get horizontalBarImageHeight(): number;
  77184. set horizontalBarImageHeight(value: number);
  77185. /** Gets or sets the height of the vertical bar image */
  77186. get verticalBarImageHeight(): number;
  77187. set verticalBarImageHeight(value: number);
  77188. /** Gets or sets the bar background */
  77189. get barBackground(): string;
  77190. set barBackground(color: string);
  77191. /** Gets or sets the bar background image */
  77192. get barImage(): Image;
  77193. set barImage(value: Image);
  77194. /** Gets or sets the horizontal bar background image */
  77195. get horizontalBarImage(): Image;
  77196. set horizontalBarImage(value: Image);
  77197. /** Gets or sets the vertical bar background image */
  77198. get verticalBarImage(): Image;
  77199. set verticalBarImage(value: Image);
  77200. private _setWindowPosition;
  77201. /** @hidden */
  77202. private _updateScroller;
  77203. _link(host: AdvancedDynamicTexture): void;
  77204. /** @hidden */
  77205. private _addBar;
  77206. /** @hidden */
  77207. private _attachWheel;
  77208. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77209. /** Releases associated resources */
  77210. dispose(): void;
  77211. }
  77212. }
  77213. declare module BABYLON.GUI {
  77214. /** Class used to render a grid */
  77215. export class DisplayGrid extends Control {
  77216. name?: string | undefined;
  77217. private _cellWidth;
  77218. private _cellHeight;
  77219. private _minorLineTickness;
  77220. private _minorLineColor;
  77221. private _majorLineTickness;
  77222. private _majorLineColor;
  77223. private _majorLineFrequency;
  77224. private _background;
  77225. private _displayMajorLines;
  77226. private _displayMinorLines;
  77227. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77228. get displayMinorLines(): boolean;
  77229. set displayMinorLines(value: boolean);
  77230. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77231. get displayMajorLines(): boolean;
  77232. set displayMajorLines(value: boolean);
  77233. /** Gets or sets background color (Black by default) */
  77234. get background(): string;
  77235. set background(value: string);
  77236. /** Gets or sets the width of each cell (20 by default) */
  77237. get cellWidth(): number;
  77238. set cellWidth(value: number);
  77239. /** Gets or sets the height of each cell (20 by default) */
  77240. get cellHeight(): number;
  77241. set cellHeight(value: number);
  77242. /** Gets or sets the tickness of minor lines (1 by default) */
  77243. get minorLineTickness(): number;
  77244. set minorLineTickness(value: number);
  77245. /** Gets or sets the color of minor lines (DarkGray by default) */
  77246. get minorLineColor(): string;
  77247. set minorLineColor(value: string);
  77248. /** Gets or sets the tickness of major lines (2 by default) */
  77249. get majorLineTickness(): number;
  77250. set majorLineTickness(value: number);
  77251. /** Gets or sets the color of major lines (White by default) */
  77252. get majorLineColor(): string;
  77253. set majorLineColor(value: string);
  77254. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77255. get majorLineFrequency(): number;
  77256. set majorLineFrequency(value: number);
  77257. /**
  77258. * Creates a new GridDisplayRectangle
  77259. * @param name defines the control name
  77260. */
  77261. constructor(name?: string | undefined);
  77262. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77263. protected _getTypeName(): string;
  77264. }
  77265. }
  77266. declare module BABYLON.GUI {
  77267. /**
  77268. * Class used to create slider controls based on images
  77269. */
  77270. export class ImageBasedSlider extends BaseSlider {
  77271. name?: string | undefined;
  77272. private _backgroundImage;
  77273. private _thumbImage;
  77274. private _valueBarImage;
  77275. private _tempMeasure;
  77276. get displayThumb(): boolean;
  77277. set displayThumb(value: boolean);
  77278. /**
  77279. * Gets or sets the image used to render the background
  77280. */
  77281. get backgroundImage(): Image;
  77282. set backgroundImage(value: Image);
  77283. /**
  77284. * Gets or sets the image used to render the value bar
  77285. */
  77286. get valueBarImage(): Image;
  77287. set valueBarImage(value: Image);
  77288. /**
  77289. * Gets or sets the image used to render the thumb
  77290. */
  77291. get thumbImage(): Image;
  77292. set thumbImage(value: Image);
  77293. /**
  77294. * Creates a new ImageBasedSlider
  77295. * @param name defines the control name
  77296. */
  77297. constructor(name?: string | undefined);
  77298. protected _getTypeName(): string;
  77299. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77300. }
  77301. }
  77302. declare module BABYLON.GUI {
  77303. /**
  77304. * Forcing an export so that this code will execute
  77305. * @hidden
  77306. */
  77307. const name = "Statics";
  77308. }
  77309. declare module BABYLON.GUI {
  77310. /**
  77311. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77312. */
  77313. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77314. /**
  77315. * Define the instrumented AdvancedDynamicTexture.
  77316. */
  77317. texture: AdvancedDynamicTexture;
  77318. private _captureRenderTime;
  77319. private _renderTime;
  77320. private _captureLayoutTime;
  77321. private _layoutTime;
  77322. private _onBeginRenderObserver;
  77323. private _onEndRenderObserver;
  77324. private _onBeginLayoutObserver;
  77325. private _onEndLayoutObserver;
  77326. /**
  77327. * Gets the perf counter used to capture render time
  77328. */
  77329. get renderTimeCounter(): BABYLON.PerfCounter;
  77330. /**
  77331. * Gets the perf counter used to capture layout time
  77332. */
  77333. get layoutTimeCounter(): BABYLON.PerfCounter;
  77334. /**
  77335. * Enable or disable the render time capture
  77336. */
  77337. get captureRenderTime(): boolean;
  77338. set captureRenderTime(value: boolean);
  77339. /**
  77340. * Enable or disable the layout time capture
  77341. */
  77342. get captureLayoutTime(): boolean;
  77343. set captureLayoutTime(value: boolean);
  77344. /**
  77345. * Instantiates a new advanced dynamic texture instrumentation.
  77346. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77347. * @param texture Defines the AdvancedDynamicTexture to instrument
  77348. */
  77349. constructor(
  77350. /**
  77351. * Define the instrumented AdvancedDynamicTexture.
  77352. */
  77353. texture: AdvancedDynamicTexture);
  77354. /**
  77355. * Dispose and release associated resources.
  77356. */
  77357. dispose(): void;
  77358. }
  77359. }
  77360. declare module BABYLON.GUI {
  77361. /**
  77362. * Class used to load GUI via XML.
  77363. */
  77364. export class XmlLoader {
  77365. private _nodes;
  77366. private _nodeTypes;
  77367. private _isLoaded;
  77368. private _objectAttributes;
  77369. private _parentClass;
  77370. /**
  77371. * Create a new xml loader
  77372. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77373. */
  77374. constructor(parentClass?: null);
  77375. private _getChainElement;
  77376. private _getClassAttribute;
  77377. private _createGuiElement;
  77378. private _parseGrid;
  77379. private _parseElement;
  77380. private _prepareSourceElement;
  77381. private _parseElementsFromSource;
  77382. private _parseXml;
  77383. /**
  77384. * Gets if the loading has finished.
  77385. * @returns whether the loading has finished or not
  77386. */
  77387. isLoaded(): boolean;
  77388. /**
  77389. * Gets a loaded node / control by id.
  77390. * @param id the Controls id set in the xml
  77391. * @returns element of type Control
  77392. */
  77393. getNodeById(id: string): any;
  77394. /**
  77395. * Gets all loaded nodes / controls
  77396. * @returns Array of controls
  77397. */
  77398. getNodes(): any;
  77399. /**
  77400. * Initiates the xml layout loading
  77401. * @param xmlFile defines the xml layout to load
  77402. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77403. * @param callback defines the callback called on layout load.
  77404. */
  77405. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77406. }
  77407. }
  77408. declare module BABYLON.GUI {
  77409. /**
  77410. * Class used to create containers for controls
  77411. */
  77412. export class Container3D extends Control3D {
  77413. private _blockLayout;
  77414. /**
  77415. * Gets the list of child controls
  77416. */
  77417. protected _children: Control3D[];
  77418. /**
  77419. * Gets the list of child controls
  77420. */
  77421. get children(): Array<Control3D>;
  77422. /**
  77423. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77424. * This is helpful to optimize layout operation when adding multiple children in a row
  77425. */
  77426. get blockLayout(): boolean;
  77427. set blockLayout(value: boolean);
  77428. /**
  77429. * Creates a new container
  77430. * @param name defines the container name
  77431. */
  77432. constructor(name?: string);
  77433. /**
  77434. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77435. * @returns the current container
  77436. */
  77437. updateLayout(): Container3D;
  77438. /**
  77439. * Gets a boolean indicating if the given control is in the children of this control
  77440. * @param control defines the control to check
  77441. * @returns true if the control is in the child list
  77442. */
  77443. containsControl(control: Control3D): boolean;
  77444. /**
  77445. * Adds a control to the children of this control
  77446. * @param control defines the control to add
  77447. * @returns the current container
  77448. */
  77449. addControl(control: Control3D): Container3D;
  77450. /**
  77451. * This function will be called everytime a new control is added
  77452. */
  77453. protected _arrangeChildren(): void;
  77454. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77455. /**
  77456. * Removes a control from the children of this control
  77457. * @param control defines the control to remove
  77458. * @returns the current container
  77459. */
  77460. removeControl(control: Control3D): Container3D;
  77461. protected _getTypeName(): string;
  77462. /**
  77463. * Releases all associated resources
  77464. */
  77465. dispose(): void;
  77466. /** Control rotation will remain unchanged */
  77467. static readonly UNSET_ORIENTATION: number;
  77468. /** Control will rotate to make it look at sphere central axis */
  77469. static readonly FACEORIGIN_ORIENTATION: number;
  77470. /** Control will rotate to make it look back at sphere central axis */
  77471. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77472. /** Control will rotate to look at z axis (0, 0, 1) */
  77473. static readonly FACEFORWARD_ORIENTATION: number;
  77474. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77475. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77476. }
  77477. }
  77478. declare module BABYLON.GUI {
  77479. /**
  77480. * Class used to manage 3D user interface
  77481. * @see http://doc.babylonjs.com/how_to/gui3d
  77482. */
  77483. export class GUI3DManager implements BABYLON.IDisposable {
  77484. private _scene;
  77485. private _sceneDisposeObserver;
  77486. private _utilityLayer;
  77487. private _rootContainer;
  77488. private _pointerObserver;
  77489. private _pointerOutObserver;
  77490. /** @hidden */
  77491. _lastPickedControl: Control3D;
  77492. /** @hidden */
  77493. _lastControlOver: {
  77494. [pointerId: number]: Control3D;
  77495. };
  77496. /** @hidden */
  77497. _lastControlDown: {
  77498. [pointerId: number]: Control3D;
  77499. };
  77500. /**
  77501. * BABYLON.Observable raised when the point picked by the pointer events changed
  77502. */
  77503. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77504. /** @hidden */
  77505. _sharedMaterials: {
  77506. [key: string]: BABYLON.Material;
  77507. };
  77508. /** Gets the hosting scene */
  77509. get scene(): BABYLON.Scene;
  77510. /** Gets associated utility layer */
  77511. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77512. /**
  77513. * Creates a new GUI3DManager
  77514. * @param scene
  77515. */
  77516. constructor(scene?: BABYLON.Scene);
  77517. private _handlePointerOut;
  77518. private _doPicking;
  77519. /**
  77520. * Gets the root container
  77521. */
  77522. get rootContainer(): Container3D;
  77523. /**
  77524. * Gets a boolean indicating if the given control is in the root child list
  77525. * @param control defines the control to check
  77526. * @returns true if the control is in the root child list
  77527. */
  77528. containsControl(control: Control3D): boolean;
  77529. /**
  77530. * Adds a control to the root child list
  77531. * @param control defines the control to add
  77532. * @returns the current manager
  77533. */
  77534. addControl(control: Control3D): GUI3DManager;
  77535. /**
  77536. * Removes a control from the root child list
  77537. * @param control defines the control to remove
  77538. * @returns the current container
  77539. */
  77540. removeControl(control: Control3D): GUI3DManager;
  77541. /**
  77542. * Releases all associated resources
  77543. */
  77544. dispose(): void;
  77545. }
  77546. }
  77547. declare module BABYLON.GUI {
  77548. /**
  77549. * Class used to transport BABYLON.Vector3 information for pointer events
  77550. */
  77551. export class Vector3WithInfo extends BABYLON.Vector3 {
  77552. /** defines the current mouse button index */
  77553. buttonIndex: number;
  77554. /**
  77555. * Creates a new Vector3WithInfo
  77556. * @param source defines the vector3 data to transport
  77557. * @param buttonIndex defines the current mouse button index
  77558. */
  77559. constructor(source: BABYLON.Vector3,
  77560. /** defines the current mouse button index */
  77561. buttonIndex?: number);
  77562. }
  77563. }
  77564. declare module BABYLON.GUI {
  77565. /**
  77566. * Class used as base class for controls
  77567. */
  77568. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77569. /** Defines the control name */
  77570. name?: string | undefined;
  77571. /** @hidden */
  77572. _host: GUI3DManager;
  77573. private _node;
  77574. private _downCount;
  77575. private _enterCount;
  77576. private _downPointerIds;
  77577. private _isVisible;
  77578. /** Gets or sets the control position in world space */
  77579. get position(): BABYLON.Vector3;
  77580. set position(value: BABYLON.Vector3);
  77581. /** Gets or sets the control scaling in world space */
  77582. get scaling(): BABYLON.Vector3;
  77583. set scaling(value: BABYLON.Vector3);
  77584. /** Callback used to start pointer enter animation */
  77585. pointerEnterAnimation: () => void;
  77586. /** Callback used to start pointer out animation */
  77587. pointerOutAnimation: () => void;
  77588. /** Callback used to start pointer down animation */
  77589. pointerDownAnimation: () => void;
  77590. /** Callback used to start pointer up animation */
  77591. pointerUpAnimation: () => void;
  77592. /**
  77593. * An event triggered when the pointer move over the control
  77594. */
  77595. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77596. /**
  77597. * An event triggered when the pointer move out of the control
  77598. */
  77599. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77600. /**
  77601. * An event triggered when the pointer taps the control
  77602. */
  77603. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77604. /**
  77605. * An event triggered when pointer is up
  77606. */
  77607. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77608. /**
  77609. * An event triggered when a control is clicked on (with a mouse)
  77610. */
  77611. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77612. /**
  77613. * An event triggered when pointer enters the control
  77614. */
  77615. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77616. /**
  77617. * Gets or sets the parent container
  77618. */
  77619. parent: BABYLON.Nullable<Container3D>;
  77620. private _behaviors;
  77621. /**
  77622. * Gets the list of attached behaviors
  77623. * @see http://doc.babylonjs.com/features/behaviour
  77624. */
  77625. get behaviors(): BABYLON.Behavior<Control3D>[];
  77626. /**
  77627. * Attach a behavior to the control
  77628. * @see http://doc.babylonjs.com/features/behaviour
  77629. * @param behavior defines the behavior to attach
  77630. * @returns the current control
  77631. */
  77632. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77633. /**
  77634. * Remove an attached behavior
  77635. * @see http://doc.babylonjs.com/features/behaviour
  77636. * @param behavior defines the behavior to attach
  77637. * @returns the current control
  77638. */
  77639. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77640. /**
  77641. * Gets an attached behavior by name
  77642. * @param name defines the name of the behavior to look for
  77643. * @see http://doc.babylonjs.com/features/behaviour
  77644. * @returns null if behavior was not found else the requested behavior
  77645. */
  77646. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77647. /** Gets or sets a boolean indicating if the control is visible */
  77648. get isVisible(): boolean;
  77649. set isVisible(value: boolean);
  77650. /**
  77651. * Creates a new control
  77652. * @param name defines the control name
  77653. */
  77654. constructor(
  77655. /** Defines the control name */
  77656. name?: string | undefined);
  77657. /**
  77658. * Gets a string representing the class name
  77659. */
  77660. get typeName(): string;
  77661. /**
  77662. * Get the current class name of the control.
  77663. * @returns current class name
  77664. */
  77665. getClassName(): string;
  77666. protected _getTypeName(): string;
  77667. /**
  77668. * Gets the transform node used by this control
  77669. */
  77670. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77671. /**
  77672. * Gets the mesh used to render this control
  77673. */
  77674. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77675. /**
  77676. * Link the control as child of the given node
  77677. * @param node defines the node to link to. Use null to unlink the control
  77678. * @returns the current control
  77679. */
  77680. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77681. /** @hidden **/
  77682. _prepareNode(scene: BABYLON.Scene): void;
  77683. /**
  77684. * Node creation.
  77685. * Can be overriden by children
  77686. * @param scene defines the scene where the node must be attached
  77687. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77688. */
  77689. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77690. /**
  77691. * Affect a material to the given mesh
  77692. * @param mesh defines the mesh which will represent the control
  77693. */
  77694. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77695. /** @hidden */
  77696. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77697. /** @hidden */
  77698. _onPointerEnter(target: Control3D): boolean;
  77699. /** @hidden */
  77700. _onPointerOut(target: Control3D): void;
  77701. /** @hidden */
  77702. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77703. /** @hidden */
  77704. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77705. /** @hidden */
  77706. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77707. /** @hidden */
  77708. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77709. /** @hidden */
  77710. _disposeNode(): void;
  77711. /**
  77712. * Releases all associated resources
  77713. */
  77714. dispose(): void;
  77715. }
  77716. }
  77717. declare module BABYLON.GUI {
  77718. /**
  77719. * Class used as a root to all buttons
  77720. */
  77721. export class AbstractButton3D extends Control3D {
  77722. /**
  77723. * Creates a new button
  77724. * @param name defines the control name
  77725. */
  77726. constructor(name?: string);
  77727. protected _getTypeName(): string;
  77728. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77729. }
  77730. }
  77731. declare module BABYLON.GUI {
  77732. /**
  77733. * Class used to create a button in 3D
  77734. */
  77735. export class Button3D extends AbstractButton3D {
  77736. /** @hidden */
  77737. protected _currentMaterial: BABYLON.Material;
  77738. private _facadeTexture;
  77739. private _content;
  77740. private _contentResolution;
  77741. private _contentScaleRatio;
  77742. /**
  77743. * Gets or sets the texture resolution used to render content (512 by default)
  77744. */
  77745. get contentResolution(): BABYLON.int;
  77746. set contentResolution(value: BABYLON.int);
  77747. /**
  77748. * Gets or sets the texture scale ratio used to render content (2 by default)
  77749. */
  77750. get contentScaleRatio(): number;
  77751. set contentScaleRatio(value: number);
  77752. protected _disposeFacadeTexture(): void;
  77753. protected _resetContent(): void;
  77754. /**
  77755. * Creates a new button
  77756. * @param name defines the control name
  77757. */
  77758. constructor(name?: string);
  77759. /**
  77760. * Gets or sets the GUI 2D content used to display the button's facade
  77761. */
  77762. get content(): Control;
  77763. set content(value: Control);
  77764. /**
  77765. * Apply the facade texture (created from the content property).
  77766. * This function can be overloaded by child classes
  77767. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77768. */
  77769. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77770. protected _getTypeName(): string;
  77771. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77772. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77773. /**
  77774. * Releases all associated resources
  77775. */
  77776. dispose(): void;
  77777. }
  77778. }
  77779. declare module BABYLON.GUI {
  77780. /**
  77781. * Abstract class used to create a container panel deployed on the surface of a volume
  77782. */
  77783. export abstract class VolumeBasedPanel extends Container3D {
  77784. private _columns;
  77785. private _rows;
  77786. private _rowThenColum;
  77787. private _orientation;
  77788. protected _cellWidth: number;
  77789. protected _cellHeight: number;
  77790. /**
  77791. * Gets or sets the distance between elements
  77792. */
  77793. margin: number;
  77794. /**
  77795. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77796. * | Value | Type | Description |
  77797. * | ----- | ----------------------------------- | ----------- |
  77798. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77799. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77800. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77801. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77802. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77803. */
  77804. get orientation(): number;
  77805. set orientation(value: number);
  77806. /**
  77807. * Gets or sets the number of columns requested (10 by default).
  77808. * The panel will automatically compute the number of rows based on number of child controls.
  77809. */
  77810. get columns(): BABYLON.int;
  77811. set columns(value: BABYLON.int);
  77812. /**
  77813. * Gets or sets a the number of rows requested.
  77814. * The panel will automatically compute the number of columns based on number of child controls.
  77815. */
  77816. get rows(): BABYLON.int;
  77817. set rows(value: BABYLON.int);
  77818. /**
  77819. * Creates new VolumeBasedPanel
  77820. */
  77821. constructor();
  77822. protected _arrangeChildren(): void;
  77823. /** Child classes must implement this function to provide correct control positioning */
  77824. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77825. /** Child classes can implement this function to provide additional processing */
  77826. protected _finalProcessing(): void;
  77827. }
  77828. }
  77829. declare module BABYLON.GUI {
  77830. /**
  77831. * Class used to create a container panel deployed on the surface of a cylinder
  77832. */
  77833. export class CylinderPanel extends VolumeBasedPanel {
  77834. private _radius;
  77835. /**
  77836. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77837. */
  77838. get radius(): BABYLON.float;
  77839. set radius(value: BABYLON.float);
  77840. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77841. private _cylindricalMapping;
  77842. }
  77843. }
  77844. declare module BABYLON.GUI {
  77845. /** @hidden */
  77846. export var fluentVertexShader: {
  77847. name: string;
  77848. shader: string;
  77849. };
  77850. }
  77851. declare module BABYLON.GUI {
  77852. /** @hidden */
  77853. export var fluentPixelShader: {
  77854. name: string;
  77855. shader: string;
  77856. };
  77857. }
  77858. declare module BABYLON.GUI {
  77859. /** @hidden */
  77860. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77861. INNERGLOW: boolean;
  77862. BORDER: boolean;
  77863. HOVERLIGHT: boolean;
  77864. TEXTURE: boolean;
  77865. constructor();
  77866. }
  77867. /**
  77868. * Class used to render controls with fluent desgin
  77869. */
  77870. export class FluentMaterial extends BABYLON.PushMaterial {
  77871. /**
  77872. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77873. */
  77874. innerGlowColorIntensity: number;
  77875. /**
  77876. * Gets or sets the inner glow color (white by default)
  77877. */
  77878. innerGlowColor: BABYLON.Color3;
  77879. /**
  77880. * Gets or sets alpha value (default is 1.0)
  77881. */
  77882. alpha: number;
  77883. /**
  77884. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77885. */
  77886. albedoColor: BABYLON.Color3;
  77887. /**
  77888. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77889. */
  77890. renderBorders: boolean;
  77891. /**
  77892. * Gets or sets border width (default is 0.5)
  77893. */
  77894. borderWidth: number;
  77895. /**
  77896. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77897. */
  77898. edgeSmoothingValue: number;
  77899. /**
  77900. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77901. */
  77902. borderMinValue: number;
  77903. /**
  77904. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77905. */
  77906. renderHoverLight: boolean;
  77907. /**
  77908. * Gets or sets the radius used to render the hover light (default is 1.0)
  77909. */
  77910. hoverRadius: number;
  77911. /**
  77912. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77913. */
  77914. hoverColor: BABYLON.Color4;
  77915. /**
  77916. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77917. */
  77918. hoverPosition: BABYLON.Vector3;
  77919. private _albedoTexture;
  77920. /** Gets or sets the texture to use for albedo color */
  77921. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77922. /**
  77923. * Creates a new Fluent material
  77924. * @param name defines the name of the material
  77925. * @param scene defines the hosting scene
  77926. */
  77927. constructor(name: string, scene: BABYLON.Scene);
  77928. needAlphaBlending(): boolean;
  77929. needAlphaTesting(): boolean;
  77930. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77931. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77932. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77933. getActiveTextures(): BABYLON.BaseTexture[];
  77934. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77935. dispose(forceDisposeEffect?: boolean): void;
  77936. clone(name: string): FluentMaterial;
  77937. serialize(): any;
  77938. getClassName(): string;
  77939. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77940. }
  77941. }
  77942. declare module BABYLON.GUI {
  77943. /**
  77944. * Class used to create a holographic button in 3D
  77945. */
  77946. export class HolographicButton extends Button3D {
  77947. private _backPlate;
  77948. private _textPlate;
  77949. private _frontPlate;
  77950. private _text;
  77951. private _imageUrl;
  77952. private _shareMaterials;
  77953. private _frontMaterial;
  77954. private _backMaterial;
  77955. private _plateMaterial;
  77956. private _pickedPointObserver;
  77957. private _tooltipFade;
  77958. private _tooltipTextBlock;
  77959. private _tooltipTexture;
  77960. private _tooltipMesh;
  77961. private _tooltipHoverObserver;
  77962. private _tooltipOutObserver;
  77963. private _disposeTooltip;
  77964. /**
  77965. * Rendering ground id of all the mesh in the button
  77966. */
  77967. set renderingGroupId(id: number);
  77968. get renderingGroupId(): number;
  77969. /**
  77970. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77971. */
  77972. set tooltipText(text: BABYLON.Nullable<string>);
  77973. get tooltipText(): BABYLON.Nullable<string>;
  77974. /**
  77975. * Gets or sets text for the button
  77976. */
  77977. get text(): string;
  77978. set text(value: string);
  77979. /**
  77980. * Gets or sets the image url for the button
  77981. */
  77982. get imageUrl(): string;
  77983. set imageUrl(value: string);
  77984. /**
  77985. * Gets the back material used by this button
  77986. */
  77987. get backMaterial(): FluentMaterial;
  77988. /**
  77989. * Gets the front material used by this button
  77990. */
  77991. get frontMaterial(): FluentMaterial;
  77992. /**
  77993. * Gets the plate material used by this button
  77994. */
  77995. get plateMaterial(): BABYLON.StandardMaterial;
  77996. /**
  77997. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77998. */
  77999. get shareMaterials(): boolean;
  78000. /**
  78001. * Creates a new button
  78002. * @param name defines the control name
  78003. */
  78004. constructor(name?: string, shareMaterials?: boolean);
  78005. protected _getTypeName(): string;
  78006. private _rebuildContent;
  78007. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78008. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78009. private _createBackMaterial;
  78010. private _createFrontMaterial;
  78011. private _createPlateMaterial;
  78012. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78013. /**
  78014. * Releases all associated resources
  78015. */
  78016. dispose(): void;
  78017. }
  78018. }
  78019. declare module BABYLON.GUI {
  78020. /**
  78021. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78022. */
  78023. export class MeshButton3D extends Button3D {
  78024. /** @hidden */
  78025. protected _currentMesh: BABYLON.Mesh;
  78026. /**
  78027. * Creates a new 3D button based on a mesh
  78028. * @param mesh mesh to become a 3D button
  78029. * @param name defines the control name
  78030. */
  78031. constructor(mesh: BABYLON.Mesh, name?: string);
  78032. protected _getTypeName(): string;
  78033. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78034. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78035. }
  78036. }
  78037. declare module BABYLON.GUI {
  78038. /**
  78039. * Class used to create a container panel deployed on the surface of a plane
  78040. */
  78041. export class PlanePanel extends VolumeBasedPanel {
  78042. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78043. }
  78044. }
  78045. declare module BABYLON.GUI {
  78046. /**
  78047. * Class used to create a container panel where items get randomized planar mapping
  78048. */
  78049. export class ScatterPanel extends VolumeBasedPanel {
  78050. private _iteration;
  78051. /**
  78052. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78053. */
  78054. get iteration(): BABYLON.float;
  78055. set iteration(value: BABYLON.float);
  78056. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78057. private _scatterMapping;
  78058. protected _finalProcessing(): void;
  78059. }
  78060. }
  78061. declare module BABYLON.GUI {
  78062. /**
  78063. * Class used to create a container panel deployed on the surface of a sphere
  78064. */
  78065. export class SpherePanel extends VolumeBasedPanel {
  78066. private _radius;
  78067. /**
  78068. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78069. */
  78070. get radius(): BABYLON.float;
  78071. set radius(value: BABYLON.float);
  78072. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78073. private _sphericalMapping;
  78074. }
  78075. }
  78076. declare module BABYLON.GUI {
  78077. /**
  78078. * Class used to create a stack panel in 3D on XY plane
  78079. */
  78080. export class StackPanel3D extends Container3D {
  78081. private _isVertical;
  78082. /**
  78083. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78084. */
  78085. get isVertical(): boolean;
  78086. set isVertical(value: boolean);
  78087. /**
  78088. * Gets or sets the distance between elements
  78089. */
  78090. margin: number;
  78091. /**
  78092. * Creates new StackPanel
  78093. * @param isVertical
  78094. */
  78095. constructor(isVertical?: boolean);
  78096. protected _arrangeChildren(): void;
  78097. }
  78098. }
  78099. declare module BABYLON {
  78100. /**
  78101. * Configuration for glTF validation
  78102. */
  78103. export interface IGLTFValidationConfiguration {
  78104. /**
  78105. * The url of the glTF validator.
  78106. */
  78107. url: string;
  78108. }
  78109. /**
  78110. * glTF validation
  78111. */
  78112. export class GLTFValidation {
  78113. /**
  78114. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78115. */
  78116. static Configuration: IGLTFValidationConfiguration;
  78117. private static _LoadScriptPromise;
  78118. /**
  78119. * Validate a glTF asset using the glTF-Validator.
  78120. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78121. * @param rootUrl The root url for the glTF
  78122. * @param fileName The file name for the glTF
  78123. * @param getExternalResource The callback to get external resources for the glTF validator
  78124. * @returns A promise that resolves with the glTF validation results once complete
  78125. */
  78126. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78127. }
  78128. }
  78129. declare module BABYLON {
  78130. /**
  78131. * Mode that determines the coordinate system to use.
  78132. */
  78133. export enum GLTFLoaderCoordinateSystemMode {
  78134. /**
  78135. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78136. */
  78137. AUTO = 0,
  78138. /**
  78139. * Sets the useRightHandedSystem flag on the scene.
  78140. */
  78141. FORCE_RIGHT_HANDED = 1
  78142. }
  78143. /**
  78144. * Mode that determines what animations will start.
  78145. */
  78146. export enum GLTFLoaderAnimationStartMode {
  78147. /**
  78148. * No animation will start.
  78149. */
  78150. NONE = 0,
  78151. /**
  78152. * The first animation will start.
  78153. */
  78154. FIRST = 1,
  78155. /**
  78156. * All animations will start.
  78157. */
  78158. ALL = 2
  78159. }
  78160. /**
  78161. * Interface that contains the data for the glTF asset.
  78162. */
  78163. export interface IGLTFLoaderData {
  78164. /**
  78165. * The object that represents the glTF JSON.
  78166. */
  78167. json: Object;
  78168. /**
  78169. * The BIN chunk of a binary glTF.
  78170. */
  78171. bin: Nullable<IDataBuffer>;
  78172. }
  78173. /**
  78174. * Interface for extending the loader.
  78175. */
  78176. export interface IGLTFLoaderExtension {
  78177. /**
  78178. * The name of this extension.
  78179. */
  78180. readonly name: string;
  78181. /**
  78182. * Defines whether this extension is enabled.
  78183. */
  78184. enabled: boolean;
  78185. /**
  78186. * Defines the order of this extension.
  78187. * The loader sorts the extensions using these values when loading.
  78188. */
  78189. order?: number;
  78190. }
  78191. /**
  78192. * Loader state.
  78193. */
  78194. export enum GLTFLoaderState {
  78195. /**
  78196. * The asset is loading.
  78197. */
  78198. LOADING = 0,
  78199. /**
  78200. * The asset is ready for rendering.
  78201. */
  78202. READY = 1,
  78203. /**
  78204. * The asset is completely loaded.
  78205. */
  78206. COMPLETE = 2
  78207. }
  78208. /** @hidden */
  78209. export interface IImportMeshAsyncOutput {
  78210. meshes: AbstractMesh[];
  78211. particleSystems: IParticleSystem[];
  78212. skeletons: Skeleton[];
  78213. animationGroups: AnimationGroup[];
  78214. lights: Light[];
  78215. transformNodes: TransformNode[];
  78216. }
  78217. /** @hidden */
  78218. export interface IGLTFLoader extends IDisposable {
  78219. readonly state: Nullable<GLTFLoaderState>;
  78220. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78221. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78222. }
  78223. /**
  78224. * File loader for loading glTF files into a scene.
  78225. */
  78226. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78227. /** @hidden */
  78228. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78229. /** @hidden */
  78230. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78231. /**
  78232. * Raised when the asset has been parsed
  78233. */
  78234. onParsedObservable: Observable<IGLTFLoaderData>;
  78235. private _onParsedObserver;
  78236. /**
  78237. * Raised when the asset has been parsed
  78238. */
  78239. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78240. /**
  78241. * 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.
  78242. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78243. * Defaults to true.
  78244. * @hidden
  78245. */
  78246. static IncrementalLoading: boolean;
  78247. /**
  78248. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78249. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78250. * @hidden
  78251. */
  78252. static HomogeneousCoordinates: boolean;
  78253. /**
  78254. * The coordinate system mode. Defaults to AUTO.
  78255. */
  78256. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78257. /**
  78258. * The animation start mode. Defaults to FIRST.
  78259. */
  78260. animationStartMode: GLTFLoaderAnimationStartMode;
  78261. /**
  78262. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78263. */
  78264. compileMaterials: boolean;
  78265. /**
  78266. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78267. */
  78268. useClipPlane: boolean;
  78269. /**
  78270. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78271. */
  78272. compileShadowGenerators: boolean;
  78273. /**
  78274. * Defines if the Alpha blended materials are only applied as coverage.
  78275. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78276. * If true, no extra effects are applied to transparent pixels.
  78277. */
  78278. transparencyAsCoverage: boolean;
  78279. /**
  78280. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78281. * Enabling will disable offline support and glTF validator.
  78282. * Defaults to false.
  78283. */
  78284. useRangeRequests: boolean;
  78285. /**
  78286. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78287. */
  78288. createInstances: boolean;
  78289. /**
  78290. * Function called before loading a url referenced by the asset.
  78291. */
  78292. preprocessUrlAsync: (url: string) => Promise<string>;
  78293. /**
  78294. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78295. */
  78296. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78297. private _onMeshLoadedObserver;
  78298. /**
  78299. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78300. */
  78301. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78302. /**
  78303. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78304. */
  78305. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78306. private _onTextureLoadedObserver;
  78307. /**
  78308. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78309. */
  78310. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78311. /**
  78312. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78313. */
  78314. readonly onMaterialLoadedObservable: Observable<Material>;
  78315. private _onMaterialLoadedObserver;
  78316. /**
  78317. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78318. */
  78319. set onMaterialLoaded(callback: (material: Material) => void);
  78320. /**
  78321. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78322. */
  78323. readonly onCameraLoadedObservable: Observable<Camera>;
  78324. private _onCameraLoadedObserver;
  78325. /**
  78326. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78327. */
  78328. set onCameraLoaded(callback: (camera: Camera) => void);
  78329. /**
  78330. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78331. * For assets with LODs, raised when all of the LODs are complete.
  78332. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78333. */
  78334. readonly onCompleteObservable: Observable<void>;
  78335. private _onCompleteObserver;
  78336. /**
  78337. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78338. * For assets with LODs, raised when all of the LODs are complete.
  78339. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78340. */
  78341. set onComplete(callback: () => void);
  78342. /**
  78343. * Observable raised when an error occurs.
  78344. */
  78345. readonly onErrorObservable: Observable<any>;
  78346. private _onErrorObserver;
  78347. /**
  78348. * Callback raised when an error occurs.
  78349. */
  78350. set onError(callback: (reason: any) => void);
  78351. /**
  78352. * Observable raised after the loader is disposed.
  78353. */
  78354. readonly onDisposeObservable: Observable<void>;
  78355. private _onDisposeObserver;
  78356. /**
  78357. * Callback raised after the loader is disposed.
  78358. */
  78359. set onDispose(callback: () => void);
  78360. /**
  78361. * Observable raised after a loader extension is created.
  78362. * Set additional options for a loader extension in this event.
  78363. */
  78364. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78365. private _onExtensionLoadedObserver;
  78366. /**
  78367. * Callback raised after a loader extension is created.
  78368. */
  78369. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78370. /**
  78371. * Defines if the loader logging is enabled.
  78372. */
  78373. get loggingEnabled(): boolean;
  78374. set loggingEnabled(value: boolean);
  78375. /**
  78376. * Defines if the loader should capture performance counters.
  78377. */
  78378. get capturePerformanceCounters(): boolean;
  78379. set capturePerformanceCounters(value: boolean);
  78380. /**
  78381. * Defines if the loader should validate the asset.
  78382. */
  78383. validate: boolean;
  78384. /**
  78385. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78386. */
  78387. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78388. private _onValidatedObserver;
  78389. /**
  78390. * Callback raised after a loader extension is created.
  78391. */
  78392. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78393. private _loader;
  78394. /**
  78395. * Name of the loader ("gltf")
  78396. */
  78397. name: string;
  78398. /** @hidden */
  78399. extensions: ISceneLoaderPluginExtensions;
  78400. /**
  78401. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78402. */
  78403. dispose(): void;
  78404. /** @hidden */
  78405. _clear(): void;
  78406. /** @hidden */
  78407. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78408. /** @hidden */
  78409. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78410. /** @hidden */
  78411. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78412. meshes: AbstractMesh[];
  78413. particleSystems: IParticleSystem[];
  78414. skeletons: Skeleton[];
  78415. animationGroups: AnimationGroup[];
  78416. }>;
  78417. /** @hidden */
  78418. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78419. /** @hidden */
  78420. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78421. /** @hidden */
  78422. canDirectLoad(data: string): boolean;
  78423. /** @hidden */
  78424. directLoad(scene: Scene, data: string): any;
  78425. /**
  78426. * The callback that allows custom handling of the root url based on the response url.
  78427. * @param rootUrl the original root url
  78428. * @param responseURL the response url if available
  78429. * @returns the new root url
  78430. */
  78431. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78432. /** @hidden */
  78433. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78434. /**
  78435. * The loader state or null if the loader is not active.
  78436. */
  78437. get loaderState(): Nullable<GLTFLoaderState>;
  78438. /**
  78439. * Returns a promise that resolves when the asset is completely loaded.
  78440. * @returns a promise that resolves when the asset is completely loaded.
  78441. */
  78442. whenCompleteAsync(): Promise<void>;
  78443. private _validate;
  78444. private _getLoader;
  78445. private _parseJson;
  78446. private _unpackBinaryAsync;
  78447. private _unpackBinaryV1Async;
  78448. private _unpackBinaryV2Async;
  78449. private static _parseVersion;
  78450. private static _compareVersion;
  78451. private static readonly _logSpaces;
  78452. private _logIndentLevel;
  78453. private _loggingEnabled;
  78454. /** @hidden */
  78455. _log: (message: string) => void;
  78456. /** @hidden */
  78457. _logOpen(message: string): void;
  78458. /** @hidden */
  78459. _logClose(): void;
  78460. private _logEnabled;
  78461. private _logDisabled;
  78462. private _capturePerformanceCounters;
  78463. /** @hidden */
  78464. _startPerformanceCounter: (counterName: string) => void;
  78465. /** @hidden */
  78466. _endPerformanceCounter: (counterName: string) => void;
  78467. private _startPerformanceCounterEnabled;
  78468. private _startPerformanceCounterDisabled;
  78469. private _endPerformanceCounterEnabled;
  78470. private _endPerformanceCounterDisabled;
  78471. }
  78472. }
  78473. declare module BABYLON.GLTF1 {
  78474. /**
  78475. * Enums
  78476. * @hidden
  78477. */
  78478. export enum EComponentType {
  78479. BYTE = 5120,
  78480. UNSIGNED_BYTE = 5121,
  78481. SHORT = 5122,
  78482. UNSIGNED_SHORT = 5123,
  78483. FLOAT = 5126
  78484. }
  78485. /** @hidden */
  78486. export enum EShaderType {
  78487. FRAGMENT = 35632,
  78488. VERTEX = 35633
  78489. }
  78490. /** @hidden */
  78491. export enum EParameterType {
  78492. BYTE = 5120,
  78493. UNSIGNED_BYTE = 5121,
  78494. SHORT = 5122,
  78495. UNSIGNED_SHORT = 5123,
  78496. INT = 5124,
  78497. UNSIGNED_INT = 5125,
  78498. FLOAT = 5126,
  78499. FLOAT_VEC2 = 35664,
  78500. FLOAT_VEC3 = 35665,
  78501. FLOAT_VEC4 = 35666,
  78502. INT_VEC2 = 35667,
  78503. INT_VEC3 = 35668,
  78504. INT_VEC4 = 35669,
  78505. BOOL = 35670,
  78506. BOOL_VEC2 = 35671,
  78507. BOOL_VEC3 = 35672,
  78508. BOOL_VEC4 = 35673,
  78509. FLOAT_MAT2 = 35674,
  78510. FLOAT_MAT3 = 35675,
  78511. FLOAT_MAT4 = 35676,
  78512. SAMPLER_2D = 35678
  78513. }
  78514. /** @hidden */
  78515. export enum ETextureWrapMode {
  78516. CLAMP_TO_EDGE = 33071,
  78517. MIRRORED_REPEAT = 33648,
  78518. REPEAT = 10497
  78519. }
  78520. /** @hidden */
  78521. export enum ETextureFilterType {
  78522. NEAREST = 9728,
  78523. LINEAR = 9728,
  78524. NEAREST_MIPMAP_NEAREST = 9984,
  78525. LINEAR_MIPMAP_NEAREST = 9985,
  78526. NEAREST_MIPMAP_LINEAR = 9986,
  78527. LINEAR_MIPMAP_LINEAR = 9987
  78528. }
  78529. /** @hidden */
  78530. export enum ETextureFormat {
  78531. ALPHA = 6406,
  78532. RGB = 6407,
  78533. RGBA = 6408,
  78534. LUMINANCE = 6409,
  78535. LUMINANCE_ALPHA = 6410
  78536. }
  78537. /** @hidden */
  78538. export enum ECullingType {
  78539. FRONT = 1028,
  78540. BACK = 1029,
  78541. FRONT_AND_BACK = 1032
  78542. }
  78543. /** @hidden */
  78544. export enum EBlendingFunction {
  78545. ZERO = 0,
  78546. ONE = 1,
  78547. SRC_COLOR = 768,
  78548. ONE_MINUS_SRC_COLOR = 769,
  78549. DST_COLOR = 774,
  78550. ONE_MINUS_DST_COLOR = 775,
  78551. SRC_ALPHA = 770,
  78552. ONE_MINUS_SRC_ALPHA = 771,
  78553. DST_ALPHA = 772,
  78554. ONE_MINUS_DST_ALPHA = 773,
  78555. CONSTANT_COLOR = 32769,
  78556. ONE_MINUS_CONSTANT_COLOR = 32770,
  78557. CONSTANT_ALPHA = 32771,
  78558. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78559. SRC_ALPHA_SATURATE = 776
  78560. }
  78561. /** @hidden */
  78562. export interface IGLTFProperty {
  78563. extensions?: {
  78564. [key: string]: any;
  78565. };
  78566. extras?: Object;
  78567. }
  78568. /** @hidden */
  78569. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78570. name?: string;
  78571. }
  78572. /** @hidden */
  78573. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78574. bufferView: string;
  78575. byteOffset: number;
  78576. byteStride: number;
  78577. count: number;
  78578. type: string;
  78579. componentType: EComponentType;
  78580. max?: number[];
  78581. min?: number[];
  78582. name?: string;
  78583. }
  78584. /** @hidden */
  78585. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78586. buffer: string;
  78587. byteOffset: number;
  78588. byteLength: number;
  78589. byteStride: number;
  78590. target?: number;
  78591. }
  78592. /** @hidden */
  78593. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78594. uri: string;
  78595. byteLength?: number;
  78596. type?: string;
  78597. }
  78598. /** @hidden */
  78599. export interface IGLTFShader extends IGLTFChildRootProperty {
  78600. uri: string;
  78601. type: EShaderType;
  78602. }
  78603. /** @hidden */
  78604. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78605. attributes: string[];
  78606. fragmentShader: string;
  78607. vertexShader: string;
  78608. }
  78609. /** @hidden */
  78610. export interface IGLTFTechniqueParameter {
  78611. type: number;
  78612. count?: number;
  78613. semantic?: string;
  78614. node?: string;
  78615. value?: number | boolean | string | Array<any>;
  78616. source?: string;
  78617. babylonValue?: any;
  78618. }
  78619. /** @hidden */
  78620. export interface IGLTFTechniqueCommonProfile {
  78621. lightingModel: string;
  78622. texcoordBindings: Object;
  78623. parameters?: Array<any>;
  78624. }
  78625. /** @hidden */
  78626. export interface IGLTFTechniqueStatesFunctions {
  78627. blendColor?: number[];
  78628. blendEquationSeparate?: number[];
  78629. blendFuncSeparate?: number[];
  78630. colorMask: boolean[];
  78631. cullFace: number[];
  78632. }
  78633. /** @hidden */
  78634. export interface IGLTFTechniqueStates {
  78635. enable: number[];
  78636. functions: IGLTFTechniqueStatesFunctions;
  78637. }
  78638. /** @hidden */
  78639. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78640. parameters: {
  78641. [key: string]: IGLTFTechniqueParameter;
  78642. };
  78643. program: string;
  78644. attributes: {
  78645. [key: string]: string;
  78646. };
  78647. uniforms: {
  78648. [key: string]: string;
  78649. };
  78650. states: IGLTFTechniqueStates;
  78651. }
  78652. /** @hidden */
  78653. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78654. technique?: string;
  78655. values: string[];
  78656. }
  78657. /** @hidden */
  78658. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78659. attributes: {
  78660. [key: string]: string;
  78661. };
  78662. indices: string;
  78663. material: string;
  78664. mode?: number;
  78665. }
  78666. /** @hidden */
  78667. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78668. primitives: IGLTFMeshPrimitive[];
  78669. }
  78670. /** @hidden */
  78671. export interface IGLTFImage extends IGLTFChildRootProperty {
  78672. uri: string;
  78673. }
  78674. /** @hidden */
  78675. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78676. magFilter?: number;
  78677. minFilter?: number;
  78678. wrapS?: number;
  78679. wrapT?: number;
  78680. }
  78681. /** @hidden */
  78682. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78683. sampler: string;
  78684. source: string;
  78685. format?: ETextureFormat;
  78686. internalFormat?: ETextureFormat;
  78687. target?: number;
  78688. type?: number;
  78689. babylonTexture?: Texture;
  78690. }
  78691. /** @hidden */
  78692. export interface IGLTFAmbienLight {
  78693. color?: number[];
  78694. }
  78695. /** @hidden */
  78696. export interface IGLTFDirectionalLight {
  78697. color?: number[];
  78698. }
  78699. /** @hidden */
  78700. export interface IGLTFPointLight {
  78701. color?: number[];
  78702. constantAttenuation?: number;
  78703. linearAttenuation?: number;
  78704. quadraticAttenuation?: number;
  78705. }
  78706. /** @hidden */
  78707. export interface IGLTFSpotLight {
  78708. color?: number[];
  78709. constantAttenuation?: number;
  78710. fallOfAngle?: number;
  78711. fallOffExponent?: number;
  78712. linearAttenuation?: number;
  78713. quadraticAttenuation?: number;
  78714. }
  78715. /** @hidden */
  78716. export interface IGLTFLight extends IGLTFChildRootProperty {
  78717. type: string;
  78718. }
  78719. /** @hidden */
  78720. export interface IGLTFCameraOrthographic {
  78721. xmag: number;
  78722. ymag: number;
  78723. zfar: number;
  78724. znear: number;
  78725. }
  78726. /** @hidden */
  78727. export interface IGLTFCameraPerspective {
  78728. aspectRatio: number;
  78729. yfov: number;
  78730. zfar: number;
  78731. znear: number;
  78732. }
  78733. /** @hidden */
  78734. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78735. type: string;
  78736. }
  78737. /** @hidden */
  78738. export interface IGLTFAnimationChannelTarget {
  78739. id: string;
  78740. path: string;
  78741. }
  78742. /** @hidden */
  78743. export interface IGLTFAnimationChannel {
  78744. sampler: string;
  78745. target: IGLTFAnimationChannelTarget;
  78746. }
  78747. /** @hidden */
  78748. export interface IGLTFAnimationSampler {
  78749. input: string;
  78750. output: string;
  78751. interpolation?: string;
  78752. }
  78753. /** @hidden */
  78754. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78755. channels?: IGLTFAnimationChannel[];
  78756. parameters?: {
  78757. [key: string]: string;
  78758. };
  78759. samplers?: {
  78760. [key: string]: IGLTFAnimationSampler;
  78761. };
  78762. }
  78763. /** @hidden */
  78764. export interface IGLTFNodeInstanceSkin {
  78765. skeletons: string[];
  78766. skin: string;
  78767. meshes: string[];
  78768. }
  78769. /** @hidden */
  78770. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78771. bindShapeMatrix: number[];
  78772. inverseBindMatrices: string;
  78773. jointNames: string[];
  78774. babylonSkeleton?: Skeleton;
  78775. }
  78776. /** @hidden */
  78777. export interface IGLTFNode extends IGLTFChildRootProperty {
  78778. camera?: string;
  78779. children: string[];
  78780. skin?: string;
  78781. jointName?: string;
  78782. light?: string;
  78783. matrix: number[];
  78784. mesh?: string;
  78785. meshes?: string[];
  78786. rotation?: number[];
  78787. scale?: number[];
  78788. translation?: number[];
  78789. babylonNode?: Node;
  78790. }
  78791. /** @hidden */
  78792. export interface IGLTFScene extends IGLTFChildRootProperty {
  78793. nodes: string[];
  78794. }
  78795. /** @hidden */
  78796. export interface IGLTFRuntime {
  78797. extensions: {
  78798. [key: string]: any;
  78799. };
  78800. accessors: {
  78801. [key: string]: IGLTFAccessor;
  78802. };
  78803. buffers: {
  78804. [key: string]: IGLTFBuffer;
  78805. };
  78806. bufferViews: {
  78807. [key: string]: IGLTFBufferView;
  78808. };
  78809. meshes: {
  78810. [key: string]: IGLTFMesh;
  78811. };
  78812. lights: {
  78813. [key: string]: IGLTFLight;
  78814. };
  78815. cameras: {
  78816. [key: string]: IGLTFCamera;
  78817. };
  78818. nodes: {
  78819. [key: string]: IGLTFNode;
  78820. };
  78821. images: {
  78822. [key: string]: IGLTFImage;
  78823. };
  78824. textures: {
  78825. [key: string]: IGLTFTexture;
  78826. };
  78827. shaders: {
  78828. [key: string]: IGLTFShader;
  78829. };
  78830. programs: {
  78831. [key: string]: IGLTFProgram;
  78832. };
  78833. samplers: {
  78834. [key: string]: IGLTFSampler;
  78835. };
  78836. techniques: {
  78837. [key: string]: IGLTFTechnique;
  78838. };
  78839. materials: {
  78840. [key: string]: IGLTFMaterial;
  78841. };
  78842. animations: {
  78843. [key: string]: IGLTFAnimation;
  78844. };
  78845. skins: {
  78846. [key: string]: IGLTFSkins;
  78847. };
  78848. currentScene?: Object;
  78849. scenes: {
  78850. [key: string]: IGLTFScene;
  78851. };
  78852. extensionsUsed: string[];
  78853. extensionsRequired?: string[];
  78854. buffersCount: number;
  78855. shaderscount: number;
  78856. scene: Scene;
  78857. rootUrl: string;
  78858. loadedBufferCount: number;
  78859. loadedBufferViews: {
  78860. [name: string]: ArrayBufferView;
  78861. };
  78862. loadedShaderCount: number;
  78863. importOnlyMeshes: boolean;
  78864. importMeshesNames?: string[];
  78865. dummyNodes: Node[];
  78866. forAssetContainer: boolean;
  78867. }
  78868. /** @hidden */
  78869. export interface INodeToRoot {
  78870. bone: Bone;
  78871. node: IGLTFNode;
  78872. id: string;
  78873. }
  78874. /** @hidden */
  78875. export interface IJointNode {
  78876. node: IGLTFNode;
  78877. id: string;
  78878. }
  78879. }
  78880. declare module BABYLON.GLTF1 {
  78881. /**
  78882. * Utils functions for GLTF
  78883. * @hidden
  78884. */
  78885. export class GLTFUtils {
  78886. /**
  78887. * Sets the given "parameter" matrix
  78888. * @param scene: the Scene object
  78889. * @param source: the source node where to pick the matrix
  78890. * @param parameter: the GLTF technique parameter
  78891. * @param uniformName: the name of the shader's uniform
  78892. * @param shaderMaterial: the shader material
  78893. */
  78894. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78895. /**
  78896. * Sets the given "parameter" matrix
  78897. * @param shaderMaterial: the shader material
  78898. * @param uniform: the name of the shader's uniform
  78899. * @param value: the value of the uniform
  78900. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78901. */
  78902. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78903. /**
  78904. * Returns the wrap mode of the texture
  78905. * @param mode: the mode value
  78906. */
  78907. static GetWrapMode(mode: number): number;
  78908. /**
  78909. * Returns the byte stride giving an accessor
  78910. * @param accessor: the GLTF accessor objet
  78911. */
  78912. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78913. /**
  78914. * Returns the texture filter mode giving a mode value
  78915. * @param mode: the filter mode value
  78916. */
  78917. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78918. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78919. /**
  78920. * Returns a buffer from its accessor
  78921. * @param gltfRuntime: the GLTF runtime
  78922. * @param accessor: the GLTF accessor
  78923. */
  78924. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78925. /**
  78926. * Decodes a buffer view into a string
  78927. * @param view: the buffer view
  78928. */
  78929. static DecodeBufferToText(view: ArrayBufferView): string;
  78930. /**
  78931. * Returns the default material of gltf. Related to
  78932. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78933. * @param scene: the Babylon.js scene
  78934. */
  78935. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78936. private static _DefaultMaterial;
  78937. }
  78938. }
  78939. declare module BABYLON.GLTF1 {
  78940. /**
  78941. * Implementation of the base glTF spec
  78942. * @hidden
  78943. */
  78944. export class GLTFLoaderBase {
  78945. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78946. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78947. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78948. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78949. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78950. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78951. }
  78952. /**
  78953. * glTF V1 Loader
  78954. * @hidden
  78955. */
  78956. export class GLTFLoader implements IGLTFLoader {
  78957. static Extensions: {
  78958. [name: string]: GLTFLoaderExtension;
  78959. };
  78960. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78961. state: Nullable<GLTFLoaderState>;
  78962. dispose(): void;
  78963. private _importMeshAsync;
  78964. /**
  78965. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78966. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78967. * @param scene the scene the meshes should be added to
  78968. * @param forAssetContainer defines if the entities must be stored in the scene
  78969. * @param data gltf data containing information of the meshes in a loaded file
  78970. * @param rootUrl root url to load from
  78971. * @param onProgress event that fires when loading progress has occured
  78972. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78973. */
  78974. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78975. private _loadAsync;
  78976. /**
  78977. * Imports all objects from a loaded gltf file and adds them to the scene
  78978. * @param scene the scene the objects should be added to
  78979. * @param data gltf data containing information of the meshes in a loaded file
  78980. * @param rootUrl root url to load from
  78981. * @param onProgress event that fires when loading progress has occured
  78982. * @returns a promise which completes when objects have been loaded to the scene
  78983. */
  78984. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78985. private _loadShadersAsync;
  78986. private _loadBuffersAsync;
  78987. private _createNodes;
  78988. }
  78989. /** @hidden */
  78990. export abstract class GLTFLoaderExtension {
  78991. private _name;
  78992. constructor(name: string);
  78993. get name(): string;
  78994. /**
  78995. * Defines an override for loading the runtime
  78996. * Return true to stop further extensions from loading the runtime
  78997. */
  78998. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78999. /**
  79000. * Defines an onverride for creating gltf runtime
  79001. * Return true to stop further extensions from creating the runtime
  79002. */
  79003. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79004. /**
  79005. * Defines an override for loading buffers
  79006. * Return true to stop further extensions from loading this buffer
  79007. */
  79008. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79009. /**
  79010. * Defines an override for loading texture buffers
  79011. * Return true to stop further extensions from loading this texture data
  79012. */
  79013. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79014. /**
  79015. * Defines an override for creating textures
  79016. * Return true to stop further extensions from loading this texture
  79017. */
  79018. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79019. /**
  79020. * Defines an override for loading shader strings
  79021. * Return true to stop further extensions from loading this shader data
  79022. */
  79023. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79024. /**
  79025. * Defines an override for loading materials
  79026. * Return true to stop further extensions from loading this material
  79027. */
  79028. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79029. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79030. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79031. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79032. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79033. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79034. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79035. private static LoadTextureBufferAsync;
  79036. private static CreateTextureAsync;
  79037. private static ApplyExtensions;
  79038. }
  79039. }
  79040. declare module BABYLON.GLTF1 {
  79041. /** @hidden */
  79042. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79043. private _bin;
  79044. constructor();
  79045. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79046. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79047. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79048. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79049. }
  79050. }
  79051. declare module BABYLON.GLTF1 {
  79052. /** @hidden */
  79053. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79054. constructor();
  79055. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79056. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79057. private _loadTexture;
  79058. }
  79059. }
  79060. declare module BABYLON.GLTF2.Loader {
  79061. /**
  79062. * Loader interface with an index field.
  79063. */
  79064. export interface IArrayItem {
  79065. /**
  79066. * The index of this item in the array.
  79067. */
  79068. index: number;
  79069. }
  79070. /**
  79071. * Loader interface with additional members.
  79072. */
  79073. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79074. /** @hidden */
  79075. _data?: Promise<ArrayBufferView>;
  79076. /** @hidden */
  79077. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79078. }
  79079. /**
  79080. * Loader interface with additional members.
  79081. */
  79082. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79083. }
  79084. /** @hidden */
  79085. export interface _IAnimationSamplerData {
  79086. input: Float32Array;
  79087. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79088. output: Float32Array;
  79089. }
  79090. /**
  79091. * Loader interface with additional members.
  79092. */
  79093. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79094. /** @hidden */
  79095. _data?: Promise<_IAnimationSamplerData>;
  79096. }
  79097. /**
  79098. * Loader interface with additional members.
  79099. */
  79100. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79101. channels: IAnimationChannel[];
  79102. samplers: IAnimationSampler[];
  79103. /** @hidden */
  79104. _babylonAnimationGroup?: AnimationGroup;
  79105. }
  79106. /**
  79107. * Loader interface with additional members.
  79108. */
  79109. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79110. /** @hidden */
  79111. _data?: Promise<ArrayBufferView>;
  79112. }
  79113. /**
  79114. * Loader interface with additional members.
  79115. */
  79116. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79117. /** @hidden */
  79118. _data?: Promise<ArrayBufferView>;
  79119. /** @hidden */
  79120. _babylonBuffer?: Promise<Buffer>;
  79121. }
  79122. /**
  79123. * Loader interface with additional members.
  79124. */
  79125. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79126. }
  79127. /**
  79128. * Loader interface with additional members.
  79129. */
  79130. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79131. /** @hidden */
  79132. _data?: Promise<ArrayBufferView>;
  79133. }
  79134. /**
  79135. * Loader interface with additional members.
  79136. */
  79137. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79138. }
  79139. /**
  79140. * Loader interface with additional members.
  79141. */
  79142. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79143. }
  79144. /**
  79145. * Loader interface with additional members.
  79146. */
  79147. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79148. baseColorTexture?: ITextureInfo;
  79149. metallicRoughnessTexture?: ITextureInfo;
  79150. }
  79151. /**
  79152. * Loader interface with additional members.
  79153. */
  79154. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79155. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79156. normalTexture?: IMaterialNormalTextureInfo;
  79157. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79158. emissiveTexture?: ITextureInfo;
  79159. /** @hidden */
  79160. _data?: {
  79161. [babylonDrawMode: number]: {
  79162. babylonMaterial: Material;
  79163. babylonMeshes: AbstractMesh[];
  79164. promise: Promise<void>;
  79165. };
  79166. };
  79167. }
  79168. /**
  79169. * Loader interface with additional members.
  79170. */
  79171. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79172. primitives: IMeshPrimitive[];
  79173. }
  79174. /**
  79175. * Loader interface with additional members.
  79176. */
  79177. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79178. /** @hidden */
  79179. _instanceData?: {
  79180. babylonSourceMesh: Mesh;
  79181. promise: Promise<any>;
  79182. };
  79183. }
  79184. /**
  79185. * Loader interface with additional members.
  79186. */
  79187. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79188. /**
  79189. * The parent glTF node.
  79190. */
  79191. parent?: INode;
  79192. /** @hidden */
  79193. _babylonTransformNode?: TransformNode;
  79194. /** @hidden */
  79195. _primitiveBabylonMeshes?: AbstractMesh[];
  79196. /** @hidden */
  79197. _babylonBones?: Bone[];
  79198. /** @hidden */
  79199. _numMorphTargets?: number;
  79200. }
  79201. /** @hidden */
  79202. export interface _ISamplerData {
  79203. noMipMaps: boolean;
  79204. samplingMode: number;
  79205. wrapU: number;
  79206. wrapV: number;
  79207. }
  79208. /**
  79209. * Loader interface with additional members.
  79210. */
  79211. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79212. /** @hidden */
  79213. _data?: _ISamplerData;
  79214. }
  79215. /**
  79216. * Loader interface with additional members.
  79217. */
  79218. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79219. }
  79220. /**
  79221. * Loader interface with additional members.
  79222. */
  79223. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79224. /** @hidden */
  79225. _data?: {
  79226. babylonSkeleton: Skeleton;
  79227. promise: Promise<void>;
  79228. };
  79229. }
  79230. /**
  79231. * Loader interface with additional members.
  79232. */
  79233. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79234. }
  79235. /**
  79236. * Loader interface with additional members.
  79237. */
  79238. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79239. }
  79240. /**
  79241. * Loader interface with additional members.
  79242. */
  79243. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79244. accessors?: IAccessor[];
  79245. animations?: IAnimation[];
  79246. buffers?: IBuffer[];
  79247. bufferViews?: IBufferView[];
  79248. cameras?: ICamera[];
  79249. images?: IImage[];
  79250. materials?: IMaterial[];
  79251. meshes?: IMesh[];
  79252. nodes?: INode[];
  79253. samplers?: ISampler[];
  79254. scenes?: IScene[];
  79255. skins?: ISkin[];
  79256. textures?: ITexture[];
  79257. }
  79258. }
  79259. declare module BABYLON.GLTF2 {
  79260. /**
  79261. * Interface for a glTF loader extension.
  79262. */
  79263. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79264. /**
  79265. * Called after the loader state changes to LOADING.
  79266. */
  79267. onLoading?(): void;
  79268. /**
  79269. * Called after the loader state changes to READY.
  79270. */
  79271. onReady?(): void;
  79272. /**
  79273. * Define this method to modify the default behavior when loading scenes.
  79274. * @param context The context when loading the asset
  79275. * @param scene The glTF scene property
  79276. * @returns A promise that resolves when the load is complete or null if not handled
  79277. */
  79278. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79279. /**
  79280. * Define this method to modify the default behavior when loading nodes.
  79281. * @param context The context when loading the asset
  79282. * @param node The glTF node property
  79283. * @param assign A function called synchronously after parsing the glTF properties
  79284. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79285. */
  79286. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79287. /**
  79288. * Define this method to modify the default behavior when loading cameras.
  79289. * @param context The context when loading the asset
  79290. * @param camera The glTF camera property
  79291. * @param assign A function called synchronously after parsing the glTF properties
  79292. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79293. */
  79294. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79295. /**
  79296. * @hidden
  79297. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79298. * @param context The context when loading the asset
  79299. * @param primitive The glTF mesh primitive property
  79300. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79301. */
  79302. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79303. /**
  79304. * @hidden
  79305. * Define this method to modify the default behavior when loading data for mesh primitives.
  79306. * @param context The context when loading the asset
  79307. * @param name The mesh name when loading the asset
  79308. * @param node The glTF node when loading the asset
  79309. * @param mesh The glTF mesh when loading the asset
  79310. * @param primitive The glTF mesh primitive property
  79311. * @param assign A function called synchronously after parsing the glTF properties
  79312. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79313. */
  79314. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79315. /**
  79316. * @hidden
  79317. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79318. * @param context The context when loading the asset
  79319. * @param material The glTF material property
  79320. * @param assign A function called synchronously after parsing the glTF properties
  79321. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79322. */
  79323. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79324. /**
  79325. * Define this method to modify the default behavior when creating materials.
  79326. * @param context The context when loading the asset
  79327. * @param material The glTF material property
  79328. * @param babylonDrawMode The draw mode for the Babylon material
  79329. * @returns The Babylon material or null if not handled
  79330. */
  79331. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79332. /**
  79333. * Define this method to modify the default behavior when loading material properties.
  79334. * @param context The context when loading the asset
  79335. * @param material The glTF material property
  79336. * @param babylonMaterial The Babylon material
  79337. * @returns A promise that resolves when the load is complete or null if not handled
  79338. */
  79339. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79340. /**
  79341. * Define this method to modify the default behavior when loading texture infos.
  79342. * @param context The context when loading the asset
  79343. * @param textureInfo The glTF texture info property
  79344. * @param assign A function called synchronously after parsing the glTF properties
  79345. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79346. */
  79347. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79348. /**
  79349. * @hidden
  79350. * Define this method to modify the default behavior when loading textures.
  79351. * @param context The context when loading the asset
  79352. * @param texture The glTF texture property
  79353. * @param assign A function called synchronously after parsing the glTF properties
  79354. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79355. */
  79356. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79357. /**
  79358. * Define this method to modify the default behavior when loading animations.
  79359. * @param context The context when loading the asset
  79360. * @param animation The glTF animation property
  79361. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79362. */
  79363. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79364. /**
  79365. * @hidden
  79366. * Define this method to modify the default behavior when loading skins.
  79367. * @param context The context when loading the asset
  79368. * @param node The glTF node property
  79369. * @param skin The glTF skin property
  79370. * @returns A promise that resolves when the load is complete or null if not handled
  79371. */
  79372. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79373. /**
  79374. * @hidden
  79375. * Define this method to modify the default behavior when loading uris.
  79376. * @param context The context when loading the asset
  79377. * @param property The glTF property associated with the uri
  79378. * @param uri The uri to load
  79379. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79380. */
  79381. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79382. /**
  79383. * Define this method to modify the default behavior when loading buffer views.
  79384. * @param context The context when loading the asset
  79385. * @param bufferView The glTF buffer view property
  79386. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79387. */
  79388. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79389. /**
  79390. * Define this method to modify the default behavior when loading buffers.
  79391. * @param context The context when loading the asset
  79392. * @param buffer The glTF buffer property
  79393. * @param byteOffset The byte offset to load
  79394. * @param byteLength The byte length to load
  79395. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79396. */
  79397. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79398. }
  79399. }
  79400. declare module BABYLON.GLTF2 {
  79401. /**
  79402. * Helper class for working with arrays when loading the glTF asset
  79403. */
  79404. export class ArrayItem {
  79405. /**
  79406. * Gets an item from the given array.
  79407. * @param context The context when loading the asset
  79408. * @param array The array to get the item from
  79409. * @param index The index to the array
  79410. * @returns The array item
  79411. */
  79412. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79413. /**
  79414. * Assign an `index` field to each item of the given array.
  79415. * @param array The array of items
  79416. */
  79417. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79418. }
  79419. /**
  79420. * The glTF 2.0 loader
  79421. */
  79422. export class GLTFLoader implements IGLTFLoader {
  79423. /** @hidden */
  79424. _completePromises: Promise<any>[];
  79425. /** @hidden */
  79426. _forAssetContainer: boolean;
  79427. /** Storage */
  79428. _babylonLights: Light[];
  79429. /** @hidden */
  79430. _disableInstancedMesh: number;
  79431. private _disposed;
  79432. private _parent;
  79433. private _state;
  79434. private _extensions;
  79435. private _rootUrl;
  79436. private _fileName;
  79437. private _uniqueRootUrl;
  79438. private _gltf;
  79439. private _bin;
  79440. private _babylonScene;
  79441. private _rootBabylonMesh;
  79442. private _defaultBabylonMaterialData;
  79443. private _progressCallback?;
  79444. private _requests;
  79445. private static _RegisteredExtensions;
  79446. /**
  79447. * The default glTF sampler.
  79448. */
  79449. static readonly DefaultSampler: ISampler;
  79450. /**
  79451. * Registers a loader extension.
  79452. * @param name The name of the loader extension.
  79453. * @param factory The factory function that creates the loader extension.
  79454. */
  79455. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79456. /**
  79457. * Unregisters a loader extension.
  79458. * @param name The name of the loader extension.
  79459. * @returns A boolean indicating whether the extension has been unregistered
  79460. */
  79461. static UnregisterExtension(name: string): boolean;
  79462. /**
  79463. * The loader state.
  79464. */
  79465. get state(): Nullable<GLTFLoaderState>;
  79466. /**
  79467. * The object that represents the glTF JSON.
  79468. */
  79469. get gltf(): IGLTF;
  79470. /**
  79471. * The BIN chunk of a binary glTF.
  79472. */
  79473. get bin(): Nullable<IDataBuffer>;
  79474. /**
  79475. * The parent file loader.
  79476. */
  79477. get parent(): GLTFFileLoader;
  79478. /**
  79479. * The Babylon scene when loading the asset.
  79480. */
  79481. get babylonScene(): Scene;
  79482. /**
  79483. * The root Babylon mesh when loading the asset.
  79484. */
  79485. get rootBabylonMesh(): Mesh;
  79486. /** @hidden */
  79487. constructor(parent: GLTFFileLoader);
  79488. /** @hidden */
  79489. dispose(): void;
  79490. /** @hidden */
  79491. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79492. /** @hidden */
  79493. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79494. private _loadAsync;
  79495. private _loadData;
  79496. private _setupData;
  79497. private _loadExtensions;
  79498. private _checkExtensions;
  79499. private _setState;
  79500. private _createRootNode;
  79501. /**
  79502. * Loads a glTF scene.
  79503. * @param context The context when loading the asset
  79504. * @param scene The glTF scene property
  79505. * @returns A promise that resolves when the load is complete
  79506. */
  79507. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79508. private _forEachPrimitive;
  79509. private _getMeshes;
  79510. private _getTransformNodes;
  79511. private _getSkeletons;
  79512. private _getAnimationGroups;
  79513. private _startAnimations;
  79514. /**
  79515. * Loads a glTF node.
  79516. * @param context The context when loading the asset
  79517. * @param node The glTF node property
  79518. * @param assign A function called synchronously after parsing the glTF properties
  79519. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79520. */
  79521. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79522. private _loadMeshAsync;
  79523. /**
  79524. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79525. * @param context The context when loading the asset
  79526. * @param name The mesh name when loading the asset
  79527. * @param node The glTF node when loading the asset
  79528. * @param mesh The glTF mesh when loading the asset
  79529. * @param primitive The glTF mesh primitive property
  79530. * @param assign A function called synchronously after parsing the glTF properties
  79531. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79532. */
  79533. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79534. private _loadVertexDataAsync;
  79535. private _createMorphTargets;
  79536. private _loadMorphTargetsAsync;
  79537. private _loadMorphTargetVertexDataAsync;
  79538. private static _LoadTransform;
  79539. private _loadSkinAsync;
  79540. private _loadBones;
  79541. private _loadBone;
  79542. private _loadSkinInverseBindMatricesDataAsync;
  79543. private _updateBoneMatrices;
  79544. private _getNodeMatrix;
  79545. /**
  79546. * Loads a glTF camera.
  79547. * @param context The context when loading the asset
  79548. * @param camera The glTF camera property
  79549. * @param assign A function called synchronously after parsing the glTF properties
  79550. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79551. */
  79552. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79553. private _loadAnimationsAsync;
  79554. /**
  79555. * Loads a glTF animation.
  79556. * @param context The context when loading the asset
  79557. * @param animation The glTF animation property
  79558. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79559. */
  79560. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79561. /**
  79562. * @hidden Loads a glTF animation channel.
  79563. * @param context The context when loading the asset
  79564. * @param animationContext The context of the animation when loading the asset
  79565. * @param animation The glTF animation property
  79566. * @param channel The glTF animation channel property
  79567. * @param babylonAnimationGroup The babylon animation group property
  79568. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79569. * @returns A void promise when the channel load is complete
  79570. */
  79571. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79572. private _loadAnimationSamplerAsync;
  79573. private _loadBufferAsync;
  79574. /**
  79575. * Loads a glTF buffer view.
  79576. * @param context The context when loading the asset
  79577. * @param bufferView The glTF buffer view property
  79578. * @returns A promise that resolves with the loaded data when the load is complete
  79579. */
  79580. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79581. private _loadAccessorAsync;
  79582. /** @hidden */
  79583. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79584. private _loadIndicesAccessorAsync;
  79585. private _loadVertexBufferViewAsync;
  79586. private _loadVertexAccessorAsync;
  79587. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79588. /** @hidden */
  79589. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79590. private _createDefaultMaterial;
  79591. /**
  79592. * Creates a Babylon material from a glTF material.
  79593. * @param context The context when loading the asset
  79594. * @param material The glTF material property
  79595. * @param babylonDrawMode The draw mode for the Babylon material
  79596. * @returns The Babylon material
  79597. */
  79598. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79599. /**
  79600. * Loads properties from a glTF material into a Babylon material.
  79601. * @param context The context when loading the asset
  79602. * @param material The glTF material property
  79603. * @param babylonMaterial The Babylon material
  79604. * @returns A promise that resolves when the load is complete
  79605. */
  79606. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79607. /**
  79608. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79609. * @param context The context when loading the asset
  79610. * @param material The glTF material property
  79611. * @param babylonMaterial The Babylon material
  79612. * @returns A promise that resolves when the load is complete
  79613. */
  79614. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79615. /**
  79616. * Loads the alpha properties from a glTF material into a Babylon material.
  79617. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79618. * @param context The context when loading the asset
  79619. * @param material The glTF material property
  79620. * @param babylonMaterial The Babylon material
  79621. */
  79622. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79623. /**
  79624. * Loads a glTF texture info.
  79625. * @param context The context when loading the asset
  79626. * @param textureInfo The glTF texture info property
  79627. * @param assign A function called synchronously after parsing the glTF properties
  79628. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79629. */
  79630. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79631. /** @hidden */
  79632. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79633. /** @hidden */
  79634. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79635. private _loadSampler;
  79636. /**
  79637. * Loads a glTF image.
  79638. * @param context The context when loading the asset
  79639. * @param image The glTF image property
  79640. * @returns A promise that resolves with the loaded data when the load is complete
  79641. */
  79642. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79643. /**
  79644. * Loads a glTF uri.
  79645. * @param context The context when loading the asset
  79646. * @param property The glTF property associated with the uri
  79647. * @param uri The base64 or relative uri
  79648. * @returns A promise that resolves with the loaded data when the load is complete
  79649. */
  79650. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79651. private _onProgress;
  79652. /**
  79653. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79654. * @param babylonObject the Babylon object with metadata
  79655. * @param pointer the JSON pointer
  79656. */
  79657. static AddPointerMetadata(babylonObject: {
  79658. metadata: any;
  79659. }, pointer: string): void;
  79660. private static _GetTextureWrapMode;
  79661. private static _GetTextureSamplingMode;
  79662. private static _GetTypedArrayConstructor;
  79663. private static _GetTypedArray;
  79664. private static _GetNumComponents;
  79665. private static _ValidateUri;
  79666. private static _GetDrawMode;
  79667. private _compileMaterialsAsync;
  79668. private _compileShadowGeneratorsAsync;
  79669. private _forEachExtensions;
  79670. private _applyExtensions;
  79671. private _extensionsOnLoading;
  79672. private _extensionsOnReady;
  79673. private _extensionsLoadSceneAsync;
  79674. private _extensionsLoadNodeAsync;
  79675. private _extensionsLoadCameraAsync;
  79676. private _extensionsLoadVertexDataAsync;
  79677. private _extensionsLoadMeshPrimitiveAsync;
  79678. private _extensionsLoadMaterialAsync;
  79679. private _extensionsCreateMaterial;
  79680. private _extensionsLoadMaterialPropertiesAsync;
  79681. private _extensionsLoadTextureInfoAsync;
  79682. private _extensionsLoadTextureAsync;
  79683. private _extensionsLoadAnimationAsync;
  79684. private _extensionsLoadSkinAsync;
  79685. private _extensionsLoadUriAsync;
  79686. private _extensionsLoadBufferViewAsync;
  79687. private _extensionsLoadBufferAsync;
  79688. /**
  79689. * Helper method called by a loader extension to load an glTF extension.
  79690. * @param context The context when loading the asset
  79691. * @param property The glTF property to load the extension from
  79692. * @param extensionName The name of the extension to load
  79693. * @param actionAsync The action to run
  79694. * @returns The promise returned by actionAsync or null if the extension does not exist
  79695. */
  79696. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79697. /**
  79698. * Helper method called by a loader extension to load a glTF extra.
  79699. * @param context The context when loading the asset
  79700. * @param property The glTF property to load the extra from
  79701. * @param extensionName The name of the extension to load
  79702. * @param actionAsync The action to run
  79703. * @returns The promise returned by actionAsync or null if the extra does not exist
  79704. */
  79705. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79706. /**
  79707. * Checks for presence of an extension.
  79708. * @param name The name of the extension to check
  79709. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79710. */
  79711. isExtensionUsed(name: string): boolean;
  79712. /**
  79713. * Increments the indentation level and logs a message.
  79714. * @param message The message to log
  79715. */
  79716. logOpen(message: string): void;
  79717. /**
  79718. * Decrements the indentation level.
  79719. */
  79720. logClose(): void;
  79721. /**
  79722. * Logs a message
  79723. * @param message The message to log
  79724. */
  79725. log(message: string): void;
  79726. /**
  79727. * Starts a performance counter.
  79728. * @param counterName The name of the performance counter
  79729. */
  79730. startPerformanceCounter(counterName: string): void;
  79731. /**
  79732. * Ends a performance counter.
  79733. * @param counterName The name of the performance counter
  79734. */
  79735. endPerformanceCounter(counterName: string): void;
  79736. }
  79737. }
  79738. declare module BABYLON.GLTF2.Loader.Extensions {
  79739. /**
  79740. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79741. */
  79742. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79743. /**
  79744. * The name of this extension.
  79745. */
  79746. readonly name: string;
  79747. /**
  79748. * Defines whether this extension is enabled.
  79749. */
  79750. enabled: boolean;
  79751. private _loader;
  79752. private _lights?;
  79753. /** @hidden */
  79754. constructor(loader: GLTFLoader);
  79755. /** @hidden */
  79756. dispose(): void;
  79757. /** @hidden */
  79758. onLoading(): void;
  79759. /** @hidden */
  79760. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79761. private _loadLightAsync;
  79762. }
  79763. }
  79764. declare module BABYLON.GLTF2.Loader.Extensions {
  79765. /**
  79766. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79767. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79768. * !!! Experimental Extension Subject to Changes !!!
  79769. */
  79770. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79771. /**
  79772. * The name of this extension.
  79773. */
  79774. readonly name: string;
  79775. /**
  79776. * Defines whether this extension is enabled.
  79777. */
  79778. enabled: boolean;
  79779. private _loader;
  79780. /** @hidden */
  79781. constructor(loader: GLTFLoader);
  79782. /** @hidden */
  79783. dispose(): void;
  79784. /** @hidden */
  79785. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79786. }
  79787. }
  79788. declare module BABYLON.GLTF2.Loader.Extensions {
  79789. /**
  79790. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79791. */
  79792. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79793. /**
  79794. * The name of this extension.
  79795. */
  79796. readonly name: string;
  79797. /**
  79798. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79799. */
  79800. dracoCompression?: DracoCompression;
  79801. /**
  79802. * Defines whether this extension is enabled.
  79803. */
  79804. enabled: boolean;
  79805. private _loader;
  79806. /** @hidden */
  79807. constructor(loader: GLTFLoader);
  79808. /** @hidden */
  79809. dispose(): void;
  79810. /** @hidden */
  79811. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79812. }
  79813. }
  79814. declare module BABYLON.GLTF2.Loader.Extensions {
  79815. /**
  79816. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79817. */
  79818. export class KHR_lights implements IGLTFLoaderExtension {
  79819. /**
  79820. * The name of this extension.
  79821. */
  79822. readonly name: string;
  79823. /**
  79824. * Defines whether this extension is enabled.
  79825. */
  79826. enabled: boolean;
  79827. private _loader;
  79828. private _lights?;
  79829. /** @hidden */
  79830. constructor(loader: GLTFLoader);
  79831. /** @hidden */
  79832. dispose(): void;
  79833. /** @hidden */
  79834. onLoading(): void;
  79835. /** @hidden */
  79836. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79837. }
  79838. }
  79839. declare module BABYLON.GLTF2.Loader.Extensions {
  79840. /**
  79841. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79842. */
  79843. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79844. /**
  79845. * The name of this extension.
  79846. */
  79847. readonly name: string;
  79848. /**
  79849. * Defines whether this extension is enabled.
  79850. */
  79851. enabled: boolean;
  79852. /**
  79853. * Defines a number that determines the order the extensions are applied.
  79854. */
  79855. order: number;
  79856. private _loader;
  79857. /** @hidden */
  79858. constructor(loader: GLTFLoader);
  79859. /** @hidden */
  79860. dispose(): void;
  79861. /** @hidden */
  79862. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79863. private _loadSpecularGlossinessPropertiesAsync;
  79864. }
  79865. }
  79866. declare module BABYLON.GLTF2.Loader.Extensions {
  79867. /**
  79868. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79869. */
  79870. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79871. /**
  79872. * The name of this extension.
  79873. */
  79874. readonly name: string;
  79875. /**
  79876. * Defines whether this extension is enabled.
  79877. */
  79878. enabled: boolean;
  79879. /**
  79880. * Defines a number that determines the order the extensions are applied.
  79881. */
  79882. order: number;
  79883. private _loader;
  79884. /** @hidden */
  79885. constructor(loader: GLTFLoader);
  79886. /** @hidden */
  79887. dispose(): void;
  79888. /** @hidden */
  79889. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79890. private _loadUnlitPropertiesAsync;
  79891. }
  79892. }
  79893. declare module BABYLON.GLTF2.Loader.Extensions {
  79894. /**
  79895. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79896. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79897. * !!! Experimental Extension Subject to Changes !!!
  79898. */
  79899. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79900. /**
  79901. * The name of this extension.
  79902. */
  79903. readonly name: string;
  79904. /**
  79905. * Defines whether this extension is enabled.
  79906. */
  79907. enabled: boolean;
  79908. /**
  79909. * Defines a number that determines the order the extensions are applied.
  79910. */
  79911. order: number;
  79912. private _loader;
  79913. /** @hidden */
  79914. constructor(loader: GLTFLoader);
  79915. /** @hidden */
  79916. dispose(): void;
  79917. /** @hidden */
  79918. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79919. private _loadClearCoatPropertiesAsync;
  79920. }
  79921. }
  79922. declare module BABYLON.GLTF2.Loader.Extensions {
  79923. /**
  79924. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79925. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79926. * !!! Experimental Extension Subject to Changes !!!
  79927. */
  79928. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79929. /**
  79930. * The name of this extension.
  79931. */
  79932. readonly name: string;
  79933. /**
  79934. * Defines whether this extension is enabled.
  79935. */
  79936. enabled: boolean;
  79937. /**
  79938. * Defines a number that determines the order the extensions are applied.
  79939. */
  79940. order: number;
  79941. private _loader;
  79942. /** @hidden */
  79943. constructor(loader: GLTFLoader);
  79944. /** @hidden */
  79945. dispose(): void;
  79946. /** @hidden */
  79947. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79948. private _loadSheenPropertiesAsync;
  79949. }
  79950. }
  79951. declare module BABYLON.GLTF2.Loader.Extensions {
  79952. /**
  79953. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79954. * !!! Experimental Extension Subject to Changes !!!
  79955. */
  79956. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79957. /**
  79958. * The name of this extension.
  79959. */
  79960. readonly name: string;
  79961. /**
  79962. * Defines whether this extension is enabled.
  79963. */
  79964. enabled: boolean;
  79965. /**
  79966. * Defines a number that determines the order the extensions are applied.
  79967. */
  79968. order: number;
  79969. private _loader;
  79970. /** @hidden */
  79971. constructor(loader: GLTFLoader);
  79972. /** @hidden */
  79973. dispose(): void;
  79974. /** @hidden */
  79975. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79976. private _loadSpecularPropertiesAsync;
  79977. }
  79978. }
  79979. declare module BABYLON.GLTF2.Loader.Extensions {
  79980. /**
  79981. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79982. * !!! Experimental Extension Subject to Changes !!!
  79983. */
  79984. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79985. /**
  79986. * Default ior Value from the spec.
  79987. */
  79988. private static readonly _DEFAULT_IOR;
  79989. /**
  79990. * The name of this extension.
  79991. */
  79992. readonly name: string;
  79993. /**
  79994. * Defines whether this extension is enabled.
  79995. */
  79996. enabled: boolean;
  79997. /**
  79998. * Defines a number that determines the order the extensions are applied.
  79999. */
  80000. order: number;
  80001. private _loader;
  80002. /** @hidden */
  80003. constructor(loader: GLTFLoader);
  80004. /** @hidden */
  80005. dispose(): void;
  80006. /** @hidden */
  80007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80008. private _loadIorPropertiesAsync;
  80009. }
  80010. }
  80011. declare module BABYLON.GLTF2.Loader.Extensions {
  80012. /**
  80013. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80014. * !!! Experimental Extension Subject to Changes !!!
  80015. */
  80016. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80017. /**
  80018. * The name of this extension.
  80019. */
  80020. readonly name: string;
  80021. /**
  80022. * Defines whether this extension is enabled.
  80023. */
  80024. enabled: boolean;
  80025. private _loader;
  80026. /**
  80027. * The default variant name.
  80028. */
  80029. defaultVariant: string | undefined;
  80030. private _tagsToMap;
  80031. /** @hidden */
  80032. constructor(loader: GLTFLoader);
  80033. /** @hidden */
  80034. dispose(): void;
  80035. /**
  80036. * Return a list of available variants for this asset.
  80037. * @returns {string[]}
  80038. */
  80039. getVariants(): string[];
  80040. /**
  80041. * Select a variant by providing a list of variant tag names.
  80042. *
  80043. * @param {(string | string[])} variantName
  80044. */
  80045. selectVariant(variantName: string | string[]): void;
  80046. /**
  80047. * Select a variant by providing a single variant tag.
  80048. *
  80049. * @param {string} variantName
  80050. */
  80051. selectVariantTag(variantName: string): void;
  80052. /** @hidden */
  80053. onLoading(): void;
  80054. /** @hidden */
  80055. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80056. }
  80057. }
  80058. declare module BABYLON.GLTF2.Loader.Extensions {
  80059. /**
  80060. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80061. * !!! Experimental Extension Subject to Changes !!!
  80062. */
  80063. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80064. /**
  80065. * The name of this extension.
  80066. */
  80067. readonly name: string;
  80068. /**
  80069. * Defines whether this extension is enabled.
  80070. */
  80071. enabled: boolean;
  80072. /**
  80073. * Defines a number that determines the order the extensions are applied.
  80074. */
  80075. order: number;
  80076. private _loader;
  80077. /** @hidden */
  80078. constructor(loader: GLTFLoader);
  80079. /** @hidden */
  80080. dispose(): void;
  80081. /** @hidden */
  80082. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80083. private _loadTransparentPropertiesAsync;
  80084. }
  80085. }
  80086. declare module BABYLON.GLTF2.Loader.Extensions {
  80087. /**
  80088. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80089. */
  80090. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80091. /**
  80092. * The name of this extension.
  80093. */
  80094. readonly name: string;
  80095. /**
  80096. * Defines whether this extension is enabled.
  80097. */
  80098. enabled: boolean;
  80099. /** @hidden */
  80100. constructor(loader: GLTFLoader);
  80101. /** @hidden */
  80102. dispose(): void;
  80103. }
  80104. }
  80105. declare module BABYLON.GLTF2.Loader.Extensions {
  80106. /**
  80107. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80108. * !!! Experimental Extension Subject to Changes !!!
  80109. */
  80110. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80111. /** The name of this extension. */
  80112. readonly name: string;
  80113. /** Defines whether this extension is enabled. */
  80114. enabled: boolean;
  80115. private _loader;
  80116. /** @hidden */
  80117. constructor(loader: GLTFLoader);
  80118. /** @hidden */
  80119. dispose(): void;
  80120. /** @hidden */
  80121. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80122. }
  80123. }
  80124. declare module BABYLON.GLTF2.Loader.Extensions {
  80125. /**
  80126. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80127. */
  80128. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80129. /**
  80130. * The name of this extension.
  80131. */
  80132. readonly name: string;
  80133. /**
  80134. * Defines whether this extension is enabled.
  80135. */
  80136. enabled: boolean;
  80137. private _loader;
  80138. /** @hidden */
  80139. constructor(loader: GLTFLoader);
  80140. /** @hidden */
  80141. dispose(): void;
  80142. /** @hidden */
  80143. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80144. }
  80145. }
  80146. declare module BABYLON.GLTF2.Loader.Extensions {
  80147. /**
  80148. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80149. * !!! Experimental Extension Subject to Changes !!!
  80150. */
  80151. export class KHR_xmp implements IGLTFLoaderExtension {
  80152. /**
  80153. * The name of this extension.
  80154. */
  80155. readonly name: string;
  80156. /**
  80157. * Defines whether this extension is enabled.
  80158. */
  80159. enabled: boolean;
  80160. /**
  80161. * Defines a number that determines the order the extensions are applied.
  80162. */
  80163. order: number;
  80164. private _loader;
  80165. /** @hidden */
  80166. constructor(loader: GLTFLoader);
  80167. /** @hidden */
  80168. dispose(): void;
  80169. /**
  80170. * Called after the loader state changes to LOADING.
  80171. */
  80172. onLoading(): void;
  80173. }
  80174. }
  80175. declare module BABYLON.GLTF2.Loader.Extensions {
  80176. /**
  80177. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80178. */
  80179. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80180. /**
  80181. * The name of this extension.
  80182. */
  80183. readonly name: string;
  80184. /**
  80185. * Defines whether this extension is enabled.
  80186. */
  80187. enabled: boolean;
  80188. private _loader;
  80189. private _clips;
  80190. private _emitters;
  80191. /** @hidden */
  80192. constructor(loader: GLTFLoader);
  80193. /** @hidden */
  80194. dispose(): void;
  80195. /** @hidden */
  80196. onLoading(): void;
  80197. /** @hidden */
  80198. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80199. /** @hidden */
  80200. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80201. /** @hidden */
  80202. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80203. private _loadClipAsync;
  80204. private _loadEmitterAsync;
  80205. private _getEventAction;
  80206. private _loadAnimationEventAsync;
  80207. }
  80208. }
  80209. declare module BABYLON.GLTF2.Loader.Extensions {
  80210. /**
  80211. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80212. */
  80213. export class MSFT_lod implements IGLTFLoaderExtension {
  80214. /**
  80215. * The name of this extension.
  80216. */
  80217. readonly name: string;
  80218. /**
  80219. * Defines whether this extension is enabled.
  80220. */
  80221. enabled: boolean;
  80222. /**
  80223. * Defines a number that determines the order the extensions are applied.
  80224. */
  80225. order: number;
  80226. /**
  80227. * Maximum number of LODs to load, starting from the lowest LOD.
  80228. */
  80229. maxLODsToLoad: number;
  80230. /**
  80231. * Observable raised when all node LODs of one level are loaded.
  80232. * The event data is the index of the loaded LOD starting from zero.
  80233. * Dispose the loader to cancel the loading of the next level of LODs.
  80234. */
  80235. onNodeLODsLoadedObservable: Observable<number>;
  80236. /**
  80237. * Observable raised when all material LODs of one level are loaded.
  80238. * The event data is the index of the loaded LOD starting from zero.
  80239. * Dispose the loader to cancel the loading of the next level of LODs.
  80240. */
  80241. onMaterialLODsLoadedObservable: Observable<number>;
  80242. private _loader;
  80243. private _nodeIndexLOD;
  80244. private _nodeSignalLODs;
  80245. private _nodePromiseLODs;
  80246. private _materialIndexLOD;
  80247. private _materialSignalLODs;
  80248. private _materialPromiseLODs;
  80249. private _indexLOD;
  80250. private _bufferLODs;
  80251. /** @hidden */
  80252. constructor(loader: GLTFLoader);
  80253. /** @hidden */
  80254. dispose(): void;
  80255. /** @hidden */
  80256. onReady(): void;
  80257. /** @hidden */
  80258. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80259. /** @hidden */
  80260. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80261. /** @hidden */
  80262. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80263. /** @hidden */
  80264. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80265. /** @hidden */
  80266. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80267. private _loadBufferLOD;
  80268. /**
  80269. * Gets an array of LOD properties from lowest to highest.
  80270. */
  80271. private _getLODs;
  80272. private _disposeTransformNode;
  80273. private _disposeMaterials;
  80274. }
  80275. }
  80276. declare module BABYLON.GLTF2.Loader.Extensions {
  80277. /** @hidden */
  80278. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80279. readonly name: string;
  80280. enabled: boolean;
  80281. private _loader;
  80282. constructor(loader: GLTFLoader);
  80283. dispose(): void;
  80284. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80285. }
  80286. }
  80287. declare module BABYLON.GLTF2.Loader.Extensions {
  80288. /** @hidden */
  80289. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80290. readonly name: string;
  80291. enabled: boolean;
  80292. private _loader;
  80293. constructor(loader: GLTFLoader);
  80294. dispose(): void;
  80295. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80296. }
  80297. }
  80298. declare module BABYLON.GLTF2.Loader.Extensions {
  80299. /**
  80300. * Store glTF extras (if present) in BJS objects' metadata
  80301. */
  80302. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80303. /**
  80304. * The name of this extension.
  80305. */
  80306. readonly name: string;
  80307. /**
  80308. * Defines whether this extension is enabled.
  80309. */
  80310. enabled: boolean;
  80311. private _loader;
  80312. private _assignExtras;
  80313. /** @hidden */
  80314. constructor(loader: GLTFLoader);
  80315. /** @hidden */
  80316. dispose(): void;
  80317. /** @hidden */
  80318. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80319. /** @hidden */
  80320. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80321. /** @hidden */
  80322. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80323. }
  80324. }
  80325. declare module BABYLON {
  80326. /**
  80327. * Class reading and parsing the MTL file bundled with the obj file.
  80328. */
  80329. export class MTLFileLoader {
  80330. /**
  80331. * Invert Y-Axis of referenced textures on load
  80332. */
  80333. static INVERT_TEXTURE_Y: boolean;
  80334. /**
  80335. * All material loaded from the mtl will be set here
  80336. */
  80337. materials: StandardMaterial[];
  80338. /**
  80339. * This function will read the mtl file and create each material described inside
  80340. * This function could be improve by adding :
  80341. * -some component missing (Ni, Tf...)
  80342. * -including the specific options available
  80343. *
  80344. * @param scene defines the scene the material will be created in
  80345. * @param data defines the mtl data to parse
  80346. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80347. * @param forAssetContainer defines if the material should be registered in the scene
  80348. */
  80349. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80350. /**
  80351. * Gets the texture for the material.
  80352. *
  80353. * If the material is imported from input file,
  80354. * We sanitize the url to ensure it takes the textre from aside the material.
  80355. *
  80356. * @param rootUrl The root url to load from
  80357. * @param value The value stored in the mtl
  80358. * @return The Texture
  80359. */
  80360. private static _getTexture;
  80361. }
  80362. }
  80363. declare module BABYLON {
  80364. /**
  80365. * Options for loading OBJ/MTL files
  80366. */
  80367. type MeshLoadOptions = {
  80368. /**
  80369. * Defines if UVs are optimized by default during load.
  80370. */
  80371. OptimizeWithUV: boolean;
  80372. /**
  80373. * Defines custom scaling of UV coordinates of loaded meshes.
  80374. */
  80375. UVScaling: Vector2;
  80376. /**
  80377. * Invert model on y-axis (does a model scaling inversion)
  80378. */
  80379. InvertY: boolean;
  80380. /**
  80381. * Invert Y-Axis of referenced textures on load
  80382. */
  80383. InvertTextureY: boolean;
  80384. /**
  80385. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80386. */
  80387. ImportVertexColors: boolean;
  80388. /**
  80389. * Compute the normals for the model, even if normals are present in the file.
  80390. */
  80391. ComputeNormals: boolean;
  80392. /**
  80393. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80394. */
  80395. SkipMaterials: boolean;
  80396. /**
  80397. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80398. */
  80399. MaterialLoadingFailsSilently: boolean;
  80400. };
  80401. /**
  80402. * OBJ file type loader.
  80403. * This is a babylon scene loader plugin.
  80404. */
  80405. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80406. /**
  80407. * Defines if UVs are optimized by default during load.
  80408. */
  80409. static OPTIMIZE_WITH_UV: boolean;
  80410. /**
  80411. * Invert model on y-axis (does a model scaling inversion)
  80412. */
  80413. static INVERT_Y: boolean;
  80414. /**
  80415. * Invert Y-Axis of referenced textures on load
  80416. */
  80417. static get INVERT_TEXTURE_Y(): boolean;
  80418. static set INVERT_TEXTURE_Y(value: boolean);
  80419. /**
  80420. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80421. */
  80422. static IMPORT_VERTEX_COLORS: boolean;
  80423. /**
  80424. * Compute the normals for the model, even if normals are present in the file.
  80425. */
  80426. static COMPUTE_NORMALS: boolean;
  80427. /**
  80428. * Defines custom scaling of UV coordinates of loaded meshes.
  80429. */
  80430. static UV_SCALING: Vector2;
  80431. /**
  80432. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80433. */
  80434. static SKIP_MATERIALS: boolean;
  80435. /**
  80436. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80437. *
  80438. * Defaults to true for backwards compatibility.
  80439. */
  80440. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80441. /**
  80442. * Defines the name of the plugin.
  80443. */
  80444. name: string;
  80445. /**
  80446. * Defines the extension the plugin is able to load.
  80447. */
  80448. extensions: string;
  80449. /** @hidden */
  80450. obj: RegExp;
  80451. /** @hidden */
  80452. group: RegExp;
  80453. /** @hidden */
  80454. mtllib: RegExp;
  80455. /** @hidden */
  80456. usemtl: RegExp;
  80457. /** @hidden */
  80458. smooth: RegExp;
  80459. /** @hidden */
  80460. vertexPattern: RegExp;
  80461. /** @hidden */
  80462. normalPattern: RegExp;
  80463. /** @hidden */
  80464. uvPattern: RegExp;
  80465. /** @hidden */
  80466. facePattern1: RegExp;
  80467. /** @hidden */
  80468. facePattern2: RegExp;
  80469. /** @hidden */
  80470. facePattern3: RegExp;
  80471. /** @hidden */
  80472. facePattern4: RegExp;
  80473. /** @hidden */
  80474. facePattern5: RegExp;
  80475. private _forAssetContainer;
  80476. private _meshLoadOptions;
  80477. /**
  80478. * Creates loader for .OBJ files
  80479. *
  80480. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80481. */
  80482. constructor(meshLoadOptions?: MeshLoadOptions);
  80483. private static get currentMeshLoadOptions();
  80484. /**
  80485. * Calls synchronously the MTL file attached to this obj.
  80486. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80487. * Without this function materials are not displayed in the first frame (but displayed after).
  80488. * In consequence it is impossible to get material information in your HTML file
  80489. *
  80490. * @param url The URL of the MTL file
  80491. * @param rootUrl
  80492. * @param onSuccess Callback function to be called when the MTL file is loaded
  80493. * @private
  80494. */
  80495. private _loadMTL;
  80496. /**
  80497. * Instantiates a OBJ file loader plugin.
  80498. * @returns the created plugin
  80499. */
  80500. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80501. /**
  80502. * If the data string can be loaded directly.
  80503. *
  80504. * @param data string containing the file data
  80505. * @returns if the data can be loaded directly
  80506. */
  80507. canDirectLoad(data: string): boolean;
  80508. /**
  80509. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80510. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80511. * @param scene the scene the meshes should be added to
  80512. * @param data the OBJ data to load
  80513. * @param rootUrl root url to load from
  80514. * @param onProgress event that fires when loading progress has occured
  80515. * @param fileName Defines the name of the file to load
  80516. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80517. */
  80518. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80519. meshes: AbstractMesh[];
  80520. particleSystems: IParticleSystem[];
  80521. skeletons: Skeleton[];
  80522. animationGroups: AnimationGroup[];
  80523. }>;
  80524. /**
  80525. * Imports all objects from the loaded OBJ data and adds them to the scene
  80526. * @param scene the scene the objects should be added to
  80527. * @param data the OBJ data to load
  80528. * @param rootUrl root url to load from
  80529. * @param onProgress event that fires when loading progress has occured
  80530. * @param fileName Defines the name of the file to load
  80531. * @returns a promise which completes when objects have been loaded to the scene
  80532. */
  80533. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80534. /**
  80535. * Load into an asset container.
  80536. * @param scene The scene to load into
  80537. * @param data The data to import
  80538. * @param rootUrl The root url for scene and resources
  80539. * @param onProgress The callback when the load progresses
  80540. * @param fileName Defines the name of the file to load
  80541. * @returns The loaded asset container
  80542. */
  80543. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80544. /**
  80545. * Read the OBJ file and create an Array of meshes.
  80546. * Each mesh contains all information given by the OBJ and the MTL file.
  80547. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80548. *
  80549. * @param meshesNames
  80550. * @param scene Scene The scene where are displayed the data
  80551. * @param data String The content of the obj file
  80552. * @param rootUrl String The path to the folder
  80553. * @returns Array<AbstractMesh>
  80554. * @private
  80555. */
  80556. private _parseSolid;
  80557. }
  80558. }
  80559. declare module BABYLON {
  80560. /**
  80561. * STL file type loader.
  80562. * This is a babylon scene loader plugin.
  80563. */
  80564. export class STLFileLoader implements ISceneLoaderPlugin {
  80565. /** @hidden */
  80566. solidPattern: RegExp;
  80567. /** @hidden */
  80568. facetsPattern: RegExp;
  80569. /** @hidden */
  80570. normalPattern: RegExp;
  80571. /** @hidden */
  80572. vertexPattern: RegExp;
  80573. /**
  80574. * Defines the name of the plugin.
  80575. */
  80576. name: string;
  80577. /**
  80578. * Defines the extensions the stl loader is able to load.
  80579. * force data to come in as an ArrayBuffer
  80580. * we'll convert to string if it looks like it's an ASCII .stl
  80581. */
  80582. extensions: ISceneLoaderPluginExtensions;
  80583. /**
  80584. * Import meshes into a scene.
  80585. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80586. * @param scene The scene to import into
  80587. * @param data The data to import
  80588. * @param rootUrl The root url for scene and resources
  80589. * @param meshes The meshes array to import into
  80590. * @param particleSystems The particle systems array to import into
  80591. * @param skeletons The skeletons array to import into
  80592. * @param onError The callback when import fails
  80593. * @returns True if successful or false otherwise
  80594. */
  80595. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80596. /**
  80597. * Load into a scene.
  80598. * @param scene The scene to load into
  80599. * @param data The data to import
  80600. * @param rootUrl The root url for scene and resources
  80601. * @param onError The callback when import fails
  80602. * @returns true if successful or false otherwise
  80603. */
  80604. load(scene: Scene, data: any, rootUrl: string): boolean;
  80605. /**
  80606. * Load into an asset container.
  80607. * @param scene The scene to load into
  80608. * @param data The data to import
  80609. * @param rootUrl The root url for scene and resources
  80610. * @param onError The callback when import fails
  80611. * @returns The loaded asset container
  80612. */
  80613. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80614. private _isBinary;
  80615. private _parseBinary;
  80616. private _parseASCII;
  80617. }
  80618. }
  80619. declare module BABYLON {
  80620. /**
  80621. * Class for generating OBJ data from a Babylon scene.
  80622. */
  80623. export class OBJExport {
  80624. /**
  80625. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80626. * @param mesh defines the list of meshes to serialize
  80627. * @param materials defines if materials should be exported
  80628. * @param matlibname defines the name of the associated mtl file
  80629. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80630. * @returns the OBJ content
  80631. */
  80632. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80633. /**
  80634. * Exports the material(s) of a mesh in .MTL file format (text)
  80635. * @param mesh defines the mesh to extract the material from
  80636. * @returns the mtl content
  80637. */
  80638. static MTL(mesh: Mesh): string;
  80639. }
  80640. }
  80641. declare module BABYLON {
  80642. /** @hidden */
  80643. export var __IGLTFExporterExtension: number;
  80644. /**
  80645. * Interface for extending the exporter
  80646. * @hidden
  80647. */
  80648. export interface IGLTFExporterExtension {
  80649. /**
  80650. * The name of this extension
  80651. */
  80652. readonly name: string;
  80653. /**
  80654. * Defines whether this extension is enabled
  80655. */
  80656. enabled: boolean;
  80657. /**
  80658. * Defines whether this extension is required
  80659. */
  80660. required: boolean;
  80661. }
  80662. }
  80663. declare module BABYLON.GLTF2.Exporter {
  80664. /** @hidden */
  80665. export var __IGLTFExporterExtensionV2: number;
  80666. /**
  80667. * Interface for a glTF exporter extension
  80668. * @hidden
  80669. */
  80670. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80671. /**
  80672. * Define this method to modify the default behavior before exporting a texture
  80673. * @param context The context when loading the asset
  80674. * @param babylonTexture The Babylon.js texture
  80675. * @param mimeType The mime-type of the generated image
  80676. * @returns A promise that resolves with the exported texture
  80677. */
  80678. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80679. /**
  80680. * Define this method to get notified when a texture info is created
  80681. * @param context The context when loading the asset
  80682. * @param textureInfo The glTF texture info
  80683. * @param babylonTexture The Babylon.js texture
  80684. */
  80685. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80686. /**
  80687. * Define this method to modify the default behavior when exporting texture info
  80688. * @param context The context when loading the asset
  80689. * @param meshPrimitive glTF mesh primitive
  80690. * @param babylonSubMesh Babylon submesh
  80691. * @param binaryWriter glTF serializer binary writer instance
  80692. * @returns nullable IMeshPrimitive promise
  80693. */
  80694. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80695. /**
  80696. * Define this method to modify the default behavior when exporting a node
  80697. * @param context The context when exporting the node
  80698. * @param node glTF node
  80699. * @param babylonNode BabylonJS node
  80700. * @returns nullable INode promise
  80701. */
  80702. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80703. [key: number]: number;
  80704. }): Promise<Nullable<INode>>;
  80705. /**
  80706. * Define this method to modify the default behavior when exporting a material
  80707. * @param material glTF material
  80708. * @param babylonMaterial BabylonJS material
  80709. * @returns nullable IMaterial promise
  80710. */
  80711. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80712. /**
  80713. * Define this method to return additional textures to export from a material
  80714. * @param material glTF material
  80715. * @param babylonMaterial BabylonJS material
  80716. * @returns List of textures
  80717. */
  80718. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80719. /** Gets a boolean indicating that this extension was used */
  80720. wasUsed: boolean;
  80721. /** Gets a boolean indicating that this extension is required for the file to work */
  80722. required: boolean;
  80723. /**
  80724. * Called after the exporter state changes to EXPORTING
  80725. */
  80726. onExporting?(): void;
  80727. }
  80728. }
  80729. declare module BABYLON.GLTF2.Exporter {
  80730. /**
  80731. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80732. * @hidden
  80733. */
  80734. export class _GLTFMaterialExporter {
  80735. /**
  80736. * Represents the dielectric specular values for R, G and B
  80737. */
  80738. private static readonly _DielectricSpecular;
  80739. /**
  80740. * Allows the maximum specular power to be defined for material calculations
  80741. */
  80742. private static readonly _MaxSpecularPower;
  80743. /**
  80744. * Mapping to store textures
  80745. */
  80746. private _textureMap;
  80747. /**
  80748. * Numeric tolerance value
  80749. */
  80750. private static readonly _Epsilon;
  80751. /**
  80752. * Reference to the glTF Exporter
  80753. */
  80754. private _exporter;
  80755. constructor(exporter: _Exporter);
  80756. /**
  80757. * Specifies if two colors are approximately equal in value
  80758. * @param color1 first color to compare to
  80759. * @param color2 second color to compare to
  80760. * @param epsilon threshold value
  80761. */
  80762. private static FuzzyEquals;
  80763. /**
  80764. * Gets the materials from a Babylon scene and converts them to glTF materials
  80765. * @param scene babylonjs scene
  80766. * @param mimeType texture mime type
  80767. * @param images array of images
  80768. * @param textures array of textures
  80769. * @param materials array of materials
  80770. * @param imageData mapping of texture names to base64 textures
  80771. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80772. */
  80773. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80774. /**
  80775. * Makes a copy of the glTF material without the texture parameters
  80776. * @param originalMaterial original glTF material
  80777. * @returns glTF material without texture parameters
  80778. */
  80779. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80780. /**
  80781. * Specifies if the material has any texture parameters present
  80782. * @param material glTF Material
  80783. * @returns boolean specifying if texture parameters are present
  80784. */
  80785. _hasTexturesPresent(material: IMaterial): boolean;
  80786. /**
  80787. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80788. * @param babylonStandardMaterial
  80789. * @returns glTF Metallic Roughness Material representation
  80790. */
  80791. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80792. /**
  80793. * Computes the metallic factor
  80794. * @param diffuse diffused value
  80795. * @param specular specular value
  80796. * @param oneMinusSpecularStrength one minus the specular strength
  80797. * @returns metallic value
  80798. */
  80799. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80800. /**
  80801. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80802. * @param glTFMaterial glTF material
  80803. * @param babylonMaterial Babylon material
  80804. */
  80805. private static _SetAlphaMode;
  80806. /**
  80807. * Converts a Babylon Standard Material to a glTF Material
  80808. * @param babylonStandardMaterial BJS Standard Material
  80809. * @param mimeType mime type to use for the textures
  80810. * @param images array of glTF image interfaces
  80811. * @param textures array of glTF texture interfaces
  80812. * @param materials array of glTF material interfaces
  80813. * @param imageData map of image file name to data
  80814. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80815. */
  80816. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80817. private _finishMaterial;
  80818. /**
  80819. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80820. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80821. * @param mimeType mime type to use for the textures
  80822. * @param images array of glTF image interfaces
  80823. * @param textures array of glTF texture interfaces
  80824. * @param materials array of glTF material interfaces
  80825. * @param imageData map of image file name to data
  80826. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80827. */
  80828. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80829. /**
  80830. * Converts an image typed array buffer to a base64 image
  80831. * @param buffer typed array buffer
  80832. * @param width width of the image
  80833. * @param height height of the image
  80834. * @param mimeType mimetype of the image
  80835. * @returns base64 image string
  80836. */
  80837. private _createBase64FromCanvasAsync;
  80838. /**
  80839. * Generates a white texture based on the specified width and height
  80840. * @param width width of the texture in pixels
  80841. * @param height height of the texture in pixels
  80842. * @param scene babylonjs scene
  80843. * @returns white texture
  80844. */
  80845. private _createWhiteTexture;
  80846. /**
  80847. * 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
  80848. * @param texture1 first texture to resize
  80849. * @param texture2 second texture to resize
  80850. * @param scene babylonjs scene
  80851. * @returns resized textures or null
  80852. */
  80853. private _resizeTexturesToSameDimensions;
  80854. /**
  80855. * Converts an array of pixels to a Float32Array
  80856. * Throws an error if the pixel format is not supported
  80857. * @param pixels - array buffer containing pixel values
  80858. * @returns Float32 of pixels
  80859. */
  80860. private _convertPixelArrayToFloat32;
  80861. /**
  80862. * Convert Specular Glossiness Textures to Metallic Roughness
  80863. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80864. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80865. * @param diffuseTexture texture used to store diffuse information
  80866. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80867. * @param factors specular glossiness material factors
  80868. * @param mimeType the mime type to use for the texture
  80869. * @returns pbr metallic roughness interface or null
  80870. */
  80871. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80872. /**
  80873. * Converts specular glossiness material properties to metallic roughness
  80874. * @param specularGlossiness interface with specular glossiness material properties
  80875. * @returns interface with metallic roughness material properties
  80876. */
  80877. private _convertSpecularGlossinessToMetallicRoughness;
  80878. /**
  80879. * Calculates the surface reflectance, independent of lighting conditions
  80880. * @param color Color source to calculate brightness from
  80881. * @returns number representing the perceived brightness, or zero if color is undefined
  80882. */
  80883. private _getPerceivedBrightness;
  80884. /**
  80885. * Returns the maximum color component value
  80886. * @param color
  80887. * @returns maximum color component value, or zero if color is null or undefined
  80888. */
  80889. private _getMaxComponent;
  80890. /**
  80891. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80892. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80893. * @param mimeType mime type to use for the textures
  80894. * @param images array of glTF image interfaces
  80895. * @param textures array of glTF texture interfaces
  80896. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80897. * @param imageData map of image file name to data
  80898. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80899. * @returns glTF PBR Metallic Roughness factors
  80900. */
  80901. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80902. private _getGLTFTextureSampler;
  80903. private _getGLTFTextureWrapMode;
  80904. private _getGLTFTextureWrapModesSampler;
  80905. /**
  80906. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80907. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80908. * @param mimeType mime type to use for the textures
  80909. * @param images array of glTF image interfaces
  80910. * @param textures array of glTF texture interfaces
  80911. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80912. * @param imageData map of image file name to data
  80913. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80914. * @returns glTF PBR Metallic Roughness factors
  80915. */
  80916. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80917. /**
  80918. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80919. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80920. * @param mimeType mime type to use for the textures
  80921. * @param images array of glTF image interfaces
  80922. * @param textures array of glTF texture interfaces
  80923. * @param materials array of glTF material interfaces
  80924. * @param imageData map of image file name to data
  80925. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80926. */
  80927. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80928. private setMetallicRoughnessPbrMaterial;
  80929. private getPixelsFromTexture;
  80930. /**
  80931. * Extracts a texture from a Babylon texture into file data and glTF data
  80932. * @param babylonTexture Babylon texture to extract
  80933. * @param mimeType Mime Type of the babylonTexture
  80934. * @return glTF texture info, or null if the texture format is not supported
  80935. */
  80936. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80937. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80938. /**
  80939. * Builds a texture from base64 string
  80940. * @param base64Texture base64 texture string
  80941. * @param baseTextureName Name to use for the texture
  80942. * @param mimeType image mime type for the texture
  80943. * @param images array of images
  80944. * @param textures array of textures
  80945. * @param imageData map of image data
  80946. * @returns glTF texture info, or null if the texture format is not supported
  80947. */
  80948. private _getTextureInfoFromBase64;
  80949. }
  80950. }
  80951. declare module BABYLON {
  80952. /**
  80953. * Class for holding and downloading glTF file data
  80954. */
  80955. export class GLTFData {
  80956. /**
  80957. * Object which contains the file name as the key and its data as the value
  80958. */
  80959. glTFFiles: {
  80960. [fileName: string]: string | Blob;
  80961. };
  80962. /**
  80963. * Initializes the glTF file object
  80964. */
  80965. constructor();
  80966. /**
  80967. * Downloads the glTF data as files based on their names and data
  80968. */
  80969. downloadFiles(): void;
  80970. }
  80971. }
  80972. declare module BABYLON {
  80973. /**
  80974. * Holds a collection of exporter options and parameters
  80975. */
  80976. export interface IExportOptions {
  80977. /**
  80978. * Function which indicates whether a babylon node should be exported or not
  80979. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80980. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80981. */
  80982. shouldExportNode?(node: Node): boolean;
  80983. /**
  80984. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80985. * @param metadata source metadata to read from
  80986. * @returns the data to store to glTF node extras
  80987. */
  80988. metadataSelector?(metadata: any): any;
  80989. /**
  80990. * The sample rate to bake animation curves
  80991. */
  80992. animationSampleRate?: number;
  80993. /**
  80994. * Begin serialization without waiting for the scene to be ready
  80995. */
  80996. exportWithoutWaitingForScene?: boolean;
  80997. /**
  80998. * Indicates if coordinate system swapping root nodes should be included in export
  80999. */
  81000. includeCoordinateSystemConversionNodes?: boolean;
  81001. }
  81002. /**
  81003. * Class for generating glTF data from a Babylon scene.
  81004. */
  81005. export class GLTF2Export {
  81006. /**
  81007. * Exports the geometry of the scene to .gltf file format asynchronously
  81008. * @param scene Babylon scene with scene hierarchy information
  81009. * @param filePrefix File prefix to use when generating the glTF file
  81010. * @param options Exporter options
  81011. * @returns Returns an object with a .gltf file and associates texture names
  81012. * as keys and their data and paths as values
  81013. */
  81014. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81015. private static _PreExportAsync;
  81016. private static _PostExportAsync;
  81017. /**
  81018. * Exports the geometry of the scene to .glb file format asychronously
  81019. * @param scene Babylon scene with scene hierarchy information
  81020. * @param filePrefix File prefix to use when generating glb file
  81021. * @param options Exporter options
  81022. * @returns Returns an object with a .glb filename as key and data as value
  81023. */
  81024. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81025. }
  81026. }
  81027. declare module BABYLON.GLTF2.Exporter {
  81028. /**
  81029. * @hidden
  81030. */
  81031. export class _GLTFUtilities {
  81032. /**
  81033. * Creates a buffer view based on the supplied arguments
  81034. * @param bufferIndex index value of the specified buffer
  81035. * @param byteOffset byte offset value
  81036. * @param byteLength byte length of the bufferView
  81037. * @param byteStride byte distance between conequential elements
  81038. * @param name name of the buffer view
  81039. * @returns bufferView for glTF
  81040. */
  81041. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81042. /**
  81043. * Creates an accessor based on the supplied arguments
  81044. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81045. * @param name The name of the accessor
  81046. * @param type The type of the accessor
  81047. * @param componentType The datatype of components in the attribute
  81048. * @param count The number of attributes referenced by this accessor
  81049. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81050. * @param min Minimum value of each component in this attribute
  81051. * @param max Maximum value of each component in this attribute
  81052. * @returns accessor for glTF
  81053. */
  81054. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81055. /**
  81056. * Calculates the minimum and maximum values of an array of position floats
  81057. * @param positions Positions array of a mesh
  81058. * @param vertexStart Starting vertex offset to calculate min and max values
  81059. * @param vertexCount Number of vertices to check for min and max values
  81060. * @returns min number array and max number array
  81061. */
  81062. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81063. min: number[];
  81064. max: number[];
  81065. };
  81066. /**
  81067. * Converts a new right-handed Vector3
  81068. * @param vector vector3 array
  81069. * @returns right-handed Vector3
  81070. */
  81071. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81072. /**
  81073. * Converts a Vector3 to right-handed
  81074. * @param vector Vector3 to convert to right-handed
  81075. */
  81076. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81077. /**
  81078. * Converts a three element number array to right-handed
  81079. * @param vector number array to convert to right-handed
  81080. */
  81081. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81082. /**
  81083. * Converts a new right-handed Vector3
  81084. * @param vector vector3 array
  81085. * @returns right-handed Vector3
  81086. */
  81087. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81088. /**
  81089. * Converts a Vector3 to right-handed
  81090. * @param vector Vector3 to convert to right-handed
  81091. */
  81092. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81093. /**
  81094. * Converts a three element number array to right-handed
  81095. * @param vector number array to convert to right-handed
  81096. */
  81097. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81098. /**
  81099. * Converts a Vector4 to right-handed
  81100. * @param vector Vector4 to convert to right-handed
  81101. */
  81102. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81103. /**
  81104. * Converts a Vector4 to right-handed
  81105. * @param vector Vector4 to convert to right-handed
  81106. */
  81107. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81108. /**
  81109. * Converts a Quaternion to right-handed
  81110. * @param quaternion Source quaternion to convert to right-handed
  81111. */
  81112. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81113. /**
  81114. * Converts a Quaternion to right-handed
  81115. * @param quaternion Source quaternion to convert to right-handed
  81116. */
  81117. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81118. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81119. }
  81120. }
  81121. declare module BABYLON.GLTF2.Exporter {
  81122. /**
  81123. * Converts Babylon Scene into glTF 2.0.
  81124. * @hidden
  81125. */
  81126. export class _Exporter {
  81127. /**
  81128. * Stores the glTF to export
  81129. */
  81130. _glTF: IGLTF;
  81131. /**
  81132. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81133. */
  81134. _bufferViews: IBufferView[];
  81135. /**
  81136. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81137. */
  81138. _accessors: IAccessor[];
  81139. /**
  81140. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81141. */
  81142. _nodes: INode[];
  81143. /**
  81144. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81145. */
  81146. private _scenes;
  81147. /**
  81148. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81149. */
  81150. private _meshes;
  81151. /**
  81152. * Stores all the generated material information, which represents the appearance of each primitive
  81153. */
  81154. _materials: IMaterial[];
  81155. _materialMap: {
  81156. [materialID: number]: number;
  81157. };
  81158. /**
  81159. * Stores all the generated texture information, which is referenced by glTF materials
  81160. */
  81161. _textures: ITexture[];
  81162. /**
  81163. * Stores all the generated image information, which is referenced by glTF textures
  81164. */
  81165. _images: IImage[];
  81166. /**
  81167. * Stores all the texture samplers
  81168. */
  81169. _samplers: ISampler[];
  81170. /**
  81171. * Stores all the generated animation samplers, which is referenced by glTF animations
  81172. */
  81173. /**
  81174. * Stores the animations for glTF models
  81175. */
  81176. private _animations;
  81177. /**
  81178. * Stores the total amount of bytes stored in the glTF buffer
  81179. */
  81180. private _totalByteLength;
  81181. /**
  81182. * Stores a reference to the Babylon scene containing the source geometry and material information
  81183. */
  81184. _babylonScene: Scene;
  81185. /**
  81186. * Stores a map of the image data, where the key is the file name and the value
  81187. * is the image data
  81188. */
  81189. _imageData: {
  81190. [fileName: string]: {
  81191. data: Uint8Array;
  81192. mimeType: ImageMimeType;
  81193. };
  81194. };
  81195. /**
  81196. * Stores a map of the unique id of a node to its index in the node array
  81197. */
  81198. _nodeMap: {
  81199. [key: number]: number;
  81200. };
  81201. /**
  81202. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81203. */
  81204. _convertToRightHandedSystem: boolean;
  81205. /**
  81206. * Specifies if a Babylon node should be converted to right-handed on export
  81207. */
  81208. _convertToRightHandedSystemMap: {
  81209. [nodeId: number]: boolean;
  81210. };
  81211. _includeCoordinateSystemConversionNodes: boolean;
  81212. /**
  81213. * Baked animation sample rate
  81214. */
  81215. private _animationSampleRate;
  81216. private _options;
  81217. private _localEngine;
  81218. _glTFMaterialExporter: _GLTFMaterialExporter;
  81219. private _extensions;
  81220. private static _ExtensionNames;
  81221. private static _ExtensionFactories;
  81222. private _applyExtension;
  81223. private _applyExtensions;
  81224. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81225. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81226. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81227. [key: number]: number;
  81228. }): Promise<Nullable<INode>>;
  81229. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81230. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81231. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81232. private _forEachExtensions;
  81233. private _extensionsOnExporting;
  81234. /**
  81235. * Load glTF serializer extensions
  81236. */
  81237. private _loadExtensions;
  81238. /**
  81239. * Creates a glTF Exporter instance, which can accept optional exporter options
  81240. * @param babylonScene Babylon scene object
  81241. * @param options Options to modify the behavior of the exporter
  81242. */
  81243. constructor(babylonScene: Scene, options?: IExportOptions);
  81244. dispose(): void;
  81245. /**
  81246. * Registers a glTF exporter extension
  81247. * @param name Name of the extension to export
  81248. * @param factory The factory function that creates the exporter extension
  81249. */
  81250. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81251. /**
  81252. * Un-registers an exporter extension
  81253. * @param name The name fo the exporter extension
  81254. * @returns A boolean indicating whether the extension has been un-registered
  81255. */
  81256. static UnregisterExtension(name: string): boolean;
  81257. /**
  81258. * Lazy load a local engine
  81259. */
  81260. _getLocalEngine(): Engine;
  81261. private reorderIndicesBasedOnPrimitiveMode;
  81262. /**
  81263. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81264. * clock-wise during export to glTF
  81265. * @param submesh BabylonJS submesh
  81266. * @param primitiveMode Primitive mode of the mesh
  81267. * @param sideOrientation the winding order of the submesh
  81268. * @param vertexBufferKind The type of vertex attribute
  81269. * @param meshAttributeArray The vertex attribute data
  81270. * @param byteOffset The offset to the binary data
  81271. * @param binaryWriter The binary data for the glTF file
  81272. * @param convertToRightHandedSystem Converts the values to right-handed
  81273. */
  81274. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81275. /**
  81276. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81277. * clock-wise during export to glTF
  81278. * @param submesh BabylonJS submesh
  81279. * @param primitiveMode Primitive mode of the mesh
  81280. * @param sideOrientation the winding order of the submesh
  81281. * @param vertexBufferKind The type of vertex attribute
  81282. * @param meshAttributeArray The vertex attribute data
  81283. * @param byteOffset The offset to the binary data
  81284. * @param binaryWriter The binary data for the glTF file
  81285. * @param convertToRightHandedSystem Converts the values to right-handed
  81286. */
  81287. private reorderTriangleFillMode;
  81288. /**
  81289. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81290. * clock-wise during export to glTF
  81291. * @param submesh BabylonJS submesh
  81292. * @param primitiveMode Primitive mode of the mesh
  81293. * @param sideOrientation the winding order of the submesh
  81294. * @param vertexBufferKind The type of vertex attribute
  81295. * @param meshAttributeArray The vertex attribute data
  81296. * @param byteOffset The offset to the binary data
  81297. * @param binaryWriter The binary data for the glTF file
  81298. * @param convertToRightHandedSystem Converts the values to right-handed
  81299. */
  81300. private reorderTriangleStripDrawMode;
  81301. /**
  81302. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81303. * clock-wise during export to glTF
  81304. * @param submesh BabylonJS submesh
  81305. * @param primitiveMode Primitive mode of the mesh
  81306. * @param sideOrientation the winding order of the submesh
  81307. * @param vertexBufferKind The type of vertex attribute
  81308. * @param meshAttributeArray The vertex attribute data
  81309. * @param byteOffset The offset to the binary data
  81310. * @param binaryWriter The binary data for the glTF file
  81311. * @param convertToRightHandedSystem Converts the values to right-handed
  81312. */
  81313. private reorderTriangleFanMode;
  81314. /**
  81315. * Writes the vertex attribute data to binary
  81316. * @param vertices The vertices to write to the binary writer
  81317. * @param byteOffset The offset into the binary writer to overwrite binary data
  81318. * @param vertexAttributeKind The vertex attribute type
  81319. * @param meshAttributeArray The vertex attribute data
  81320. * @param binaryWriter The writer containing the binary data
  81321. * @param convertToRightHandedSystem Converts the values to right-handed
  81322. */
  81323. private writeVertexAttributeData;
  81324. /**
  81325. * Writes mesh attribute data to a data buffer
  81326. * Returns the bytelength of the data
  81327. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81328. * @param meshAttributeArray Array containing the attribute data
  81329. * @param binaryWriter The buffer to write the binary data to
  81330. * @param indices Used to specify the order of the vertex data
  81331. * @param convertToRightHandedSystem Converts the values to right-handed
  81332. */
  81333. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81334. /**
  81335. * Generates glTF json data
  81336. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81337. * @param glTFPrefix Text to use when prefixing a glTF file
  81338. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81339. * @returns json data as string
  81340. */
  81341. private generateJSON;
  81342. /**
  81343. * Generates data for .gltf and .bin files based on the glTF prefix string
  81344. * @param glTFPrefix Text to use when prefixing a glTF file
  81345. * @param dispose Dispose the exporter
  81346. * @returns GLTFData with glTF file data
  81347. */
  81348. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81349. /**
  81350. * Creates a binary buffer for glTF
  81351. * @returns array buffer for binary data
  81352. */
  81353. private _generateBinaryAsync;
  81354. /**
  81355. * Pads the number to a multiple of 4
  81356. * @param num number to pad
  81357. * @returns padded number
  81358. */
  81359. private _getPadding;
  81360. /**
  81361. * @hidden
  81362. */
  81363. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81364. /**
  81365. * Sets the TRS for each node
  81366. * @param node glTF Node for storing the transformation data
  81367. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81368. * @param convertToRightHandedSystem Converts the values to right-handed
  81369. */
  81370. private setNodeTransformation;
  81371. private getVertexBufferFromMesh;
  81372. /**
  81373. * Creates a bufferview based on the vertices type for the Babylon mesh
  81374. * @param kind Indicates the type of vertices data
  81375. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81376. * @param binaryWriter The buffer to write the bufferview data to
  81377. * @param convertToRightHandedSystem Converts the values to right-handed
  81378. */
  81379. private createBufferViewKind;
  81380. /**
  81381. * The primitive mode of the Babylon mesh
  81382. * @param babylonMesh The BabylonJS mesh
  81383. */
  81384. private getMeshPrimitiveMode;
  81385. /**
  81386. * Sets the primitive mode of the glTF mesh primitive
  81387. * @param meshPrimitive glTF mesh primitive
  81388. * @param primitiveMode The primitive mode
  81389. */
  81390. private setPrimitiveMode;
  81391. /**
  81392. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81393. * @param meshPrimitive glTF mesh primitive
  81394. * @param attributeKind vertex attribute
  81395. * @returns boolean specifying if uv coordinates are present
  81396. */
  81397. private setAttributeKind;
  81398. /**
  81399. * Sets data for the primitive attributes of each submesh
  81400. * @param mesh glTF Mesh object to store the primitive attribute information
  81401. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81402. * @param binaryWriter Buffer to write the attribute data to
  81403. * @param convertToRightHandedSystem Converts the values to right-handed
  81404. */
  81405. private setPrimitiveAttributesAsync;
  81406. /**
  81407. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81408. * @param node The node to check
  81409. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81410. */
  81411. private isBabylonCoordinateSystemConvertingNode;
  81412. /**
  81413. * Creates a glTF scene based on the array of meshes
  81414. * Returns the the total byte offset
  81415. * @param babylonScene Babylon scene to get the mesh data from
  81416. * @param binaryWriter Buffer to write binary data to
  81417. */
  81418. private createSceneAsync;
  81419. /**
  81420. * Creates a mapping of Node unique id to node index and handles animations
  81421. * @param babylonScene Babylon Scene
  81422. * @param nodes Babylon transform nodes
  81423. * @param binaryWriter Buffer to write binary data to
  81424. * @returns Node mapping of unique id to index
  81425. */
  81426. private createNodeMapAndAnimationsAsync;
  81427. /**
  81428. * Creates a glTF node from a Babylon mesh
  81429. * @param babylonMesh Source Babylon mesh
  81430. * @param binaryWriter Buffer for storing geometry data
  81431. * @param convertToRightHandedSystem Converts the values to right-handed
  81432. * @param nodeMap Node mapping of unique id to glTF node index
  81433. * @returns glTF node
  81434. */
  81435. private createNodeAsync;
  81436. }
  81437. /**
  81438. * @hidden
  81439. *
  81440. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81441. */
  81442. export class _BinaryWriter {
  81443. /**
  81444. * Array buffer which stores all binary data
  81445. */
  81446. private _arrayBuffer;
  81447. /**
  81448. * View of the array buffer
  81449. */
  81450. private _dataView;
  81451. /**
  81452. * byte offset of data in array buffer
  81453. */
  81454. private _byteOffset;
  81455. /**
  81456. * Initialize binary writer with an initial byte length
  81457. * @param byteLength Initial byte length of the array buffer
  81458. */
  81459. constructor(byteLength: number);
  81460. /**
  81461. * Resize the array buffer to the specified byte length
  81462. * @param byteLength
  81463. */
  81464. private resizeBuffer;
  81465. /**
  81466. * Get an array buffer with the length of the byte offset
  81467. * @returns ArrayBuffer resized to the byte offset
  81468. */
  81469. getArrayBuffer(): ArrayBuffer;
  81470. /**
  81471. * Get the byte offset of the array buffer
  81472. * @returns byte offset
  81473. */
  81474. getByteOffset(): number;
  81475. /**
  81476. * Stores an UInt8 in the array buffer
  81477. * @param entry
  81478. * @param byteOffset If defined, specifies where to set the value as an offset.
  81479. */
  81480. setUInt8(entry: number, byteOffset?: number): void;
  81481. /**
  81482. * Gets an UInt32 in the array buffer
  81483. * @param entry
  81484. * @param byteOffset If defined, specifies where to set the value as an offset.
  81485. */
  81486. getUInt32(byteOffset: number): number;
  81487. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81488. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81489. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81490. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81491. /**
  81492. * Stores a Float32 in the array buffer
  81493. * @param entry
  81494. */
  81495. setFloat32(entry: number, byteOffset?: number): void;
  81496. /**
  81497. * Stores an UInt32 in the array buffer
  81498. * @param entry
  81499. * @param byteOffset If defined, specifies where to set the value as an offset.
  81500. */
  81501. setUInt32(entry: number, byteOffset?: number): void;
  81502. }
  81503. }
  81504. declare module BABYLON.GLTF2.Exporter {
  81505. /**
  81506. * @hidden
  81507. * Interface to store animation data.
  81508. */
  81509. export interface _IAnimationData {
  81510. /**
  81511. * Keyframe data.
  81512. */
  81513. inputs: number[];
  81514. /**
  81515. * Value data.
  81516. */
  81517. outputs: number[][];
  81518. /**
  81519. * Animation interpolation data.
  81520. */
  81521. samplerInterpolation: AnimationSamplerInterpolation;
  81522. /**
  81523. * Minimum keyframe value.
  81524. */
  81525. inputsMin: number;
  81526. /**
  81527. * Maximum keyframe value.
  81528. */
  81529. inputsMax: number;
  81530. }
  81531. /**
  81532. * @hidden
  81533. */
  81534. export interface _IAnimationInfo {
  81535. /**
  81536. * The target channel for the animation
  81537. */
  81538. animationChannelTargetPath: AnimationChannelTargetPath;
  81539. /**
  81540. * The glTF accessor type for the data.
  81541. */
  81542. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81543. /**
  81544. * Specifies if quaternions should be used.
  81545. */
  81546. useQuaternion: boolean;
  81547. }
  81548. /**
  81549. * @hidden
  81550. * Utility class for generating glTF animation data from BabylonJS.
  81551. */
  81552. export class _GLTFAnimation {
  81553. /**
  81554. * @ignore
  81555. *
  81556. * Creates glTF channel animation from BabylonJS animation.
  81557. * @param babylonTransformNode - BabylonJS mesh.
  81558. * @param animation - animation.
  81559. * @param animationChannelTargetPath - The target animation channel.
  81560. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81561. * @param useQuaternion - Specifies if quaternions are used.
  81562. * @returns nullable IAnimationData
  81563. */
  81564. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81565. private static _DeduceAnimationInfo;
  81566. /**
  81567. * @ignore
  81568. * Create node animations from the transform node animations
  81569. * @param babylonNode
  81570. * @param runtimeGLTFAnimation
  81571. * @param idleGLTFAnimations
  81572. * @param nodeMap
  81573. * @param nodes
  81574. * @param binaryWriter
  81575. * @param bufferViews
  81576. * @param accessors
  81577. * @param convertToRightHandedSystem
  81578. * @param animationSampleRate
  81579. */
  81580. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81581. [key: number]: number;
  81582. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81583. /**
  81584. * @ignore
  81585. * Create node animations from the animation groups
  81586. * @param babylonScene
  81587. * @param glTFAnimations
  81588. * @param nodeMap
  81589. * @param nodes
  81590. * @param binaryWriter
  81591. * @param bufferViews
  81592. * @param accessors
  81593. * @param convertToRightHandedSystemMap
  81594. * @param animationSampleRate
  81595. */
  81596. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81597. [key: number]: number;
  81598. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81599. [nodeId: number]: boolean;
  81600. }, animationSampleRate: number): void;
  81601. private static AddAnimation;
  81602. /**
  81603. * Create a baked animation
  81604. * @param babylonTransformNode BabylonJS mesh
  81605. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81606. * @param animationChannelTargetPath animation target channel
  81607. * @param minFrame minimum animation frame
  81608. * @param maxFrame maximum animation frame
  81609. * @param fps frames per second of the animation
  81610. * @param inputs input key frames of the animation
  81611. * @param outputs output key frame data of the animation
  81612. * @param convertToRightHandedSystem converts the values to right-handed
  81613. * @param useQuaternion specifies if quaternions should be used
  81614. */
  81615. private static _CreateBakedAnimation;
  81616. private static _ConvertFactorToVector3OrQuaternion;
  81617. private static _SetInterpolatedValue;
  81618. /**
  81619. * Creates linear animation from the animation key frames
  81620. * @param babylonTransformNode BabylonJS mesh
  81621. * @param animation BabylonJS animation
  81622. * @param animationChannelTargetPath The target animation channel
  81623. * @param frameDelta The difference between the last and first frame of the animation
  81624. * @param inputs Array to store the key frame times
  81625. * @param outputs Array to store the key frame data
  81626. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81627. * @param useQuaternion Specifies if quaternions are used in the animation
  81628. */
  81629. private static _CreateLinearOrStepAnimation;
  81630. /**
  81631. * Creates cubic spline animation from the animation key frames
  81632. * @param babylonTransformNode BabylonJS mesh
  81633. * @param animation BabylonJS animation
  81634. * @param animationChannelTargetPath The target animation channel
  81635. * @param frameDelta The difference between the last and first frame of the animation
  81636. * @param inputs Array to store the key frame times
  81637. * @param outputs Array to store the key frame data
  81638. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81639. * @param useQuaternion Specifies if quaternions are used in the animation
  81640. */
  81641. private static _CreateCubicSplineAnimation;
  81642. private static _GetBasePositionRotationOrScale;
  81643. /**
  81644. * Adds a key frame value
  81645. * @param keyFrame
  81646. * @param animation
  81647. * @param outputs
  81648. * @param animationChannelTargetPath
  81649. * @param basePositionRotationOrScale
  81650. * @param convertToRightHandedSystem
  81651. * @param useQuaternion
  81652. */
  81653. private static _AddKeyframeValue;
  81654. /**
  81655. * Determine the interpolation based on the key frames
  81656. * @param keyFrames
  81657. * @param animationChannelTargetPath
  81658. * @param useQuaternion
  81659. */
  81660. private static _DeduceInterpolation;
  81661. /**
  81662. * Adds an input tangent or output tangent to the output data
  81663. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81664. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81665. * @param outputs The animation data by keyframe
  81666. * @param animationChannelTargetPath The target animation channel
  81667. * @param interpolation The interpolation type
  81668. * @param keyFrame The key frame with the animation data
  81669. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81670. * @param useQuaternion Specifies if quaternions are used
  81671. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81672. */
  81673. private static AddSplineTangent;
  81674. /**
  81675. * Get the minimum and maximum key frames' frame values
  81676. * @param keyFrames animation key frames
  81677. * @returns the minimum and maximum key frame value
  81678. */
  81679. private static calculateMinMaxKeyFrames;
  81680. }
  81681. }
  81682. declare module BABYLON.GLTF2.Exporter {
  81683. /** @hidden */
  81684. export var textureTransformPixelShader: {
  81685. name: string;
  81686. shader: string;
  81687. };
  81688. }
  81689. declare module BABYLON.GLTF2.Exporter.Extensions {
  81690. /**
  81691. * @hidden
  81692. */
  81693. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81694. private _recordedTextures;
  81695. /** Name of this extension */
  81696. readonly name: string;
  81697. /** Defines whether this extension is enabled */
  81698. enabled: boolean;
  81699. /** Defines whether this extension is required */
  81700. required: boolean;
  81701. /** Reference to the glTF exporter */
  81702. private _wasUsed;
  81703. constructor(exporter: _Exporter);
  81704. dispose(): void;
  81705. /** @hidden */
  81706. get wasUsed(): boolean;
  81707. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81708. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81709. /**
  81710. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81711. * @param babylonTexture
  81712. * @param offset
  81713. * @param rotation
  81714. * @param scale
  81715. * @param scene
  81716. */
  81717. private _textureTransformTextureAsync;
  81718. }
  81719. }
  81720. declare module BABYLON.GLTF2.Exporter.Extensions {
  81721. /**
  81722. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81723. */
  81724. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81725. /** The name of this extension. */
  81726. readonly name: string;
  81727. /** Defines whether this extension is enabled. */
  81728. enabled: boolean;
  81729. /** Defines whether this extension is required */
  81730. required: boolean;
  81731. /** Reference to the glTF exporter */
  81732. private _exporter;
  81733. private _lights;
  81734. /** @hidden */
  81735. constructor(exporter: _Exporter);
  81736. /** @hidden */
  81737. dispose(): void;
  81738. /** @hidden */
  81739. get wasUsed(): boolean;
  81740. /** @hidden */
  81741. onExporting(): void;
  81742. /**
  81743. * Define this method to modify the default behavior when exporting a node
  81744. * @param context The context when exporting the node
  81745. * @param node glTF node
  81746. * @param babylonNode BabylonJS node
  81747. * @param nodeMap Node mapping of unique id to glTF node index
  81748. * @returns nullable INode promise
  81749. */
  81750. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81751. [key: number]: number;
  81752. }): Promise<Nullable<INode>>;
  81753. }
  81754. }
  81755. declare module BABYLON.GLTF2.Exporter.Extensions {
  81756. /**
  81757. * @hidden
  81758. */
  81759. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81760. /** Name of this extension */
  81761. readonly name: string;
  81762. /** Defines whether this extension is enabled */
  81763. enabled: boolean;
  81764. /** Defines whether this extension is required */
  81765. required: boolean;
  81766. /** Reference to the glTF exporter */
  81767. private _textureInfos;
  81768. private _exportedTextures;
  81769. private _wasUsed;
  81770. constructor(exporter: _Exporter);
  81771. dispose(): void;
  81772. /** @hidden */
  81773. get wasUsed(): boolean;
  81774. private _getTextureIndex;
  81775. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81776. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81777. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81778. }
  81779. }
  81780. declare module BABYLON {
  81781. /**
  81782. * Class for generating STL data from a Babylon scene.
  81783. */
  81784. export class STLExport {
  81785. /**
  81786. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81787. * @param meshes list defines the mesh to serialize
  81788. * @param download triggers the automatic download of the file.
  81789. * @param fileName changes the downloads fileName.
  81790. * @param binary changes the STL to a binary type.
  81791. * @param isLittleEndian toggle for binary type exporter.
  81792. * @returns the STL as UTF8 string
  81793. */
  81794. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81795. }
  81796. }
  81797. declare module "babylonjs-gltf2interface" {
  81798. export = BABYLON.GLTF2;
  81799. }
  81800. /**
  81801. * Module for glTF 2.0 Interface
  81802. */
  81803. declare module BABYLON.GLTF2 {
  81804. /**
  81805. * The datatype of the components in the attribute
  81806. */
  81807. const enum AccessorComponentType {
  81808. /**
  81809. * Byte
  81810. */
  81811. BYTE = 5120,
  81812. /**
  81813. * Unsigned Byte
  81814. */
  81815. UNSIGNED_BYTE = 5121,
  81816. /**
  81817. * Short
  81818. */
  81819. SHORT = 5122,
  81820. /**
  81821. * Unsigned Short
  81822. */
  81823. UNSIGNED_SHORT = 5123,
  81824. /**
  81825. * Unsigned Int
  81826. */
  81827. UNSIGNED_INT = 5125,
  81828. /**
  81829. * Float
  81830. */
  81831. FLOAT = 5126,
  81832. }
  81833. /**
  81834. * Specifies if the attirbute is a scalar, vector, or matrix
  81835. */
  81836. const enum AccessorType {
  81837. /**
  81838. * Scalar
  81839. */
  81840. SCALAR = "SCALAR",
  81841. /**
  81842. * Vector2
  81843. */
  81844. VEC2 = "VEC2",
  81845. /**
  81846. * Vector3
  81847. */
  81848. VEC3 = "VEC3",
  81849. /**
  81850. * Vector4
  81851. */
  81852. VEC4 = "VEC4",
  81853. /**
  81854. * Matrix2x2
  81855. */
  81856. MAT2 = "MAT2",
  81857. /**
  81858. * Matrix3x3
  81859. */
  81860. MAT3 = "MAT3",
  81861. /**
  81862. * Matrix4x4
  81863. */
  81864. MAT4 = "MAT4",
  81865. }
  81866. /**
  81867. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81868. */
  81869. const enum AnimationChannelTargetPath {
  81870. /**
  81871. * Translation
  81872. */
  81873. TRANSLATION = "translation",
  81874. /**
  81875. * Rotation
  81876. */
  81877. ROTATION = "rotation",
  81878. /**
  81879. * Scale
  81880. */
  81881. SCALE = "scale",
  81882. /**
  81883. * Weights
  81884. */
  81885. WEIGHTS = "weights",
  81886. }
  81887. /**
  81888. * Interpolation algorithm
  81889. */
  81890. const enum AnimationSamplerInterpolation {
  81891. /**
  81892. * The animated values are linearly interpolated between keyframes
  81893. */
  81894. LINEAR = "LINEAR",
  81895. /**
  81896. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81897. */
  81898. STEP = "STEP",
  81899. /**
  81900. * The animation's interpolation is computed using a cubic spline with specified tangents
  81901. */
  81902. CUBICSPLINE = "CUBICSPLINE",
  81903. }
  81904. /**
  81905. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81906. */
  81907. const enum CameraType {
  81908. /**
  81909. * A perspective camera containing properties to create a perspective projection matrix
  81910. */
  81911. PERSPECTIVE = "perspective",
  81912. /**
  81913. * An orthographic camera containing properties to create an orthographic projection matrix
  81914. */
  81915. ORTHOGRAPHIC = "orthographic",
  81916. }
  81917. /**
  81918. * The mime-type of the image
  81919. */
  81920. const enum ImageMimeType {
  81921. /**
  81922. * JPEG Mime-type
  81923. */
  81924. JPEG = "image/jpeg",
  81925. /**
  81926. * PNG Mime-type
  81927. */
  81928. PNG = "image/png",
  81929. }
  81930. /**
  81931. * The alpha rendering mode of the material
  81932. */
  81933. const enum MaterialAlphaMode {
  81934. /**
  81935. * The alpha value is ignored and the rendered output is fully opaque
  81936. */
  81937. OPAQUE = "OPAQUE",
  81938. /**
  81939. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81940. */
  81941. MASK = "MASK",
  81942. /**
  81943. * 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)
  81944. */
  81945. BLEND = "BLEND",
  81946. }
  81947. /**
  81948. * The type of the primitives to render
  81949. */
  81950. const enum MeshPrimitiveMode {
  81951. /**
  81952. * Points
  81953. */
  81954. POINTS = 0,
  81955. /**
  81956. * Lines
  81957. */
  81958. LINES = 1,
  81959. /**
  81960. * Line Loop
  81961. */
  81962. LINE_LOOP = 2,
  81963. /**
  81964. * Line Strip
  81965. */
  81966. LINE_STRIP = 3,
  81967. /**
  81968. * Triangles
  81969. */
  81970. TRIANGLES = 4,
  81971. /**
  81972. * Triangle Strip
  81973. */
  81974. TRIANGLE_STRIP = 5,
  81975. /**
  81976. * Triangle Fan
  81977. */
  81978. TRIANGLE_FAN = 6,
  81979. }
  81980. /**
  81981. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81982. */
  81983. const enum TextureMagFilter {
  81984. /**
  81985. * Nearest
  81986. */
  81987. NEAREST = 9728,
  81988. /**
  81989. * Linear
  81990. */
  81991. LINEAR = 9729,
  81992. }
  81993. /**
  81994. * Minification filter. All valid values correspond to WebGL enums
  81995. */
  81996. const enum TextureMinFilter {
  81997. /**
  81998. * Nearest
  81999. */
  82000. NEAREST = 9728,
  82001. /**
  82002. * Linear
  82003. */
  82004. LINEAR = 9729,
  82005. /**
  82006. * Nearest Mip-Map Nearest
  82007. */
  82008. NEAREST_MIPMAP_NEAREST = 9984,
  82009. /**
  82010. * Linear Mipmap Nearest
  82011. */
  82012. LINEAR_MIPMAP_NEAREST = 9985,
  82013. /**
  82014. * Nearest Mipmap Linear
  82015. */
  82016. NEAREST_MIPMAP_LINEAR = 9986,
  82017. /**
  82018. * Linear Mipmap Linear
  82019. */
  82020. LINEAR_MIPMAP_LINEAR = 9987,
  82021. }
  82022. /**
  82023. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82024. */
  82025. const enum TextureWrapMode {
  82026. /**
  82027. * Clamp to Edge
  82028. */
  82029. CLAMP_TO_EDGE = 33071,
  82030. /**
  82031. * Mirrored Repeat
  82032. */
  82033. MIRRORED_REPEAT = 33648,
  82034. /**
  82035. * Repeat
  82036. */
  82037. REPEAT = 10497,
  82038. }
  82039. /**
  82040. * glTF Property
  82041. */
  82042. interface IProperty {
  82043. /**
  82044. * Dictionary object with extension-specific objects
  82045. */
  82046. extensions?: {
  82047. [key: string]: any;
  82048. };
  82049. /**
  82050. * Application-Specific data
  82051. */
  82052. extras?: any;
  82053. }
  82054. /**
  82055. * glTF Child of Root Property
  82056. */
  82057. interface IChildRootProperty extends IProperty {
  82058. /**
  82059. * The user-defined name of this object
  82060. */
  82061. name?: string;
  82062. }
  82063. /**
  82064. * Indices of those attributes that deviate from their initialization value
  82065. */
  82066. interface IAccessorSparseIndices extends IProperty {
  82067. /**
  82068. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82069. */
  82070. bufferView: number;
  82071. /**
  82072. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82073. */
  82074. byteOffset?: number;
  82075. /**
  82076. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82077. */
  82078. componentType: AccessorComponentType;
  82079. }
  82080. /**
  82081. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82082. */
  82083. interface IAccessorSparseValues extends IProperty {
  82084. /**
  82085. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82086. */
  82087. bufferView: number;
  82088. /**
  82089. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82090. */
  82091. byteOffset?: number;
  82092. }
  82093. /**
  82094. * Sparse storage of attributes that deviate from their initialization value
  82095. */
  82096. interface IAccessorSparse extends IProperty {
  82097. /**
  82098. * The number of attributes encoded in this sparse accessor
  82099. */
  82100. count: number;
  82101. /**
  82102. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82103. */
  82104. indices: IAccessorSparseIndices;
  82105. /**
  82106. * 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
  82107. */
  82108. values: IAccessorSparseValues;
  82109. }
  82110. /**
  82111. * 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
  82112. */
  82113. interface IAccessor extends IChildRootProperty {
  82114. /**
  82115. * The index of the bufferview
  82116. */
  82117. bufferView?: number;
  82118. /**
  82119. * The offset relative to the start of the bufferView in bytes
  82120. */
  82121. byteOffset?: number;
  82122. /**
  82123. * The datatype of components in the attribute
  82124. */
  82125. componentType: AccessorComponentType;
  82126. /**
  82127. * Specifies whether integer data values should be normalized
  82128. */
  82129. normalized?: boolean;
  82130. /**
  82131. * The number of attributes referenced by this accessor
  82132. */
  82133. count: number;
  82134. /**
  82135. * Specifies if the attribute is a scalar, vector, or matrix
  82136. */
  82137. type: AccessorType;
  82138. /**
  82139. * Maximum value of each component in this attribute
  82140. */
  82141. max?: number[];
  82142. /**
  82143. * Minimum value of each component in this attribute
  82144. */
  82145. min?: number[];
  82146. /**
  82147. * Sparse storage of attributes that deviate from their initialization value
  82148. */
  82149. sparse?: IAccessorSparse;
  82150. }
  82151. /**
  82152. * Targets an animation's sampler at a node's property
  82153. */
  82154. interface IAnimationChannel extends IProperty {
  82155. /**
  82156. * The index of a sampler in this animation used to compute the value for the target
  82157. */
  82158. sampler: number;
  82159. /**
  82160. * The index of the node and TRS property to target
  82161. */
  82162. target: IAnimationChannelTarget;
  82163. }
  82164. /**
  82165. * The index of the node and TRS property that an animation channel targets
  82166. */
  82167. interface IAnimationChannelTarget extends IProperty {
  82168. /**
  82169. * The index of the node to target
  82170. */
  82171. node: number;
  82172. /**
  82173. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82174. */
  82175. path: AnimationChannelTargetPath;
  82176. }
  82177. /**
  82178. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82179. */
  82180. interface IAnimationSampler extends IProperty {
  82181. /**
  82182. * The index of an accessor containing keyframe input values, e.g., time
  82183. */
  82184. input: number;
  82185. /**
  82186. * Interpolation algorithm
  82187. */
  82188. interpolation?: AnimationSamplerInterpolation;
  82189. /**
  82190. * The index of an accessor, containing keyframe output values
  82191. */
  82192. output: number;
  82193. }
  82194. /**
  82195. * A keyframe animation
  82196. */
  82197. interface IAnimation extends IChildRootProperty {
  82198. /**
  82199. * An array of channels, each of which targets an animation's sampler at a node's property
  82200. */
  82201. channels: IAnimationChannel[];
  82202. /**
  82203. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82204. */
  82205. samplers: IAnimationSampler[];
  82206. }
  82207. /**
  82208. * Metadata about the glTF asset
  82209. */
  82210. interface IAsset extends IChildRootProperty {
  82211. /**
  82212. * A copyright message suitable for display to credit the content creator
  82213. */
  82214. copyright?: string;
  82215. /**
  82216. * Tool that generated this glTF model. Useful for debugging
  82217. */
  82218. generator?: string;
  82219. /**
  82220. * The glTF version that this asset targets
  82221. */
  82222. version: string;
  82223. /**
  82224. * The minimum glTF version that this asset targets
  82225. */
  82226. minVersion?: string;
  82227. }
  82228. /**
  82229. * A buffer points to binary geometry, animation, or skins
  82230. */
  82231. interface IBuffer extends IChildRootProperty {
  82232. /**
  82233. * 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
  82234. */
  82235. uri?: string;
  82236. /**
  82237. * The length of the buffer in bytes
  82238. */
  82239. byteLength: number;
  82240. }
  82241. /**
  82242. * A view into a buffer generally representing a subset of the buffer
  82243. */
  82244. interface IBufferView extends IChildRootProperty {
  82245. /**
  82246. * The index of the buffer
  82247. */
  82248. buffer: number;
  82249. /**
  82250. * The offset into the buffer in bytes
  82251. */
  82252. byteOffset?: number;
  82253. /**
  82254. * The lenth of the bufferView in bytes
  82255. */
  82256. byteLength: number;
  82257. /**
  82258. * The stride, in bytes
  82259. */
  82260. byteStride?: number;
  82261. }
  82262. /**
  82263. * An orthographic camera containing properties to create an orthographic projection matrix
  82264. */
  82265. interface ICameraOrthographic extends IProperty {
  82266. /**
  82267. * The floating-point horizontal magnification of the view. Must not be zero
  82268. */
  82269. xmag: number;
  82270. /**
  82271. * The floating-point vertical magnification of the view. Must not be zero
  82272. */
  82273. ymag: number;
  82274. /**
  82275. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82276. */
  82277. zfar: number;
  82278. /**
  82279. * The floating-point distance to the near clipping plane
  82280. */
  82281. znear: number;
  82282. }
  82283. /**
  82284. * A perspective camera containing properties to create a perspective projection matrix
  82285. */
  82286. interface ICameraPerspective extends IProperty {
  82287. /**
  82288. * The floating-point aspect ratio of the field of view
  82289. */
  82290. aspectRatio?: number;
  82291. /**
  82292. * The floating-point vertical field of view in radians
  82293. */
  82294. yfov: number;
  82295. /**
  82296. * The floating-point distance to the far clipping plane
  82297. */
  82298. zfar?: number;
  82299. /**
  82300. * The floating-point distance to the near clipping plane
  82301. */
  82302. znear: number;
  82303. }
  82304. /**
  82305. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82306. */
  82307. interface ICamera extends IChildRootProperty {
  82308. /**
  82309. * An orthographic camera containing properties to create an orthographic projection matrix
  82310. */
  82311. orthographic?: ICameraOrthographic;
  82312. /**
  82313. * A perspective camera containing properties to create a perspective projection matrix
  82314. */
  82315. perspective?: ICameraPerspective;
  82316. /**
  82317. * Specifies if the camera uses a perspective or orthographic projection
  82318. */
  82319. type: CameraType;
  82320. }
  82321. /**
  82322. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82323. */
  82324. interface IImage extends IChildRootProperty {
  82325. /**
  82326. * 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
  82327. */
  82328. uri?: string;
  82329. /**
  82330. * The image's MIME type
  82331. */
  82332. mimeType?: ImageMimeType;
  82333. /**
  82334. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82335. */
  82336. bufferView?: number;
  82337. }
  82338. /**
  82339. * Material Normal Texture Info
  82340. */
  82341. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82342. /**
  82343. * The scalar multiplier applied to each normal vector of the normal texture
  82344. */
  82345. scale?: number;
  82346. }
  82347. /**
  82348. * Material Occlusion Texture Info
  82349. */
  82350. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82351. /**
  82352. * A scalar multiplier controlling the amount of occlusion applied
  82353. */
  82354. strength?: number;
  82355. }
  82356. /**
  82357. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82358. */
  82359. interface IMaterialPbrMetallicRoughness {
  82360. /**
  82361. * The material's base color factor
  82362. */
  82363. baseColorFactor?: number[];
  82364. /**
  82365. * The base color texture
  82366. */
  82367. baseColorTexture?: ITextureInfo;
  82368. /**
  82369. * The metalness of the material
  82370. */
  82371. metallicFactor?: number;
  82372. /**
  82373. * The roughness of the material
  82374. */
  82375. roughnessFactor?: number;
  82376. /**
  82377. * The metallic-roughness texture
  82378. */
  82379. metallicRoughnessTexture?: ITextureInfo;
  82380. }
  82381. /**
  82382. * The material appearance of a primitive
  82383. */
  82384. interface IMaterial extends IChildRootProperty {
  82385. /**
  82386. * 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
  82387. */
  82388. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82389. /**
  82390. * The normal map texture
  82391. */
  82392. normalTexture?: IMaterialNormalTextureInfo;
  82393. /**
  82394. * The occlusion map texture
  82395. */
  82396. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82397. /**
  82398. * The emissive map texture
  82399. */
  82400. emissiveTexture?: ITextureInfo;
  82401. /**
  82402. * 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
  82403. */
  82404. emissiveFactor?: number[];
  82405. /**
  82406. * The alpha rendering mode of the material
  82407. */
  82408. alphaMode?: MaterialAlphaMode;
  82409. /**
  82410. * The alpha cutoff value of the material
  82411. */
  82412. alphaCutoff?: number;
  82413. /**
  82414. * Specifies whether the material is double sided
  82415. */
  82416. doubleSided?: boolean;
  82417. }
  82418. /**
  82419. * Geometry to be rendered with the given material
  82420. */
  82421. interface IMeshPrimitive extends IProperty {
  82422. /**
  82423. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82424. */
  82425. attributes: {
  82426. [name: string]: number;
  82427. };
  82428. /**
  82429. * The index of the accessor that contains the indices
  82430. */
  82431. indices?: number;
  82432. /**
  82433. * The index of the material to apply to this primitive when rendering
  82434. */
  82435. material?: number;
  82436. /**
  82437. * The type of primitives to render. All valid values correspond to WebGL enums
  82438. */
  82439. mode?: MeshPrimitiveMode;
  82440. /**
  82441. * 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
  82442. */
  82443. targets?: {
  82444. [name: string]: number;
  82445. }[];
  82446. }
  82447. /**
  82448. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82449. */
  82450. interface IMesh extends IChildRootProperty {
  82451. /**
  82452. * An array of primitives, each defining geometry to be rendered with a material
  82453. */
  82454. primitives: IMeshPrimitive[];
  82455. /**
  82456. * Array of weights to be applied to the Morph Targets
  82457. */
  82458. weights?: number[];
  82459. }
  82460. /**
  82461. * A node in the node hierarchy
  82462. */
  82463. interface INode extends IChildRootProperty {
  82464. /**
  82465. * The index of the camera referenced by this node
  82466. */
  82467. camera?: number;
  82468. /**
  82469. * The indices of this node's children
  82470. */
  82471. children?: number[];
  82472. /**
  82473. * The index of the skin referenced by this node
  82474. */
  82475. skin?: number;
  82476. /**
  82477. * A floating-point 4x4 transformation matrix stored in column-major order
  82478. */
  82479. matrix?: number[];
  82480. /**
  82481. * The index of the mesh in this node
  82482. */
  82483. mesh?: number;
  82484. /**
  82485. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82486. */
  82487. rotation?: number[];
  82488. /**
  82489. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82490. */
  82491. scale?: number[];
  82492. /**
  82493. * The node's translation along the x, y, and z axes
  82494. */
  82495. translation?: number[];
  82496. /**
  82497. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82498. */
  82499. weights?: number[];
  82500. }
  82501. /**
  82502. * Texture sampler properties for filtering and wrapping modes
  82503. */
  82504. interface ISampler extends IChildRootProperty {
  82505. /**
  82506. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82507. */
  82508. magFilter?: TextureMagFilter;
  82509. /**
  82510. * Minification filter. All valid values correspond to WebGL enums
  82511. */
  82512. minFilter?: TextureMinFilter;
  82513. /**
  82514. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82515. */
  82516. wrapS?: TextureWrapMode;
  82517. /**
  82518. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82519. */
  82520. wrapT?: TextureWrapMode;
  82521. }
  82522. /**
  82523. * The root nodes of a scene
  82524. */
  82525. interface IScene extends IChildRootProperty {
  82526. /**
  82527. * The indices of each root node
  82528. */
  82529. nodes: number[];
  82530. }
  82531. /**
  82532. * Joints and matrices defining a skin
  82533. */
  82534. interface ISkin extends IChildRootProperty {
  82535. /**
  82536. * 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
  82537. */
  82538. inverseBindMatrices?: number;
  82539. /**
  82540. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82541. */
  82542. skeleton?: number;
  82543. /**
  82544. * 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)
  82545. */
  82546. joints: number[];
  82547. }
  82548. /**
  82549. * A texture and its sampler
  82550. */
  82551. interface ITexture extends IChildRootProperty {
  82552. /**
  82553. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82554. */
  82555. sampler?: number;
  82556. /**
  82557. * The index of the image used by this texture
  82558. */
  82559. source: number;
  82560. }
  82561. /**
  82562. * Reference to a texture
  82563. */
  82564. interface ITextureInfo extends IProperty {
  82565. /**
  82566. * The index of the texture
  82567. */
  82568. index: number;
  82569. /**
  82570. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82571. */
  82572. texCoord?: number;
  82573. }
  82574. /**
  82575. * The root object for a glTF asset
  82576. */
  82577. interface IGLTF extends IProperty {
  82578. /**
  82579. * An array of accessors. An accessor is a typed view into a bufferView
  82580. */
  82581. accessors?: IAccessor[];
  82582. /**
  82583. * An array of keyframe animations
  82584. */
  82585. animations?: IAnimation[];
  82586. /**
  82587. * Metadata about the glTF asset
  82588. */
  82589. asset: IAsset;
  82590. /**
  82591. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82592. */
  82593. buffers?: IBuffer[];
  82594. /**
  82595. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82596. */
  82597. bufferViews?: IBufferView[];
  82598. /**
  82599. * An array of cameras
  82600. */
  82601. cameras?: ICamera[];
  82602. /**
  82603. * Names of glTF extensions used somewhere in this asset
  82604. */
  82605. extensionsUsed?: string[];
  82606. /**
  82607. * Names of glTF extensions required to properly load this asset
  82608. */
  82609. extensionsRequired?: string[];
  82610. /**
  82611. * An array of images. An image defines data used to create a texture
  82612. */
  82613. images?: IImage[];
  82614. /**
  82615. * An array of materials. A material defines the appearance of a primitive
  82616. */
  82617. materials?: IMaterial[];
  82618. /**
  82619. * An array of meshes. A mesh is a set of primitives to be rendered
  82620. */
  82621. meshes?: IMesh[];
  82622. /**
  82623. * An array of nodes
  82624. */
  82625. nodes?: INode[];
  82626. /**
  82627. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82628. */
  82629. samplers?: ISampler[];
  82630. /**
  82631. * The index of the default scene
  82632. */
  82633. scene?: number;
  82634. /**
  82635. * An array of scenes
  82636. */
  82637. scenes?: IScene[];
  82638. /**
  82639. * An array of skins. A skin is defined by joints and matrices
  82640. */
  82641. skins?: ISkin[];
  82642. /**
  82643. * An array of textures
  82644. */
  82645. textures?: ITexture[];
  82646. }
  82647. /**
  82648. * The glTF validation results
  82649. * @ignore
  82650. */
  82651. interface IGLTFValidationResults {
  82652. info: {
  82653. generator: string;
  82654. hasAnimations: boolean;
  82655. hasDefaultScene: boolean;
  82656. hasMaterials: boolean;
  82657. hasMorphTargets: boolean;
  82658. hasSkins: boolean;
  82659. hasTextures: boolean;
  82660. maxAttributesUsed: number;
  82661. primitivesCount: number
  82662. };
  82663. issues: {
  82664. messages: Array<string>;
  82665. numErrors: number;
  82666. numHints: number;
  82667. numInfos: number;
  82668. numWarnings: number;
  82669. truncated: boolean
  82670. };
  82671. mimeType: string;
  82672. uri: string;
  82673. validatedAt: string;
  82674. validatorVersion: string;
  82675. }
  82676. /**
  82677. * The glTF validation options
  82678. */
  82679. interface IGLTFValidationOptions {
  82680. /** Uri to use */
  82681. uri?: string;
  82682. /** Function used to load external resources */
  82683. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82684. /** Boolean indicating that we need to validate accessor data */
  82685. validateAccessorData?: boolean;
  82686. /** max number of issues allowed */
  82687. maxIssues?: number;
  82688. /** Ignored issues */
  82689. ignoredIssues?: Array<string>;
  82690. /** Value to override severy settings */
  82691. severityOverrides?: Object;
  82692. }
  82693. /**
  82694. * The glTF validator object
  82695. * @ignore
  82696. */
  82697. interface IGLTFValidator {
  82698. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82699. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82700. }
  82701. }
  82702. declare module BABYLON {
  82703. /** @hidden */
  82704. export var cellPixelShader: {
  82705. name: string;
  82706. shader: string;
  82707. };
  82708. }
  82709. declare module BABYLON {
  82710. /** @hidden */
  82711. export var cellVertexShader: {
  82712. name: string;
  82713. shader: string;
  82714. };
  82715. }
  82716. declare module BABYLON {
  82717. export class CellMaterial extends BABYLON.PushMaterial {
  82718. private _diffuseTexture;
  82719. diffuseTexture: BABYLON.BaseTexture;
  82720. diffuseColor: BABYLON.Color3;
  82721. _computeHighLevel: boolean;
  82722. computeHighLevel: boolean;
  82723. private _disableLighting;
  82724. disableLighting: boolean;
  82725. private _maxSimultaneousLights;
  82726. maxSimultaneousLights: number;
  82727. constructor(name: string, scene: BABYLON.Scene);
  82728. needAlphaBlending(): boolean;
  82729. needAlphaTesting(): boolean;
  82730. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82731. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82732. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82733. getAnimatables(): BABYLON.IAnimatable[];
  82734. getActiveTextures(): BABYLON.BaseTexture[];
  82735. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82736. dispose(forceDisposeEffect?: boolean): void;
  82737. getClassName(): string;
  82738. clone(name: string): CellMaterial;
  82739. serialize(): any;
  82740. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82741. }
  82742. }
  82743. declare module BABYLON {
  82744. export class CustomShaderStructure {
  82745. FragmentStore: string;
  82746. VertexStore: string;
  82747. constructor();
  82748. }
  82749. export class ShaderSpecialParts {
  82750. constructor();
  82751. Fragment_Begin: string;
  82752. Fragment_Definitions: string;
  82753. Fragment_MainBegin: string;
  82754. Fragment_Custom_Diffuse: string;
  82755. Fragment_Before_Lights: string;
  82756. Fragment_Before_Fog: string;
  82757. Fragment_Custom_Alpha: string;
  82758. Fragment_Before_FragColor: string;
  82759. Vertex_Begin: string;
  82760. Vertex_Definitions: string;
  82761. Vertex_MainBegin: string;
  82762. Vertex_Before_PositionUpdated: string;
  82763. Vertex_Before_NormalUpdated: string;
  82764. Vertex_After_WorldPosComputed: string;
  82765. Vertex_MainEnd: string;
  82766. }
  82767. export class CustomMaterial extends BABYLON.StandardMaterial {
  82768. static ShaderIndexer: number;
  82769. CustomParts: ShaderSpecialParts;
  82770. _isCreatedShader: boolean;
  82771. _createdShaderName: string;
  82772. _customUniform: string[];
  82773. _newUniforms: string[];
  82774. _newUniformInstances: {
  82775. [name: string]: any;
  82776. };
  82777. _newSamplerInstances: {
  82778. [name: string]: BABYLON.Texture;
  82779. };
  82780. _customAttributes: string[];
  82781. FragmentShader: string;
  82782. VertexShader: string;
  82783. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82784. ReviewUniform(name: string, arr: string[]): string[];
  82785. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82786. constructor(name: string, scene: BABYLON.Scene);
  82787. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82788. AddAttribute(name: string): CustomMaterial;
  82789. Fragment_Begin(shaderPart: string): CustomMaterial;
  82790. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82791. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82792. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82793. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82794. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82795. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82796. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82797. Vertex_Begin(shaderPart: string): CustomMaterial;
  82798. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82799. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82800. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82801. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82802. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82803. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82804. }
  82805. }
  82806. declare module BABYLON {
  82807. export class ShaderAlebdoParts {
  82808. constructor();
  82809. Fragment_Begin: string;
  82810. Fragment_Definitions: string;
  82811. Fragment_MainBegin: string;
  82812. Fragment_Custom_Albedo: string;
  82813. Fragment_Before_Lights: string;
  82814. Fragment_Custom_MetallicRoughness: string;
  82815. Fragment_Custom_MicroSurface: string;
  82816. Fragment_Before_Fog: string;
  82817. Fragment_Custom_Alpha: string;
  82818. Fragment_Before_FragColor: string;
  82819. Vertex_Begin: string;
  82820. Vertex_Definitions: string;
  82821. Vertex_MainBegin: string;
  82822. Vertex_Before_PositionUpdated: string;
  82823. Vertex_Before_NormalUpdated: string;
  82824. Vertex_After_WorldPosComputed: string;
  82825. Vertex_MainEnd: string;
  82826. }
  82827. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82828. static ShaderIndexer: number;
  82829. CustomParts: ShaderAlebdoParts;
  82830. _isCreatedShader: boolean;
  82831. _createdShaderName: string;
  82832. _customUniform: string[];
  82833. _newUniforms: string[];
  82834. _newUniformInstances: {
  82835. [name: string]: any;
  82836. };
  82837. _newSamplerInstances: {
  82838. [name: string]: BABYLON.Texture;
  82839. };
  82840. _customAttributes: string[];
  82841. FragmentShader: string;
  82842. VertexShader: string;
  82843. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82844. ReviewUniform(name: string, arr: string[]): string[];
  82845. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82846. constructor(name: string, scene: BABYLON.Scene);
  82847. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82848. AddAttribute(name: string): PBRCustomMaterial;
  82849. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82850. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82851. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82852. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82853. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82854. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82855. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82856. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82857. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82858. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82859. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82860. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82861. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82862. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82863. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82864. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82865. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82866. }
  82867. }
  82868. declare module BABYLON {
  82869. /** @hidden */
  82870. export var firePixelShader: {
  82871. name: string;
  82872. shader: string;
  82873. };
  82874. }
  82875. declare module BABYLON {
  82876. /** @hidden */
  82877. export var fireVertexShader: {
  82878. name: string;
  82879. shader: string;
  82880. };
  82881. }
  82882. declare module BABYLON {
  82883. export class FireMaterial extends BABYLON.PushMaterial {
  82884. private _diffuseTexture;
  82885. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82886. private _distortionTexture;
  82887. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82888. private _opacityTexture;
  82889. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82890. diffuseColor: BABYLON.Color3;
  82891. speed: number;
  82892. private _scaledDiffuse;
  82893. private _lastTime;
  82894. constructor(name: string, scene: BABYLON.Scene);
  82895. needAlphaBlending(): boolean;
  82896. needAlphaTesting(): boolean;
  82897. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82898. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82899. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82900. getAnimatables(): BABYLON.IAnimatable[];
  82901. getActiveTextures(): BABYLON.BaseTexture[];
  82902. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82903. getClassName(): string;
  82904. dispose(forceDisposeEffect?: boolean): void;
  82905. clone(name: string): FireMaterial;
  82906. serialize(): any;
  82907. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82908. }
  82909. }
  82910. declare module BABYLON {
  82911. /** @hidden */
  82912. export var furPixelShader: {
  82913. name: string;
  82914. shader: string;
  82915. };
  82916. }
  82917. declare module BABYLON {
  82918. /** @hidden */
  82919. export var furVertexShader: {
  82920. name: string;
  82921. shader: string;
  82922. };
  82923. }
  82924. declare module BABYLON {
  82925. export class FurMaterial extends BABYLON.PushMaterial {
  82926. private _diffuseTexture;
  82927. diffuseTexture: BABYLON.BaseTexture;
  82928. private _heightTexture;
  82929. heightTexture: BABYLON.BaseTexture;
  82930. diffuseColor: BABYLON.Color3;
  82931. furLength: number;
  82932. furAngle: number;
  82933. furColor: BABYLON.Color3;
  82934. furOffset: number;
  82935. furSpacing: number;
  82936. furGravity: BABYLON.Vector3;
  82937. furSpeed: number;
  82938. furDensity: number;
  82939. furOcclusion: number;
  82940. furTexture: BABYLON.DynamicTexture;
  82941. private _disableLighting;
  82942. disableLighting: boolean;
  82943. private _maxSimultaneousLights;
  82944. maxSimultaneousLights: number;
  82945. highLevelFur: boolean;
  82946. _meshes: BABYLON.AbstractMesh[];
  82947. private _furTime;
  82948. constructor(name: string, scene: BABYLON.Scene);
  82949. get furTime(): number;
  82950. set furTime(furTime: number);
  82951. needAlphaBlending(): boolean;
  82952. needAlphaTesting(): boolean;
  82953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82954. updateFur(): void;
  82955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82956. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82957. getAnimatables(): BABYLON.IAnimatable[];
  82958. getActiveTextures(): BABYLON.BaseTexture[];
  82959. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82960. dispose(forceDisposeEffect?: boolean): void;
  82961. clone(name: string): FurMaterial;
  82962. serialize(): any;
  82963. getClassName(): string;
  82964. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82965. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82966. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82967. }
  82968. }
  82969. declare module BABYLON {
  82970. /** @hidden */
  82971. export var gradientPixelShader: {
  82972. name: string;
  82973. shader: string;
  82974. };
  82975. }
  82976. declare module BABYLON {
  82977. /** @hidden */
  82978. export var gradientVertexShader: {
  82979. name: string;
  82980. shader: string;
  82981. };
  82982. }
  82983. declare module BABYLON {
  82984. export class GradientMaterial extends BABYLON.PushMaterial {
  82985. private _maxSimultaneousLights;
  82986. maxSimultaneousLights: number;
  82987. topColor: BABYLON.Color3;
  82988. topColorAlpha: number;
  82989. bottomColor: BABYLON.Color3;
  82990. bottomColorAlpha: number;
  82991. offset: number;
  82992. scale: number;
  82993. smoothness: number;
  82994. private _disableLighting;
  82995. disableLighting: boolean;
  82996. constructor(name: string, scene: BABYLON.Scene);
  82997. needAlphaBlending(): boolean;
  82998. needAlphaTesting(): boolean;
  82999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83000. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83001. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83002. getAnimatables(): BABYLON.IAnimatable[];
  83003. dispose(forceDisposeEffect?: boolean): void;
  83004. clone(name: string): GradientMaterial;
  83005. serialize(): any;
  83006. getClassName(): string;
  83007. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83008. }
  83009. }
  83010. declare module BABYLON {
  83011. /** @hidden */
  83012. export var gridPixelShader: {
  83013. name: string;
  83014. shader: string;
  83015. };
  83016. }
  83017. declare module BABYLON {
  83018. /** @hidden */
  83019. export var gridVertexShader: {
  83020. name: string;
  83021. shader: string;
  83022. };
  83023. }
  83024. declare module BABYLON {
  83025. /**
  83026. * The grid materials allows you to wrap any shape with a grid.
  83027. * Colors are customizable.
  83028. */
  83029. export class GridMaterial extends BABYLON.PushMaterial {
  83030. /**
  83031. * Main color of the grid (e.g. between lines)
  83032. */
  83033. mainColor: BABYLON.Color3;
  83034. /**
  83035. * Color of the grid lines.
  83036. */
  83037. lineColor: BABYLON.Color3;
  83038. /**
  83039. * The scale of the grid compared to unit.
  83040. */
  83041. gridRatio: number;
  83042. /**
  83043. * Allows setting an offset for the grid lines.
  83044. */
  83045. gridOffset: BABYLON.Vector3;
  83046. /**
  83047. * The frequency of thicker lines.
  83048. */
  83049. majorUnitFrequency: number;
  83050. /**
  83051. * The visibility of minor units in the grid.
  83052. */
  83053. minorUnitVisibility: number;
  83054. /**
  83055. * The grid opacity outside of the lines.
  83056. */
  83057. opacity: number;
  83058. /**
  83059. * Determine RBG output is premultiplied by alpha value.
  83060. */
  83061. preMultiplyAlpha: boolean;
  83062. private _opacityTexture;
  83063. opacityTexture: BABYLON.BaseTexture;
  83064. private _gridControl;
  83065. /**
  83066. * constructor
  83067. * @param name The name given to the material in order to identify it afterwards.
  83068. * @param scene The scene the material is used in.
  83069. */
  83070. constructor(name: string, scene: BABYLON.Scene);
  83071. /**
  83072. * Returns wehter or not the grid requires alpha blending.
  83073. */
  83074. needAlphaBlending(): boolean;
  83075. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83076. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83077. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83078. /**
  83079. * Dispose the material and its associated resources.
  83080. * @param forceDisposeEffect will also dispose the used effect when true
  83081. */
  83082. dispose(forceDisposeEffect?: boolean): void;
  83083. clone(name: string): GridMaterial;
  83084. serialize(): any;
  83085. getClassName(): string;
  83086. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83087. }
  83088. }
  83089. declare module BABYLON {
  83090. /** @hidden */
  83091. export var lavaPixelShader: {
  83092. name: string;
  83093. shader: string;
  83094. };
  83095. }
  83096. declare module BABYLON {
  83097. /** @hidden */
  83098. export var lavaVertexShader: {
  83099. name: string;
  83100. shader: string;
  83101. };
  83102. }
  83103. declare module BABYLON {
  83104. export class LavaMaterial extends BABYLON.PushMaterial {
  83105. private _diffuseTexture;
  83106. diffuseTexture: BABYLON.BaseTexture;
  83107. noiseTexture: BABYLON.BaseTexture;
  83108. fogColor: BABYLON.Color3;
  83109. speed: number;
  83110. movingSpeed: number;
  83111. lowFrequencySpeed: number;
  83112. fogDensity: number;
  83113. private _lastTime;
  83114. diffuseColor: BABYLON.Color3;
  83115. private _disableLighting;
  83116. disableLighting: boolean;
  83117. private _unlit;
  83118. unlit: boolean;
  83119. private _maxSimultaneousLights;
  83120. maxSimultaneousLights: number;
  83121. private _scaledDiffuse;
  83122. constructor(name: string, scene: BABYLON.Scene);
  83123. needAlphaBlending(): boolean;
  83124. needAlphaTesting(): boolean;
  83125. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83126. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83127. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83128. getAnimatables(): BABYLON.IAnimatable[];
  83129. getActiveTextures(): BABYLON.BaseTexture[];
  83130. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83131. dispose(forceDisposeEffect?: boolean): void;
  83132. clone(name: string): LavaMaterial;
  83133. serialize(): any;
  83134. getClassName(): string;
  83135. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83136. }
  83137. }
  83138. declare module BABYLON {
  83139. /** @hidden */
  83140. export var mixPixelShader: {
  83141. name: string;
  83142. shader: string;
  83143. };
  83144. }
  83145. declare module BABYLON {
  83146. /** @hidden */
  83147. export var mixVertexShader: {
  83148. name: string;
  83149. shader: string;
  83150. };
  83151. }
  83152. declare module BABYLON {
  83153. export class MixMaterial extends BABYLON.PushMaterial {
  83154. /**
  83155. * Mix textures
  83156. */
  83157. private _mixTexture1;
  83158. mixTexture1: BABYLON.BaseTexture;
  83159. private _mixTexture2;
  83160. mixTexture2: BABYLON.BaseTexture;
  83161. /**
  83162. * Diffuse textures
  83163. */
  83164. private _diffuseTexture1;
  83165. diffuseTexture1: BABYLON.Texture;
  83166. private _diffuseTexture2;
  83167. diffuseTexture2: BABYLON.Texture;
  83168. private _diffuseTexture3;
  83169. diffuseTexture3: BABYLON.Texture;
  83170. private _diffuseTexture4;
  83171. diffuseTexture4: BABYLON.Texture;
  83172. private _diffuseTexture5;
  83173. diffuseTexture5: BABYLON.Texture;
  83174. private _diffuseTexture6;
  83175. diffuseTexture6: BABYLON.Texture;
  83176. private _diffuseTexture7;
  83177. diffuseTexture7: BABYLON.Texture;
  83178. private _diffuseTexture8;
  83179. diffuseTexture8: BABYLON.Texture;
  83180. /**
  83181. * Uniforms
  83182. */
  83183. diffuseColor: BABYLON.Color3;
  83184. specularColor: BABYLON.Color3;
  83185. specularPower: number;
  83186. private _disableLighting;
  83187. disableLighting: boolean;
  83188. private _maxSimultaneousLights;
  83189. maxSimultaneousLights: number;
  83190. constructor(name: string, scene: BABYLON.Scene);
  83191. needAlphaBlending(): boolean;
  83192. needAlphaTesting(): boolean;
  83193. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83194. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83195. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83196. getAnimatables(): BABYLON.IAnimatable[];
  83197. getActiveTextures(): BABYLON.BaseTexture[];
  83198. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83199. dispose(forceDisposeEffect?: boolean): void;
  83200. clone(name: string): MixMaterial;
  83201. serialize(): any;
  83202. getClassName(): string;
  83203. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83204. }
  83205. }
  83206. declare module BABYLON {
  83207. /** @hidden */
  83208. export var normalPixelShader: {
  83209. name: string;
  83210. shader: string;
  83211. };
  83212. }
  83213. declare module BABYLON {
  83214. /** @hidden */
  83215. export var normalVertexShader: {
  83216. name: string;
  83217. shader: string;
  83218. };
  83219. }
  83220. declare module BABYLON {
  83221. export class NormalMaterial extends BABYLON.PushMaterial {
  83222. private _diffuseTexture;
  83223. diffuseTexture: BABYLON.BaseTexture;
  83224. diffuseColor: BABYLON.Color3;
  83225. private _disableLighting;
  83226. disableLighting: boolean;
  83227. private _maxSimultaneousLights;
  83228. maxSimultaneousLights: number;
  83229. constructor(name: string, scene: BABYLON.Scene);
  83230. needAlphaBlending(): boolean;
  83231. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83232. needAlphaTesting(): boolean;
  83233. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83236. getAnimatables(): BABYLON.IAnimatable[];
  83237. getActiveTextures(): BABYLON.BaseTexture[];
  83238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83239. dispose(forceDisposeEffect?: boolean): void;
  83240. clone(name: string): NormalMaterial;
  83241. serialize(): any;
  83242. getClassName(): string;
  83243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83244. }
  83245. }
  83246. declare module BABYLON {
  83247. /** @hidden */
  83248. export var shadowOnlyPixelShader: {
  83249. name: string;
  83250. shader: string;
  83251. };
  83252. }
  83253. declare module BABYLON {
  83254. /** @hidden */
  83255. export var shadowOnlyVertexShader: {
  83256. name: string;
  83257. shader: string;
  83258. };
  83259. }
  83260. declare module BABYLON {
  83261. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83262. private _activeLight;
  83263. private _needAlphaBlending;
  83264. constructor(name: string, scene: BABYLON.Scene);
  83265. shadowColor: BABYLON.Color3;
  83266. needAlphaBlending(): boolean;
  83267. needAlphaTesting(): boolean;
  83268. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83269. get activeLight(): BABYLON.IShadowLight;
  83270. set activeLight(light: BABYLON.IShadowLight);
  83271. private _getFirstShadowLightForMesh;
  83272. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83273. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83274. clone(name: string): ShadowOnlyMaterial;
  83275. serialize(): any;
  83276. getClassName(): string;
  83277. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83278. }
  83279. }
  83280. declare module BABYLON {
  83281. /** @hidden */
  83282. export var simplePixelShader: {
  83283. name: string;
  83284. shader: string;
  83285. };
  83286. }
  83287. declare module BABYLON {
  83288. /** @hidden */
  83289. export var simpleVertexShader: {
  83290. name: string;
  83291. shader: string;
  83292. };
  83293. }
  83294. declare module BABYLON {
  83295. export class SimpleMaterial extends BABYLON.PushMaterial {
  83296. private _diffuseTexture;
  83297. diffuseTexture: BABYLON.BaseTexture;
  83298. diffuseColor: BABYLON.Color3;
  83299. private _disableLighting;
  83300. disableLighting: boolean;
  83301. private _maxSimultaneousLights;
  83302. maxSimultaneousLights: number;
  83303. constructor(name: string, scene: BABYLON.Scene);
  83304. needAlphaBlending(): boolean;
  83305. needAlphaTesting(): boolean;
  83306. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83307. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83308. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83309. getAnimatables(): BABYLON.IAnimatable[];
  83310. getActiveTextures(): BABYLON.BaseTexture[];
  83311. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83312. dispose(forceDisposeEffect?: boolean): void;
  83313. clone(name: string): SimpleMaterial;
  83314. serialize(): any;
  83315. getClassName(): string;
  83316. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83317. }
  83318. }
  83319. declare module BABYLON {
  83320. /** @hidden */
  83321. export var skyPixelShader: {
  83322. name: string;
  83323. shader: string;
  83324. };
  83325. }
  83326. declare module BABYLON {
  83327. /** @hidden */
  83328. export var skyVertexShader: {
  83329. name: string;
  83330. shader: string;
  83331. };
  83332. }
  83333. declare module BABYLON {
  83334. /**
  83335. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83336. * @see https://doc.babylonjs.com/extensions/sky
  83337. */
  83338. export class SkyMaterial extends BABYLON.PushMaterial {
  83339. /**
  83340. * Defines the overall luminance of sky in interval ]0, 1[.
  83341. */
  83342. luminance: number;
  83343. /**
  83344. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83345. */
  83346. turbidity: number;
  83347. /**
  83348. * Defines the sky appearance (light intensity).
  83349. */
  83350. rayleigh: number;
  83351. /**
  83352. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83353. */
  83354. mieCoefficient: number;
  83355. /**
  83356. * Defines the amount of haze particles following the Mie scattering theory.
  83357. */
  83358. mieDirectionalG: number;
  83359. /**
  83360. * Defines the distance of the sun according to the active scene camera.
  83361. */
  83362. distance: number;
  83363. /**
  83364. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83365. * "inclined".
  83366. */
  83367. inclination: number;
  83368. /**
  83369. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83370. * an object direction and a reference direction.
  83371. */
  83372. azimuth: number;
  83373. /**
  83374. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83375. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83376. */
  83377. sunPosition: BABYLON.Vector3;
  83378. /**
  83379. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83380. * .sunPosition property.
  83381. */
  83382. useSunPosition: boolean;
  83383. /**
  83384. * Defines an offset vector used to get a horizon offset.
  83385. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83386. */
  83387. cameraOffset: BABYLON.Vector3;
  83388. private _cameraPosition;
  83389. /**
  83390. * Instantiates a new sky material.
  83391. * This material allows to create dynamic and texture free
  83392. * effects for skyboxes by taking care of the atmosphere state.
  83393. * @see https://doc.babylonjs.com/extensions/sky
  83394. * @param name Define the name of the material in the scene
  83395. * @param scene Define the scene the material belong to
  83396. */
  83397. constructor(name: string, scene: BABYLON.Scene);
  83398. /**
  83399. * Specifies if the material will require alpha blending
  83400. * @returns a boolean specifying if alpha blending is needed
  83401. */
  83402. needAlphaBlending(): boolean;
  83403. /**
  83404. * Specifies if this material should be rendered in alpha test mode
  83405. * @returns false as the sky material doesn't need alpha testing.
  83406. */
  83407. needAlphaTesting(): boolean;
  83408. /**
  83409. * Get the texture used for alpha test purpose.
  83410. * @returns null as the sky material has no texture.
  83411. */
  83412. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83413. /**
  83414. * Get if the submesh is ready to be used and all its information available.
  83415. * Child classes can use it to update shaders
  83416. * @param mesh defines the mesh to check
  83417. * @param subMesh defines which submesh to check
  83418. * @param useInstances specifies that instances should be used
  83419. * @returns a boolean indicating that the submesh is ready or not
  83420. */
  83421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83422. /**
  83423. * Binds the submesh to this material by preparing the effect and shader to draw
  83424. * @param world defines the world transformation matrix
  83425. * @param mesh defines the mesh containing the submesh
  83426. * @param subMesh defines the submesh to bind the material to
  83427. */
  83428. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83429. /**
  83430. * Get the list of animatables in the material.
  83431. * @returns the list of animatables object used in the material
  83432. */
  83433. getAnimatables(): BABYLON.IAnimatable[];
  83434. /**
  83435. * Disposes the material
  83436. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83437. */
  83438. dispose(forceDisposeEffect?: boolean): void;
  83439. /**
  83440. * Makes a duplicate of the material, and gives it a new name
  83441. * @param name defines the new name for the duplicated material
  83442. * @returns the cloned material
  83443. */
  83444. clone(name: string): SkyMaterial;
  83445. /**
  83446. * Serializes this material in a JSON representation
  83447. * @returns the serialized material object
  83448. */
  83449. serialize(): any;
  83450. /**
  83451. * Gets the current class name of the material e.g. "SkyMaterial"
  83452. * Mainly use in serialization.
  83453. * @returns the class name
  83454. */
  83455. getClassName(): string;
  83456. /**
  83457. * Creates a sky material from parsed material data
  83458. * @param source defines the JSON representation of the material
  83459. * @param scene defines the hosting scene
  83460. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83461. * @returns a new sky material
  83462. */
  83463. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83464. }
  83465. }
  83466. declare module BABYLON {
  83467. /** @hidden */
  83468. export var terrainPixelShader: {
  83469. name: string;
  83470. shader: string;
  83471. };
  83472. }
  83473. declare module BABYLON {
  83474. /** @hidden */
  83475. export var terrainVertexShader: {
  83476. name: string;
  83477. shader: string;
  83478. };
  83479. }
  83480. declare module BABYLON {
  83481. export class TerrainMaterial extends BABYLON.PushMaterial {
  83482. private _mixTexture;
  83483. mixTexture: BABYLON.BaseTexture;
  83484. private _diffuseTexture1;
  83485. diffuseTexture1: BABYLON.Texture;
  83486. private _diffuseTexture2;
  83487. diffuseTexture2: BABYLON.Texture;
  83488. private _diffuseTexture3;
  83489. diffuseTexture3: BABYLON.Texture;
  83490. private _bumpTexture1;
  83491. bumpTexture1: BABYLON.Texture;
  83492. private _bumpTexture2;
  83493. bumpTexture2: BABYLON.Texture;
  83494. private _bumpTexture3;
  83495. bumpTexture3: BABYLON.Texture;
  83496. diffuseColor: BABYLON.Color3;
  83497. specularColor: BABYLON.Color3;
  83498. specularPower: number;
  83499. private _disableLighting;
  83500. disableLighting: boolean;
  83501. private _maxSimultaneousLights;
  83502. maxSimultaneousLights: number;
  83503. constructor(name: string, scene: BABYLON.Scene);
  83504. needAlphaBlending(): boolean;
  83505. needAlphaTesting(): boolean;
  83506. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83507. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83508. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83509. getAnimatables(): BABYLON.IAnimatable[];
  83510. getActiveTextures(): BABYLON.BaseTexture[];
  83511. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83512. dispose(forceDisposeEffect?: boolean): void;
  83513. clone(name: string): TerrainMaterial;
  83514. serialize(): any;
  83515. getClassName(): string;
  83516. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83517. }
  83518. }
  83519. declare module BABYLON {
  83520. /** @hidden */
  83521. export var triplanarPixelShader: {
  83522. name: string;
  83523. shader: string;
  83524. };
  83525. }
  83526. declare module BABYLON {
  83527. /** @hidden */
  83528. export var triplanarVertexShader: {
  83529. name: string;
  83530. shader: string;
  83531. };
  83532. }
  83533. declare module BABYLON {
  83534. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83535. mixTexture: BABYLON.BaseTexture;
  83536. private _diffuseTextureX;
  83537. diffuseTextureX: BABYLON.BaseTexture;
  83538. private _diffuseTextureY;
  83539. diffuseTextureY: BABYLON.BaseTexture;
  83540. private _diffuseTextureZ;
  83541. diffuseTextureZ: BABYLON.BaseTexture;
  83542. private _normalTextureX;
  83543. normalTextureX: BABYLON.BaseTexture;
  83544. private _normalTextureY;
  83545. normalTextureY: BABYLON.BaseTexture;
  83546. private _normalTextureZ;
  83547. normalTextureZ: BABYLON.BaseTexture;
  83548. tileSize: number;
  83549. diffuseColor: BABYLON.Color3;
  83550. specularColor: BABYLON.Color3;
  83551. specularPower: number;
  83552. private _disableLighting;
  83553. disableLighting: boolean;
  83554. private _maxSimultaneousLights;
  83555. maxSimultaneousLights: number;
  83556. constructor(name: string, scene: BABYLON.Scene);
  83557. needAlphaBlending(): boolean;
  83558. needAlphaTesting(): boolean;
  83559. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83561. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83562. getAnimatables(): BABYLON.IAnimatable[];
  83563. getActiveTextures(): BABYLON.BaseTexture[];
  83564. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83565. dispose(forceDisposeEffect?: boolean): void;
  83566. clone(name: string): TriPlanarMaterial;
  83567. serialize(): any;
  83568. getClassName(): string;
  83569. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83570. }
  83571. }
  83572. declare module BABYLON {
  83573. /** @hidden */
  83574. export var waterPixelShader: {
  83575. name: string;
  83576. shader: string;
  83577. };
  83578. }
  83579. declare module BABYLON {
  83580. /** @hidden */
  83581. export var waterVertexShader: {
  83582. name: string;
  83583. shader: string;
  83584. };
  83585. }
  83586. declare module BABYLON {
  83587. export class WaterMaterial extends BABYLON.PushMaterial {
  83588. renderTargetSize: BABYLON.Vector2;
  83589. private _bumpTexture;
  83590. bumpTexture: BABYLON.BaseTexture;
  83591. diffuseColor: BABYLON.Color3;
  83592. specularColor: BABYLON.Color3;
  83593. specularPower: number;
  83594. private _disableLighting;
  83595. disableLighting: boolean;
  83596. private _maxSimultaneousLights;
  83597. maxSimultaneousLights: number;
  83598. /**
  83599. * @param {number}: Represents the wind force
  83600. */
  83601. windForce: number;
  83602. /**
  83603. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83604. */
  83605. windDirection: BABYLON.Vector2;
  83606. /**
  83607. * @param {number}: Wave height, represents the height of the waves
  83608. */
  83609. waveHeight: number;
  83610. /**
  83611. * @param {number}: Bump height, represents the bump height related to the bump map
  83612. */
  83613. bumpHeight: number;
  83614. /**
  83615. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83616. */
  83617. private _bumpSuperimpose;
  83618. bumpSuperimpose: boolean;
  83619. /**
  83620. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83621. */
  83622. private _fresnelSeparate;
  83623. fresnelSeparate: boolean;
  83624. /**
  83625. * @param {boolean}: bump Waves modify the reflection.
  83626. */
  83627. private _bumpAffectsReflection;
  83628. bumpAffectsReflection: boolean;
  83629. /**
  83630. * @param {number}: The water color blended with the refraction (near)
  83631. */
  83632. waterColor: BABYLON.Color3;
  83633. /**
  83634. * @param {number}: The blend factor related to the water color
  83635. */
  83636. colorBlendFactor: number;
  83637. /**
  83638. * @param {number}: The water color blended with the reflection (far)
  83639. */
  83640. waterColor2: BABYLON.Color3;
  83641. /**
  83642. * @param {number}: The blend factor related to the water color (reflection, far)
  83643. */
  83644. colorBlendFactor2: number;
  83645. /**
  83646. * @param {number}: Represents the maximum length of a wave
  83647. */
  83648. waveLength: number;
  83649. /**
  83650. * @param {number}: Defines the waves speed
  83651. */
  83652. waveSpeed: number;
  83653. /**
  83654. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83655. * will avoid calculating useless pixels in the pixel shader of the water material.
  83656. */
  83657. disableClipPlane: boolean;
  83658. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83659. private _mesh;
  83660. private _refractionRTT;
  83661. private _reflectionRTT;
  83662. private _reflectionTransform;
  83663. private _lastTime;
  83664. private _lastDeltaTime;
  83665. private _useLogarithmicDepth;
  83666. private _waitingRenderList;
  83667. private _imageProcessingConfiguration;
  83668. private _imageProcessingObserver;
  83669. /**
  83670. * Gets a boolean indicating that current material needs to register RTT
  83671. */
  83672. get hasRenderTargetTextures(): boolean;
  83673. /**
  83674. * Constructor
  83675. */
  83676. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83677. get useLogarithmicDepth(): boolean;
  83678. set useLogarithmicDepth(value: boolean);
  83679. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83680. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83681. addToRenderList(node: any): void;
  83682. enableRenderTargets(enable: boolean): void;
  83683. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83684. get renderTargetsEnabled(): boolean;
  83685. needAlphaBlending(): boolean;
  83686. needAlphaTesting(): boolean;
  83687. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83690. private _createRenderTargets;
  83691. getAnimatables(): BABYLON.IAnimatable[];
  83692. getActiveTextures(): BABYLON.BaseTexture[];
  83693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83694. dispose(forceDisposeEffect?: boolean): void;
  83695. clone(name: string): WaterMaterial;
  83696. serialize(): any;
  83697. getClassName(): string;
  83698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83699. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83700. }
  83701. }
  83702. declare module BABYLON {
  83703. /** @hidden */
  83704. export var asciiartPixelShader: {
  83705. name: string;
  83706. shader: string;
  83707. };
  83708. }
  83709. declare module BABYLON {
  83710. /**
  83711. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83712. *
  83713. * It basically takes care rendering the font front the given font size to a texture.
  83714. * This is used later on in the postprocess.
  83715. */
  83716. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83717. private _font;
  83718. private _text;
  83719. private _charSize;
  83720. /**
  83721. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83722. */
  83723. get charSize(): number;
  83724. /**
  83725. * Create a new instance of the Ascii Art FontTexture class
  83726. * @param name the name of the texture
  83727. * @param font the font to use, use the W3C CSS notation
  83728. * @param text the caracter set to use in the rendering.
  83729. * @param scene the scene that owns the texture
  83730. */
  83731. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83732. /**
  83733. * Gets the max char width of a font.
  83734. * @param font the font to use, use the W3C CSS notation
  83735. * @return the max char width
  83736. */
  83737. private getFontWidth;
  83738. /**
  83739. * Gets the max char height of a font.
  83740. * @param font the font to use, use the W3C CSS notation
  83741. * @return the max char height
  83742. */
  83743. private getFontHeight;
  83744. /**
  83745. * Clones the current AsciiArtTexture.
  83746. * @return the clone of the texture.
  83747. */
  83748. clone(): AsciiArtFontTexture;
  83749. /**
  83750. * Parses a json object representing the texture and returns an instance of it.
  83751. * @param source the source JSON representation
  83752. * @param scene the scene to create the texture for
  83753. * @return the parsed texture
  83754. */
  83755. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83756. }
  83757. /**
  83758. * Option available in the Ascii Art Post Process.
  83759. */
  83760. export interface IAsciiArtPostProcessOptions {
  83761. /**
  83762. * The font to use following the w3c font definition.
  83763. */
  83764. font?: string;
  83765. /**
  83766. * The character set to use in the postprocess.
  83767. */
  83768. characterSet?: string;
  83769. /**
  83770. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83771. * This number is defined between 0 and 1;
  83772. */
  83773. mixToTile?: number;
  83774. /**
  83775. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83776. * This number is defined between 0 and 1;
  83777. */
  83778. mixToNormal?: number;
  83779. }
  83780. /**
  83781. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83782. *
  83783. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83784. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83785. */
  83786. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83787. /**
  83788. * The font texture used to render the char in the post process.
  83789. */
  83790. private _asciiArtFontTexture;
  83791. /**
  83792. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83793. * This number is defined between 0 and 1;
  83794. */
  83795. mixToTile: number;
  83796. /**
  83797. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83798. * This number is defined between 0 and 1;
  83799. */
  83800. mixToNormal: number;
  83801. /**
  83802. * Instantiates a new Ascii Art Post Process.
  83803. * @param name the name to give to the postprocess
  83804. * @camera the camera to apply the post process to.
  83805. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83806. */
  83807. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83808. }
  83809. }
  83810. declare module BABYLON {
  83811. /** @hidden */
  83812. export var digitalrainPixelShader: {
  83813. name: string;
  83814. shader: string;
  83815. };
  83816. }
  83817. declare module BABYLON {
  83818. /**
  83819. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83820. *
  83821. * It basically takes care rendering the font front the given font size to a texture.
  83822. * This is used later on in the postprocess.
  83823. */
  83824. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83825. private _font;
  83826. private _text;
  83827. private _charSize;
  83828. /**
  83829. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83830. */
  83831. get charSize(): number;
  83832. /**
  83833. * Create a new instance of the Digital Rain FontTexture class
  83834. * @param name the name of the texture
  83835. * @param font the font to use, use the W3C CSS notation
  83836. * @param text the caracter set to use in the rendering.
  83837. * @param scene the scene that owns the texture
  83838. */
  83839. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83840. /**
  83841. * Gets the max char width of a font.
  83842. * @param font the font to use, use the W3C CSS notation
  83843. * @return the max char width
  83844. */
  83845. private getFontWidth;
  83846. /**
  83847. * Gets the max char height of a font.
  83848. * @param font the font to use, use the W3C CSS notation
  83849. * @return the max char height
  83850. */
  83851. private getFontHeight;
  83852. /**
  83853. * Clones the current DigitalRainFontTexture.
  83854. * @return the clone of the texture.
  83855. */
  83856. clone(): DigitalRainFontTexture;
  83857. /**
  83858. * Parses a json object representing the texture and returns an instance of it.
  83859. * @param source the source JSON representation
  83860. * @param scene the scene to create the texture for
  83861. * @return the parsed texture
  83862. */
  83863. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83864. }
  83865. /**
  83866. * Option available in the Digital Rain Post Process.
  83867. */
  83868. export interface IDigitalRainPostProcessOptions {
  83869. /**
  83870. * The font to use following the w3c font definition.
  83871. */
  83872. font?: string;
  83873. /**
  83874. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83875. * This number is defined between 0 and 1;
  83876. */
  83877. mixToTile?: number;
  83878. /**
  83879. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83880. * This number is defined between 0 and 1;
  83881. */
  83882. mixToNormal?: number;
  83883. }
  83884. /**
  83885. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83886. *
  83887. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83888. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83889. */
  83890. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83891. /**
  83892. * The font texture used to render the char in the post process.
  83893. */
  83894. private _digitalRainFontTexture;
  83895. /**
  83896. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83897. * This number is defined between 0 and 1;
  83898. */
  83899. mixToTile: number;
  83900. /**
  83901. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83902. * This number is defined between 0 and 1;
  83903. */
  83904. mixToNormal: number;
  83905. /**
  83906. * Instantiates a new Digital Rain Post Process.
  83907. * @param name the name to give to the postprocess
  83908. * @camera the camera to apply the post process to.
  83909. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83910. */
  83911. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83912. }
  83913. }
  83914. declare module BABYLON {
  83915. /** @hidden */
  83916. export var brickProceduralTexturePixelShader: {
  83917. name: string;
  83918. shader: string;
  83919. };
  83920. }
  83921. declare module BABYLON {
  83922. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83923. private _numberOfBricksHeight;
  83924. private _numberOfBricksWidth;
  83925. private _jointColor;
  83926. private _brickColor;
  83927. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83928. updateShaderUniforms(): void;
  83929. get numberOfBricksHeight(): number;
  83930. set numberOfBricksHeight(value: number);
  83931. get numberOfBricksWidth(): number;
  83932. set numberOfBricksWidth(value: number);
  83933. get jointColor(): BABYLON.Color3;
  83934. set jointColor(value: BABYLON.Color3);
  83935. get brickColor(): BABYLON.Color3;
  83936. set brickColor(value: BABYLON.Color3);
  83937. /**
  83938. * Serializes this brick procedural texture
  83939. * @returns a serialized brick procedural texture object
  83940. */
  83941. serialize(): any;
  83942. /**
  83943. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83944. * @param parsedTexture defines parsed texture data
  83945. * @param scene defines the current scene
  83946. * @param rootUrl defines the root URL containing brick procedural texture information
  83947. * @returns a parsed Brick Procedural BABYLON.Texture
  83948. */
  83949. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83950. }
  83951. }
  83952. declare module BABYLON {
  83953. /** @hidden */
  83954. export var cloudProceduralTexturePixelShader: {
  83955. name: string;
  83956. shader: string;
  83957. };
  83958. }
  83959. declare module BABYLON {
  83960. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83961. private _skyColor;
  83962. private _cloudColor;
  83963. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83964. updateShaderUniforms(): void;
  83965. get skyColor(): BABYLON.Color4;
  83966. set skyColor(value: BABYLON.Color4);
  83967. get cloudColor(): BABYLON.Color4;
  83968. set cloudColor(value: BABYLON.Color4);
  83969. /**
  83970. * Serializes this cloud procedural texture
  83971. * @returns a serialized cloud procedural texture object
  83972. */
  83973. serialize(): any;
  83974. /**
  83975. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83976. * @param parsedTexture defines parsed texture data
  83977. * @param scene defines the current scene
  83978. * @param rootUrl defines the root URL containing cloud procedural texture information
  83979. * @returns a parsed Cloud Procedural BABYLON.Texture
  83980. */
  83981. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83982. }
  83983. }
  83984. declare module BABYLON {
  83985. /** @hidden */
  83986. export var fireProceduralTexturePixelShader: {
  83987. name: string;
  83988. shader: string;
  83989. };
  83990. }
  83991. declare module BABYLON {
  83992. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83993. private _time;
  83994. private _speed;
  83995. private _autoGenerateTime;
  83996. private _fireColors;
  83997. private _alphaThreshold;
  83998. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83999. updateShaderUniforms(): void;
  84000. render(useCameraPostProcess?: boolean): void;
  84001. static get PurpleFireColors(): BABYLON.Color3[];
  84002. static get GreenFireColors(): BABYLON.Color3[];
  84003. static get RedFireColors(): BABYLON.Color3[];
  84004. static get BlueFireColors(): BABYLON.Color3[];
  84005. get autoGenerateTime(): boolean;
  84006. set autoGenerateTime(value: boolean);
  84007. get fireColors(): BABYLON.Color3[];
  84008. set fireColors(value: BABYLON.Color3[]);
  84009. get time(): number;
  84010. set time(value: number);
  84011. get speed(): BABYLON.Vector2;
  84012. set speed(value: BABYLON.Vector2);
  84013. get alphaThreshold(): number;
  84014. set alphaThreshold(value: number);
  84015. /**
  84016. * Serializes this fire procedural texture
  84017. * @returns a serialized fire procedural texture object
  84018. */
  84019. serialize(): any;
  84020. /**
  84021. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84022. * @param parsedTexture defines parsed texture data
  84023. * @param scene defines the current scene
  84024. * @param rootUrl defines the root URL containing fire procedural texture information
  84025. * @returns a parsed Fire Procedural BABYLON.Texture
  84026. */
  84027. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84028. }
  84029. }
  84030. declare module BABYLON {
  84031. /** @hidden */
  84032. export var grassProceduralTexturePixelShader: {
  84033. name: string;
  84034. shader: string;
  84035. };
  84036. }
  84037. declare module BABYLON {
  84038. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84039. private _grassColors;
  84040. private _groundColor;
  84041. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84042. updateShaderUniforms(): void;
  84043. get grassColors(): BABYLON.Color3[];
  84044. set grassColors(value: BABYLON.Color3[]);
  84045. get groundColor(): BABYLON.Color3;
  84046. set groundColor(value: BABYLON.Color3);
  84047. /**
  84048. * Serializes this grass procedural texture
  84049. * @returns a serialized grass procedural texture object
  84050. */
  84051. serialize(): any;
  84052. /**
  84053. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84054. * @param parsedTexture defines parsed texture data
  84055. * @param scene defines the current scene
  84056. * @param rootUrl defines the root URL containing grass procedural texture information
  84057. * @returns a parsed Grass Procedural BABYLON.Texture
  84058. */
  84059. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84060. }
  84061. }
  84062. declare module BABYLON {
  84063. /** @hidden */
  84064. export var marbleProceduralTexturePixelShader: {
  84065. name: string;
  84066. shader: string;
  84067. };
  84068. }
  84069. declare module BABYLON {
  84070. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84071. private _numberOfTilesHeight;
  84072. private _numberOfTilesWidth;
  84073. private _amplitude;
  84074. private _jointColor;
  84075. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84076. updateShaderUniforms(): void;
  84077. get numberOfTilesHeight(): number;
  84078. set numberOfTilesHeight(value: number);
  84079. get amplitude(): number;
  84080. set amplitude(value: number);
  84081. get numberOfTilesWidth(): number;
  84082. set numberOfTilesWidth(value: number);
  84083. get jointColor(): BABYLON.Color3;
  84084. set jointColor(value: BABYLON.Color3);
  84085. /**
  84086. * Serializes this marble procedural texture
  84087. * @returns a serialized marble procedural texture object
  84088. */
  84089. serialize(): any;
  84090. /**
  84091. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84092. * @param parsedTexture defines parsed texture data
  84093. * @param scene defines the current scene
  84094. * @param rootUrl defines the root URL containing marble procedural texture information
  84095. * @returns a parsed Marble Procedural BABYLON.Texture
  84096. */
  84097. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84098. }
  84099. }
  84100. declare module BABYLON {
  84101. /** @hidden */
  84102. export var normalMapProceduralTexturePixelShader: {
  84103. name: string;
  84104. shader: string;
  84105. };
  84106. }
  84107. declare module BABYLON {
  84108. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84109. private _baseTexture;
  84110. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84111. updateShaderUniforms(): void;
  84112. render(useCameraPostProcess?: boolean): void;
  84113. resize(size: any, generateMipMaps: any): void;
  84114. get baseTexture(): BABYLON.Texture;
  84115. set baseTexture(texture: BABYLON.Texture);
  84116. /**
  84117. * Serializes this normal map procedural texture
  84118. * @returns a serialized normal map procedural texture object
  84119. */
  84120. serialize(): any;
  84121. /**
  84122. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84123. * @param parsedTexture defines parsed texture data
  84124. * @param scene defines the current scene
  84125. * @param rootUrl defines the root URL containing normal map procedural texture information
  84126. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84127. */
  84128. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84129. }
  84130. }
  84131. declare module BABYLON {
  84132. /** @hidden */
  84133. export var perlinNoiseProceduralTexturePixelShader: {
  84134. name: string;
  84135. shader: string;
  84136. };
  84137. }
  84138. declare module BABYLON {
  84139. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84140. time: number;
  84141. timeScale: number;
  84142. translationSpeed: number;
  84143. private _currentTranslation;
  84144. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84145. updateShaderUniforms(): void;
  84146. render(useCameraPostProcess?: boolean): void;
  84147. resize(size: any, generateMipMaps: any): void;
  84148. /**
  84149. * Serializes this perlin noise procedural texture
  84150. * @returns a serialized perlin noise procedural texture object
  84151. */
  84152. serialize(): any;
  84153. /**
  84154. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84155. * @param parsedTexture defines parsed texture data
  84156. * @param scene defines the current scene
  84157. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84158. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84159. */
  84160. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84161. }
  84162. }
  84163. declare module BABYLON {
  84164. /** @hidden */
  84165. export var roadProceduralTexturePixelShader: {
  84166. name: string;
  84167. shader: string;
  84168. };
  84169. }
  84170. declare module BABYLON {
  84171. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84172. private _roadColor;
  84173. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84174. updateShaderUniforms(): void;
  84175. get roadColor(): BABYLON.Color3;
  84176. set roadColor(value: BABYLON.Color3);
  84177. /**
  84178. * Serializes this road procedural texture
  84179. * @returns a serialized road procedural texture object
  84180. */
  84181. serialize(): any;
  84182. /**
  84183. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84184. * @param parsedTexture defines parsed texture data
  84185. * @param scene defines the current scene
  84186. * @param rootUrl defines the root URL containing road procedural texture information
  84187. * @returns a parsed Road Procedural BABYLON.Texture
  84188. */
  84189. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84190. }
  84191. }
  84192. declare module BABYLON {
  84193. /** @hidden */
  84194. export var starfieldProceduralTexturePixelShader: {
  84195. name: string;
  84196. shader: string;
  84197. };
  84198. }
  84199. declare module BABYLON {
  84200. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84201. private _time;
  84202. private _alpha;
  84203. private _beta;
  84204. private _zoom;
  84205. private _formuparam;
  84206. private _stepsize;
  84207. private _tile;
  84208. private _brightness;
  84209. private _darkmatter;
  84210. private _distfading;
  84211. private _saturation;
  84212. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84213. updateShaderUniforms(): void;
  84214. get time(): number;
  84215. set time(value: number);
  84216. get alpha(): number;
  84217. set alpha(value: number);
  84218. get beta(): number;
  84219. set beta(value: number);
  84220. get formuparam(): number;
  84221. set formuparam(value: number);
  84222. get stepsize(): number;
  84223. set stepsize(value: number);
  84224. get zoom(): number;
  84225. set zoom(value: number);
  84226. get tile(): number;
  84227. set tile(value: number);
  84228. get brightness(): number;
  84229. set brightness(value: number);
  84230. get darkmatter(): number;
  84231. set darkmatter(value: number);
  84232. get distfading(): number;
  84233. set distfading(value: number);
  84234. get saturation(): number;
  84235. set saturation(value: number);
  84236. /**
  84237. * Serializes this starfield procedural texture
  84238. * @returns a serialized starfield procedural texture object
  84239. */
  84240. serialize(): any;
  84241. /**
  84242. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84243. * @param parsedTexture defines parsed texture data
  84244. * @param scene defines the current scene
  84245. * @param rootUrl defines the root URL containing startfield procedural texture information
  84246. * @returns a parsed Starfield Procedural BABYLON.Texture
  84247. */
  84248. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84249. }
  84250. }
  84251. declare module BABYLON {
  84252. /** @hidden */
  84253. export var woodProceduralTexturePixelShader: {
  84254. name: string;
  84255. shader: string;
  84256. };
  84257. }
  84258. declare module BABYLON {
  84259. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84260. private _ampScale;
  84261. private _woodColor;
  84262. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84263. updateShaderUniforms(): void;
  84264. get ampScale(): number;
  84265. set ampScale(value: number);
  84266. get woodColor(): BABYLON.Color3;
  84267. set woodColor(value: BABYLON.Color3);
  84268. /**
  84269. * Serializes this wood procedural texture
  84270. * @returns a serialized wood procedural texture object
  84271. */
  84272. serialize(): any;
  84273. /**
  84274. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84275. * @param parsedTexture defines parsed texture data
  84276. * @param scene defines the current scene
  84277. * @param rootUrl defines the root URL containing wood procedural texture information
  84278. * @returns a parsed Wood Procedural BABYLON.Texture
  84279. */
  84280. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84281. }
  84282. }